|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sap.aii.af.sample.adapter.ra.SPIManagedConnectionFactory
public class SPIManagedConnectionFactory
An object of the class SpiManagedConnectionFactory (MCF) is a factory of both,
ManagedConnection and CciConnectionFactory instances.
This class supports connection pooling by defining methods for matching and creating connections.
SpiManagedConnectionFactory MUST be a Java Bean to be JCA compliant (see pg. 51)
A SAP J2EE server peculiarity is the implementation of the ManagedConnectionFactoryActivation
interface. This allows the MCF to be informed when the adapter is being started or stopped.
It represents a JCA 1.0 workaround for the missing JCA 1.5 activation feature in NetWeaver'04 (hence
it is deprecated since the next major NetWeaver version supports JCA 1.5).
Changes from 3.0/7.0 to 7.1:
1. Repackaging com.sap.engine.interfaces.messaging
2. AuditLog simplified: MessageDirection, MessageKey instead of AuditDirection, AuditKey
3. MessageIDMapper:
4. Use of SAP J2EE transaction manager instead of JTA. (com.sap.transaction.TxManager instead of javax.transaction.TransactionManager)
5. XIInteractionSpec: START, STOP removed, is offered by com.sap.aii.af.service.administration.api now
6. XIMessageRecord does not extend com.sap.engine.interfaces.messaging.api.Message anymore, but wraps it now. Use get/setMessage() instead of direct calls.
7. Introduce XITrace utility class and refer to J2EE logging directly
8. Built against the new XI AF facades, see cross reference Excel for details.
9. ModuleProcessor reference is not cached. (7.1 SP3 change)
| Field Summary | |
|---|---|
static String |
JNDI_NAME
|
| Constructor Summary | |
|---|---|
SPIManagedConnectionFactory()
The JCA specification requires a default constructor since this class must be Java Bean compliant and is propagated from this class to them. |
|
| Method Summary | |
|---|---|
Object |
createConnectionFactory()
This factory method is used for the two-tier, non J2EE container approach: The ConnectionManager implementation of the resource adapter
is used instead of the J2EE ConnectionManager. |
Object |
createConnectionFactory(javax.resource.spi.ConnectionManager cm)
This factory method is used in the context of XI AF: The J2EE server passed a ConnectionManager object
via the createConnectionFactory call to the ManagedConnectionFactory, which in turn
will the approriate constructor of the CciConnectionFactory. |
javax.resource.spi.ManagedConnection |
createManagedConnection(Subject subject,
javax.resource.spi.ConnectionRequestInfo info)
This factory method is used called by the J2EE server to create a new managed connection. |
boolean |
equals(Object obj)
A JCA 1.0 compliant SpiManagedConnectionFactory must implement
the equals() to allow the J2EE container a sensible
connection pooling. |
String |
getAdapterNamespace()
Getter for the adapterNamespace for JCA ra configuration. |
String |
getAdapterType()
Getter for the adapterType for JCA ra configuration. |
String |
getAddressMode()
This class must be JavaBean compliant hence it offers getters for properties |
static int |
getFileCounter()
This class must be JavaBean compliant hence it offers at least getters for properties |
PrintWriter |
getLogWriter()
Gets the JCA J2EE logwriter PrintWriter object. |
com.sap.guid.GUID |
getMcfLocalGuid()
Getter for the MCF GUID |
String |
getOutFileName(String outFileNamePrefix)
Gets a new unique file name for a new physical connection (ra implementation specific) |
int |
hashCode()
A JCA 1.0 compliant SpiManagedConnectionFactory must implement
the hashCode() to allow the J2EE container a sensible
connection pooling. |
boolean |
isRunning()
Checks whether this mcf has a running inbound processing thread |
javax.resource.spi.ManagedConnection |
matchManagedConnections(Set connectionSet,
Subject subject,
javax.resource.spi.ConnectionRequestInfo info)
This method is not a factory method but more a selection method: It selects the best-fitting managed connection contained in the connection set based on the subject (user, password) and connection information ( ConnectionRequestInfo). |
void |
run()
Simulates incoming messages in a separate thread. |
void |
setAdapterNamespace(String adapterNamespace)
Setter for the adapterNamespace for JCA ra configuration. |
void |
setAdapterType(String adapterType)
Setter for the adapterType for JCA ra configuration. |
void |
setAddressMode(String addressMode)
This class must be JavaBean compliant hence it offers setters for properties |
void |
setLogWriter(PrintWriter out)
Sets the JCA J2EE logwriter PrintWriter object. |
void |
start()
The start() is called by the J2EE JCA container when the JCA adapter
is started via the J2EE admin console (e.g. |
void |
startMCF()
Starts the inbound processing (ra implementation specific) |
void |
startTimer()
Starts the control timer For debugging purposes the MCF prints out the MCF GUID ID and its status periodically (ra implementation specific) |
void |
stop()
The stop() is called by the J2EE JCA container when the JCA adapter
is stopped via the J2EE admin console (e.g. |
void |
stopMCF()
Stops the inbound processing (ra implementation specific) |
void |
stopTimer()
Stops the control timer (ra implementation specific) |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String JNDI_NAME
| Constructor Detail |
|---|
public SPIManagedConnectionFactory()
throws javax.resource.ResourceException
javax.resource.ResourceException - not thrown| Method Detail |
|---|
public Object createConnectionFactory(javax.resource.spi.ConnectionManager cm)
throws javax.resource.ResourceException
ConnectionManager object
via the createConnectionFactory call to the ManagedConnectionFactory, which in turn
will the approriate constructor of the CciConnectionFactory.
(SPI JCA 1.0)
createConnectionFactory in interface javax.resource.spi.ManagedConnectionFactorycm - ConnectionManager of the J2EE server
javax.resource.ResourceException
public Object createConnectionFactory()
throws javax.resource.ResourceException
ConnectionManager implementation of the resource adapter
is used instead of the J2EE ConnectionManager.
(SPI JCA 1.0)
createConnectionFactory in interface javax.resource.spi.ManagedConnectionFactoryjavax.resource.ResourceException
public javax.resource.spi.ManagedConnection createManagedConnection(Subject subject,
javax.resource.spi.ConnectionRequestInfo info)
throws javax.resource.ResourceException
createManagedConnection in interface javax.resource.spi.ManagedConnectionFactorysubject - JAAS authentification data with logon credentials to open the physical connectioninfo - ConnectionRequestInfo with additional information to open the managed connection
SpiManagedConnection
javax.resource.ResourceException - Thrown if managed connection cannot be created
public javax.resource.spi.ManagedConnection matchManagedConnections(Set connectionSet,
Subject subject,
javax.resource.spi.ConnectionRequestInfo info)
throws javax.resource.ResourceException
ConnectionRequestInfo).
This sample simply checks the equality of the subject and that the managed connection
was opened for a given XI channel.
(SPI JCA 1.0)
matchManagedConnections in interface javax.resource.spi.ManagedConnectionFactoryconnectionSet - containing SpiManagedConnection objectssubject - JAAS authentification data with logon credentials to open the physical connectioninfo - ConnectionRequestInfo with additional information to open the managed connection
SpiManagedConnection
javax.resource.ResourceException - Thrown if managed connection cannot be created
public void setLogWriter(PrintWriter out)
throws javax.resource.ResourceException
PrintWriter object. Although JCA specifies
this mechansim it is not being used by XI AF. Instead the resource adapters should
use the XI AF trace service classes as done here in this sample.
(SPI JCA 1.0)
setLogWriter in interface javax.resource.spi.ManagedConnectionFactoryout - PrintWriter print writer for logging purposes
javax.resource.ResourceException
public PrintWriter getLogWriter()
throws javax.resource.ResourceException
PrintWriter object.
(SPI JCA 1.0)
getLogWriter in interface javax.resource.spi.ManagedConnectionFactoryPrintWriter print writer for logging purposes
javax.resource.ResourceExceptionpublic String getOutFileName(String outFileNamePrefix)
public boolean equals(Object obj)
SpiManagedConnectionFactory must implement
the equals() to allow the J2EE container a sensible
connection pooling. The equality MUST be defined on the complete
property set (see pg. 50)
(SPI JCA 1.0)
equals in interface javax.resource.spi.ManagedConnectionFactoryequals in class Objectobj - Object to compare
SpiManagedConnectionFactory, false otherwisepublic int hashCode()
SpiManagedConnectionFactory must implement
the hashCode() to allow the J2EE container a sensible
connection pooling. The equality MUST be defined on the complete
property set (see pg. 50)
(SPI JCA 1.0)
hashCode in interface javax.resource.spi.ManagedConnectionFactoryhashCode in class ObjectSpiManagedConnectionFactorypublic static int getFileCounter()
public String getAddressMode()
public void setAddressMode(String addressMode)
addressMode - The address determination mode
public void startMCF()
throws javax.resource.ResourceException
javax.resource.ResourceException - Thrown if thread cannot be started
public void stopMCF()
throws javax.resource.ResourceException
javax.resource.ResourceExceptionpublic void startTimer()
public void stopTimer()
public void run()
run in interface Runnablepublic String getAdapterNamespace()
public String getAdapterType()
public void setAdapterNamespace(String adapterNamespace)
adapterNamespace - for XI CPA lookuppublic void setAdapterType(String adapterType)
adapterType - for XI CPA lookuppublic com.sap.guid.GUID getMcfLocalGuid()
public void start()
start() is called by the J2EE JCA container when the JCA adapter
is started via the J2EE admin console (e.g. explicitly in the connector service or
implicitly during a deployment). The inbound processing MUST be started now.
start in interface com.sap.engine.interfaces.connector.ManagedConnectionFactoryActivation(ra implementation specific)public void stop()
stop() is called by the J2EE JCA container when the JCA adapter
is stopped via the J2EE admin console (e.g. explicitly in the connector service or
implicitly during a deployment). The inbound processing MUST be stopped now, shared
ressources such as ports MUST be released now.
stop in interface com.sap.engine.interfaces.connector.ManagedConnectionFactoryActivation(ra implementation specific)public boolean isRunning()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||