Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/LocalAndXATransaction.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/LocalAndXATransaction.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/LocalAndXATransaction.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/LocalAndXATransaction.java Sat Aug 11 22:27:21 2007
@@ -30,17 +30,18 @@
*/
public class LocalAndXATransaction implements XAResource, LocalTransaction {
- final private TransactionContext transactionContext;
+ private final TransactionContext transactionContext;
private boolean inManagedTx;
-
+
public LocalAndXATransaction(TransactionContext transactionContext) {
- this.transactionContext=transactionContext;
+ this.transactionContext = transactionContext;
}
public void setInManagedTx(boolean inManagedTx) throws JMSException {
- this.inManagedTx=inManagedTx;
- if( !inManagedTx )
+ this.inManagedTx = inManagedTx;
+ if (!inManagedTx) {
transactionContext.cleanup();
+ }
}
public void begin() throws ResourceException {
@@ -61,8 +62,8 @@
try {
setInManagedTx(false);
} catch (JMSException e) {
- throw new ResourceException("commit failed.",e);
- }
+ throw new ResourceException("commit failed.", e);
+ }
}
}
@@ -75,8 +76,8 @@
try {
setInManagedTx(false);
} catch (JMSException e) {
- throw new ResourceException("rollback failed.",e);
- }
+ throw new ResourceException("rollback failed.", e);
+ }
}
}
@@ -92,7 +93,7 @@
setInManagedTx(false);
} catch (JMSException e) {
throw (XAException)new XAException(XAException.XAER_PROTO).initCause(e);
- }
+ }
}
}
@@ -105,8 +106,9 @@
}
public boolean isSameRM(XAResource xaresource) throws XAException {
- if (xaresource == null)
+ if (xaresource == null) {
return false;
+ }
// Do we have to unwrap?
if (xaresource instanceof LocalAndXATransaction) {
xaresource = ((LocalAndXATransaction)xaresource).transactionContext;
@@ -130,14 +132,13 @@
return transactionContext.setTransactionTimeout(arg0);
}
-
public void start(Xid arg0, int arg1) throws XAException {
transactionContext.start(arg0, arg1);
try {
setInManagedTx(true);
} catch (JMSException e) {
throw (XAException)new XAException(XAException.XAER_PROTO).initCause(e);
- }
+ }
}
public boolean isInManagedTx() {
@@ -146,6 +147,6 @@
public void cleanup() {
transactionContext.cleanup();
- inManagedTx=false;
+ inManagedTx = false;
}
}
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedConnectionProxy.java Sat Aug 11 22:27:21 2007
@@ -39,17 +39,16 @@
import org.apache.activemq.ActiveMQSession;
import org.apache.activemq.ActiveMQTopicSession;
-
/**
- * Acts as a pass through proxy for a JMS Connection object.
- * It intercepts events that are of interest of the ActiveMQManagedConnection.
- *
+ * Acts as a pass through proxy for a JMS Connection object. It intercepts
+ * events that are of interest of the ActiveMQManagedConnection.
+ *
* @version $Revision$
*/
public class ManagedConnectionProxy implements Connection, QueueConnection, TopicConnection, ExceptionListener {
private ActiveMQManagedConnection managedConnection;
- private ArrayList sessions = new ArrayList();
+ private ArrayList<ManagedSessionProxy> sessions = new ArrayList<ManagedSessionProxy>();
private ExceptionListener exceptionListener;
public ManagedConnectionProxy(ActiveMQManagedConnection managedConnection) {
@@ -57,13 +56,13 @@
}
/**
- * Used to let the ActiveMQManagedConnection that this connection
- * handel is not needed by the app.
- *
+ * Used to let the ActiveMQManagedConnection that this connection handel is
+ * not needed by the app.
+ *
* @throws JMSException
*/
public void close() throws JMSException {
- if( managedConnection!=null ) {
+ if (managedConnection != null) {
managedConnection.proxyClosedEvent(this);
}
}
@@ -72,10 +71,10 @@
* Called by the ActiveMQManagedConnection to invalidate this proxy.
*/
public void cleanup() {
- exceptionListener=null;
+ exceptionListener = null;
managedConnection = null;
- for (Iterator iter = sessions.iterator(); iter.hasNext();) {
- ManagedSessionProxy p = (ManagedSessionProxy) iter.next();
+ for (Iterator<ManagedSessionProxy> iter = sessions.iterator(); iter.hasNext();) {
+ ManagedSessionProxy p = iter.next();
try {
p.cleanup();
} catch (JMSException ignore) {
@@ -100,8 +99,7 @@
* @return
* @throws JMSException
*/
- public Session createSession(boolean transacted, int acknowledgeMode)
- throws JMSException {
+ public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
return createSessionProxy(transacted, acknowledgeMode);
}
@@ -111,19 +109,19 @@
* @return
* @throws JMSException
*/
- private ManagedSessionProxy createSessionProxy(boolean transacted, int acknowledgeMode) throws JMSException {
- ActiveMQSession session = (ActiveMQSession) getConnection().createSession(transacted, acknowledgeMode);
+ private ManagedSessionProxy createSessionProxy(boolean transacted, int acknowledgeMode) throws JMSException {
+ ActiveMQSession session = (ActiveMQSession)getConnection().createSession(transacted, acknowledgeMode);
ManagedTransactionContext txContext = new ManagedTransactionContext(managedConnection.getTransactionContext());
- session.setTransactionContext(txContext);
- ManagedSessionProxy p = new ManagedSessionProxy(session);
+ session.setTransactionContext(txContext);
+ ManagedSessionProxy p = new ManagedSessionProxy(session);
p.setUseSharedTxContext(managedConnection.isInManagedTx());
- sessions.add(p);
+ sessions.add(p);
return p;
}
public void setUseSharedTxContext(boolean enable) throws JMSException {
- for (Iterator iter = sessions.iterator(); iter.hasNext();) {
- ManagedSessionProxy p = (ManagedSessionProxy) iter.next();
+ for (Iterator<ManagedSessionProxy> iter = sessions.iterator(); iter.hasNext();) {
+ ManagedSessionProxy p = iter.next();
p.setUseSharedTxContext(enable);
}
}
@@ -134,8 +132,7 @@
* @return
* @throws JMSException
*/
- public QueueSession createQueueSession(boolean transacted,
- int acknowledgeMode) throws JMSException {
+ public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
return new ActiveMQQueueSession(createSessionProxy(transacted, acknowledgeMode));
}
@@ -145,8 +142,7 @@
* @return
* @throws JMSException
*/
- public TopicSession createTopicSession(boolean transacted,
- int acknowledgeMode) throws JMSException {
+ public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException {
return new ActiveMQTopicSession(createSessionProxy(transacted, acknowledgeMode));
}
@@ -186,8 +182,7 @@
* @param listener
* @throws JMSException
*/
- public void setExceptionListener(ExceptionListener listener)
- throws JMSException {
+ public void setExceptionListener(ExceptionListener listener) throws JMSException {
getConnection();
exceptionListener = listener;
}
@@ -206,7 +201,6 @@
getConnection().stop();
}
-
/**
* @param queue
* @param messageSelector
@@ -215,9 +209,7 @@
* @return
* @throws JMSException
*/
- public ConnectionConsumer createConnectionConsumer(Queue queue,
- String messageSelector, ServerSessionPool sessionPool,
- int maxMessages) throws JMSException {
+ public ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
throw new JMSException("Not Supported.");
}
@@ -229,9 +221,7 @@
* @return
* @throws JMSException
*/
- public ConnectionConsumer createConnectionConsumer(Topic topic,
- String messageSelector, ServerSessionPool sessionPool,
- int maxMessages) throws JMSException {
+ public ConnectionConsumer createConnectionConsumer(Topic topic, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
throw new JMSException("Not Supported.");
}
@@ -243,9 +233,7 @@
* @return
* @throws JMSException
*/
- public ConnectionConsumer createConnectionConsumer(Destination destination,
- String messageSelector, ServerSessionPool sessionPool,
- int maxMessages) throws JMSException {
+ public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
throw new JMSException("Not Supported.");
}
@@ -258,9 +246,7 @@
* @return
* @throws JMSException
*/
- public ConnectionConsumer createDurableConnectionConsumer(Topic topic,
- String subscriptionName, String messageSelector,
- ServerSessionPool sessionPool, int maxMessages) throws JMSException {
+ public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
throw new JMSException("Not Supported.");
}
@@ -272,7 +258,7 @@
}
public void onException(JMSException e) {
- if(exceptionListener!=null && managedConnection!=null) {
+ if (exceptionListener != null && managedConnection != null) {
try {
exceptionListener.onException(e);
} catch (Throwable ignore) {
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedSessionProxy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedSessionProxy.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedSessionProxy.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedSessionProxy.java Sat Aug 11 22:27:21 2007
@@ -54,14 +54,14 @@
public class ManagedSessionProxy implements Session, QueueSession, TopicSession {
private final ActiveMQSession session;
- boolean closed = false;
+ private boolean closed;
public ManagedSessionProxy(ActiveMQSession session) {
this.session = session;
}
public void setUseSharedTxContext(boolean enable) throws JMSException {
- if( session.getTransactionContext() !=null ) {
+ if (session.getTransactionContext() != null) {
((ManagedTransactionContext)session.getTransactionContext()).setUseSharedTxContext(enable);
}
}
@@ -75,9 +75,9 @@
/**
* Called by the ActiveMQManagedConnection to invalidate this proxy.
- * @throws JMSException
*
* @throws JMSException
+ * @throws JMSException
*/
public void cleanup() throws JMSException {
closed = true;
@@ -150,13 +150,12 @@
/**
* @param destination
* @param messageSelector
- * @param NoLocal
+ * @param noLocal
* @return
* @throws JMSException
*/
- public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean NoLocal)
- throws JMSException {
- return getSession().createConsumer(destination, messageSelector, NoLocal);
+ public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal) throws JMSException {
+ return getSession().createConsumer(destination, messageSelector, noLocal);
}
/**
@@ -177,8 +176,7 @@
* @return
* @throws JMSException
*/
- public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal)
- throws JMSException {
+ public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException {
return getSession().createDurableSubscriber(topic, name, messageSelector, noLocal);
}
@@ -343,7 +341,7 @@
* @throws JMSException
*/
public QueueReceiver createReceiver(Queue queue) throws JMSException {
- return ((QueueSession) getSession()).createReceiver(queue);
+ return ((QueueSession)getSession()).createReceiver(queue);
}
/**
@@ -353,7 +351,7 @@
* @throws JMSException
*/
public QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException {
- return ((QueueSession) getSession()).createReceiver(queue, messageSelector);
+ return ((QueueSession)getSession()).createReceiver(queue, messageSelector);
}
/**
@@ -362,7 +360,7 @@
* @throws JMSException
*/
public QueueSender createSender(Queue queue) throws JMSException {
- return ((QueueSession) getSession()).createSender(queue);
+ return ((QueueSession)getSession()).createSender(queue);
}
/**
@@ -371,7 +369,7 @@
* @throws JMSException
*/
public TopicPublisher createPublisher(Topic topic) throws JMSException {
- return ((TopicSession) getSession()).createPublisher(topic);
+ return ((TopicSession)getSession()).createPublisher(topic);
}
/**
@@ -380,7 +378,7 @@
* @throws JMSException
*/
public TopicSubscriber createSubscriber(Topic topic) throws JMSException {
- return ((TopicSession) getSession()).createSubscriber(topic);
+ return ((TopicSession)getSession()).createSubscriber(topic);
}
/**
@@ -391,7 +389,7 @@
* @throws JMSException
*/
public TopicSubscriber createSubscriber(Topic topic, String messageSelector, boolean noLocal) throws JMSException {
- return ((TopicSession) getSession()).createSubscriber(topic, messageSelector, noLocal);
+ return ((TopicSession)getSession()).createSubscriber(topic, messageSelector, noLocal);
}
/**
@@ -402,7 +400,7 @@
}
public String toString() {
- return "ManagedSessionProxy { "+session+" }";
+ return "ManagedSessionProxy { " + session + " }";
}
}
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ManagedTransactionContext.java Sat Aug 11 22:27:21 2007
@@ -26,143 +26,162 @@
import org.apache.activemq.transaction.Synchronization;
/**
- * Allows us to switch between using a shared transaction context,
- * or using a local transaction context.
+ * Allows us to switch between using a shared transaction context, or using a
+ * local transaction context.
*
* @version $Revision$
*/
public class ManagedTransactionContext extends TransactionContext {
private final TransactionContext sharedContext;
- boolean useSharedTxContext=false;
+ private boolean useSharedTxContext;
public ManagedTransactionContext(TransactionContext sharedContext) {
super(sharedContext.getConnection());
this.sharedContext = sharedContext;
setLocalTransactionEventListener(sharedContext.getLocalTransactionEventListener());
}
-
+
public void setUseSharedTxContext(boolean enable) throws JMSException {
- if( isInLocalTransaction() || isInXATransaction() )
+ if (isInLocalTransaction() || isInXATransaction()) {
throw new JMSException("The resource is allready being used in transaction context.");
+ }
useSharedTxContext = enable;
- }
-
+ }
+
public void begin() throws JMSException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.begin();
- else
+ } else {
super.begin();
+ }
}
+
public void commit() throws JMSException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.commit();
- else
+ } else {
super.commit();
+ }
}
public void commit(Xid xid, boolean onePhase) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.commit(xid, onePhase);
- else
+ } else {
super.commit(xid, onePhase);
+ }
}
public void end(Xid xid, int flags) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.end(xid, flags);
- else
+ } else {
super.end(xid, flags);
+ }
}
public void forget(Xid xid) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.forget(xid);
- else
+ } else {
super.forget(xid);
+ }
}
public TransactionId getTransactionId() {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.getTransactionId();
- else
+ } else {
return super.getTransactionId();
+ }
}
public int getTransactionTimeout() throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.getTransactionTimeout();
- else
+ } else {
return super.getTransactionTimeout();
+ }
}
public boolean isInLocalTransaction() {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.isInLocalTransaction();
- else
+ } else {
return super.isInLocalTransaction();
+ }
}
public boolean isInXATransaction() {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.isInXATransaction();
- else
+ } else {
return super.isInXATransaction();
+ }
}
public boolean isSameRM(XAResource xaResource) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.isSameRM(xaResource);
- else
+ } else {
return super.isSameRM(xaResource);
+ }
}
public int prepare(Xid xid) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.prepare(xid);
- else
+ } else {
return super.prepare(xid);
+ }
}
public Xid[] recover(int flag) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.recover(flag);
- else
+ } else {
return super.recover(flag);
+ }
}
public void rollback() throws JMSException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.rollback();
- else
+ } else {
super.rollback();
+ }
}
public void rollback(Xid xid) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.rollback(xid);
- else
+ } else {
super.rollback(xid);
+ }
}
public boolean setTransactionTimeout(int seconds) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
return sharedContext.setTransactionTimeout(seconds);
- else
+ } else {
return super.setTransactionTimeout(seconds);
+ }
}
public void start(Xid xid, int flags) throws XAException {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.start(xid, flags);
- else
+ } else {
super.start(xid, flags);
+ }
}
-
+
public void addSynchronization(Synchronization s) {
- if( useSharedTxContext )
+ if (useSharedTxContext) {
sharedContext.addSynchronization(s);
- else
+ } else {
super.addSynchronization(s);
+ }
}
}
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageActivationSpec.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageActivationSpec.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageActivationSpec.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageActivationSpec.java Sat Aug 11 22:27:21 2007
@@ -50,14 +50,12 @@
* @version $Revision$ $Date$
* @since 0.1
*/
-public interface MessageActivationSpec
- extends ActivationSpec
-{
+public interface MessageActivationSpec extends ActivationSpec {
/**
*/
String getClientId();
-
+
/**
*/
boolean isDurableSubscription();
@@ -76,7 +74,7 @@
/**
*/
- String getSubscriptionName();
+ String getSubscriptionName();
/**
*/
@@ -92,18 +90,18 @@
/**
*/
- String getDestinationType();
+ String getDestinationType();
/**
*/
- String getDestination();
+ String getDestination();
- /**
- */
- int getMaxSessionsIntValue();
+ /**
+ */
+ int getMaxSessionsIntValue();
/**
- *
+ *
*/
int getAcknowledgeModeForSession();
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageEndpointProxy.java Sat Aug 11 22:27:21 2007
@@ -27,31 +27,30 @@
* @author <a href="mailto:michael.gaffney@panacya.com">Michael Gaffney </a>
*/
public class MessageEndpointProxy implements MessageListener, MessageEndpoint {
-
+
private static final MessageEndpointState ALIVE = new MessageEndpointAlive();
private static final MessageEndpointState DEAD = new MessageEndpointDead();
-
-
- private static int proxyCount = 0;
+
+ private static int proxyCount;
private final int proxyID;
-
+
private final MessageEndpoint endpoint;
private final MessageListener messageListener;
private MessageEndpointState state = ALIVE;
- private static int getID() {
- return ++proxyCount;
- }
-
- public MessageEndpointProxy(MessageEndpoint endpoint) {
+ public MessageEndpointProxy(MessageEndpoint endpoint) {
if (!(endpoint instanceof MessageListener)) {
- throw new IllegalArgumentException("MessageEndpoint is not a MessageListener");
- }
- messageListener = (MessageListener) endpoint;
+ throw new IllegalArgumentException("MessageEndpoint is not a MessageListener");
+ }
+ messageListener = (MessageListener)endpoint;
proxyID = getID();
this.endpoint = endpoint;
}
+ private static int getID() {
+ return ++proxyCount;
+ }
+
public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException {
state.beforeDelivery(this, method);
}
@@ -69,12 +68,9 @@
}
public String toString() {
- return "MessageEndpointProxy{ " +
- "proxyID: " + proxyID +
- ", endpoint: " + endpoint +
- " }";
+ return "MessageEndpointProxy{ " + "proxyID: " + proxyID + ", endpoint: " + endpoint + " }";
}
-
+
private abstract static class MessageEndpointState {
public void beforeDelivery(MessageEndpointProxy proxy, Method method) throws NoSuchMethodException, ResourceException {
@@ -92,28 +88,28 @@
public void release(MessageEndpointProxy proxy) {
throw new IllegalStateException();
}
-
+
protected final void transition(MessageEndpointProxy proxy, MessageEndpointState nextState) {
proxy.state = nextState;
nextState.enter(proxy);
}
-
- protected void enter(MessageEndpointProxy proxy) {
- }
+
+ protected void enter(MessageEndpointProxy proxy) {
+ }
}
-
+
private static class MessageEndpointAlive extends MessageEndpointState {
- public void beforeDelivery(MessageEndpointProxy proxy, Method method) throws NoSuchMethodException, ResourceException {
+ public void beforeDelivery(MessageEndpointProxy proxy, Method method) throws NoSuchMethodException, ResourceException {
try {
proxy.endpoint.beforeDelivery(method);
} catch (NoSuchMethodException e) {
transition(proxy, DEAD);
throw e;
} catch (ResourceException e) {
- transition(proxy, DEAD);
+ transition(proxy, DEAD);
throw e;
- }
+ }
}
public void onMessage(MessageEndpointProxy proxy, Message message) {
@@ -124,13 +120,13 @@
try {
proxy.endpoint.afterDelivery();
} catch (ResourceException e) {
- transition(proxy, DEAD);
+ transition(proxy, DEAD);
throw e;
- }
+ }
}
public void release(MessageEndpointProxy proxy) {
- transition(proxy, DEAD);
+ transition(proxy, DEAD);
}
}
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageResourceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageResourceAdapter.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageResourceAdapter.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageResourceAdapter.java Sat Aug 11 22:27:21 2007
@@ -28,52 +28,46 @@
* Knows how to connect to one ActiveMQ server. It can then activate endpoints
* and deliver messages to those end points using the connection configure in
* the resource adapter. <p/>Must override equals and hashCode (JCA spec 16.4)
- *
+ *
* @org.apache.xbean.XBean element="resourceAdapter" rootElement="true"
- * description="The JCA Resource Adaptor for ActiveMQ"
+ * description="The JCA Resource Adaptor for ActiveMQ"
* @version $Revision$
*/
-public interface MessageResourceAdapter
- extends ResourceAdapter
-{
+interface MessageResourceAdapter extends ResourceAdapter {
/**
*/
- public ActiveMQConnection makeConnection()
- throws JMSException;
+ ActiveMQConnection makeConnection() throws JMSException;
/**
*/
- public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info)
- throws JMSException;
+ ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info) throws JMSException;
/**
*/
- public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info, ActiveMQConnectionFactory connectionFactory)
- throws JMSException;
+ ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info, ActiveMQConnectionFactory connectionFactory) throws JMSException;
/**
- * @param activationSpec
+ * @param activationSpec
*/
- public ActiveMQConnection makeConnection(MessageActivationSpec activationSpec)
- throws JMSException;
+ ActiveMQConnection makeConnection(MessageActivationSpec activationSpec) throws JMSException;
/**
- * @return bootstrap context
+ * @return bootstrap context
*/
- public BootstrapContext getBootstrapContext();
+ BootstrapContext getBootstrapContext();
/**
*/
- public String getBrokerXmlConfig();
+ String getBrokerXmlConfig();
/**
* @return Returns the info.
*/
- public ActiveMQConnectionRequestInfo getInfo();
+ ActiveMQConnectionRequestInfo getInfo();
/**
*/
- public ActiveMQConnectionFactory getConnectionFactory();
+ ActiveMQConnectionFactory getConnectionFactory();
}
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java Sat Aug 11 22:27:21 2007
@@ -32,8 +32,8 @@
import javax.resource.spi.work.WorkManager;
import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.TransactionContext;
import org.apache.activemq.ActiveMQSession.DeliveryListener;
+import org.apache.activemq.TransactionContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,24 +43,22 @@
public class ServerSessionImpl implements ServerSession, InboundContext, Work, DeliveryListener {
public static final Method ON_MESSAGE_METHOD;
+ private static int nextLogId;
static {
try {
- ON_MESSAGE_METHOD = MessageListener.class.getMethod("onMessage", new Class[]{Message.class});
- }
- catch (Exception e) {
+ ON_MESSAGE_METHOD = MessageListener.class.getMethod("onMessage", new Class[] {
+ Message.class
+ });
+ } catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
- private static int nextLogId=0;
- synchronized static private int getNextLogId() {
- return nextLogId++;
- }
private int serverSessionId = getNextLogId();
- private final Log log = LogFactory.getLog( ServerSessionImpl.class.getName()+":"+serverSessionId );
-
+ private final Log log = LogFactory.getLog(ServerSessionImpl.class.getName() + ":" + serverSessionId);
+
private ActiveMQSession session;
private WorkManager workManager;
private MessageEndpoint endpoint;
@@ -68,10 +66,10 @@
private final ServerSessionPoolImpl pool;
private Object runControlMutex = new Object();
- private boolean runningFlag = false;
- /**
- * True if an error was detected that cause this session to be stale. When a session
- * is stale, it should not be used again for proccessing.
+ private boolean runningFlag;
+ /**
+ * True if an error was detected that cause this session to be stale. When a
+ * session is stale, it should not be used again for proccessing.
*/
private boolean stale;
/**
@@ -93,11 +91,15 @@
this.workManager = workManager;
this.endpoint = endpoint;
this.useRAManagedTx = useRAManagedTx;
- this.session.setMessageListener((MessageListener) endpoint);
+ this.session.setMessageListener((MessageListener)endpoint);
this.session.setDeliveryListener(this);
this.batchSize = batchSize;
}
+ private static synchronized int getNextLogId() {
+ return nextLogId++;
+ }
+
public Session getSession() throws JMSException {
return session;
}
@@ -125,29 +127,27 @@
// We get here because we need to start a async worker.
log.debug("Starting run.");
try {
- workManager.scheduleWork(this, WorkManager.INDEFINITE, null,
- new WorkListener() {
- //The work listener is useful only for debugging...
- public void workAccepted(WorkEvent event) {
- log.debug("Work accepted: " + event);
- }
-
- public void workRejected(WorkEvent event) {
- log.debug("Work rejected: " + event);
- }
-
- public void workStarted(WorkEvent event) {
- log.debug("Work started: " + event);
- }
-
- public void workCompleted(WorkEvent event) {
- log.debug("Work completed: " + event);
- }
+ workManager.scheduleWork(this, WorkManager.INDEFINITE, null, new WorkListener() {
+ // The work listener is useful only for debugging...
+ public void workAccepted(WorkEvent event) {
+ log.debug("Work accepted: " + event);
+ }
- });
- }
- catch (WorkException e) {
- throw (JMSException) new JMSException("Start failed: " + e).initCause(e);
+ public void workRejected(WorkEvent event) {
+ log.debug("Work rejected: " + event);
+ }
+
+ public void workStarted(WorkEvent event) {
+ log.debug("Work started: " + event);
+ }
+
+ public void workCompleted(WorkEvent event) {
+ log.debug("Work completed: " + event);
+ }
+
+ });
+ } catch (WorkException e) {
+ throw (JMSException)new JMSException("Start failed: " + e).initCause(e);
}
}
@@ -155,43 +155,40 @@
* @see java.lang.Runnable#run()
*/
public void run() {
- log.debug("Running");
+ log.debug("Running");
while (true) {
- log.debug("run loop start");
+ log.debug("run loop start");
try {
- InboundContextSupport.register(this);
+ InboundContextSupport.register(this);
currentBatchSize = 0;
session.run();
- }
- catch (Throwable e) {
- stale=true;
+ } catch (Throwable e) {
+ stale = true;
log.debug("Endpoint failed to process message.", e);
log.info("Endpoint failed to process message. Reason: " + e);
- }
- finally {
- InboundContextSupport.unregister(this);
- log.debug("run loop end");
+ } finally {
+ InboundContextSupport.unregister(this);
+ log.debug("run loop end");
synchronized (runControlMutex) {
// This endpoint may have gone stale due to error
- if( stale) {
+ if (stale) {
runningFlag = false;
pool.removeFromPool(this);
break;
}
- if( !session.hasUncomsumedMessages() ) {
+ if (!session.hasUncomsumedMessages()) {
runningFlag = false;
pool.returnToPool(this);
break;
- }
+ }
}
}
}
log.debug("Run finished");
}
-
/**
- * The ActiveMQSession's run method will call back to this method before
+ * The ActiveMQSession's run method will call back to this method before
* dispactching a message to the MessageListener.
*/
public void beforeDelivery(ActiveMQSession session, Message msg) {
@@ -205,7 +202,7 @@
}
/**
- * The ActiveMQSession's run method will call back to this method after
+ * The ActiveMQSession's run method will call back to this method after
* dispactching a message to the MessageListener.
*/
public void afterDelivery(ActiveMQSession session, Message msg) {
@@ -217,9 +214,10 @@
throw new RuntimeException("Endpoint after delivery notification failure", e);
} finally {
TransactionContext transactionContext = session.getTransactionContext();
- if( transactionContext != null && transactionContext.isInLocalTransaction() ) {
- if( !useRAManagedTx ) {
- // Sanitiy Check: If the local transaction has not been commited..
+ if (transactionContext != null && transactionContext.isInLocalTransaction()) {
+ if (!useRAManagedTx) {
+ // Sanitiy Check: If the local transaction has not been
+ // commited..
// Commit it now.
log.warn("Local transaction had not been commited. Commiting now.");
}
@@ -244,19 +242,19 @@
* @see java.lang.Object#toString()
*/
public String toString() {
- return "ServerSessionImpl:"+serverSessionId;
+ return "ServerSessionImpl:" + serverSessionId;
}
public void close() {
try {
endpoint.release();
} catch (Throwable e) {
- log.debug("Endpoint did not release properly: "+e,e);
+ log.debug("Endpoint did not release properly: " + e, e);
}
try {
session.close();
} catch (Throwable e) {
- log.debug("Session did not close properly: "+e,e);
+ log.debug("Session did not close properly: " + e, e);
}
}
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionPoolImpl.java Sat Aug 11 22:27:21 2007
@@ -18,6 +18,8 @@
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.JMSException;
import javax.jms.ServerSession;
@@ -32,51 +34,49 @@
import org.apache.activemq.command.MessageDispatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
/**
* @version $Revision$ $Date$
*/
public class ServerSessionPoolImpl implements ServerSessionPool {
-
- private static final Log log = LogFactory.getLog(ServerSessionPoolImpl.class);
+
+ private static final Log LOG = LogFactory.getLog(ServerSessionPoolImpl.class);
private final ActiveMQEndpointWorker activeMQAsfEndpointWorker;
private final int maxSessions;
- private List idleSessions = new CopyOnWriteArrayList();
- private List activeSessions = new CopyOnWriteArrayList();
+ private List<ServerSessionImpl> idleSessions = new CopyOnWriteArrayList<ServerSessionImpl>();
+ private List<ServerSessionImpl> activeSessions = new CopyOnWriteArrayList<ServerSessionImpl>();
private AtomicBoolean closing = new AtomicBoolean(false);
public ServerSessionPoolImpl(ActiveMQEndpointWorker activeMQAsfEndpointWorker, int maxSessions) {
this.activeMQAsfEndpointWorker = activeMQAsfEndpointWorker;
- this.maxSessions=maxSessions;
+ this.maxSessions = maxSessions;
}
private ServerSessionImpl createServerSessionImpl() throws JMSException {
MessageActivationSpec activationSpec = activeMQAsfEndpointWorker.endpointActivationKey.getActivationSpec();
int acknowledge = (activeMQAsfEndpointWorker.transacted) ? Session.SESSION_TRANSACTED : activationSpec.getAcknowledgeModeForSession();
- final ActiveMQSession session = (ActiveMQSession) activeMQAsfEndpointWorker.connection.createSession(activeMQAsfEndpointWorker.transacted,acknowledge);
+ final ActiveMQSession session = (ActiveMQSession)activeMQAsfEndpointWorker.connection.createSession(activeMQAsfEndpointWorker.transacted, acknowledge);
MessageEndpoint endpoint;
- try {
+ try {
int batchSize = 0;
if (activationSpec.getEnableBatchBooleanValue()) {
batchSize = activationSpec.getMaxMessagesPerBatchIntValue();
}
- if( activationSpec.isUseRAManagedTransactionEnabled() ) {
+ if (activationSpec.isUseRAManagedTransactionEnabled()) {
// The RA will manage the transaction commit.
- endpoint = createEndpoint(null);
+ endpoint = createEndpoint(null);
return new ServerSessionImpl(this, (ActiveMQSession)session, activeMQAsfEndpointWorker.workManager, endpoint, true, batchSize);
} else {
// Give the container an object to manage to transaction with.
- endpoint = createEndpoint(new LocalAndXATransaction(session.getTransactionContext()));
+ endpoint = createEndpoint(new LocalAndXATransaction(session.getTransactionContext()));
return new ServerSessionImpl(this, (ActiveMQSession)session, activeMQAsfEndpointWorker.workManager, endpoint, false, batchSize);
}
} catch (UnavailableException e) {
// The container could be limiting us on the number of endpoints
// that are being created.
- log.debug("Could not create an endpoint.", e);
+ LOG.debug("Could not create an endpoint.", e);
session.close();
return null;
}
@@ -92,15 +92,15 @@
/**
*/
public ServerSession getServerSession() throws JMSException {
- log.debug("ServerSession requested.");
+ LOG.debug("ServerSession requested.");
if (closing.get()) {
throw new JMSException("Session Pool Shutting Down.");
}
if (idleSessions.size() > 0) {
- ServerSessionImpl ss = (ServerSessionImpl) idleSessions.remove(idleSessions.size() - 1);
+ ServerSessionImpl ss = idleSessions.remove(idleSessions.size() - 1);
activeSessions.add(ss);
- log.debug("Using idle session: " + ss);
+ LOG.debug("Using idle session: " + ss);
return ss;
} else {
// Are we at the upper limit?
@@ -121,7 +121,7 @@
return getExistingServerSession();
}
activeSessions.add(ss);
- log.debug("Created a new session: " + ss);
+ LOG.debug("Created a new session: " + ss);
return ss;
}
}
@@ -135,52 +135,51 @@
ServerSession serverSession = getServerSession();
Session s = serverSession.getSession();
ActiveMQSession session = null;
- if( s instanceof ActiveMQSession ) {
- session = (ActiveMQSession) s;
- } else if(s instanceof ActiveMQQueueSession) {
- session = (ActiveMQSession) s;
- } else if(s instanceof ActiveMQTopicSession) {
- session = (ActiveMQSession) s;
+ if (s instanceof ActiveMQSession) {
+ session = (ActiveMQSession)s;
+ } else if (s instanceof ActiveMQQueueSession) {
+ session = (ActiveMQSession)s;
+ } else if (s instanceof ActiveMQTopicSession) {
+ session = (ActiveMQSession)s;
} else {
- activeMQAsfEndpointWorker.connection.onAsyncException(new JMSException("Session pool provided an invalid session type: "+s.getClass()));
+ activeMQAsfEndpointWorker.connection.onAsyncException(new JMSException("Session pool provided an invalid session type: " + s.getClass()));
}
session.dispatch(messageDispatch);
serverSession.start();
}
-
/**
* @return
*/
private ServerSession getExistingServerSession() {
- ServerSessionImpl ss = (ServerSessionImpl) activeSessions.remove(0);
+ ServerSessionImpl ss = activeSessions.remove(0);
activeSessions.add(ss);
- log.debug("Reusing an active session: " + ss);
+ LOG.debug("Reusing an active session: " + ss);
return ss;
}
public void returnToPool(ServerSessionImpl ss) {
- log.debug("Session returned to pool: " + ss);
+ LOG.debug("Session returned to pool: " + ss);
activeSessions.remove(ss);
idleSessions.add(ss);
- synchronized(closing){
+ synchronized (closing) {
closing.notify();
}
}
- public void removeFromPool(ServerSessionImpl ss) {
+ public void removeFromPool(ServerSessionImpl ss) {
activeSessions.remove(ss);
try {
- ActiveMQSession session = (ActiveMQSession) ss.getSession();
+ ActiveMQSession session = (ActiveMQSession)ss.getSession();
List l = session.getUnconsumedMessages();
for (Iterator i = l.iterator(); i.hasNext();) {
- dispatchToSession((MessageDispatch) i.next());
+ dispatchToSession((MessageDispatch)i.next());
}
} catch (Throwable t) {
- log.error("Error redispatching unconsumed messages from stale session", t);
+ LOG.error("Error redispatching unconsumed messages from stale session", t);
}
ss.close();
- synchronized(closing){
+ synchronized (closing) {
closing.notify();
}
}
@@ -189,7 +188,7 @@
synchronized (closing) {
closing.set(true);
closeIdleSessions();
- while( activeSessions.size() > 0 ) {
+ while (activeSessions.size() > 0) {
System.out.println("ACtive Sessions = " + activeSessions.size());
try {
closing.wait(1000);
@@ -203,8 +202,8 @@
}
private void closeIdleSessions() {
- for (Iterator iter = idleSessions.iterator(); iter.hasNext();) {
- ServerSessionImpl ss = (ServerSessionImpl) iter.next();
+ for (Iterator<ServerSessionImpl> iter = idleSessions.iterator(); iter.hasNext();) {
+ ServerSessionImpl ss = iter.next();
ss.close();
}
}
@@ -212,14 +211,14 @@
/**
* @return Returns the closing.
*/
- public boolean isClosing(){
+ public boolean isClosing() {
return closing.get();
}
/**
* @param closing The closing to set.
*/
- public void setClosing(boolean closing){
+ public void setClosing(boolean closing) {
this.closing.set(closing);
}
Modified: activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/SimpleConnectionManager.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/SimpleConnectionManager.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/SimpleConnectionManager.java (original)
+++ activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/SimpleConnectionManager.java Sat Aug 11 22:27:21 2007
@@ -16,9 +16,6 @@
*/
package org.apache.activemq.ra;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
import javax.resource.spi.ConnectionEventListener;
@@ -28,21 +25,24 @@
import javax.resource.spi.ManagedConnectionFactory;
import javax.security.auth.Subject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
- * A simple implementation of a ConnectionManager.
- * An Application Server will have a better implementation with pooling and security etc.
+ * A simple implementation of a ConnectionManager. An Application Server will
+ * have a better implementation with pooling and security etc.
*
* @version $Revision$
*/
public class SimpleConnectionManager implements ConnectionManager, ConnectionEventListener {
private static final long serialVersionUID = -7662970495944876239L;
-
- private static final Log log = LogFactory.getLog(SimpleConnectionManager.class);
+
+ private static final Log LOG = LogFactory.getLog(SimpleConnectionManager.class);
/**
- * @see javax.resource.spi.ConnectionManager#allocateConnection(javax.resource.spi.ManagedConnectionFactory, javax.resource.spi.ConnectionRequestInfo)
+ * @see javax.resource.spi.ConnectionManager#allocateConnection(javax.resource.spi.ManagedConnectionFactory,
+ * javax.resource.spi.ConnectionRequestInfo)
*/
public Object allocateConnection(ManagedConnectionFactory connectionFactory, ConnectionRequestInfo info) throws ResourceException {
Subject subject = null;
@@ -56,16 +56,14 @@
*/
public void connectionClosed(ConnectionEvent event) {
try {
- ((ManagedConnection) event.getSource()).cleanup();
- }
- catch (ResourceException e) {
- log.warn("Error occured during the cleanup of a managed connection: ", e);
+ ((ManagedConnection)event.getSource()).cleanup();
+ } catch (ResourceException e) {
+ LOG.warn("Error occured during the cleanup of a managed connection: ", e);
}
try {
- ((ManagedConnection) event.getSource()).destroy();
- }
- catch (ResourceException e) {
- log.warn("Error occured during the destruction of a managed connection: ", e);
+ ((ManagedConnection)event.getSource()).destroy();
+ } catch (ResourceException e) {
+ LOG.warn("Error occured during the destruction of a managed connection: ", e);
}
}
@@ -91,18 +89,16 @@
* @see javax.resource.spi.ConnectionEventListener#connectionErrorOccurred(javax.resource.spi.ConnectionEvent)
*/
public void connectionErrorOccurred(ConnectionEvent event) {
- log.warn("Managed connection experiened an error: ", event.getException());
+ LOG.warn("Managed connection experiened an error: ", event.getException());
try {
- ((ManagedConnection) event.getSource()).cleanup();
- }
- catch (ResourceException e) {
- log.warn("Error occured during the cleanup of a managed connection: ", e);
+ ((ManagedConnection)event.getSource()).cleanup();
+ } catch (ResourceException e) {
+ LOG.warn("Error occured during the cleanup of a managed connection: ", e);
}
try {
- ((ManagedConnection) event.getSource()).destroy();
- }
- catch (ResourceException e) {
- log.warn("Error occured during the destruction of a managed connection: ", e);
+ ((ManagedConnection)event.getSource()).destroy();
+ } catch (ResourceException e) {
+ LOG.warn("Error occured during the destruction of a managed connection: ", e);
}
}
Modified: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQActivationSpecTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQActivationSpecTest.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQActivationSpecTest.java (original)
+++ activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQActivationSpecTest.java Sat Aug 11 22:27:21 2007
@@ -27,9 +27,7 @@
import javax.resource.spi.InvalidPropertyException;
import junit.framework.TestCase;
-
import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.ra.ActiveMQActivationSpec;
/**
* @version $Revision$
@@ -38,6 +36,7 @@
private static final String DESTINATION = "defaultQueue";
private static final String DESTINATION_TYPE = Queue.class.getName();
+ private static final String EMPTY_STRING = " ";
private ActiveMQActivationSpec activationSpec;
private PropertyDescriptor destinationProperty;
@@ -46,7 +45,6 @@
private PropertyDescriptor subscriptionDurabilityProperty;
private PropertyDescriptor clientIdProperty;
private PropertyDescriptor subscriptionNameProperty;
- private static final String EMPTY_STRING = " ";
public ActiveMQActivationSpecTest(String name) {
super(name);
@@ -297,8 +295,8 @@
*/
assertNotNull("No PropertyDescriptors returned", expected);
assertEquals("PropertyDescriptor array size is incorrect ", expected.length, actual.length);
- List expectedList = Arrays.asList(expected);
- List actualList = Arrays.asList(actual);
+ List<PropertyDescriptor> expectedList = Arrays.asList(expected);
+ List<PropertyDescriptor> actualList = Arrays.asList(actual);
assertTrue("Incorrect PropertyDescriptors returned", expectedList.containsAll(actualList));
}
Modified: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQAsfEndpointWorkerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQAsfEndpointWorkerTest.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQAsfEndpointWorkerTest.java (original)
+++ activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQAsfEndpointWorkerTest.java Sat Aug 11 22:27:21 2007
@@ -16,50 +16,38 @@
*/
package org.apache.activemq.ra;
-import org.apache.activemq.ra.ActiveMQActivationSpec;
-import org.apache.activemq.ra.ActiveMQEndpointActivationKey;
-import org.apache.activemq.ra.ActiveMQEndpointWorker;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
-import org.jmock.cglib.Mock;
-import org.jmock.cglib.MockObjectTestCase;
-import org.jmock.core.Constraint;
-
import javax.jms.Connection;
-import javax.jms.Topic;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.endpoint.MessageEndpointFactory;
+import org.jmock.cglib.Mock;
+import org.jmock.cglib.MockObjectTestCase;
/**
* @author <a href="mailto:michael.gaffney@panacya.com">Michael Gaffney </a>
*/
public class ActiveMQAsfEndpointWorkerTest extends MockObjectTestCase {
- private ActiveMQEndpointWorker worker;
private Mock mockResourceAdapter;
private Mock mockActivationKey;
private Mock mockEndpointFactory;
private Mock mockBootstrapContext;
private ActiveMQActivationSpec stubActivationSpec;
- private Mock mockConnection;
+// private Mock mockConnection;
public ActiveMQAsfEndpointWorkerTest(String name) {
setName(name);
}
-
+
public void testTopicSubscriberDurableNoDups() throws Exception {
/*
- Constraint[] args = {isA(Topic.class), eq(stubActivationSpec.getSubscriptionId()), NULL,
- ANYTHING, ANYTHING};
-
- mockConnection.expects(once())
- .method("createDurableConnectionConsumer")
- .with(args)
- .will(returnValue(null));
- worker.start();
- verifyMocks();
- */
+ * Constraint[] args = {isA(Topic.class),
+ * eq(stubActivationSpec.getSubscriptionId()), NULL, ANYTHING,
+ * ANYTHING}; mockConnection.expects(once())
+ * .method("createDurableConnectionConsumer") .with(args)
+ * .will(returnValue(null)); worker.start(); verifyMocks();
+ */
}
protected void setUp() throws Exception {
@@ -82,46 +70,34 @@
mockActivationKey = new Mock(ActiveMQEndpointActivationKey.class);
mockEndpointFactory = new Mock(MessageEndpointFactory.class);
mockBootstrapContext = new Mock(BootstrapContext.class);
- mockConnection = new Mock(Connection.class);
-
- mockActivationKey.expects(atLeastOnce())
- .method("getMessageEndpointFactory")
- .will(returnValue((MessageEndpointFactory) mockEndpointFactory.proxy()));
-
- mockActivationKey.expects(atLeastOnce())
- .method("getActivationSpec")
- .will(returnValue(stubActivationSpec));
-
- mockResourceAdapter.expects(atLeastOnce())
- .method("getBootstrapContext")
- .will(returnValue((BootstrapContext) mockBootstrapContext.proxy()));
-
- mockBootstrapContext.expects(atLeastOnce())
- .method("getWorkManager")
- .will(returnValue(null));
+// mockConnection = new Mock(Connection.class);
+
+ mockActivationKey.expects(atLeastOnce()).method("getMessageEndpointFactory").will(returnValue((MessageEndpointFactory)mockEndpointFactory.proxy()));
+
+ mockActivationKey.expects(atLeastOnce()).method("getActivationSpec").will(returnValue(stubActivationSpec));
+
+ mockResourceAdapter.expects(atLeastOnce()).method("getBootstrapContext").will(returnValue((BootstrapContext)mockBootstrapContext.proxy()));
+
+ mockBootstrapContext.expects(atLeastOnce()).method("getWorkManager").will(returnValue(null));
final boolean isTransactedResult = true;
setupIsTransacted(isTransactedResult);
}
private void setupIsTransacted(final boolean transactedResult) {
- mockEndpointFactory.expects(atLeastOnce())
- .method("isDeliveryTransacted")
- .with(ANYTHING)
- .will(returnValue(transactedResult));
+ mockEndpointFactory.expects(atLeastOnce()).method("isDeliveryTransacted").with(ANYTHING).will(returnValue(transactedResult));
}
private void setupEndpointWorker() throws Exception {
- worker = new ActiveMQEndpointWorker((ActiveMQResourceAdapter)mockResourceAdapter.proxy(),
- (ActiveMQEndpointActivationKey)mockActivationKey.proxy());
+ new ActiveMQEndpointWorker((ActiveMQResourceAdapter)mockResourceAdapter.proxy(), (ActiveMQEndpointActivationKey)mockActivationKey.proxy());
}
- private void verifyMocks() {
- mockResourceAdapter.verify();
- mockActivationKey.verify();
- mockEndpointFactory.verify();
- mockBootstrapContext.verify();
- mockConnection.verify();
- }
+// private void verifyMocks() {
+// mockResourceAdapter.verify();
+// mockActivationKey.verify();
+// mockEndpointFactory.verify();
+// mockBootstrapContext.verify();
+// mockConnection.verify();
+// }
}
Modified: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQResourceAdapterJavaBeanEqualityTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQResourceAdapterJavaBeanEqualityTest.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQResourceAdapterJavaBeanEqualityTest.java (original)
+++ activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQResourceAdapterJavaBeanEqualityTest.java Sat Aug 11 22:27:21 2007
@@ -16,8 +16,6 @@
*/
package org.apache.activemq.ra;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
-
import junit.framework.TestCase;
/**
@@ -34,14 +32,14 @@
protected void setUp() throws Exception {
super.setUp();
- raOne = new ActiveMQResourceAdapter();
+ raOne = new ActiveMQResourceAdapter();
raTwo = new ActiveMQResourceAdapter();
}
public void testSelfEquality() {
- assertEquality(raOne, raOne);
+ assertEquality(raOne, raOne);
}
-
+
public void testEmptyEquality() {
assertEquality(raOne, raTwo);
}
@@ -53,13 +51,13 @@
public void testServerUrlEquality() {
raOne.setServerUrl("one");
raTwo.setServerUrl("one");
- assertEquality(raOne,raTwo);
+ assertEquality(raOne, raTwo);
}
public void testServerUrlInequality() {
raOne.setServerUrl("one");
raTwo.setServerUrl("two");
- assertNonEquality(raOne,raTwo);
+ assertNonEquality(raOne, raTwo);
}
public void testServerUrlInequalityDifferentCase() {
@@ -97,7 +95,7 @@
raTwo.setBrokerXmlConfig(null);
assertNonEquality(raOne, raTwo);
}
-
+
public void testPasswordNotPartOfEquality() {
raOne.setClientid("one");
raTwo.setClientid("one");
@@ -118,5 +116,4 @@
assertFalse("HashCodes are equal", leftRa.hashCode() == rightRa.hashCode());
}
-
}
Modified: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ConnectionManagerAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ConnectionManagerAdapter.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ConnectionManagerAdapter.java (original)
+++ activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ConnectionManagerAdapter.java Sat Aug 11 22:27:21 2007
@@ -31,44 +31,44 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
/**
- * A simple implementation of a ConnectionManager that can be extended so that it can
- * see how the RA connections are interacting with it.
- *
+ * A simple implementation of a ConnectionManager that can be extended so that
+ * it can see how the RA connections are interacting with it.
+ *
* @version $Revision$
*/
public class ConnectionManagerAdapter implements ConnectionManager, ConnectionEventListener {
-
+
private static final long serialVersionUID = 5205646563916645831L;
-
- private static final Log log = LogFactory.getLog(ConnectionManagerAdapter.class);
- ArrayList listners = new ArrayList();
- ArrayList connections = new ArrayList();
-
+
+ private static final Log LOG = LogFactory.getLog(ConnectionManagerAdapter.class);
+ ArrayList<ConnectionEventListener> listners = new ArrayList<ConnectionEventListener>();
+ ArrayList<ManagedConnection> connections = new ArrayList<ManagedConnection>();
+
/**
- * Adds a listner to all connections created by this connection manager.
- * This listner will be added to all previously created connections.
+ * Adds a listener to all connections created by this connection manager.
+ * This listener will be added to all previously created connections.
*
* @param l
*/
- public void addConnectionEventListener(ConnectionEventListener l ) {
- for (Iterator iter = connections.iterator(); iter.hasNext();) {
- ManagedConnection c = (ManagedConnection) iter.next();
+ public void addConnectionEventListener(ConnectionEventListener l) {
+ for (Iterator<ManagedConnection> iter = connections.iterator(); iter.hasNext();) {
+ ManagedConnection c = iter.next();
c.addConnectionEventListener(l);
}
listners.add(l);
}
-
+
/**
- * @see javax.resource.spi.ConnectionManager#allocateConnection(javax.resource.spi.ManagedConnectionFactory, javax.resource.spi.ConnectionRequestInfo)
+ * @see javax.resource.spi.ConnectionManager#allocateConnection(javax.resource.spi.ManagedConnectionFactory,
+ * javax.resource.spi.ConnectionRequestInfo)
*/
public Object allocateConnection(ManagedConnectionFactory connectionFactory, ConnectionRequestInfo info) throws ResourceException {
Subject subject = null;
ManagedConnection connection = connectionFactory.createManagedConnection(subject, info);
connection.addConnectionEventListener(this);
- for (Iterator iter = listners.iterator(); iter.hasNext();) {
- ConnectionEventListener l = (ConnectionEventListener) iter.next();
+ for (Iterator<ConnectionEventListener> iter = listners.iterator(); iter.hasNext();) {
+ ConnectionEventListener l = iter.next();
connection.addConnectionEventListener(l);
}
connections.add(connection);
@@ -83,12 +83,12 @@
try {
((ManagedConnection)event.getSource()).cleanup();
} catch (ResourceException e) {
- log.warn("Error occured during the cleanup of a managed connection: ",e);
+ LOG.warn("Error occured during the cleanup of a managed connection: ", e);
}
try {
((ManagedConnection)event.getSource()).destroy();
} catch (ResourceException e) {
- log.warn("Error occured during the destruction of a managed connection: ",e);
+ LOG.warn("Error occured during the destruction of a managed connection: ", e);
}
}
@@ -114,16 +114,16 @@
* @see javax.resource.spi.ConnectionEventListener#connectionErrorOccurred(javax.resource.spi.ConnectionEvent)
*/
public void connectionErrorOccurred(ConnectionEvent event) {
- log.warn("Managed connection experiened an error: ",event.getException());
+ LOG.warn("Managed connection experiened an error: ", event.getException());
try {
((ManagedConnection)event.getSource()).cleanup();
} catch (ResourceException e) {
- log.warn("Error occured during the cleanup of a managed connection: ",e);
+ LOG.warn("Error occured during the cleanup of a managed connection: ", e);
}
try {
((ManagedConnection)event.getSource()).destroy();
} catch (ResourceException e) {
- log.warn("Error occured during the destruction of a managed connection: ",e);
+ LOG.warn("Error occured during the destruction of a managed connection: ", e);
}
}
Modified: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java (original)
+++ activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java Sat Aug 11 22:27:21 2007
@@ -21,6 +21,8 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Timer;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import javax.jms.Connection;
import javax.jms.Message;
@@ -43,46 +45,39 @@
import javax.transaction.xa.Xid;
import junit.framework.TestCase;
-
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.ra.ActiveMQActivationSpec;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
public class MDBTest extends TestCase {
+ long txGenerator = System.currentTimeMillis();
+
private static final class StubBootstrapContext implements BootstrapContext {
public WorkManager getWorkManager() {
return new WorkManager() {
public void doWork(Work work) throws WorkException {
new Thread(work).start();
}
-
- public void doWork(Work work, long arg1, ExecutionContext arg2, WorkListener arg3)
- throws WorkException {
+
+ public void doWork(Work work, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
new Thread(work).start();
}
-
+
public long startWork(Work work) throws WorkException {
new Thread(work).start();
return 0;
}
-
- public long startWork(Work work, long arg1, ExecutionContext arg2, WorkListener arg3)
- throws WorkException {
+
+ public long startWork(Work work, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
new Thread(work).start();
return 0;
}
-
+
public void scheduleWork(Work work) throws WorkException {
new Thread(work).start();
}
-
- public void scheduleWork(Work work, long arg1, ExecutionContext arg2, WorkListener arg3)
- throws WorkException {
+
+ public void scheduleWork(Work work, long arg1, ExecutionContext arg2, WorkListener arg3) throws WorkException {
new Thread(work).start();
}
};
@@ -98,15 +93,16 @@
}
public class StubMessageEndpoint implements MessageEndpoint, MessageListener {
- public int messageCount;
+ public int messageCount;
public XAResource xaresource;
- public Xid xid=null;
-
+ public Xid xid;
+
public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException {
try {
- if( xid==null )
+ if (xid == null) {
xid = createXid();
- xaresource.start(xid,0);
+ }
+ xaresource.start(xid, 0);
} catch (Throwable e) {
throw new ResourceException(e);
}
@@ -114,9 +110,9 @@
public void afterDelivery() throws ResourceException {
try {
- xaresource.end(xid,0);
+ xaresource.end(xid, 0);
xaresource.prepare(xid);
- xaresource.commit(xid,false);
+ xaresource.commit(xid, false);
} catch (Throwable e) {
throw new ResourceException(e);
}
@@ -130,7 +126,7 @@
}
}
-
+
public void testMessageDelivery() throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
@@ -142,25 +138,26 @@
adapter.start(new StubBootstrapContext());
final CountDownLatch messageDelivered = new CountDownLatch(1);
-
+
final StubMessageEndpoint endpoint = new StubMessageEndpoint() {
public void onMessage(Message message) {
super.onMessage(message);
messageDelivered.countDown();
};
};
-
+
ActiveMQActivationSpec activationSpec = new ActiveMQActivationSpec();
activationSpec.setDestinationType(Queue.class.getName());
activationSpec.setDestination("TEST");
activationSpec.setResourceAdapter(adapter);
activationSpec.validate();
-
+
MessageEndpointFactory messageEndpointFactory = new MessageEndpointFactory() {
public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException {
endpoint.xaresource = resource;
return endpoint;
}
+
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException {
return true;
}
@@ -168,31 +165,30 @@
// Activate an Endpoint
adapter.endpointActivation(messageEndpointFactory, activationSpec);
-
+
// Give endpoint a chance to setup and register its listeners
try {
Thread.sleep(1000);
} catch (Exception e) {
}
-
+
// Send the broker a message to that endpoint
MessageProducer producer = session.createProducer(new ActiveMQQueue("TEST"));
producer.send(session.createTextMessage("Hello!"));
connection.close();
-
+
// Wait for the message to be delivered.
assertTrue(messageDelivered.await(5000, TimeUnit.MILLISECONDS));
-
+
// Shut the Endpoint down.
adapter.endpointDeactivation(messageEndpointFactory, activationSpec);
- adapter.stop();
-
+ adapter.stop();
+
}
-
- long txGenerator = System.currentTimeMillis();
-
- public Xid createXid() throws IOException {
+
+
+ public Xid createXid() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);
os.writeLong(++txGenerator);
@@ -203,14 +199,16 @@
public int getFormatId() {
return 86;
}
+
public byte[] getGlobalTransactionId() {
return bs;
}
+
public byte[] getBranchQualifier() {
return bs;
}
};
-
+
}
}
Modified: activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ManagedConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ManagedConnectionFactoryTest.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ManagedConnectionFactoryTest.java (original)
+++ activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ManagedConnectionFactoryTest.java Sat Aug 11 22:27:21 2007
@@ -36,84 +36,79 @@
import javax.resource.spi.work.WorkManager;
import junit.framework.TestCase;
-
import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ra.ActiveMQConnectionRequestInfo;
-import org.apache.activemq.ra.ActiveMQManagedConnectionFactory;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
-import org.apache.activemq.ra.ManagedConnectionProxy;
-
/**
* @version $Revision$
*/
public class ManagedConnectionFactoryTest extends TestCase {
-
+
private static final String DEFAULT_HOST = "vm://localhost?broker.persistent=false";
private static final String REMOTE_HOST = "vm://remotehost?broker.persistent=false";
private ActiveMQManagedConnectionFactory managedConnectionFactory;
-
+
/**
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
-
- ActiveMQResourceAdapter adapter = new ActiveMQResourceAdapter();
- adapter.setServerUrl(DEFAULT_HOST);
- adapter.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
- adapter.setPassword(ActiveMQConnectionFactory.DEFAULT_PASSWORD);
- adapter.start(new BootstrapContext(){
- public WorkManager getWorkManager() {
- return null;
- }
- public XATerminator getXATerminator() {
- return null;
- }
-
- public Timer createTimer() throws UnavailableException {
- return null;
- }
- });
-
+
+ ActiveMQResourceAdapter adapter = new ActiveMQResourceAdapter();
+ adapter.setServerUrl(DEFAULT_HOST);
+ adapter.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
+ adapter.setPassword(ActiveMQConnectionFactory.DEFAULT_PASSWORD);
+ adapter.start(new BootstrapContext() {
+ public WorkManager getWorkManager() {
+ return null;
+ }
+
+ public XATerminator getXATerminator() {
+ return null;
+ }
+
+ public Timer createTimer() throws UnavailableException {
+ return null;
+ }
+ });
+
managedConnectionFactory = new ActiveMQManagedConnectionFactory();
managedConnectionFactory.setResourceAdapter(adapter);
-
+
}
-
+
public void testConnectionFactoryAllocation() throws ResourceException, JMSException {
-
- // Make sure that the ConnectionFactory is asking the connection manager to
+
+ // Make sure that the ConnectionFactory is asking the connection manager
+ // to
// allocate the connection.
- final boolean allocateRequested[] = new boolean[]{false};
- Object cf = managedConnectionFactory.createConnectionFactory(
- new ConnectionManagerAdapter() {
- private static final long serialVersionUID = 1699499816530099939L;
-
- public Object allocateConnection(ManagedConnectionFactory connectionFactory, ConnectionRequestInfo info)
- throws ResourceException {
- allocateRequested[0]=true;
- return super.allocateConnection(connectionFactory, info);
- }
- }
- );
-
+ final boolean allocateRequested[] = new boolean[] {
+ false
+ };
+ Object cf = managedConnectionFactory.createConnectionFactory(new ConnectionManagerAdapter() {
+ private static final long serialVersionUID = 1699499816530099939L;
+
+ public Object allocateConnection(ManagedConnectionFactory connectionFactory, ConnectionRequestInfo info) throws ResourceException {
+ allocateRequested[0] = true;
+ return super.allocateConnection(connectionFactory, info);
+ }
+ });
+
// We should be getting a JMS Connection Factory.
- assertTrue( cf instanceof ConnectionFactory );
+ assertTrue(cf instanceof ConnectionFactory);
ConnectionFactory connectionFactory = (ConnectionFactory)cf;
-
- // Make sure that the connection factory is using the ConnectionManager..
- Connection connection = connectionFactory.createConnection();
+
+ // Make sure that the connection factory is using the
+ // ConnectionManager..
+ Connection connection = connectionFactory.createConnection();
assertTrue(allocateRequested[0]);
-
+
// Make sure that the returned connection is of the expected type.
- assertTrue( connection!=null );
- assertTrue( connection instanceof ManagedConnectionProxy );
-
+ assertTrue(connection != null);
+ assertTrue(connection instanceof ManagedConnectionProxy);
+
}
-
public void testConnectionFactoryConnectionMatching() throws ResourceException, JMSException {
-
+
ActiveMQConnectionRequestInfo ri1 = new ActiveMQConnectionRequestInfo();
ri1.setServerUrl(DEFAULT_HOST);
ri1.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
@@ -124,40 +119,40 @@
ri2.setUserName(ActiveMQConnectionFactory.DEFAULT_USER);
ri2.setPassword(ActiveMQConnectionFactory.DEFAULT_PASSWORD);
assertNotSame(ri1, ri2);
-
+
ManagedConnection connection1 = managedConnectionFactory.createManagedConnection(null, ri1);
- ManagedConnection connection2 = managedConnectionFactory.createManagedConnection(null, ri2);
- assertTrue(connection1!=connection2);
-
- HashSet set = new HashSet();
+ ManagedConnection connection2 = managedConnectionFactory.createManagedConnection(null, ri2);
+ assertTrue(connection1 != connection2);
+
+ HashSet<ManagedConnection> set = new HashSet<ManagedConnection>();
set.add(connection1);
set.add(connection2);
-
+
// Can we match for the first connection?
ActiveMQConnectionRequestInfo ri3 = ri1.copy();
- assertTrue( ri1!=ri3 && ri1.equals(ri3) );
- ManagedConnection test = managedConnectionFactory.matchManagedConnections(set,null, ri3);
- assertTrue( connection1==test );
+ assertTrue(ri1 != ri3 && ri1.equals(ri3));
+ ManagedConnection test = managedConnectionFactory.matchManagedConnections(set, null, ri3);
+ assertTrue(connection1 == test);
// Can we match for the second connection?
ri3 = ri2.copy();
- assertTrue( ri2!=ri3 && ri2.equals(ri3) );
- test = managedConnectionFactory.matchManagedConnections(set,null, ri2);
- assertTrue( connection2==test );
-
+ assertTrue(ri2 != ri3 && ri2.equals(ri3));
+ test = managedConnectionFactory.matchManagedConnections(set, null, ri2);
+ assertTrue(connection2 == test);
+
}
-
+
public void testConnectionFactoryIsSerializableAndReferenceable() throws ResourceException, JMSException {
Object cf = managedConnectionFactory.createConnectionFactory(new ConnectionManagerAdapter());
- assertTrue( cf!=null );
- assertTrue( cf instanceof Serializable );
- assertTrue( cf instanceof Referenceable );
+ assertTrue(cf != null);
+ assertTrue(cf instanceof Serializable);
+ assertTrue(cf instanceof Referenceable);
}
public void testImplementsQueueAndTopicConnectionFactory() throws Exception {
Object cf = managedConnectionFactory.createConnectionFactory(new ConnectionManagerAdapter());
- assertTrue( cf instanceof QueueConnectionFactory );
- assertTrue( cf instanceof TopicConnectionFactory );
+ assertTrue(cf instanceof QueueConnectionFactory);
+ assertTrue(cf instanceof TopicConnectionFactory);
}
}
|