Java Reference
In-Depth Information
the DME. For example, some database vendors offer data mining
capabilities where the DME is embedded in the database. Non-
database vendors provide the DME as a middle tier component that
accesses data from databases and file systems. How applications con-
nect to a DME depends on a vendor's implementation choices. To
isolate vendor-specific dependencies, JDM uses a vendor-neutral
connector architecture that allows applications to connect to a DME
with interoperable code. Using the Java Naming and Directory Inter-
face (JNDI) and the factory method pattern, JDM isolates the vendor-
specific connection implementation. This section discusses the
details of the connection interfaces.
ConnectionFactory is the factory object that can create a Connection
object. The ConnectionFactory object has three overloaded getConnec-
tion methods. Each method supports a different type of DME con-
nection configuration. The getConnection(ConnectionSpec) method,
allows users to specify the DME location and authentication details
in a ConnectionSpec object to obtain a connection. In this approach,
the application must provide a ConnectionSpec object each time it
wants to obtain a connection. This would be suitable for applica-
tions where a user must log into the DME with credentials to do a
mining operation.
The getConnection(javax.resource.cci.Connection) method connects
to DMEs that support the J2EE Connector Architecture (JCA). In this
case, applications can use a DME's JCA connection and supply it to
the getConnection method to obtain a JDM Connection object. This
approach is suitable for DMEs that provide JCA-based connections.
The third method, getConnection( ) , does not take any inputs from
the application. The ConnectionFactory holds the DME connection
details and creates a Connection object. This approach is suitable for
applications where the user does not need to provide DME details to
perform mining. Vendor products can support all three methods;
however, at least one of the getConnection methods must be
Figure 8-14 illustrates how a vendor, XYZ, might implement
connection-related interfaces using the factory method pattern.
Here, the ConnectionFactory interface provides getConnection meth-
ods to create a Connection object. Note that the XYZConnectionFac-
tory implements Serializable and Referenceable interfaces in addition
to the ConnectionFactory interface. This enables the connection fac-
tory object to register with a JNDI service, and applications can look
up the JNDI server to obtain the connection factory object in a
Search WWH ::

Custom Search