exposes the Bean in EL - and allows us to access it from – really simple app, we keep the game data in the session - to play two concurrent games, need two sessions. App has no persistence – As we discussed CDI is typesafe, (beans are injected by type) but sometimes need to access in a non-typesafe fashion. Game.java – this is the main controller for the game. When CDI needs to inject something, the first thing it looks at is the type - and if the type of the injection point is assignable from a bean, CDI will inject that bean This is typesafe (refactor safe, take advantage of the compiler and the IDE - we just saw that!) Probably used to string based bean resolution This is a CDI bean - very simple, no annotations required! Show that we use the service (line 41) #Cmd-click on HelloService Show that we can inject services into a Servlet Point out the - explain this one annotation removes about 8 lines of XML - no need to separately map a path either. Open up src/main/java and open up the HelloWorldServlet. , configure the JBoss AS Maven Plugin, set the Java version to 6. Show the plugin sections - nothing that exciting here, the war plugin is out of date and requires you to provide web.xml Show that these are all provided - we are depending on build in server implementations, not packaging this stuff! Show the import for CDI, JSR-250 and Servlet API. Explain we could also depend on this directly, which would give us the whole set of APIs, but that here we've decided to go for slightly tighter control and specify each dependency ourselves Explain that this gives you all the versions for all of the JBoss AS 7 APIs that are in the web profile. Here we import the JBoss AS 7 Web Profile API. Show that we are enabling the JBoss Maven repo - explain you can do this in your POM or in system wide ( settings.xml) There is no parent pom, everything for the build is here Open up the pom.xm - and emphasise that it's pretty simple. Show index.html, and explain it is just used to kick the user into the app (open it, show the meta-refresh) Show beans.xml and explain it's a marker file used to JBoss AS to enable CDI (open it, show that it is empty) Point out that we don't require a web.xml anymore! Open up the helloworld quickstart in Eclipse, and open up src/main/webapp.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |