com.mulesoft.adapter.ra
Class SPIManagedConnectionFactory

java.lang.Object
  extended by com.mulesoft.adapter.ra.SPIManagedConnectionFactory
All Implemented Interfaces:
com.sap.engine.interfaces.connector.ManagedConnectionFactoryActivation, Serializable, Runnable, javax.resource.spi.ManagedConnectionFactory

public class SPIManagedConnectionFactory
extends Object
implements javax.resource.spi.ManagedConnectionFactory, Serializable, Runnable, com.sap.engine.interfaces.connector.ManagedConnectionFactoryActivation

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)

See Also:
Serialized Form

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
 void addChannel(com.sap.aii.af.service.cpa.Channel channel)
           
 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
 PrintWriter getLogWriter()
          Gets the JCA J2EE logwriter PrintWriter object.
 com.sap.guid.GUID getMcfLocalGuid()
          Getter for the MCF GUID
 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 removeChannel(com.sap.aii.af.service.cpa.Channel channel)
           
 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 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 updateChannels(List<ChannelOperationTuple> channelOperations)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JNDI_NAME

public static final String JNDI_NAME
See Also:
Constant Field Values
Constructor Detail

SPIManagedConnectionFactory

public SPIManagedConnectionFactory()
                            throws javax.resource.ResourceException
The JCA specification requires a default constructor since this class must be Java Bean compliant and is propagated from this class to them. XI specific is the access to the SAPAdapterResource typed objects that allow access to the SAP J2EE thread and transaction manager as substitute for the missing work and inbound transaction concepts of JCA 1.0. (SPI JCA 1.0)

Throws:
javax.resource.ResourceException - not thrown
Method Detail

createConnectionFactory

public Object createConnectionFactory(javax.resource.spi.ConnectionManager cm)
                               throws javax.resource.ResourceException
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. (SPI JCA 1.0)

Specified by:
createConnectionFactory in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
cm - ConnectionManager of the J2EE server
Throws:
javax.resource.ResourceException

createConnectionFactory

public Object createConnectionFactory()
                               throws javax.resource.ResourceException
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. (SPI JCA 1.0)

Specified by:
createConnectionFactory in interface javax.resource.spi.ManagedConnectionFactory
Throws:
javax.resource.ResourceException

createManagedConnection

public javax.resource.spi.ManagedConnection createManagedConnection(Subject subject,
                                                                    javax.resource.spi.ConnectionRequestInfo info)
                                                             throws javax.resource.ResourceException
This factory method is used called by the J2EE server to create a new managed connection. Note that it does not necessarily mean that a new physical connection is being created. However, in this sample a new file is opened. (SPI JCA 1.0)

Specified by:
createManagedConnection in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
subject - JAAS authentification data with logon credentials to open the physical connection
info - ConnectionRequestInfo with additional information to open the managed connection
Returns:
New created managed connection of class SpiManagedConnection
Throws:
javax.resource.ResourceException - Thrown if managed connection cannot be created

matchManagedConnections

public javax.resource.spi.ManagedConnection matchManagedConnections(Set connectionSet,
                                                                    Subject subject,
                                                                    javax.resource.spi.ConnectionRequestInfo info)
                                                             throws javax.resource.ResourceException
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). 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)

Specified by:
matchManagedConnections in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
connectionSet - containing SpiManagedConnection objects
subject - JAAS authentification data with logon credentials to open the physical connection
info - ConnectionRequestInfo with additional information to open the managed connection
Returns:
Existing managed connection of class SpiManagedConnection
Throws:
javax.resource.ResourceException - Thrown if managed connection cannot be created

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws javax.resource.ResourceException
Sets the JCA J2EE logwriter 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)

Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
out - PrintWriter print writer for logging purposes
Throws:
javax.resource.ResourceException

getLogWriter

public PrintWriter getLogWriter()
                         throws javax.resource.ResourceException
Gets the JCA J2EE logwriter PrintWriter object. (SPI JCA 1.0)

Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnectionFactory
Returns:
PrintWriter print writer for logging purposes
Throws:
javax.resource.ResourceException

equals

public boolean equals(Object obj)
A JCA 1.0 compliant 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)

Specified by:
equals in interface javax.resource.spi.ManagedConnectionFactory
Overrides:
equals in class Object
Parameters:
obj - Object to compare
Returns:
True of obj is equal (but not necessarily identical) with this SpiManagedConnectionFactory, false otherwise

hashCode

public int hashCode()
A JCA 1.0 compliant 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)

Specified by:
hashCode in interface javax.resource.spi.ManagedConnectionFactory
Overrides:
hashCode in class Object
Returns:
Integer value representing the hash code of this SpiManagedConnectionFactory

getAddressMode

public String getAddressMode()
This class must be JavaBean compliant hence it offers getters for properties

Returns:
The address determination mode

setAddressMode

public void setAddressMode(String addressMode)
This class must be JavaBean compliant hence it offers setters for properties

Parameters:
addressMode - The address determination mode

startMCF

public void startMCF()
              throws javax.resource.ResourceException
Starts the inbound processing (ra implementation specific)

Throws:
javax.resource.ResourceException - Thrown if thread cannot be started

stopMCF

public void stopMCF()
             throws javax.resource.ResourceException
Stops the inbound processing (ra implementation specific)

Throws:
javax.resource.ResourceException

run

public void run()
Simulates incoming messages in a separate thread. (ra implementation specific)

Specified by:
run in interface Runnable

addChannel

public void addChannel(com.sap.aii.af.service.cpa.Channel channel)

removeChannel

public void removeChannel(com.sap.aii.af.service.cpa.Channel channel)

updateChannels

public void updateChannels(List<ChannelOperationTuple> channelOperations)

getAdapterNamespace

public String getAdapterNamespace()
Getter for the adapterNamespace for JCA ra configuration. The adapterNamespace must be equal to related one configured in the XI IR.

Returns:
String current adapterNamespace

getAdapterType

public String getAdapterType()
Getter for the adapterType for JCA ra configuration. The adapterType must be equal to related one configured in the XI IR.

Returns:
String current adapterType

setAdapterNamespace

public void setAdapterNamespace(String adapterNamespace)
Setter for the adapterNamespace for JCA ra configuration. The adapterNamespace must be equal to related one configured in the XI IR.

Parameters:
adapterNamespace - for XI CPA lookup

setAdapterType

public void setAdapterType(String adapterType)
Setter for the adapterType for JCA ra configuration. The adapterType must be equal to related one configured in the XI IR.

Parameters:
adapterType - for XI CPA lookup

getMcfLocalGuid

public com.sap.guid.GUID getMcfLocalGuid()
Getter for the MCF GUID

Returns:
GUID Guid of this MCF (ra implementation specific)

start

public void start()
The 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.

Specified by:
start in interface com.sap.engine.interfaces.connector.ManagedConnectionFactoryActivation
See Also:
(ra implementation specific)

stop

public void stop()
The 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.

Specified by:
stop in interface com.sap.engine.interfaces.connector.ManagedConnectionFactoryActivation
See Also:
(ra implementation specific)

isRunning

public boolean isRunning()
Checks whether this mcf has a running inbound processing thread

Returns:
true if running. If false is returned no inbound messages can be sent (ra implementation specific)


Copyright © 2012. All Rights Reserved.