|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectibi.broker.api.CasterManagedConnectionFactory
public class CasterManagedConnectionFactory
Within the ReportCaster API, theCasterManagedConnectionFactory
class along with theCasterConnectionFactory
andCasterConnection
classes are the primary means for obtaining connections to ReportCaster. The three classes facilitate the application client component's ability to obtain a connection to ReportCaster repository and Distribution Server and are implementations of the JCA'sManagedConnectionFactory
,ConnectionFactory
, andConnection
classes respectively. These three classes together form the basis of ReportCaster's implementation of the J2EE CCI interfaces.The
CasterManagedConnectionFactory
class acts essentially as a factory for bothCasterConnectionFactory
instances andManagedConnection
instances. Whereas theCasterConnectionFactory
object creates connections to the ReportCaster Repository (in the form ofCasterConnection
instances), CasterManagedConnectionFactory creates managed connections (i.e.,ManagedConnection
instances), which represent the actual physical connection to ReportCaster. This is the class which is responsible for all the Application Server level connection pooling facilities available through JCA. When an application server needs to create a connection factory it calls the createConnectionFactory method of CasterManagedConnnectionFactory, passing in an instance ofConnectionManager
. This ConnectionManager instance is what is called by the client application component (EJB, Servlets, JSP, as well as the ReportCaster application itself) when it issues a call toCasterConnectionFactory.getConnection()
in order to obtain a connection handle (i.e.,CasterConnection
to ReportCaster. The main methods CasterConnectioFactory uses to support its functionality are the following:
The code below illustrates how the CasterManagedConnectionFactory
class is used.
The sample code below is taken from the samples packaged with the product.
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Copyright (c) 2004 Information Builders, Inc. All Rights Reserved. +
+ +
+ Information Builders offers sample API programs as a heuristic device. +
+ They are not intended, as is, for production use. Licensed users are +
+ welcome to alter and extend these samples and deploy them in other +
+ environments, or alternate configurations, as they see fit. +
+ Information Builders will support the documented functionality of +
+ its API classes and methods. However, Information Builders is not +
+ responsible for functionality or behavior of products built with +
+ its API unless the documented behavior of its discrete classes and +
+ methods is different than the actual results. +
+ +
+ Redistributions of IBI source code and documentation must be within +
+ the scope of the Information Builders Software License Agreement. +
+ +
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package ibi.broker.api.samples;
import ibi.broker.api.CasterManagedConnectionFactory;
import ibi.broker.api.cci.CasterConnection;
import ibi.broker.api.cci.CasterConnectionFactory;
import ibi.broker.api.cci.PasswordCredential;
import java.util.ResourceBundle;
import javax.resource.cci.ConnectionSpec;
public class Util
{
public static CasterConnection createCasterConnection() throws Exception
{
ResourceBundle bundle = null;
String host = "localhost";
String port = "8200";
String user = "admin";
String password = "";
try
{
bundle = ResourceBundle.getBundle("ibi.broker.api.samples.samples");
host = bundle.getString("host");
port = bundle.getString("port");
user = bundle.getString("user");
password = bundle.getString("password");
}
catch(Exception ex){}
CasterManagedConnectionFactory managedConnectionFactory = new CasterManagedConnectionFactory();
managedConnectionFactory.setServerName(host);
managedConnectionFactory.setPortNumber(port);
CasterConnectionFactory connectionFactory = (CasterConnectionFactory)managedConnectionFactory.createConnectionFactory();
ConnectionSpec credential = new PasswordCredential(user, password.toCharArray());
return ((CasterConnection)connectionFactory.getConnection(credential));
}
Field Summary | |
---|---|
static int |
CONSOLE_MODE
|
static int |
DB
Repository type representing a RDMS database. |
static int |
FULLFUNCTION_MODE
|
static int |
LDAP
Repository type representing a LDAP directory. |
Constructor Summary | |
---|---|
CasterManagedConnectionFactory()
Constructor for CasterManagedConnectionFactory. |
Method Summary | |
---|---|
java.lang.Object |
createConnectionFactory()
Creates a CasterConnectionFactory instance. |
java.lang.Object |
createConnectionFactory(javax.resource.spi.ConnectionManager cxManager)
Creates a CasterConnectionFactory instance. |
javax.resource.spi.ManagedConnection |
createManagedConnection(javax.security.auth.Subject subject,
javax.resource.spi.ConnectionRequestInfo connInfo)
Creates a new physical connection to ReportCaster's underlying Repository. |
java.io.PrintWriter |
getLogWriter()
Obtains the log writer for this CasterManagedConnectionFactory instance. |
int |
getServerStatus()
|
javax.resource.spi.ManagedConnection |
matchManagedConnections(java.util.Set set,
javax.security.auth.Subject subject,
javax.resource.spi.ConnectionRequestInfo connReqInfo)
Determines whether there is an existing connection in the connection pool (which contains a pool of ManagedConnection instances
and stored in the connection set parameter, set ) that can be used
as a connection to the ReportCaster Repository. |
void |
setIbiDocumentRoot(java.lang.String ibiDocumentRoot)
|
void |
setLogWriter(java.io.PrintWriter arg0)
Sets the log writer for this CasterManagedConnectionFactory
instance. |
void |
setPortNumber(java.lang.String agentPort)
Specifies the ReportCaster Distribution Server's port number. |
void |
setReporsitoryType(int type)
Specifies the repository type. |
void |
setServerName(java.lang.String agentNode)
Specifies the server name where ReportCaster Distribution Server is located. |
void |
setTrustedKeyFile(java.lang.String file)
Deprecated. this method is no longer needed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.resource.spi.ManagedConnectionFactory |
---|
equals, hashCode |
Field Detail |
---|
public static final int DB
public static final int LDAP
public static final int FULLFUNCTION_MODE
public static final int CONSOLE_MODE
Constructor Detail |
---|
public CasterManagedConnectionFactory()
Method Detail |
---|
public java.lang.Object createConnectionFactory(javax.resource.spi.ConnectionManager cxManager) throws javax.resource.ResourceException
CasterConnectionFactory
instance. In this case, the
connection factory instance gets initialized with the passed
ConnectionManager
. Associated with the connection factory
are a CasterManagedConnectionFactory or optionally a
ConnectionManager
, which in the managed scenario is
provided by the J2EE Application Server.
createConnectionFactory
in interface javax.resource.spi.ManagedConnectionFactory
cxManager
- - Connection Manager to be associated with created
CasterConnectionFactory
instance
javax.resource.ResourceException
ManagedConnectionFactory.createConnectionFactory(javax.resource.spi.ConnectionManager)
public java.lang.Object createConnectionFactory() throws javax.resource.ResourceException
CasterConnectionFactory
instance. In this case, the
CasterConnectionFactory
instance gets
initialized with a default ConnectionManager
provided by the
resource adapter.
createConnectionFactory
in interface javax.resource.spi.ManagedConnectionFactory
javax.resource.ResourceException
- - Generic exceptionManagedConnectionFactory.createConnectionFactory()
public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo connInfo) throws javax.resource.ResourceException
CasterManagedConnectionFactory
uses the
security information (passed as a Subject
) and additional
ConnectionRequestInfo
from the client application
component which is generating the request to create a new connection.
createManagedConnection
in interface javax.resource.spi.ManagedConnectionFactory
subject
- - JAAS concept representing a grouping of
related security information for a single user/entity (i.e, the caller). It includes
identities (each known as a Principal), and security-related attributes called
Credentials. In the case of container managed sign-on (which we do not
currently support) the Subject object comes from the security contract that is a
part of the system contract between the application server and the resource
adapter. In the case of application managed sign-on (which we do support),
security information is sent as a ConnnectionRequestInfo object, and the
subject that is sent to the resource adapter is null
.connInfo
- Security related connection request information (e.g., username and password).
javax.resource.ResourceException
ManagedConnectionFactory.createManagedConnection(javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
public javax.resource.spi.ManagedConnection matchManagedConnections(java.util.Set set, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo connReqInfo) throws javax.resource.ResourceException
ManagedConnection
instances
and stored in the connection set parameter, set
) that can be used
as a connection to the ReportCaster Repository. The criteria for making a
match is based on the security information of the current user as represented in
the Subject
instance (non-null in managed mode) and
ConnectionRequestInfo
instance. This method returns a single
ManagedConnection instance that is the best match for handling the connection
allocation request. If no match is found, the method will return
null
.
matchManagedConnections
in interface javax.resource.spi.ManagedConnectionFactory
javax.resource.ResourceException
ManagedConnectionFactory.matchManagedConnections(java.util.Set, javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
public void setLogWriter(java.io.PrintWriter arg0) throws javax.resource.ResourceException
CasterManagedConnectionFactory
instance. The log writer is a character output stream to which all logging and
tracing messages will be printed. The J2EE Application Server manages the
association of output stream with this
CasterManagedConnectionFactory
. When an instance of
CasterManagedConnectionFactory
is created the log writer is
initially null
, in other words, logging is disabled. Once a log
writer is associated with a CasterManagedConnectionFactory instance, logging
and tracing is enabled.
The ManagedConnection
instances created by
CasterManagedConnectionFactory inherits the log writer, which can be
overridden by the Application Server using this method to specify the logging
and tracing for a managed connection. Once a managed connection object is
returned to the connection pool, this instance of
CasterManagedConnectionFactory should be set to null
.
setLogWriter
in interface javax.resource.spi.ManagedConnectionFactory
javax.resource.ResourceException
ManagedConnectionFactory.setLogWriter(java.io.PrintWriter)
public java.io.PrintWriter getLogWriter() throws javax.resource.ResourceException
CasterManagedConnectionFactory
instance.
The log writer is a character output stream to which all logging and tracing
messages pertaining to this Code>CasterManagedConnectionFactory instance
will be printed. The J2EE Application Server manages the
association of output stream with this
CasterManagedConnectionFactory
. When an instance of
CasterManagedConnectionFactory
is created the log writer is
initially null
, in other words, logging is disabled. Once a log
writer is associated with a CasterManagedConnectionFactory object, logging
and tracing is enabled.
getLogWriter
in interface javax.resource.spi.ManagedConnectionFactory
javax.resource.ResourceException
ManagedConnectionFactory.getLogWriter()
public void setServerName(java.lang.String agentNode)
CasterConnection
object)from the connection pool. This will accept
either the TCP/IP address of the server or the host name.
agentNode
- represents a server agent.public void setPortNumber(java.lang.String agentPort)
agentPort
- The port number as a String.public void setReporsitoryType(int type)
type
- Repository type.public void setTrustedKeyFile(java.lang.String file)
file
- The name of the Trusted Key File.public int getServerStatus() throws CasterException
CasterException
public void setIbiDocumentRoot(java.lang.String ibiDocumentRoot)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |