Monday, December 18, 2006

Section 1: EJB 3.0 Overview - 1b

1b) Identify the APIs that all EJB 3.0 containers must make available to developers

An EJB 3.0 container must make the following APIs available to the enterprise bean instances at runtime:


· Java 2 Platform, Standard Edition v5 (J2SE) APIs, which include the following APIs:

o JDBC
The EJB container must include the JDBC 3.0 extension and provide its functionality to the enterprise bean instances, with the exception of the low-level XA and connection pooling interfaces. These low-level interfaces are intended for integration of a JDBC driver with an application server, not for direct use by enterprise beans.

o RMI-IIOP
An enterprise bean's remote business interfaces and/or remote home and remote interfaces are remote interfaces for Java RMI. The container must ensure the semantics for passing arguments conforms to Java RMI-IIOP. Non-remote objects must be passed by value.
Specifically, the EJB container is not allowed to pass non-remote objects by reference on inter-EJB invocations when the calling and called enterprise beans are collocated in the same JVM. Doing so could result in the multiple beans sharing the state of a Java object, which would break the enterprise bean's semantics. Any local optimizations of remote interface calls must ensure the semantics for passing arguments conforms to Java RMI-IIOP.
An enterprise bean's local business interfaces and/or local home and local interfaces are local Java interfaces. The caller and callee enterprise beans that make use of these local interfaces are typically collocated in the same JVM. The EJB container must ensure the semantics for passing arguments across these interfaces conforms to the standard argument passing semantics of the Java programming language.

o JNDI
At the minimum, the EJB container must provide a JNDI API name space to the enterprise bean instances. The EJB container must make the name space available to an instance when the instance invokes the javax.naming.InitialContext default (no-arg) constructor.
The EJB container must make available at least the following objects in the name space:
· The business interfaces of other enterprise beans.
· The resource factories used by the enterprise beans.
· The entity managers and entity manager factories used by the enterprise beans.
· The web service interfaces used by the enterprise beans.
· The home interfaces of other enterprise beans.
· ORB objects
· UserTransaction objects
· EJBContext objects
· TimerService objects

o JAXP

o Java IDL
· EJB 3.0 APIs, including the Java Persistence API
The container must implement the semantics of the metadata annotations that are supported by EJB 3.0
The container must implement (or provide through a third-party implementation) the javax.persistence interfaces and metadata annotations.
· JTA 1.1, the UserTransaction interface only
The EJB container must include the JTA 1.1 extension, and it must provide the javax.transaction. UserTransaction interface to enterprise beans with bean-managed transaction demarcation through the javax.ejb.EJBContext interface, and also in JNDI under the name java:comp/UserTransaction, in the cases required by the EJB specification.
· JMS 1.1
The EJB container must include the JMS 1.1 extension and provide its functionality to the enterprise bean instances, with the exception of the low-level interfaces that are intended for integration of a JMS provider with an application server, not for direct use by enterprise beans.
· JavaMail 1.4, sending mail only
· JAF 1.1
· JAXP 1.2
· JAXR 1.0
· JAX-RPC 1.1
· JAX-WS 2.0
· JAXB 2.0
· SAAJ 1.3
· Connector 1.5
· Web Services 1.2
· Web Services Metadata 2.0
· Common Annotations 1.0
· StAX 1.0

NOTE: The EJB architecture DOES NOT require the EJB container to support the JTS interfaces.

Sunday, December 17, 2006

Section 1: EJB 3.0 Overview - 1a

  • Identify the uses, benefits, and characteristics of Enterprise JavaBeans technology, for version 3.0 of the EJB specification.
  • Identify the APIs that all EJB 3.0 containers must make available to developers.
  • 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.
  • Describe the packaging and deployment requirements for enterprise beans.
  • Describe the purposes and uses of annotations and deployment descriptors, including how the two mechanisms interact, how overriding is handled, and how these mechanisms function at the class, method, and field levels.
1a) Identify the uses, benefits, and characteristics of Enterprise JavaBeans technology, for version 3.0 of the EJB specification

ENTERPRISE beans are Java Enterprise Edition (Java EE) components that implement Enterprise Java-Beans (EJB) technology. An enterprise bean is a server-side component that encapsulates the business logic of an application. Enterprise beans run in the EJB container, a runtime environment within the Application Server. By using EJB, you can write scalable, reliable and secure applications without writing your own complex distributed component framework. Although transparent to the application developer, the EJB container provides system-level services such as transactions and security to its enterprise beans. EJB is about rapid application development for the server side.




When to Use Enterprise Beans
You should consider using enterprise beans if your application has any of the following requirements:
• The application must be scalable. To accommodate a growing number of users, you may need to distribute an application’s components across multiple machines. Not only can the enterprise beans of an application run on different machines, but also their location will remain transparent to the clients.
• Transactions must ensure data integrity. Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects.
• The application will have a variety of clients. With only a few lines of code, remote clients can easily locate enterprise beans. These clients can be thin, various, and numerous.

Benefits of Enterprise Beans

For several reasons, enterprise beans simplify the development of large, distributed applications.

First, because the EJB container provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems. The EJB container—and not the bean developer—is responsible for system-level services such as transaction management and security authorization.

Second, because the beans—and not the clients—contain the application’s business logic, the client developer can focus on the presentation of the client. The client developer does not have to code the routines that implement business rules or access databases. As a result, the clients are thinner, a benefit that is particularly important for clients that run on small devices.

Third, because enterprise beans are portable components, the application assembler can build new applications from existing beans. These applications can run on any compliant Java EE server provided that they use the standard APIs.

Characteristics of Enterprise Beans
The essential characteristics of an enterprise bean are:
• An enterprise bean typically contains business logic that operates on the enterprise’s data.
• An enterprise bean’s instances are managed at runtime by a container.
• An enterprise bean can be customized at deployment time by editing its environment entries.
• Various service information, such as transaction and security attributes, may be specified together with the business logic of the enterprise bean class in the form of metadata annotations, or separately, in an XML deployment descriptor. This service information may be extracted and managed by tools during application assembly and deployment.
• Client access is mediated by the container in which the enterprise bean is deployed.
• If an enterprise bean uses only the services defined by the EJB specification, the enterprise bean can be deployed in any compliant EJB container. Specialized containers can provide additional services beyond those defined by the EJB specification. An enterprise bean that depends on such a service can be deployed only in a container that supports that service.
• An enterprise bean can be included in an assembled application without requiring source code changes or recompilation of the enterprise bean.
• The Bean Provider defines a client view of an enterprise bean. The Bean Provider can manually define the client view or it can be generated automatically by application development tools. The client view is unaffected by the container and server in which the bean is deployed. This ensures that both the beans and their clients can be deployed in multiple execution environments without changes or recompilation.


Flexible Model
The enterprise bean architecture is flexible enough to implement the following:
• An object that represents a stateless service.
• An object that represents a stateless service and that implements a web service endpoint.
• An object that represents a stateless service and whose invocation is asynchronous, driven by the arrival of messages.
• An object that represents a conversational session with a particular client. Such session objects automatically maintain their conversational state across multiple client-invoked methods.
• An entity object that represents a fine-grained persistent object.

Enterprise beans that are remotely accessible components are intended to be relatively coarse-grained business objects (e.g. shopping cart, stock quote service). Fine-grained objects (e.g. employee record, line items on a purchase order) should be modeled as light weight persistent entities, not as remotely accessible components.

Although the state management protocol defined by the Enterprise JavaBeans architecture is simple, it provides an enterprise bean developer great flexibility in managing a bean’s state.

Session, Entity, and Message-Driven Objects
The Enterprise JavaBeans architecture defines the following types of enterprise bean objects:
• A session object.
• A message-driven object.
• An entity object.


Session Objects
A typical session object has the following characteristics:
• Executes on behalf of a single client.
• Can be transaction-aware.
• Updates shared data in an underlying database.
• Does not represent directly shared data in the database, although it may access and update such data.
• Is relatively short-lived.
• Is removed when the EJB container crashes. The client has to re-establish a new session object to continue computation.

A typical EJB container provides a scalable runtime environment to execute a large number of session objects concurrently. The EJB specification defines both stateful and stateless session beans. There are differences in the API between stateful session beans and stateless session beans.

Message-Driven Objects
A typical message-driven object has the following characteristics:
• Executes upon receipt of a single client message.
• Is asynchronously invoked.
• Can be transaction-aware.
• May update shared data in an underlying database.
• Does not represent directly shared data in the database, although it may access and update such data.
• Is relatively short-lived.
• Is stateless.
• Is removed when the EJB container crashes. The container has to re-establish a new message-driven object to continue computation.

A typical EJB container provides a scalable runtime environment to execute a large number of message-driven objects concurrently.

Entity Objects
A typical entity object has the following characteristics:
• Is part of a domain model, providing an object view of data in the database.
• Can be long-lived (lives as long as the data in the database).
• The entity and its primary key survive the crash of the EJB container. If the state of an entity was being updated by a transaction at the time the container crashed, the entity’s state is restored to the state of the last committed transaction when the entity is next retrieved.

A typical EJB container and server provide a scalable runtime environment for a large number of concurrently active entity objects.

What is New in EJB 3.0

The Enterprise JavaBeans 3.0 architecture extends Enterprise JavaBeans to include the following new functionality and simplifications to the earlier EJB APIs:

  • Definition of the Java language metadata annotations that can be used to annotate EJB applications.
  • Specification of programmatic defaults, including for metadata, to reduce the need for the developer to specify common, expected behaviors and requirements on the EJB container. A “configuration by exception” approach is taken whenever possible.
  • Encapsulation of environmental dependencies and JNDI access through the use of annotations, dependency injection mechanisms, and simple lookup mechanisms.
  • Simplification of the enterprise bean types.
  • Elimination of the requirement for EJB component interfaces for session beans. The required business interface for a session bean can be a plain Java interface rather than an EJBObject, EJBLocalObject, or java.rmi.Remote interface.
  • Elimination of the requirement for home interfaces for session beans.
  • Simplification of entity persistence through the Java Persistence API. Support for light-weight domain modeling, including inheritance and polymorphism.
  • Elimination of all required interfaces for persistent entities.
  • Specification of Java language metadata annotations and XML deployment descriptor elements for the object/relational mapping of persistent entities.
  • A query language for Java Persistence that is an extension to EJB QL, with addition of projection, explicit inner and outer join operations, bulk update and delete, subqueries, and group-by. Addition of a dynamic query capability and support for native SQL queries.
  • An interceptor facility for session beans and message-driven beans.
  • Reduction of the requirements for usage of checked exceptions.
  • Elimination of the requirement for the implementation of callback interfaces.

Feedback on Question Pattern

These were collected off different sites from comments of people who did the Free SCBCD 5.0 beta exam.

Persistence, Entity Beans, Query Language,Transactions (50% of Questions)
Session bean (15%)
Message driven Bean (15%)
Security (6%)
Others(14%)

Initially there were few survey questions (around 11). There are total 180 questions for the exam. Time: 5 hours.

Have good understanding on basic concepts. Concentrate more on Entity Beans/Peristance, Query Language and Transactions. There were also a couple of Task oriented questions in addition to the usual objective type questions. Exam is very tough.
I had prepared using Mastering EJB and Specs. Please do not rely on Mastering for Entity or Persistence I would rather suggest to go for Persistence specs from Sun, agreed they are bit difficult to understand but worth.

