66. Managed Beans 1.0: Example @ManagedBean @Interceptors(LoggingInterceptor.class) public class MyPojo { public void myMethod() {...} } public class LoggingInterceptor { @AroundInvoke public Object logMethod(InvContext ic) {...} }
67.
68. Inject the managed bean through @Resource (works only under a container environment)
89. ItemController Bean and Dependency Injection import service.CatalogService; @Controller @Scope("session") public class ItemController { @Inject private CatalogService catalogService ; . . . Inject Bean Creates ItemController bean no need to put in .xml CatalogService injected by type
90. Demo: How to Check Out “ glassfish-samples” www.javapassion.com/handsonlabs/javaee6_examples/#Exercise_1
91. Demo: DI & CDI “ webbeans-guess” (Available from “ glassfish-samples” project)
103. JPA 2.0: Collection of basic types @Entity Public class Item { @ElementCollection private Set<String> tags; } @Entity Public class Item { @ElementCollection @CollectionTable(name="TAGS") private Set<String> tags; } Mapped by default in ITEM_TAGS Mapped in TAGS
109. Example: JPQL CASE Expression @Entity public class Employee { @Id Integer empId; String name; Float salary; Integer rating; // ... } UPDATE Employee e SET e.salary = CASE WHEN e.rating = 1 THEN e.salary * 1.05 WHEN e.rating = 2 THEN e.salary * 1.02 ELSE e.salary * 0.95 END
118. read then lock and refresh public enum LockModeType { OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC, PESSIMISTIC_FORCE_INCREMENT, NONE }
119. Example Scenario public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId); // … Do some work to compute charge double balance = acct.getBalance(); if (charge > 0){ acct.setBalance(balance – charge); } em.getTransaction().commit(); } source: Mike Keith
120. Pessimistic Locking: Example 1 // // Read then lock // public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId); // … Do some work to compute charge double balance = acct.getBalance(); if (charge > 0){ em.lock(acct, PESSIMISTIC); acct.setBalance(balance – charge); } em.getTransaction().commit(); } source: Mike Keith
121. Pessimistic Locking: Example 2 // // Read and lock // public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId, PESSIMISTIC ); // … Do some work to compute charge double balance = acct.getBalance(); if (charge > 0){ acct.setBalance(balance – charge); } em.getTransaction().commit(); } source: Mike Keith
122. Pessimistic Locking: Example 3 // // Read then lock and refresh // public void applyCharges () { em.getTransaction().begin(); Account acct = em.find (Account.class, acctId); // … Do some work to compute charge em.refresh(acct, PESSIMISTIC); double balance = acct.getBalance(); if (charge > 0){ acct.setBalance(balance – charge); } em.getTransaction().commit(); } source: Mike Keith
127. JPA 2.0: Criteria API Example #1 // Retrieve all orders whose lineitems is empty. // Using Criteria API CriteriaBuilder qb = em.getEntityManagerFactory().getCriteriaBuilder(); CriteriaQuery<Order> cq = qb.createQuery(Order.class); Root<Order> order = cq.from(Order.class); cq.where(qb.isEmpty(order.get(Order_.lineitems))).select(order); // Using JPQL SELECT o FROM Order o WHERE o.lineItems IS EMPTY
128. JPA 2.0: Criteria API Example #2 // Using Criteria API CriteriaBuilder qb = em.getEntityManagerFactory().getCriteriaBuilder(); CriteriaQuery<Customer> q = qb.createQuery(Customer.class); Root<Customer> customer = q.from(Customer.class); Join<Customer,Order> order = customer.join(Customer_.orders, JoinType.LEFT); q.where(qb.equal(customer.get(Customer_.status), 1)) .select(customer); // Using JPQL SELECT c FROM Customer c LEFT JOIN c.orders o WHERE c.status = 1
136. // web.xml is not needed anymore @WebServlet(urlPatterns=“/foo”, name=”MyServlet”, asyncSupported=true ) public class SimpleSample extends HttpServlet{ public void doGet( HttpServletRequest req, HttpServletResponse res){ // Some code } } Ease of Use: Use of Annotation
137. public class TestServletContextListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { ServletContext servletConext = sce.getServletContext(); // Servlets/Filters can be added during runtime ServletRegistration.Dynamic dynamic = servletContext. addServlet ( "DynamicServlet", "com.mycom.MyServlet"); dynamic. addMapping ("/dynamicServlet"); dynamic. setAsyncSupported (true); Dynamic Registration of Servlets/Filters
169. EJB 3.1: Asynchronous calls @Stateless public class OrderBean { public void createOrder() { Order order = persistOrder(); sendEmail(order) ; } public Order persistOrder() {...} @Asynchronous public Future<Long> sendEmail(Order order){ ...} }
170. EJB 3.1: Timer Service @Stateless public class WakeUpBean { @Schedule(dayOfWeek="Mon-Fri", hour="9") void wakeUp() { ... } }
214. Bean Validation 1.0: Example public class Address { @NotNull @Size(max=30, message="longer than {max} characters") private String street1; ... @NotNull @Valid private Country country; } public class Country { @NotNull @Size(max=30) private String name; ... }
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
Based on java.util.concurrent.Future<V> For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future<V> e.g. public Future<int> compute(Task t) Method implementation returns javax.ejb.AsyncResult<V> Concrete helper class for passing result value to container javax.ejb.AsyncResult<V> implements Future<V> Constructor takes result value as argument
Based on java.util.concurrent.Future<V> For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future<V> e.g. public Future<int> compute(Task t) Method implementation returns javax.ejb.AsyncResult<V> Concrete helper class for passing result value to container javax.ejb.AsyncResult<V> implements Future<V> Constructor takes result value as argument
Based on java.util.concurrent.Future<V> For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future<V> e.g. public Future<int> compute(Task t) Method implementation returns javax.ejb.AsyncResult<V> Concrete helper class for passing result value to container javax.ejb.AsyncResult<V> implements Future<V> Constructor takes result value as argument
Based on java.util.concurrent.Future<V> For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future<V> e.g. public Future<int> compute(Task t) Method implementation returns javax.ejb.AsyncResult<V> Concrete helper class for passing result value to container javax.ejb.AsyncResult<V> implements Future<V> Constructor takes result value as argument
getItems() method wraps a List of items, returned from the CatalogFacade Stateless Session EJB, in a DataModel. dataTable, supports data binding to a collection of data objects represented by a DataModel instance, which is the current value of this component itself. The data collection underlying a DataModel instance is modeled as a collection of row objects that can be accessed by a row index. The APIs provide mechanisms to position to a specified row index, and to retrieve an object that represents the data that corresponds to the current row index.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
Based on java.util.concurrent.Future<V> For : Result values System/Application exceptions thrown from target bean Cancelation requests Method signature declares return type as Future<V> e.g. public Future<int> compute(Task t) Method implementation returns javax.ejb.AsyncResult<V> Concrete helper class for passing result value to container javax.ejb.AsyncResult<V> implements Future<V> Constructor takes result value as argument
Goal is to remove an artificial packaging restriction NOT to create a new flavor of EJB component EJB component behavior is independent of packaging One exception : module-level vs. component-level environment Full EJB container functionality available No new restrictions placed on .war Deploy stand-alone OR in an .ear
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.
This is a single one-slider on Java EE 5 trying to capture the essence of the improvements from a developer perspective. Ease of development doesn't mean we remove anything, simply add a level of abstraction, use sensible default, and keep the number for files and artifacts to a minimum. Deployment descriptors are still present if you or your company needs them. JSF is not new (v1.2) but it's now part of the platform. Every application server from now on has a JSF implementation.