Announcement Announcement Module
Collapse
No announcement yet.
JCA Tuxedo adapter with Spring JCA CCI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JCA Tuxedo adapter with Spring JCA CCI

    Using Spring 3.2.0 and trying to get my feet wet with JCA CCI....

    Never programmed against JCA before but got the general gist. Trying to wrap a JCA adapter against Tuxedo (ATMI C/C++) and Oracle documents only deploying their RAR package inside a container. Looking to get it going in non-managed mode.

    Uses config annotations and the major bean seems to be the LocalConnectionFactoryBean that houses the ConnectionFactory used by the CciTemplate. The Tuxedo adapter works with direct Record objects only. I got:
    Code:
    	@Bean
    	public TuxedoManagedConnectionFactory tuxedoManagedConnectionFactory() {
    		(setup the Resource Adapter here and add it to a singleton that the managed factory gets at)
    		
    		TuxedoManagedConnectionFactory mcf = new TuxedoManagedConnectionFactory();
    
    		return mcf;
    	}
    
    	@Bean
    	public ConnectionFactory tuxedoConnectionFactory() {
    		LocalConnectionFactoryBean cf = new LocalConnectionFactoryBean();
    		cf.setManagedConnectionFactory(tuxedoManagedConnectionFactory());
    
    		try {
    			cf.afterPropertiesSet();
    		} catch (ResourceException e) {
    			System.out.println("Big problem after setting properties");
    		}
    
    		return (ConnectionFactory) cf.getObject();
    	}
    
    	@Bean
    	public CciTemplate tuxedoTemplate() {
    		CciTemplate t = new CciTemplate();
    		t.setConnectionFactory(tuxedoConnectionFactory());
    
    		return t;
    	}
    
    	@Bean
    	public TuxedoCciDAO tuxedoDAO() {
    		TuxedoCciDAO dao = new TuxedoCciDAO();
    		dao.setConnectionFactory(tuxedoConnectionFactory());
    
    		return dao;
    	}
    Not sure I can handling the LocalConnectionFactoryBean correctly? The afterSetPropertiesmethod isn't executed automatically (assuming it is alright to fire it manually). Was also surprised that the Cci template doesn't swallow the LocalConnectionFactoryBean but rather than via the "getObject".

    Anyways, the main problem is that when my resource adapter (for some reason) needs to get at the context to "createSubcontext" a NamingException is thrown:
    Code:
    Naming exception error: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    How is the context deal with in a non-managed mode?

  • #2
    converting a ra.xml file, maybe some help

    Thought some info from the supplied ra.xml file from Oracle might help somebody point in the right directions...

    The ra.xml starts off with:
    Code:
    <resourceadapter>
        <resourceadapter-class>com.oracle.tuxedo.adapter.TuxedoFBCResourceAdapter</resourceadapter-class>
        .....
        <outbound-resourceadapter>
          <connection-definition>
            <managedconnectionfactory-class>com.oracle.tuxedo.adapter.spi.TuxedoFBCManagedConnectionFactory</managedconnectionfactory-class>
        ..... (bunch of config properties)
    
            <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
            <connectionfactory-impl-class>com.oracle.tuxedo.adapter.cci.TuxedoConnectionFactory</connectionfactory-impl-class>
            <connection-interface>javax.resource.cci.Connection</connection-interface>
            <connection-impl-class>com.oracle.tuxedo.adapter.cci.TuxedoJCAConnection</connection-impl-class>
          </connection-definition>
    
           <transaction-support>XATransaction</transaction-support>
           <reauthentication-support>false</reauthentication-support>
        </outbound-resourceadapter>
    Programmatically I can push the majority of the configuration properties directly into the resource adapater (TuxedoClientSideResourceAdapter) which gets registered to a Tuxedo supervisor which from the code looks like it makes it accessible from the manager connection factory (first bean i listed in my original post). Will try to find a way to configuration with XML. That might help me find the right setup. Feels right now that I am programmatically by-passing stuff.

    Would love to here back from somebody that has refactored a ra.xml file either with the XML configuration or annotations.

    Comment


    • #3
      The application gets at the ConnectionFactory via CciTemplate which is how one gets a connection and kicks off the ConnectionManager behind the scenes. But doesn't the resource adapter need to be registered in non-managed mode? Like with the ResourceAdapterFactoryBean where the afterSetProperties starts the RA? Think I get the basic flow of application call:
      Code:
           http://www.ibm.com/developerworks/java/tutorials/j-jca/section3.html
      where the CF (Connection Factory) does a get on the connection and issues an allocate connection on the CM (Connection Manager). Via the CM one should get the ManagedConnection (MC) and context stuff (provided by the RA). This is where I get lost.

      Comment

      Working...
      X