1) Focus on Entities, EJB-QL (Existing features + enhancements).
2) Know annotations well.
3) You can easily get through the questions on Session beans, MDBs, Security, Exceptions, Transaction just don't ignore anything while you are studying...
4) Keep cool during exam, you have 5 hours so plan your strategy accordingly. You must finish 36 questions every hour to be in pace. Keep a watch on your pace to avoid last hour rush.
5) Don't waste time on tough questions just go ahead with the next, keep a note of those to be later if time permits.
Start studies with Mastering EJB 3.0, it is very useful to get aquainted with the concepts. You have to study only first 12 chapters if you are focussing only for certification. In addition with this use specs(EJB core and persistence). You can finish 12 chapters of Mastering easily in 10 days, and then use rest of the time to study Entity, persistence and Exceptions. It is good to know relationship between elements in DD and annotations and overriding rules. I would suggest to spend more time of annotation than DD. Lastly you need to have good understanding of persistence.xml

In fact in Chaper 11, you can skip around 25-35 pages and read only part relevant to EJB exam. Read Headfirst EJB book for prior version for Security. It is oriented more towards exam and I believe it covers Security details in good depth. Mastering doesn't cover it in enough depth for exam.

I believe you can skip the Chapter 7 to 11 from Specs and read sections relevant only to EJB3.0 But some of the concepts in EJB3.0 are based on prior versions so just browse through once. Try to get in depth information about BMP, CMP and EJB-QL.

From Headfirst you can study following topics.
1) Transaction
2) Exceptions
3) Security Management
4) Message Driven Beans (Only conceptual part and their lifecycle, information about clients and type of subscribers supported.)

Make sure you refer to corresponding annotations for the new version. This will be solid enough to answer any questions in this area. For topics like- Persistence, Entity Beans, EJB Query Language (which comprises 50% of Questions) I would recommend EJB 3.0 by Orielly.

Useful Links for EJB 3.0/J2EE 1.5

Beta Exam Registration Procedure - 311-091

Recommended Prerequisites

  • Candidates MUST already be a Sun Certified Programmer (any edition) in order to receive your certification kit if you pass the beta exam.
  • It is strongly recommended that beta takers have 4-6 months experience using EJB 3.0.

Beta Exam Registration Procedure
Unlike other Sun Microsystems certification exams, this exam does NOT require a voucher. To register for the "Sun Certified Business Component Developer for the Java Platform, Enterprise Edition 5.0" Beta exam, you may register by phone, by calling your regional Prometric registration office, listed at: www.prometric.com/Sun/default.htm.


Please reference exam number 311-091 when calling.

Asia/Australia: Phone numbers listed at www.prometric.com/Sun/APACIT.htm
Europe: Phone numbers listed at www.prometric.com/Sun/EMEAIT.htm
Japan: 81-0120-107737
USA/Canada: 1-800-795-3926
Latin America, India, and Pakistan: Contact your local Prometric testing center, listed at www.prometric.com/Sun/default.htm

Detailed Exam Objectives

FREE: SCBCD 5.0 Beta Certification Exam
Detailed Exam Objectives: Sun Certified Business Component Developer (SCBCD)

Section 1: EJB 3.0 Overview

  • Identify the uses, benefits, and characteristics of Enterprise JavaBeans technology, for version 3.0 of the EJB specification.
  • Identify the APIs that all EJB 3.0 containers must make available to developers.
  • 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.
  • Describe the packaging and deployment requirements for enterprise beans.
  • Describe the purposes and uses of annotations and deployment descriptors, including how the two mechanisms interact, how overriding is handled, and how these mechanisms function at the class, method, and field levels.


Section 2: General EJB 3.0 Enterprise Bean Knowledge

  • Identify correct and incorrect statements or examples about the lifecycle of all 3.0 Enterprise Bean instances, including the use of the @PostConstruct and @PreDestroy callback methods.
  • Identify correct and incorrect statements or examples about interceptors, including implementing an interceptor class, the lifecycle of interceptor instances, @AroundInvoke methods, invocation order, exception handling, lifecycle callback methods, default and method level interceptors, and specifying interceptors in the deployment descriptor.
  • Identify correct and incorrect statements or examples about how enterprise beans declare dependencies on external resources using JNDI or dependency injection, including the general rules for using JNDI, annotations and/or deployment descriptors, EJB references, connection factories, resource environment entries, and persistence context and persistence unit references.
  • Identify correct and incorrect statements or examples about Timer Services, including the bean provider's view and responsibilities, the TimerService, Timer and TimerHandle interfaces, and @Timeout callback methods.
  • Identify correct and incorrect statements or examples about the EJB context objects that the container provides to 3.0 Session beans and 3.0 Message-Driven beans, including the security, transaction, timer, and lookup services the context can provide.
  • Identify correct and incorrect statements or examples about EJB 3.0 / EJB 2.x interoperability, including how to adapt an EJB 3.0 bean for use with clients written to the EJB 2.x API and how to access beans written to the EJB 2.x API from beans written to the EJB 3.0 API.


Section 3: EJB 3.0 Session Bean Component Contract & Lifecycle

  • Identify correct and incorrect statements or examples that compare the purpose and use of Stateful and Stateless Session Beans.
  • Identify correct and incorrect statements or examples about remote and local business interfaces for Session Beans.
  • Write code for the bean classes of Stateful and Stateless Session Beans.
  • Identify correct and incorrect statements or examples about the lifecycle of a Stateful Session Bean including the @PrePassivate and @PostActivate lifecycle callback methods and @Remove methods.
  • Given a list of methods of a Stateful or Stateless Session Bean class, define which of the following operations can be performed from each of those methods: SessionContext interface methods, UserTransaction methods, access to the java:comp/env environment naming context, resource manager access, and other enterprise bean access.
  • Identify correct and incorrect statements or examples about implementing a session bean as a web service endpoint, including rules for writing a web service endpoint interface and use of the @WebService and @WebMethod annotations.
  • Identify correct and incorrect statements or examples about the client view of a session bean, including the client view of a session object's life cycle, obtaining and using a session object, and session object identity.


Section 4: EJB 3.0 Message-Driven Bean Component Contract

  • Develop code that implements a Message-Driven Bean Class.
  • Identify correct and incorrect statements or examples about the interface(s) and methods a JMS Message-Driven bean must implement, and the required metadata.
  • Describe the use and behavior of a JMS message driven bean, including concurrency of message processing, message redelivery, and message acknowledgement.
  • Identify correct and incorrect statements or examples about the client view of a message driven bean.


Section 5: Java Persistence API Entities

  • Identify correct and incorrect statements or examples about the characteristics of Java Persistence entities.
  • Develop code to create valid entity classes, including the use of fields and properties, admissible types, and embeddable classes.
  • Identify correct and incorrect statements or examples about primary keys and entity identity, including the use of compound primary keys.
  • Implement association relationships using persistence entities, including the following associations: bidirectional for @OneToOne, @ManyToOne, @OneToMany, and @ManyToMany; unidirectional for @OneToOne, @ManyToOne, @OneToMany, and @ManyToMany.
  • Given a set of requirements and entity classes choose and implement an appropriate object-relational mapping for association relationships.
  • Given a set of requirements and entity classes, choose and implement an appropriate inheritance hierarchy strategy and/or an appropriate mapping strategy.
  • Describe the use of annotations and XML mapping files, individually and in combination, for object-relational mapping.


Section 6: Java Persistence Entity Operations

  • Describe how to manage entities, including using the EntityManager API and the cascade option.
  • Identify correct and incorrect statements or examples about entity instance lifecycle, including the new, managed, detached, and removed states.
  • Identify correct and incorrect statements or examples about EntityManager operations for managing an instance's state, including eager/lazy fetching, handling detached entities, and merging detached entities.
  • Identify correct and incorrect statements or examples about Entity Listeners and Callback Methods, including: @PrePersist, @PostPersist, @PreRemove, @PostRemove, @PreUpdate, @PostUpdate, and @PostLoad, and when they are invoked.
  • Identify correct and incorrect statements about concurrency, including how it is managed through the use of @Version attributes and optimistic locking.


Section 7: Persistence Units and Persistence Contexts

  • Identify correct and incorrect statements or examples about JTA and resource-local entity managers.
  • Identify correct and incorrect statements or examples about container-managed persistence contexts.
  • Identify correct and incorrect statements or examples about application-managed persistence contexts.
  • Identify correct and incorrect statements or examples about transaction management for persistence contexts, including persistence context propagation, the use of the EntityManager.joinTransaction() method, and the EntityTransaction API.
  • Identify correct and incorrect statements or examples about persistence units, how persistence units are packaged, and the use of the persistence.xml file.
  • Identify correct and incorrect statements or examples about the effect of persistence exceptions on transactions and persistence contexts.

Section 8: Java Persistence Query Language

  • Develop queries that use the SELECT clause to determine query results, including the use of entity types, use of aggregates, and returning multiple values.
  • Develop queries that use Java Persistence Query Language syntax for defining the domain of a query using JOIN clauses, IN, and prefetching.
  • Use the WHERE clause to restrict query results using conditional expressions, including the use of literals, path expressions, named and positional parameters, logical operators, the following expressions (and their NOT options): BETWEEN, IN, LIKE, NULL, EMPTY, MEMBER [OF], EXISTS, ALL, ANY, SOME, and functional expressions.
  • Develop Java Persistence Query Language statements that update a set of entities using UPDATE/SET and DELETE FROM.
  • Declare and use named queries, dynamic queries, and SQL (native) queries.
    Obtain javax.persistence.Query objects and use the javax.persistence.Query API.


Section 9: Transactions

  • Identify correct and incorrect statements or examples about bean-managed transaction demarcation.
  • Identify correct and incorrect statements or examples about container-managed transaction demarcation, and given a list of transaction behaviors, match them with the appropriate transaction attribute.
  • Identify correct and incorrect statements or examples about transaction propagation semantics.
  • Identify correct and incorrect statements or examples about specifying transaction information via annotations and/or deployment descriptors.
  • Identify correct and incorrect statements or examples about the use of the EJB API for transaction management, including getRollbackOnly, setRollbackOnly and the SessionSynchronization interfaces.


Section 10: Exceptions

  • Identify correct and incorrect statements or examples about exception handling in EJB.
  • Identify correct and incorrect statements or examples about application exceptions and system exceptions in session beans and message-driven beans, and defining a runtime exception as an application exception.
  • Given a list of responsibilities related to exceptions, identify those which are the bean provider's, and those which are the responsibility of the container provider. Be prepared to recognize responsibilities for which neither the bean nor container provider is responsible.
  • Identify correct and incorrect statements or examples about the client's view of exceptions received from an enterprise bean invocation.
  • Given a particular method condition, identify the following: whether an exception will be thrown, the type of exception thrown, the container's action, and the client's view.


Section 11: Security Management

  • Match security behaviors to declarative security specifications (default behavior, security roles, security role references, and method permissions).
  • From a list of responsibilities, identify which roles are responsible for which aspects of security: application assembler, bean provider, deployer, container provider, system administrator, or server provider.
  • Identify correct and incorrect statements or examples about use of the isCallerInRole and getCallerPrincipal EJB programmatic security APIs.
  • Given a security-related deployment descriptor tag or annotation, identify correct and incorrect statements and/or code related to that tag.

Main Exam Objectives:

In short the exam mainly covers the following topics:

  • EJB 3.0 Overview
  • Session Beans
  • Message Driven Beans
  • Java Persistence API
  • Entity Beans
  • Java Persistence QL
  • Transactions
  • Exceptions
  • Security

FREE: SCBCD 5.0 Beta Certification Exam

Are you a developer who is responsible for designing and implementing applications using Enterprise JavaBeans 3.0? If so, this is your opportunity to get involved in the creation of the Sun Certified Business Component Developer (SCBCD) 5.0 exam!!!!!

» Beta Dates: December 8, 2006 – January 2, 2007
» Registration Start Date: November 24, 2006
» Beta Exam Number: 311-091

As a beta tester, you officially test the test and will be able to provide Sun with valuable comments and technical feedback about the Sun Certified Business Component Developer questions. The Sun beta exam counts towards official SCBCD Certification!

For more info, visit - http://www.sun.com/training/certification/java/beta_scbcd.xml