Commit 3e6acd37 authored by Nicolas Tachker's avatar Nicolas Tachker

Refactoring of the resource adapter.

Add new functionalities (bind the resource adapter in jndi, deploy many resource adapter in the application server, ...)
Fix bugs.
parent f0250c93
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 - Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -131,16 +131,9 @@ public class DefaultConnectionManager
private void setFactoryParameters(AbstractConnectionFactory factory , ManagedConnectionFactoryImpl mcf) {
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
this + " setFactoryParameters(" + factory + "," + mcf + ")");
factory.getParameters().connectingTimer = mcf.getConnectingTimer();
factory.getParameters().cnxPendingTimer = mcf.getCnxPendingTimer();
factory.getParameters().txPendingTimer = mcf.getTxPendingTimer();
factory.getParameters().asyncSend = mcf.isAsyncSend();
factory.getParameters().multiThreadSync = mcf.isMultiThreadSync();
factory.getParameters().multiThreadSyncDelay = mcf.getMultiThreadSyncDelay();
factory.getParameters().outLocalAddress = mcf.getOutLocalAddress();
factory.getParameters().outLocalPort = mcf.getOutLocalPort().intValue();
this + " setFactoryParameters(" + factory + "," + mcf + ")");
mcf.setParameters(factory);
}
/**
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 - Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -126,6 +127,7 @@ class InboundConsumer implements javax.jms.ServerSessionPool
this.cnx = cnx;
this.transacted = transacted;
this.ackMode = ackMode;
this.closeDurSub = closeDurSub;
if (maxWorks < 0) maxWorks = 0;
this.maxWorks = maxWorks;
......
......@@ -75,11 +75,11 @@ public interface JoramAdapterMBean {
public Short getServerId();
/**
* Returns the name of the Joram server.
* Returns the name of the resource adapter.
*
* @return The name of the Joram server.
* @return The name of the resource adapter.
*/
public String getServerName();
public String getName();
/**
* Returns the location of the Joram server.
......@@ -95,19 +95,19 @@ public interface JoramAdapterMBean {
*/
public Integer getServerPort();
/**
* Returns <code>true</code> if the Joram server is persistent.
*
* @return <code>true</code> if the Joram server is persistent.
*/
public Boolean getPersistentPlatform();
// /**
// * Returns <code>true</code> if the Joram server is persistent.
// *
// * @return <code>true</code> if the Joram server is persistent.
// */
// public Boolean getPersistentPlatform();
/**
* Returns <code>true</code> if the Joram server is collocated.
*
* @return <code>true</code> if the Joram server is collocated.
*/
public Boolean getCollocatedServer();
public Boolean getCollocated();
/**
......@@ -117,20 +117,20 @@ public interface JoramAdapterMBean {
*/
public Integer getConnectingTimer();
/**
* Duration in seconds during which a JMS transacted (non XA) session might
* be pending; above that duration the session is rolled back and closed;
* the 0 value means "no timer".
*/
public Integer getTxPendingTimer();
/**
* Period in milliseconds between two ping requests sent by the client
* connection to the server; if the server does not receive any ping
* request during more than 2 * cnxPendingTimer, the connection is
* considered as dead and processed as required.
*/
public Integer getCnxPendingTimer();
// /**
// * Duration in seconds during which a JMS transacted (non XA) session might
// * be pending; above that duration the session is rolled back and closed;
// * the 0 value means "no timer".
// */
// public Integer getTxPendingTimer();
//
// /**
// * Period in milliseconds between two ping requests sent by the client
// * connection to the server; if the server does not receive any ping
// * request during more than 2 * cnxPendingTimer, the connection is
// * considered as dead and processed as required.
// */
// public Integer getCnxPendingTimer();
/**
* Sets timeout before abort a request.
......@@ -421,7 +421,7 @@ public interface JoramAdapterMBean {
*
* @param name Name of created connection factory.
*/
public void createCF(String name);
public void createCF(String name) throws Exception;
/**
* Creates a non managed PTP connection factory and binds it to JNDI.
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 - ScalAgent Distributed Technologies
* Copyright (C) 2008 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 - Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -33,22 +33,20 @@ import org.objectweb.util.monolog.api.BasicLevel;
* This class is a factory for building non managed outbound connection
* factories from their JNDI reference.
*/
public class ObjectFactoryImpl implements javax.naming.spi.ObjectFactory
{
String cf =
"org.objectweb.joram.client.connector.OutboundConnectionFactory";
String qcf =
"org.objectweb.joram.client.connector.OutboundQueueConnectionFactory";
String tcf =
"org.objectweb.joram.client.connector.OutboundTopicConnectionFactory";
public class ObjectFactoryImpl implements javax.naming.spi.ObjectFactory {
String cf =
"org.objectweb.joram.client.connector.OutboundConnectionFactory";
String qcf =
"org.objectweb.joram.client.connector.OutboundQueueConnectionFactory";
String tcf =
"org.objectweb.joram.client.connector.OutboundTopicConnectionFactory";
/** Returns a factory given its reference. */
public Object getObjectInstance(Object obj,
Name name,
Context ctx,
java.util.Hashtable env)
throws Exception {
/** Returns a factory given its reference. */
public Object getObjectInstance(Object obj,
Name name,
Context ctx,
java.util.Hashtable env) throws Exception {
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " getObjectInstance(" + obj +
......@@ -59,12 +57,13 @@ public class ObjectFactoryImpl implements javax.naming.spi.ObjectFactory
Reference ref = (Reference) obj;
String hostName = (String) ref.get("hostName").getContent();
Integer serverPort =
new Integer((String) ref.get("serverPort").getContent());
Integer serverPort = new Integer((String) ref.get("serverPort").getContent());
String userName = (String) ref.get("userName").getContent();
String password = (String) ref.get("password").getContent();
String identityClass = (String) ref.get("identityClass").getContent();
ManagedConnectionFactoryImpl mcf = null;
if (ref.getClassName().equals(cf))
......@@ -75,18 +74,19 @@ public class ObjectFactoryImpl implements javax.naming.spi.ObjectFactory
mcf = new ManagedTopicConnectionFactoryImpl();
else
return null;
// set ManagedConnectionFactoryConfig
mcf.setCollocated(new Boolean(false));
mcf.setHostName(hostName);
mcf.setServerPort(serverPort);
mcf.setUserName(userName);
mcf.setPassword(password);
mcf.setIdentityClass(identityClass);
//TODO: ? set connectingTimer, cnxPending, ...
try {
return mcf.createConnectionFactory();
}
catch (Exception exc) {
} catch (Exception exc) {
return null;
}
}
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - Bull SA
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -22,10 +23,22 @@
*/
package org.objectweb.joram.client.connector;
import javax.jms.*;
import javax.jms.IllegalStateException;
import java.util.Vector;
import javax.jms.Connection;
import javax.jms.ConnectionConsumer;
import javax.jms.ConnectionMetaData;
import javax.jms.Destination;
import javax.jms.ExceptionListener;
import javax.jms.IllegalStateException;
import javax.jms.JMSException;
import javax.jms.ServerSessionPool;
import javax.jms.Session;
import javax.jms.Topic;
import javax.jms.XAConnection;
import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnection;
import org.objectweb.util.monolog.api.BasicLevel;
/**
......@@ -34,8 +47,7 @@ import org.objectweb.util.monolog.api.BasicLevel;
* transparently use this physical connection possibly within a transaction
* (local or global).
*/
public class OutboundConnection implements javax.jms.Connection
{
public class OutboundConnection implements javax.jms.Connection {
/** The managed connection this "handle" belongs to. */
ManagedConnectionImpl managedCx;
/** The physical connection this "handle" handles. */
......@@ -51,13 +63,9 @@ public class OutboundConnection implements javax.jms.Connection
* @param managedCx The managed connection building the handle.
* @param xac The underlying physical connection to handle.
*/
OutboundConnection(ManagedConnectionImpl managedCx,
XAConnection xac) {
OutboundConnection(ManagedConnectionImpl managedCx, XAConnection xac) {
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
"OutboundConnection(" + managedCx +
", " + xac + ")");
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, "OutboundConnection(" + managedCx + ", " + xac + ")");
this.managedCx = managedCx;
this.xac = xac;
......@@ -114,12 +122,35 @@ public class OutboundConnection implements javax.jms.Connection
throw new javax.jms.IllegalStateException("Invalid connection handle.");
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
this + " createSession sess = " + managedCx.session);
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createSession managedCx.session = " + managedCx.session);
Session sess = managedCx.session;
if (sess == null)
sess = xac.createSession(false, acknowledgeMode);
if (sess == null) {
try {
sess = xac.createSession(false, acknowledgeMode);
} catch (IllegalStateException e) {
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createSession (IllegalStateException)" + e);
AdapterTracing.dbgAdapter.log(BasicLevel.WARN, this + " createSession reconnection in progress...");
try {
if (managedCx.isReconnected()) {
ManagedConnection mc = managedCx.mcf.createManagedConnection(managedCx.subject, managedCx.cxRequest);
OutboundConnection outboundConnection = (OutboundConnection) mc.getConnection(managedCx.subject, managedCx.cxRequest);
outboundConnection.managedCx.associateConnection(this);
} else {
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createSession : managed connection is not reconnected.");
throw new JMSException(this + " createSession : managed connection is not reconnected.");
}
sess = xac.createSession(false, acknowledgeMode);
} catch (ResourceException exc) {
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.WARN))
AdapterTracing.dbgAdapter.log(BasicLevel.WARN, this + " createSession (ResourceException)", exc);
}
}
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createSession sess = " + sess);
}
return new OutboundSession(sess, this, transacted);
}
......@@ -128,13 +159,11 @@ public class OutboundConnection implements javax.jms.Connection
* Forbidden call on an application or component's outbound connection,
* throws a <code>IllegalStateException</code> instance.
*/
public String getClientID() throws JMSException
{
public String getClientID() throws JMSException {
if (! valid)
throw new javax.jms.IllegalStateException("Invalid connection handle.");
throw new IllegalStateException("Forbidden call on a component's "
+ "connection.");
throw new IllegalStateException("Forbidden call on a component's connection.");
}
/**
......@@ -143,8 +172,7 @@ public class OutboundConnection implements javax.jms.Connection
* @exception javax.jms.IllegalStateException If the handle is invalid.
* @exception javax.jms.JMSException Generic exception.
*/
public ConnectionMetaData getMetaData() throws JMSException
{
public ConnectionMetaData getMetaData() throws JMSException {
if (! valid)
throw new javax.jms.IllegalStateException("Invalid connection handle.");
......@@ -155,13 +183,11 @@ public class OutboundConnection implements javax.jms.Connection
* Forbidden call on an application or component's outbound connection,
* throws a <code>IllegalStateException</code> instance.
*/
public ExceptionListener getExceptionListener() throws JMSException
{
public ExceptionListener getExceptionListener() throws JMSException {
if (! valid)
throw new javax.jms.IllegalStateException("Invalid connection handle.");
throw new IllegalStateException("Forbidden call on a component's "
+ "connection.");
throw new IllegalStateException("Forbidden call on a component's connection.");
}
/**
......@@ -200,8 +226,7 @@ public class OutboundConnection implements javax.jms.Connection
if (! valid)
throw new javax.jms.IllegalStateException("Invalid connection handle.");
throw new IllegalStateException("Forbidden call on a component's "
+ "connection.");
throw new IllegalStateException("Forbidden call on a component's connection.");
}
/**
......@@ -217,8 +242,7 @@ public class OutboundConnection implements javax.jms.Connection
if (! valid)
throw new javax.jms.IllegalStateException("Invalid connection handle.");
throw new IllegalStateException("Forbidden call on a component's "
+ "connection.");
throw new IllegalStateException("Forbidden call on a component's connection.");
}
/**
......@@ -231,13 +255,11 @@ public class OutboundConnection implements javax.jms.Connection
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
throws JMSException
{
throws JMSException {
if (! valid)
throw new javax.jms.IllegalStateException("Invalid connection handle.");
throw new IllegalStateException("Forbidden call on a component's "
+ "connection.");
throw new IllegalStateException("Forbidden call on a component's connection.");
}
/**
......@@ -284,8 +306,7 @@ public class OutboundConnection implements javax.jms.Connection
cnx.cleanup();
}
public String toString()
{
public String toString() {
return "OutboundConnection[" + xac.toString() + "]";
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -87,7 +87,7 @@ public class OutboundConnectionFactory implements javax.jms.ConnectionFactory,
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createConnection()");
return createConnection(mcf.userName, mcf.password);
return createConnection(mcf.getUserName(), mcf.getPassword());
}
/**
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 - ScalAgent Distributed Technologies
* Copyright (C) 2008 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 - Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -70,7 +70,7 @@ public class OutboundQueueConnectionFactory extends OutboundConnectionFactory im
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createQueueConnection()");
return createQueueConnection(mcf.userName, mcf.password);
return createQueueConnection(mcf.getUserName(), mcf.getPassword());
}
/**
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2012 ScalAgent Distributed Technologies
* Copyright (C) 2004 Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -70,7 +70,7 @@ public class OutboundTopicConnectionFactory extends OutboundConnectionFactory im
if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " createTopicConnection()");
return createTopicConnection(mcf.userName, mcf.password);
return createTopicConnection(mcf.getUserName(), mcf.getPassword());
}
/**
......
You can set in each activationSpec some properties :
use @ActivationConfigProperty(propertyName and propertyValue)
or xml activationspec description
Properties:
- Collocated
- HostName
- ServerPort
- ConnectingTimer
- CnxPendingTimer
- TxPendingTimer
- queueMessageReadMax
- topicAckBufferMax
- DeleteDurableSubscription
This diff is collapsed.
......@@ -49,12 +49,6 @@
<groupId>org.ow2.joram</groupId>
<artifactId>a3-osgi</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.ow2.joram</groupId>
<artifactId>a3-rt</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ow2.joram</groupId>
......@@ -65,23 +59,15 @@
<groupId>org.ow2.joram</groupId>
<artifactId>jndi-server</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.ow2.joram</groupId>
<artifactId>a3-rt</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ow2.jonas.osgi</groupId>
<artifactId>monolog</artifactId>
<exclusions>
<exclusion>
<groupId>org.objectweb.monolog</groupId>
<artifactId>monolog</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment