... h1. Implement business logic as Java technology classes.
h2. Task: Plan the development of a business service or model
* Design classes to contain business logic. * Select which classes with require synchronous or asynchronous processing. * Analyze which classes will require stateful behavior and which can use stateless. * Assess the need of EJB technology (instead of POJOs) (what are the compelling features). * Select the correct profile (Web vs Full) based on the required functionality.
h1. Implement synchronous processing
h2. Task: Create a Stateful Session Bean
* Create a class that is marked as a stateful session bean. * Determine whether local or remote clients, or both, will access the session bean. ** If remote clients will access the session bean, expose a remote view through a remote business interface. ** If local clients will access the session bean, expose a local view through a local business interface or a no-interface view. * Add one or more business method(s).
h2. Task: Create a Stateless Session Bean
* Create a class that is marked as a stateless session bean. * Determine whether local or remote clients, or both, will access the session bean. ** If remote clients will access the session bean, expose a remote view through a remote business interface. ** If local clients will access the session bean, expose a local view through a local business interface or a no-interface view. * Add one or more business method(s).
h2. Task: Create a Singleton Session Bean
* Create a class that is marked as a singleton. * Determine whether local or remote clients, or both, will access the singleton. * Based on the types of clients that will access the singleton, create the appropriate view. * Decide whether the singleton's concurrency access will be managed by the container or by the singleton bean. * If the singleton's concurrency is managed by the container, decide whether the business methods of the singleton require shared or exclusive concurrency access, and annotate the class or methods. * Decide whether the singleton needs to be initialized at application startup, and if so add the appropriate annotations. * Decide whether the business methods that need exclusive concurrency access need more or less time before an access timeout is thrown, and add the appropriate annotations.
h2. Task: Create a Session Bean client
* Decide whether the session bean the client is accessing is local or remote. * Decide the environment in which the client will run. ** If the environment supports dependency injection, use annotations to inject a session bean. ** If the environment doesn't support dependency injection, use context and JNDI lookup code to obtain a reference to a session bean. * Write code that invokes the session bean's business methods.
h1. Implement Enterprise Bean Interceptors
h2. Task: Create interceptors for an EJB
* Predict the order in which enterprise bean interceptors are invoked for a given enterprise bean and its interceptor(s). * Determine whether the enterprise bean requires class\- or method-level interceptors. * Determine whether the enterprise bean will use an internal interceptor. * Create interceptors in an enterprise bean: ** declare a method-level interceptor if needed. ** declare a class-level interceptor if needed. ** include an interceptor method if needed. * Create the interceptor classes required by the enterprise bean, if needed.
h1. Implement asynchronous processing
h2. Task: Modify a Session bean to be asynchronous
* Identify session bean methods that could benefit from asynchronous execution * Add the Asynchronous annotation to session bean methods * Use the java.util.Concurrent return type and the javax.ejb.AsyncResult<V> class to return information to the caller of an asynchronous method
h2. Task: Create a Message Driven Bean
* Determine what type of message the message-driven bean will process. * Create a class that is marked as a message-driven bean. * Determine whether the message-driven bean will implement the listener interface for the message type. * Determine whether the message-driven bean requires access to the message-driven context, and if so add the appropriate annotations to inject the context. * Add an {{onMessage}} method that contains the business logic of the message-driven bean.
h2. Task: Create a Client that Sends a Message to a JMS Queue
* Determine the environment in which the client will run. ** If the environment supports dependency injection, use annotations to inject the JMS connection factory and queue. ** If the environment does not support dependency injection, use context and JNDI lookup code to obtain references to the JMS connection factory and queue. * Create code that creates a message using the JMS connection factory and queue. * Create code that sends the message.
h1. Controlling Transactions in Enterprise Beans
h2. Task: Add Transaction Demarkation Information to an Enterprise Bean
* Determine whether the enterprise bean will use container-managed transaction demarkation or if the bean will manage its own transactions. * If the enterprise bean will use container-managed transaction demarkation: ** Determine the appropriate transaction attributes of an enterprise bean's business methods. ** Determine whether the enterprise bean requires class\- or method-level transaction attributes. ** If the enterprise bean is a stateful session bean, determine if the session bean should receive transaction notification messages. If so: *** Implement the {{SessionSynchronizationInterface}} in the enterprise bean class. *** Add the session synchronization methods to the enterprise bean class. ** Add transaction attribute annotations to the enterprise bean class or methods. ** Determine whether the business methods need to explicitly cause a transaction rollback, and if so, invoke the {{setRollbackOnly}} method. * If the enterprise bean will use bean-managed transaction demarkation: ** Determine whether the enterprise bean will use JTA transactions. ** If the enterprise bean uses JTA transactions: *** Implement the {{UserTransaction}} interface in the enterprise bean class. *** Call {{commit}} and {{rollback}} in the enterprise bean's business methods.
h1. Exposing Session Beans as Web Services
h2. Task: Expose a Session Bean as a JAX-WS Web Service
* Create a Stateless Session Bean that: ** exposes a web-service endpoint. {color:red}(overlap with Web Services Developer){color} ** has one or more web methods. {color:red}(overlap with Web Services Developer){color}
h2. Task: Expose a Session Bean as a JAX-RS Resource
* Create a Session Bean that: ** represents a JAX-RS resource. {color:red}(overlap with Web Services Developer/Web Developer){color} ** responds to HTTP GET and POST requests. {color:red}(overlap with Web Services Developer/Web Developer){color}
h1. Enabling and disabling access
h2. Task: Add security checks to business logic
* Modify an enterprise bean to limit the invocation of one or more business methods to a particular role. * Modify an enterprise bean to limit all the business methods of the enterprise bean to a particular role. * Match security behaviors to declarative security specifications (default behavior, security roles, security role references, and method permissions). * From a list of responsibilities, predict which roles are responsible for which aspects of security: application assembler, bean provider, deployer, container provider, system administrator, or server provider. * Use the {{isCallerInRole}} and {{getCallerPrincipal}} methods in an enterprise bean to restrict access to the enterprise bean's business methods. * Predict the behavior of an enterprise bean that: ** only uses security annotations. ** uses both security annotations and security tags in the enterprise bean's deployment descriptor.
h1. Other Tasks
h2. Task: Schedule the execution of business logic
* Create a Session Bean that: ** sets a programmatic timer that logs a message. ** has a business method that lists all active timers. ** has a business method that cancels a timer. ** creates an automatic timer.
h2. Task: Package and Deploy EJB applications
* Determine the application in which the EJB will be used. ** If the EJB will be used in a web application, put the EJB classes and optional deployment descriptor, or JAR containing the EJB classes and optional deployment descriptor, in the appropriate location in the WAR. ** If the EJB will be used in an enterprise application, create an EJB JAR that contains the EJB classes and optional deployment descriptor. ** Use EARs (prefer WARs) ** Use embedded EJB containers and EJB-lite ** Provide the biz interface and any required stub jars to the EJB client if the client is not deployed in the same module as the EJBs * Deploy the application.
---- h1. EJB 3.1 Technology Content - additional material for building certification questions and course material
h2. EJB 3.1 Overview
* Design an application that appropriately uses EJB 3.1 technology. * Predict which types of EJBs are capable of running on a server conforming to the Java EE 6 Web Profile * Identify correct and incorrect statements or examples about EJB programming restrictions. * Match the seven EJB roles with the corresponding description of the role's responsibilities. \[{color:#ff0000}Is this still correct?{color}\] * Package an EJB in a WAR. * Package an EJB in an EJB-JAR. * Package an EJB in an EAR. * Predict the behavior of the EJB Container when deploying an enterprise bean that: ** only uses annotations. ** uses both annotations and a deployment descriptor.
h2. -General EJB 3.1 Enterprise Bean Knowledge-
|
... h2. EJB 3.1 Session Beans
* Design the EJB tier of an application that appropriately uses Stateful, Singleton, and Stateless Session Beans * Create a Singleton Session Bean that: ** exposes a no-interface, local view. ** has one or more business method(s) ** logs a message before being destroyed. ** starts-up on application-deployment. ** injects a local EJB. ** injects a remote EJB. * Create a Stateful Session Bean that: ** has one or more business method(s). ** exposes a local view through a remote business interface. ** logs a message before being passivated. ** logs a message after being activated. ** logs a message upon being removed. * Create a Stateless Session Bean that: ** has one or more business method(s). ** uses transaction demarkation annotations on at least one of the business methods. ** exposes a remote view through a remote business interface. ** exposes a local view through a local business interface ** logs a message after being created. ** uses JNDI to lookup another EJB. * Create a Singleton Session Bean that: ** has one or more business method(s). ** exposes a local, no-interface view. ** injects another EJB that exposes a no-interface view. ** depends on one or more other singleton session beans. ** uses container-managed concurrency. ** explicitly sets the concurrency lock-mode at the class and method level. ** Modifies the default access timeout value. * Create a Stateless Session Bean that: ** exposes a web-service endpoint. {color:red}(overlap with Web Services Developer){color} ** has one or more web methods. {color:red}(overlap with Web Services Developer){color} * Create a Singleton Session Bean that: ** represents a JAX-RS resource. {color:red}(overlap with Web Services Developer/Web Developer){color} ** responds to HTTP GET and POST requests. {color:red}(overlap with Web Services Developer/Web Developer){color} ** injects a resource. * Create a Stateless Session Bean that: ** sets a programmatic timer that logs a message. ** has a business method that lists all active timers. ** has a business method that cancels a timer. ** creates an automatic timer. * Predict when EJB clients can modify an EJB objects state (pass-by-reference vs. pass-by-value). * Predict the Java EE components that are allowed to inject references to enterprise beans.
h2. EJB 3.1 Message-Driven Beans
* Create a Message-Driven Bean. * Create code that uses JMS to send a message by: ** Injecting a JMS connection factory. ** Injecting a JMS queue. ** Creating a message using the connection factory and queue. ** Sending the message.
h2. Transactions
* Create an enterprise bean that uses container-managed transaction demarkation. * Create an enterprise bean that uses bean-managed transaction demarkation. * Modify the transaction attributes of an enterprise bean. * Predict the behavior of an enterprise bean with both transaction annotations and deployment descriptor tags. * Modify an enterprise bean to correctly use {{getRollbackOnly}}, {{setRollbackOnly}} and the {{SessionSynchronization}} interface.
h2. Interceptors
* Create an enterprise bean: ** declares a method-level interceptor. ** declares a class-level interceptor. ** includes an interceptor method. * Create the interceptor classes required by the previous enterprise bean. * Predict the order in which enterprise bean interceptors are invokes for a given enterprise bean and its interceptor(s). * Predict the behavior of an enterprise bean interceptor that: ** uses interceptor annotations only. ** uses both interceptor annotations and tags in the deployment descriptor.
h2. Exceptions
* Modify an enterprise bean to correctly use an application exception. * Modify an enterprise bean to correctly handle a system exception. * Modify an enterprise bean to define a runtime exception as an application exception. * Predict whether the bean-developer, container provider, or neither is responsible for throwing or handling an exception. * Predict what happens when an EJB client encounters an exception when it invokes an EJB. * Given a particular method condition, predict: whether an exception will be thrown, the type of exception thrown, the container's action, and the client's view.
h2. Embeddable EJB Containers
* EJB-lite vs Full EJBs * Use in unit testing
h2. Security Management
* Modify an enterprise bean to limit the invokation of one or more business methods to a particular role. * Modify an enterprise bean to limit all the business methods of the enterprise bean to a particular role. * Match security behaviors to declarative security specifications (default behavior, security roles, security role references, and method permissions). * From a list of responsibilities, predict which roles are responsible for which aspects of security: application assembler, bean provider, deployer, container provider, system administrator, or server provider. * Use the {{isCallerInRole}} and {{getCallerPrincipal}} methods in an enterprise bean to restrict access to the enterprise bean's business methods. * Predict the behavior of an enterprise bean that: ** only uses security annotations. ** uses both security annotations and security tags in the enterprise bean's deployment descriptor. |