Ch 1.9.2 of Java EE 7 Tutorial
Chapter 3 of Java EE 7 Tutorial
Resource
direct look-up through JNDI interface
@Resource annotation
deployment descriptor
JNDI
naming environment - a naming environment allow a component to be customized without need to access / change source code
naming context - container implements the component's environment and provide it to the component as a JNDI naming context
JNDI interface - javax.naming.InitialContext
Component's environment naming context (system provided): under java:comp/env
User-defined objects:
should be named within a subcontext of the naming environment according to the type
enterprise bean: java:comp/env/ejb
JDBC data source: java:comp/env/jdbc
GlassFish default data source: java/comp/DefaultDataSource
DataSource
JDBC API
getConnection
pooling
type - PooledConnection
has no effect on application code
(like all connections) should always be explicitly closed