Repository: activemq Updated Branches: refs/heads/master 3348ade99 -> da36f78a6
https://issues.apache.org/jira/browse/AMQ-5596 Remove some additional references to old JMS Streams properties. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/da36f78a Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/da36f78a Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/da36f78a Branch: refs/heads/master Commit: da36f78a6aa3194b650f49681229682875239e3f Parents: 3348ade Author: Timothy Bish <[email protected]> Authored: Mon Aug 3 17:11:44 2015 -0400 Committer: Timothy Bish <[email protected]> Committed: Mon Aug 3 17:11:44 2015 -0400 ---------------------------------------------------------------------- .../apache/activemq/ActiveMQPrefetchPolicy.java | 17 +- .../ra/ActiveMQConnectionRequestInfo.java | 40 ++--- .../activemq/ra/ActiveMQConnectionSupport.java | 177 +++++++++---------- .../ra/ActiveMQManagedConnectionFactory.java | 82 +++++---- 4 files changed, 148 insertions(+), 168 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/da36f78a/activemq-client/src/main/java/org/apache/activemq/ActiveMQPrefetchPolicy.java ---------------------------------------------------------------------- diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQPrefetchPolicy.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQPrefetchPolicy.java index 4bde68e..e045d90 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQPrefetchPolicy.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQPrefetchPolicy.java @@ -35,7 +35,6 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable { public static final int DEFAULT_QUEUE_BROWSER_PREFETCH = 500; public static final int DEFAULT_DURABLE_TOPIC_PREFETCH = 100; public static final int DEFAULT_OPTIMIZE_DURABLE_TOPIC_PREFETCH = 1000; - public static final int DEFAULT_INPUT_STREAM_PREFETCH = 100; public static final int DEFAULT_TOPIC_PREFETCH = MAX_PREFETCH_SIZE; private static final Logger LOG = LoggerFactory.getLogger(ActiveMQPrefetchPolicy.class); @@ -45,7 +44,6 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable { private int topicPrefetch; private int durableTopicPrefetch; private int optimizeDurableTopicPrefetch; - private int inputStreamPrefetch; private int maximumPendingMessageLimit; /** @@ -57,7 +55,6 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable { this.topicPrefetch = DEFAULT_TOPIC_PREFETCH; this.durableTopicPrefetch = DEFAULT_DURABLE_TOPIC_PREFETCH; this.optimizeDurableTopicPrefetch = DEFAULT_OPTIMIZE_DURABLE_TOPIC_PREFETCH; - this.inputStreamPrefetch = DEFAULT_INPUT_STREAM_PREFETCH; } /** @@ -160,20 +157,9 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable { this.queueBrowserPrefetch = getMaxPrefetchLimit(i); this.queuePrefetch = getMaxPrefetchLimit(i); this.topicPrefetch = getMaxPrefetchLimit(i); - this.inputStreamPrefetch = getMaxPrefetchLimit(i); this.optimizeDurableTopicPrefetch = getMaxPrefetchLimit(i); } - @Deprecated - public int getInputStreamPrefetch() { - return inputStreamPrefetch; - } - - @Deprecated - public void setInputStreamPrefetch(int inputStreamPrefetch) { - this.inputStreamPrefetch = getMaxPrefetchLimit(inputStreamPrefetch); - } - @Override public boolean equals(Object object) { if (object instanceof ActiveMQPrefetchPolicy) { @@ -182,8 +168,7 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable { this.queueBrowserPrefetch == other.queueBrowserPrefetch && this.topicPrefetch == other.topicPrefetch && this.durableTopicPrefetch == other.durableTopicPrefetch && - this.optimizeDurableTopicPrefetch == other.optimizeDurableTopicPrefetch && - this.inputStreamPrefetch == other.inputStreamPrefetch; + this.optimizeDurableTopicPrefetch == other.optimizeDurableTopicPrefetch; } return false; } http://git-wip-us.apache.org/repos/asf/activemq/blob/da36f78a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java ---------------------------------------------------------------------- diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java index 7c94721..7ed3f26 100755 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java @@ -28,7 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Must override equals and hashCode (JCA spec 16.4) + * Must override equals and hashCode (JCA spec 16.4) */ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Serializable, Cloneable { @@ -51,7 +51,7 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser public ActiveMQConnectionRequestInfo copy() { try { - ActiveMQConnectionRequestInfo answer = (ActiveMQConnectionRequestInfo)clone(); + ActiveMQConnectionRequestInfo answer = (ActiveMQConnectionRequestInfo) clone(); if (redeliveryPolicy != null) { answer.redeliveryPolicy = redeliveryPolicy.copy(); } @@ -121,6 +121,7 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser /** * @see javax.resource.spi.ConnectionRequestInfo#hashCode() */ + @Override public int hashCode() { int rc = 0; if (useInboundSession != null) { @@ -138,6 +139,7 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser /** * @see javax.resource.spi.ConnectionRequestInfo#equals(java.lang.Object) */ + @Override public boolean equals(Object o) { if (o == null) { return false; @@ -145,7 +147,7 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser if (!getClass().equals(o.getClass())) { return false; } - ActiveMQConnectionRequestInfo i = (ActiveMQConnectionRequestInfo)o; + ActiveMQConnectionRequestInfo i = (ActiveMQConnectionRequestInfo) o; if (notEqual(serverUrl, i.serverUrl)) { return false; } @@ -174,7 +176,8 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser } /** - * @param url The url to set. + * @param url + * The url to set. */ public void setServerUrl(String url) { this.serverUrl = url; @@ -188,7 +191,8 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser } /** - * @param password The password to set. + * @param password + * The password to set. */ public void setPassword(String password) { this.password = password; @@ -202,7 +206,8 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser } /** - * @param userid The userid to set. + * @param userid + * The userid to set. */ public void setUserName(String userid) { this.userName = userid; @@ -216,7 +221,8 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser } /** - * @param clientid The clientid to set. + * @param clientid + * The clientid to set. */ public void setClientid(String clientid) { this.clientid = clientid; @@ -264,13 +270,10 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser @Override public String toString() { - return new StringBuffer("ActiveMQConnectionRequestInfo{ userName = '").append(userName).append("' ") - .append(", serverUrl = '").append(serverUrl).append("' ") - .append(", clientid = '").append(clientid).append("' ") - .append(", userName = '").append(userName).append("' ") - .append(", useSessionArgs = '").append(useSessionArgs).append("' ") - .append(", useInboundSession = '").append(useInboundSession).append("' }") - .toString(); + return new StringBuffer("ActiveMQConnectionRequestInfo{ userName = '").append(userName).append("' ").append(", serverUrl = '").append(serverUrl) + .append("' ").append(", clientid = '").append(clientid).append("' ").append(", userName = '").append(userName).append("' ") + .append(", useSessionArgs = '").append(useSessionArgs).append("' ").append(", useInboundSession = '").append(useInboundSession).append("' }") + .toString(); } public Boolean getUseInboundSession() { @@ -343,8 +346,9 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser return Integer.valueOf(prefetchPolicy().getOptimizeDurableTopicPrefetch()); } + @Deprecated public Integer getInputStreamPrefetch() { - return Integer.valueOf(prefetchPolicy().getInputStreamPrefetch()); + return 0; } public Integer getQueueBrowserPrefetch() { @@ -377,12 +381,6 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser } } - public void setInputStreamPrefetch(Integer inputStreamPrefetch) { - if (inputStreamPrefetch != null) { - prefetchPolicy().setInputStreamPrefetch(inputStreamPrefetch.intValue()); - } - } - public void setQueueBrowserPrefetch(Integer queueBrowserPrefetch) { if (queueBrowserPrefetch != null) { prefetchPolicy().setQueueBrowserPrefetch(queueBrowserPrefetch.intValue()); http://git-wip-us.apache.org/repos/asf/activemq/blob/da36f78a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionSupport.java ---------------------------------------------------------------------- diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionSupport.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionSupport.java index 8d7c9fd..c3e0e9b 100644 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionSupport.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionSupport.java @@ -17,6 +17,7 @@ package org.apache.activemq.ra; import javax.jms.JMSException; + import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQSslConnectionFactory; @@ -24,41 +25,46 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Abstract base class providing support for creating physical - * connections to an ActiveMQ instance. - * - * + * Abstract base class providing support for creating physical connections to an + * ActiveMQ instance. + * + * */ public class ActiveMQConnectionSupport { - + private ActiveMQConnectionRequestInfo info = new ActiveMQConnectionRequestInfo(); protected Logger log = LoggerFactory.getLogger(getClass()); - + /** * Creates a factory for obtaining physical connections to an Active MQ - * broker. The factory is configured with the given configuration information. - * - * @param connectionRequestInfo the configuration request information + * broker. The factory is configured with the given configuration + * information. + * + * @param connectionRequestInfo + * the configuration request information * @param activationSpec * @return the connection factory - * @throws java.lang.IllegalArgumentException if the server URL given in the - * configuration information is not a valid URL + * @throws java.lang.IllegalArgumentException + * if the server URL given in the configuration information is not a + * valid URL */ protected ActiveMQConnectionFactory createConnectionFactory(ActiveMQConnectionRequestInfo connectionRequestInfo, MessageActivationSpec activationSpec) { - //ActiveMQSslConnectionFactory defaults to TCP anyway + // ActiveMQSslConnectionFactory defaults to TCP anyway ActiveMQConnectionFactory factory = new ActiveMQSslConnectionFactory(); connectionRequestInfo.configure(factory, activationSpec); return factory; } /** - * Creates a new physical connection to an Active MQ broker identified by given - * connection request information. - * - * @param connectionRequestInfo the connection request information identifying the broker and any - * required connection parameters, e.g. username/password + * Creates a new physical connection to an Active MQ broker identified by + * given connection request information. + * + * @param connectionRequestInfo + * the connection request information identifying the broker and any + * required connection parameters, e.g. username/password * @return the physical connection - * @throws JMSException if the connection could not be established + * @throws JMSException + * if the connection could not be established */ public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo connectionRequestInfo) throws JMSException { return makeConnection(connectionRequestInfo, createConnectionFactory(connectionRequestInfo, null)); @@ -66,24 +72,24 @@ public class ActiveMQConnectionSupport { /** * Creates a new physical connection to an Active MQ broker using a given - * connection factory and credentials supplied in connection request information. - * - * @param connectionRequestInfo the connection request information containing the credentials to use - * for the connection request + * connection factory and credentials supplied in connection request + * information. + * + * @param connectionRequestInfo + * the connection request information containing the credentials to + * use for the connection request * @return the physical connection - * @throws JMSException if the connection could not be established + * @throws JMSException + * if the connection could not be established */ - public ActiveMQConnection makeConnection( - ActiveMQConnectionRequestInfo connectionRequestInfo, - ActiveMQConnectionFactory connectionFactory) throws JMSException - { + public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo connectionRequestInfo, ActiveMQConnectionFactory connectionFactory) + throws JMSException { String userName = connectionRequestInfo.getUserName(); String password = connectionRequestInfo.getPassword(); ActiveMQConnection physicalConnection = (ActiveMQConnection) connectionFactory.createConnection(userName, password); String clientId = connectionRequestInfo.getClientid(); - if ( clientId != null && clientId.length() > 0 ) - { + if (clientId != null && clientId.length() > 0) { physicalConnection.setClientID(clientId); } return physicalConnection; @@ -91,22 +97,22 @@ public class ActiveMQConnectionSupport { /** * Gets the connection request information. - * + * * @return the connection request information */ - public ActiveMQConnectionRequestInfo getInfo() - { + public ActiveMQConnectionRequestInfo getInfo() { return info; } - + /** * Sets the connection request information as a whole. - * - * @param connectionRequestInfo the connection request information + * + * @param connectionRequestInfo + * the connection request information */ - protected void setInfo(ActiveMQConnectionRequestInfo connectionRequestInfo){ + protected void setInfo(ActiveMQConnectionRequestInfo connectionRequestInfo) { info = connectionRequestInfo; - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug(this + ", setting [info] to: " + info); } } @@ -116,12 +122,9 @@ public class ActiveMQConnectionSupport { } protected String emptyToNull(String value) { - if (value == null || value.length() == 0) - { + if (value == null || value.length() == 0) { return null; - } - else - { + } else { return value; } } @@ -150,7 +153,7 @@ public class ActiveMQConnectionSupport { * @param clientid */ public void setClientid(String clientid) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug(this + ", setting [clientid] to: " + clientid); } info.setClientid(clientid); @@ -167,7 +170,7 @@ public class ActiveMQConnectionSupport { * @param password */ public void setPassword(String password) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug(this + ", setting [password] property"); } info.setPassword(password); @@ -184,44 +187,44 @@ public class ActiveMQConnectionSupport { * @param url */ public void setServerUrl(String url) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug(this + ", setting [serverUrl] to: " + url); } info.setServerUrl(url); } public void setTrustStore(String trustStore) { - if ( log.isDebugEnabled() ) { - log.debug(this + ", setting [trustStore] to: " + trustStore); - } + if (log.isDebugEnabled()) { + log.debug(this + ", setting [trustStore] to: " + trustStore); + } info.setTrustStore(trustStore); } public void setTrustStorePassword(String trustStorePassword) { - if ( log.isDebugEnabled() ) { - log.debug(this + ", setting [trustStorePassword] to: " + trustStorePassword); - } + if (log.isDebugEnabled()) { + log.debug(this + ", setting [trustStorePassword] to: " + trustStorePassword); + } info.setTrustStorePassword(trustStorePassword); } public void setKeyStore(String keyStore) { - if ( log.isDebugEnabled() ) { - log.debug(this + ", setting [keyStore] to: " + keyStore); - } + if (log.isDebugEnabled()) { + log.debug(this + ", setting [keyStore] to: " + keyStore); + } info.setKeyStore(keyStore); } public void setKeyStorePassword(String keyStorePassword) { - if ( log.isDebugEnabled() ) { - log.debug(this + ", setting [keyStorePassword] to: " + keyStorePassword); - } + if (log.isDebugEnabled()) { + log.debug(this + ", setting [keyStorePassword] to: " + keyStorePassword); + } info.setKeyStorePassword(keyStorePassword); } public void setKeyStoreKeyPassword(String keyStoreKeyPassword) { - if ( log.isDebugEnabled() ) { - log.debug(this + ", setting [keyStoreKeyPassword] to: " + keyStoreKeyPassword); - } + if (log.isDebugEnabled()) { + log.debug(this + ", setting [keyStoreKeyPassword] to: " + keyStoreKeyPassword); + } info.setKeyStoreKeyPassword(keyStoreKeyPassword); } @@ -236,7 +239,7 @@ public class ActiveMQConnectionSupport { * @param userid */ public void setUserName(String userid) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [userName] to: " + userid); } info.setUserName(userid); @@ -253,7 +256,7 @@ public class ActiveMQConnectionSupport { * @param optimizeDurableTopicPrefetch */ public void setOptimizeDurableTopicPrefetch(Integer optimizeDurableTopicPrefetch) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [optimizeDurableTopicPrefetch] to: " + optimizeDurableTopicPrefetch); } info.setOptimizeDurableTopicPrefetch(optimizeDurableTopicPrefetch); @@ -270,7 +273,7 @@ public class ActiveMQConnectionSupport { * @param durableTopicPrefetch */ public void setDurableTopicPrefetch(Integer durableTopicPrefetch) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [durableTopicPrefetch] to: " + durableTopicPrefetch); } info.setDurableTopicPrefetch(durableTopicPrefetch); @@ -287,13 +290,12 @@ public class ActiveMQConnectionSupport { * @param value */ public void setInitialRedeliveryDelay(Long value) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [initialRedeliveryDelay] to: " + value); } info.setInitialRedeliveryDelay(value); } - /** * @return initial redelivery delay */ @@ -305,7 +307,7 @@ public class ActiveMQConnectionSupport { * @param value */ public void setMaximumRedeliveryDelay(Long value) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [maximumRedeliveryDelay] to: " + value); } info.setMaximumRedeliveryDelay(value); @@ -314,18 +316,9 @@ public class ActiveMQConnectionSupport { /** * @return input stream prefetch */ + @Deprecated public Integer getInputStreamPrefetch() { - return info.getInputStreamPrefetch(); - } - - /** - * @param inputStreamPrefetch - */ - public void setInputStreamPrefetch(Integer inputStreamPrefetch) { - if ( log.isDebugEnabled() ) { - log.debug("setting [inputStreamPrefetch] to: " + inputStreamPrefetch); - } - info.setInputStreamPrefetch(inputStreamPrefetch); + return 0; } /** @@ -339,7 +332,7 @@ public class ActiveMQConnectionSupport { * @param value */ public void setMaximumRedeliveries(Integer value) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [maximumRedeliveries] to: " + value); } info.setMaximumRedeliveries(value); @@ -356,7 +349,7 @@ public class ActiveMQConnectionSupport { * @param queueBrowserPrefetch */ public void setQueueBrowserPrefetch(Integer queueBrowserPrefetch) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [queueBrowserPrefetch] to: " + queueBrowserPrefetch); } info.setQueueBrowserPrefetch(queueBrowserPrefetch); @@ -373,7 +366,7 @@ public class ActiveMQConnectionSupport { * @param queuePrefetch */ public void setQueuePrefetch(Integer queuePrefetch) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [queuePrefetch] to: " + queuePrefetch); } info.setQueuePrefetch(queuePrefetch); @@ -390,7 +383,7 @@ public class ActiveMQConnectionSupport { * @param value */ public void setRedeliveryBackOffMultiplier(Double value) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [redeliveryBackOffMultiplier] to: " + value); } info.setRedeliveryBackOffMultiplier(value); @@ -407,7 +400,7 @@ public class ActiveMQConnectionSupport { * @param value */ public void setRedeliveryUseExponentialBackOff(Boolean value) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [redeliveryUseExponentialBackOff] to: " + value); } info.setRedeliveryUseExponentialBackOff(value); @@ -424,7 +417,7 @@ public class ActiveMQConnectionSupport { * @param topicPrefetch */ public void setTopicPrefetch(Integer topicPrefetch) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [topicPrefetch] to: " + topicPrefetch); } info.setTopicPrefetch(topicPrefetch); @@ -455,7 +448,7 @@ public class ActiveMQConnectionSupport { * @param useInboundSession */ public void setUseInboundSession(Boolean useInboundSession) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug("setting [useInboundSession] to: " + useInboundSession); } info.setUseInboundSession(useInboundSession); @@ -470,19 +463,19 @@ public class ActiveMQConnectionSupport { } /** - * if true, calls to managed connection factory.connection.createSession will - * respect the passed in args. When false (default) the args are ignored b/c - * the container will do transaction demarcation via xa or local transaction rar - * contracts. - * This option is useful when a managed connection is used in plain jms mode - * and a jms transacted session session is required. + * if true, calls to managed connection factory.connection.createSession + * will respect the passed in args. When false (default) the args are + * ignored b/c the container will do transaction demarcation via xa or local + * transaction rar contracts. This option is useful when a managed + * connection is used in plain jms mode and a jms transacted session session + * is required. + * * @param useSessionArgs */ public void setUseSessionArgs(Boolean useSessionArgs) { - if ( log.isDebugEnabled() ) { + if (log.isDebugEnabled()) { log.debug(this + ", setting [useSessionArgs] to: " + useSessionArgs); } info.setUseSessionArgs(useSessionArgs); } - } http://git-wip-us.apache.org/repos/asf/activemq/blob/da36f78a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java ---------------------------------------------------------------------- diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java index 2dd84cb..a7344e4 100755 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java @@ -33,14 +33,14 @@ import javax.resource.spi.ManagedConnectionFactory; import javax.resource.spi.ResourceAdapter; import javax.resource.spi.ResourceAdapterAssociation; import javax.security.auth.Subject; + import org.slf4j.LoggerFactory; /** * @version $Revisio n$ TODO: Must override equals and hashCode (JCA spec 16.4) * @org.apache.xbean.XBean element="managedConnectionFactory" */ -public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport - implements ManagedConnectionFactory, ResourceAdapterAssociation { +public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport implements ManagedConnectionFactory, ResourceAdapterAssociation { private static final long serialVersionUID = 6196921962230582875L; private PrintWriter logWriter; @@ -48,13 +48,12 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport /** * @see javax.resource.spi.ResourceAdapterAssociation#setResourceAdapter(javax.resource.spi.ResourceAdapter) */ + @Override public void setResourceAdapter(ResourceAdapter adapter) throws ResourceException { if (!(adapter instanceof MessageResourceAdapter)) { throw new ResourceException("ResourceAdapter is not of type: " + MessageResourceAdapter.class.getName()); - } - else - { - if ( log.isDebugEnabled() ) { + } else { + if (log.isDebugEnabled()) { log.debug(this + ", copying standard ResourceAdapter configuration properties"); } @@ -92,15 +91,13 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport if (getTopicPrefetch() != null) { setTopicPrefetch(baseInfo.getTopicPrefetch()); } - if (getInputStreamPrefetch() != null) { - setInputStreamPrefetch(baseInfo.getInputStreamPrefetch()); - } } } /** * @see javax.resource.spi.ResourceAdapterAssociation#getResourceAdapter() */ + @Override public ResourceAdapter getResourceAdapter() { return null; } @@ -113,7 +110,7 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport if (object == null || object.getClass() != ActiveMQManagedConnectionFactory.class) { return false; } - return ((ActiveMQManagedConnectionFactory)object).getInfo().equals(getInfo()); + return ((ActiveMQManagedConnectionFactory) object).getInfo().equals(getInfo()); } /** @@ -125,41 +122,49 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport } /** - * Writes this factory during serialization along with the superclass' <i>info</i> property. - * This needs to be done manually since the superclass is not serializable itself. - * - * @param out the stream to write object state to - * @throws java.io.IOException if the object cannot be serialized + * Writes this factory during serialization along with the superclass' + * <i>info</i> property. This needs to be done manually since the superclass + * is not serializable itself. + * + * @param out + * the stream to write object state to + * @throws java.io.IOException + * if the object cannot be serialized */ private void writeObject(ObjectOutputStream out) throws IOException { - if ( logWriter != null && !(logWriter instanceof Serializable) ) { + if (logWriter != null && !(logWriter instanceof Serializable)) { // if the PrintWriter injected by the application server is not // serializable we just drop the reference and let the application // server re-inject a PrintWriter later (after this factory has been // deserialized again) using the standard setLogWriter() method logWriter = null; - } + } out.defaultWriteObject(); out.writeObject(getInfo()); } /** * Restores this factory along with the superclass' <i>info</i> property. - * This needs to be done manually since the superclass is not serializable itself. - * - * @param in the stream to read object state from - * @throws java.io.IOException if the object state could not be restored - * @throws java.lang.ClassNotFoundException if the object state could not be restored + * This needs to be done manually since the superclass is not serializable + * itself. + * + * @param in + * the stream to read object state from + * @throws java.io.IOException + * if the object state could not be restored + * @throws java.lang.ClassNotFoundException + * if the object state could not be restored */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); setInfo((ActiveMQConnectionRequestInfo) in.readObject()); log = LoggerFactory.getLogger(getClass()); } - + /** * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory(javax.resource.spi.ConnectionManager) */ + @Override public Object createConnectionFactory(ConnectionManager manager) throws ResourceException { return new ActiveMQConnectionFactory(this, manager, getInfo()); } @@ -169,9 +174,10 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport * ConnectionFactory that has our SimpleConnectionManager implementation but * it may be a better idea to not support this. The JMS api will have many * quirks the user may not expect when running through the resource adapter. - * + * * @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory() */ + @Override public Object createConnectionFactory() throws ResourceException { return new ActiveMQConnectionFactory(this, new SimpleConnectionManager(), getInfo()); } @@ -180,13 +186,12 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport * @see javax.resource.spi.ManagedConnectionFactory#createManagedConnection(javax.security.auth.Subject, * javax.resource.spi.ConnectionRequestInfo) */ - public ManagedConnection createManagedConnection( - Subject subject, - ConnectionRequestInfo connectionRequestInfo) throws ResourceException { + @Override + public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { ActiveMQConnectionRequestInfo amqInfo = getInfo(); - if ( connectionRequestInfo instanceof ActiveMQConnectionRequestInfo ) { + if (connectionRequestInfo instanceof ActiveMQConnectionRequestInfo) { amqInfo = (ActiveMQConnectionRequestInfo) connectionRequestInfo; - } + } try { return new ActiveMQManagedConnection(subject, makeConnection(amqInfo), amqInfo); } catch (JMSException e) { @@ -199,13 +204,11 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport * javax.security.auth.Subject, * javax.resource.spi.ConnectionRequestInfo) */ - public ManagedConnection matchManagedConnections( - Set connections, - Subject subject, - ConnectionRequestInfo connectionRequestInfo) throws ResourceException { + @Override + public ManagedConnection matchManagedConnections(Set connections, Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { Iterator iterator = connections.iterator(); while (iterator.hasNext()) { - ActiveMQManagedConnection c = (ActiveMQManagedConnection)iterator.next(); + ActiveMQManagedConnection c = (ActiveMQManagedConnection) iterator.next(); if (c.matches(subject, connectionRequestInfo)) { try { c.associate(subject, (ActiveMQConnectionRequestInfo) connectionRequestInfo); @@ -221,21 +224,22 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport /** * @see javax.resource.spi.ManagedConnectionFactory#setLogWriter(java.io.PrintWriter) */ + @Override public void setLogWriter(PrintWriter aLogWriter) throws ResourceException { - if ( log.isTraceEnabled() ) { + if (log.isTraceEnabled()) { log.trace("setting log writer [" + aLogWriter + "]"); - } + } this.logWriter = aLogWriter; } /** * @see javax.resource.spi.ManagedConnectionFactory#getLogWriter() */ + @Override public PrintWriter getLogWriter() throws ResourceException { - if ( log.isTraceEnabled() ) { + if (log.isTraceEnabled()) { log.trace("getting log writer [" + logWriter + "]"); } return logWriter; } - - } +}
