j2ee connector

Hi

I'磛e a package that allow applications connect to an IBM host using sockets and 3270 telnet protocol.

I want to isolate and standarize such layer using JCA to run it as a resource adapter in an application server.

I'm new to jca and reading specification is drivin me a little bit confused. I' ve "googled" for sample code but the few I found are simple db resource adapters implementations so I wonder if some one could point me to a non db jca samples... or guides/books about this matter.

Thanks in advance

C

[554 byte] By [xleybaa] at [2007-11-27 9:00:05]
# 1

Well, I'll reply myself and ask a new question.

I found a sample code from IBM. In this sample, they define a ConnectionImpl as

public class HelloWorldConnectionImpl implements Connection {

private static final String CLOSED_ERROR = "Connection closed";

private static final String TRANSACTIONS_NOT_SUPPORTED =

"Local transactions not supported";

private static final String RESULT_SETS_NOT_SUPPORTED =

"Result sets not supported";

private boolean valid;

private ManagedConnection mc;

/**

* Constructor for HelloWorldConnectionImpl

*/

public HelloWorldConnectionImpl(ManagedConnection mc) {

super();

this.mc = mc;

valid = true;

}

void invalidate() {

mc = null;

valid = false;

}

......

After read docs, I supposed that the connection implementation is the lower layer where I should put my code to connect with the EIS (in my case, the code wich will open sockets and offer methods to read/write streams), but the above code confused me.

Where should I made my connections ?

Could somebody give me a clue ?

Thanks in advance

C

xleybaa at 2007-7-12 21:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Refer : http://java.sun.com/developer/technicalArticles/J2EE/connectorclient/resourceadapter.htmlYou can have a wrapper around physical connection (connection to EIS) and expose the wrapped connection to user.
Jagadish.Prasatha at 2007-7-12 21:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Jagadish

Thanks for your reply.

The article you sent is similar to those I've read but I'm still confused.

I know I need to wrap my EIS connector with my resource adapter but what I couldn磘 see clear is where should I do it.

I supposed that it should be in the lower layer, the connection implementation, but all the sample codes I saw make and instance of this class but recommend to put the EIS code in the managedconnection class.

I've a simple class called CICSSocket that make the connection with EIS and with two methods read and write to allow those operation the EIS throw sockets and a open method to open the socket.

If make an instance of CICSSocket in the Connection class constructor, it will be a wrapper but I'll be returning a Connection instance, not a CICSSocket instance, so how the AS or the client will call CICSSockets methods ? How the AS could pass parameters to CICSSocket to make the connection ?

What happen if I do the above in the ManagedConnection class as I saw in various samples ? How will it work to wrap my class ?

So, I've a clear map of all but I really don't understand how all components interact and how to do it and couldn磘 found real samples about it.

Could somebody please send me a simple sample code or explanation to make me see the light ?

Thanks in advance

C

xleybaa at 2007-7-12 21:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

https://glassfish.dev.java.net/source/browse/glassfish/jdbcra/src/com/sun/gjc/spi/base/ConnectionHolder.java?annotate=1.3

You will see that any connection related call will be delegated to the physical connection.

"protected Connection con;" in the source.

When close() is called, wrapper will intimate ManagedConnection to make further action.

Physical connection is created by Managed Connection, passed to the wrapper (ConnectionHolder) during wrapper instantiation.

See ManagedConnection.getConnection()

https://glassfish.dev.java.net/source/browse/glassfish/jdbcra/src/com/sun/gjc/spi/ManagedConnection.java?annotate=1.14

You can also see :

https://genericjmsra.dev.java.net/source/browse/genericjmsra/src/java/com/sun/genericra/outbound/ManagedConnection.java?annotate=1.4

https://genericjmsra.dev.java.net/source/browse/genericjmsra/src/java/com/sun/genericra/outbound/ConnectionHandle.java?annotate=1.5

Jagadish.Prasatha at 2007-7-12 21:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

Hi

Well, I did my resource adapter defined as follows:

--

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE connector PUBLIC '-//Sun Microsystems, Inc.//DTD Connector 1.0//EN' 'http://java.sun.com/dtd/connector_1_0.dtd'>

<connector>

<display-name>CometResourceAdapter</display-name>

<vendor-name>BancSabadell</vendor-name>

<spec-version>1.5</spec-version>

<eis-type>CicsSocket</eis-type>

<version>1.0</version>

<resourceadapter>

<managedconnectionfactory-class>com.bs.cds.jca.CdsManagedConnectionFactoryImpl</managedconnectionfactory-class>

<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>

<connectionfactory-impl-class>com.bs.cds.jca.CdsConnectionFactoryImpl</connectionfactory-impl-class>

<connection-interface>javax.resource.cci.Connection</connection-interface>

<connection-impl-class>com.bs.cds.jca.CdsConnection</connection-impl-class>

<transaction-support>NoTransaction</transaction-support>

</resourceadapter>

</connector>

-

But when I deployed in my JBoss I receive the error:

-

org.jboss.deployment.DeploymentException: Error parsing meta data jar:file:/D:/j

boss/server/jcara/tmp/deploy/tmp34080com.bs.cds.jca.ra-0.0.1.rar!/META-INF/ra.xm

l; - nested throwable: (org.jboss.xb.binding.JBossXBException: Failed to parse s

ource.)

at org.jboss.deployment.DeploymentException.rethrowAsDeploymentException

(DeploymentException.java:39)

at org.jboss.deployment.ObjectModelFactorySimpleSubDeployerSupport.parse

MetaData(ObjectModelFactorySimpleSubDeployerSupport.java:41)

at org.jboss.deployment.SimpleSubDeployerSupport.init(SimpleSubDeployerS

upport.java:73)

at org.jboss.deployment.MainDeployer.init(MainDeployer.java:843)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:780)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)

