2. EJB 3 Sample Project Installation
What It Does
The EJB 3 sample application shows a basic address book with a list of persons in the left panel and, for each selected person, a list of contacts in the right panel. You may search existing persons by first or last name, and create, edit, and delete persons or contacts based on the login you choose. Note that admins have the right to make modifications, users have not.
The two panels are packed in HDividedBox container and the current position of this divider is saved in an EJB 3 stateful bean. This position will be restored if you reload the application via the Reload button of your browser.
More specifically, this sample illustrates:
- EJB 3 entity beans externalization, via the HibernateExternalizer class, with Gas3 generated ActionScript3 classes.
- EJB 3 stateless session beans. The PersonServiceBean class uses an EntityManager for persistence operations.
- EJB 3 stateful session beans. The PositionServiceBean stores the current divider position and, even if you reload the Flex application, this position is restored from this stateful context. However, if you click the "][" button at the top right corner of the Flex application, the remove() method is called on the EJB and the initial value is restored. This appends because the previous stateful bean instance is destroyed and the new one returns a default initial value of 300.
- Automatic configuration. Entity bean externalization and remote destinations are automatically configured. See the scan="true" attribute in ear/addressbook.war/WEB-INF/granite/granite-config.xml, the ejb3/META-INF/services-config.properties file and the @RemoteDestination annotation in session bean classes.
- Security settings, via the TomcatSecurityService class (see granite-config.xml), at two levels; a web-tier security that forbids unauthenticated accesses (@RemoteDestination annotation in PersonServiceBean), and a EJB-tier security that forbids modification method calls for a simple user (@SecurityDomain and @RolesAllowed annotations in PersonServiceBean).
Requirements, Installation & Deployment
Follow general requirements here and point your browser to http://localhost:8080/graniteds-ejb3/.
Note: you must have setup the security accordingly to instructions in the graniteds/examples/README.txt file.
You should now see the EJB 3 sample application running.