at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch

er.java:141)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)

at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept

or.java:118)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM

BeanOperationInterceptor.java:127)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.

java:245)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)

at $Proxy9.deploy(Unknown Source)

at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen

tScanner.java:319)

at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS

canner.java:507)

at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.

doScan(AbstractDeploymentScanner.java:192)

at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(A

bstractDeploymentScanner.java:265)

at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS

upport.java:274)

at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB

eanSupport.java:230)

at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch

er.java:141)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.

java:245)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)

at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl

ler.java:943)

at $Proxy0.start(Unknown Source)

at org.jboss.system.ServiceController.start(ServiceController.java:428)

at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch

er.java:141)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.

java:245)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)

at $Proxy4.start(Unknown Source)

at org.jboss.deployment.SARDeployer.start(SARDeployer.java:285)

at org.jboss.deployment.MainDeployer.start(MainDeployer.java:989)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:790)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)

at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:737)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch

er.java:141)

at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)

at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept

or.java:118)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM

BeanOperationInterceptor.java:127)

at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.

java:245)

at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)

at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)

at $Proxy5.deploy(Unknown Source)

at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:453)

at org.jboss.system.server.ServerImpl.start(ServerImpl.java:330)

at org.jboss.Main.boot(Main.java:187)

at org.jboss.Main$1.run(Main.java:438)

at java.lang.Thread.run(Thread.java:619)

Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source.

at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBPars

er.java:125)

at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java

:150)

at org.jboss.deployment.ObjectModelFactorySimpleSubDeployerSupport.parse

MetaData(ObjectModelFactorySimpleSubDeployerSupport.java:37)

... 68 more

Caused by: java.lang.IllegalArgumentException: Unknown connector newChild: nuri=

localName=managedconnectionfactory-class attrs=org.apache.xerces.parsers.Abstra

ctSAXParser$AttributesProxy@cc9d70

at org.jboss.resource.deployment.ResourceAdapterObjectModelFactory.newCh

ild(ResourceAdapterObjectModelFactory.java:162)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.jboss.xb.binding.ObjectModelBuilder.invokeFactory(ObjectModelBuil

der.java:421)

at org.jboss.xb.binding.DelegatingObjectModelFactory.newChild(Delegating

ObjectModelFactory.java:78)

at org.jboss.xb.binding.ObjectModelBuilder.startElement(ObjectModelBuild

er.java:323)

at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHan

dler.startElement(SaxJBossXBParser.java:217)

at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Sour

ce)

at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Sourc

e)

at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unkn

own Source)

at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent

Dispatcher.dispatch(Unknown Source)

at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un

known Source)

at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour

ce)

at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBPars

er.java:121)

... 70 more

-

I wonder if someone could give me a clue about the origin of the problem. I think my ra.xml is well defined and my managedconnectionfactory-class too.

Thanks in advance

J

Message was edited by:

xleyba

xleybaa at 2007-7-12 21:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...