http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQActivationSpec.java ---------------------------------------------------------------------- diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQActivationSpec.java b/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQActivationSpec.java deleted file mode 100644 index 9a87d34..0000000 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQActivationSpec.java +++ /dev/null @@ -1,945 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package org.apache.activemq.ra.inflow; - -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.Topic; -import javax.resource.ResourceException; -import javax.resource.spi.ActivationSpec; -import javax.resource.spi.InvalidPropertyException; -import javax.resource.spi.ResourceAdapter; -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; - -import org.apache.activemq.ra.ConnectionFactoryProperties; -import org.apache.activemq.ra.HornetQRALogger; -import org.apache.activemq.ra.HornetQRaUtils; -import org.apache.activemq.ra.HornetQResourceAdapter; - -/** - * The activation spec - * These properties are set on the MDB ActivactionProperties - * - * @author <a href="adr...@jboss.com">Adrian Brock</a> - * @author <a href="jesper.peder...@jboss.org">Jesper Pedersen</a> - * @author <a href="mailto:andy.tay...@jboss.org">Andy Taylor</a> - * @author <a href="mailto:clebert.suco...@jboss.org">Clebert Suconic</a> - */ -public class HornetQActivationSpec extends ConnectionFactoryProperties implements ActivationSpec, Serializable -{ - private static final long serialVersionUID = -7997041053897964654L; - - private static final int DEFAULT_MAX_SESSION = 15; - - /** - * Whether trace is enabled - */ - private static boolean trace = HornetQRALogger.LOGGER.isTraceEnabled(); - - public String strConnectorClassName; - - public String strConnectionParameters; - - /** - * The resource adapter - */ - private HornetQResourceAdapter ra; - - /** - * The connection factory lookup - */ - private String connectionFactoryLookup; - - /** - * The destination - */ - private String destination; - - /** - * The destination type - */ - private String destinationType; - - /** - * The message selector - */ - private String messageSelector; - - /** - * The acknowledgement mode - */ - private int acknowledgeMode; - - /** - * The subscription durability - */ - private boolean subscriptionDurability; - - /** - * The subscription name - */ - private String subscriptionName; - - /** - * If this is true, a durable subscription could be shared by multiple MDB instances - */ - private boolean shareSubscriptions; - - /** - * The user - */ - private String user; - - /** - * The password - */ - private String password; - - /** - * The maximum number of sessions - */ - private Integer maxSession; - - /** - * Transaction timeout - */ - private Integer transactionTimeout; - - private Boolean useJNDI = true; - - private String jndiParams = null; - - private Hashtable parsedJndiParams; - - /* use local tx instead of XA*/ - private Boolean localTx; - - // undefined by default, default is specified at the RA level in HornetQRAProperties - private Integer setupAttempts; - - // undefined by default, default is specified at the RA level in HornetQRAProperties - private Long setupInterval; - - /** - * Constructor - */ - public HornetQActivationSpec() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("constructor()"); - } - - ra = null; - destination = null; - destinationType = null; - messageSelector = null; - acknowledgeMode = Session.AUTO_ACKNOWLEDGE; - subscriptionDurability = false; - subscriptionName = null; - user = null; - password = null; - maxSession = DEFAULT_MAX_SESSION; - transactionTimeout = 0; - } - - /** - * Get the resource adapter - * - * @return The resource adapter - */ - public ResourceAdapter getResourceAdapter() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getResourceAdapter()"); - } - - return ra; - } - - /** - * @return the useJNDI - */ - public boolean isUseJNDI() - { - if (useJNDI == null) - { - return ra.isUseJNDI(); - } - return useJNDI; - } - - /** - * @param value the useJNDI to set - */ - public void setUseJNDI(final boolean value) - { - useJNDI = value; - } - - /** - * @return return the jndi params to use - */ - public String getJndiParams() - { - if (jndiParams == null) - { - return ra.getJndiParams(); - } - return jndiParams; - } - - public void setJndiParams(String jndiParams) - { - this.jndiParams = jndiParams; - parsedJndiParams = HornetQRaUtils.parseHashtableConfig(jndiParams); - } - - public Hashtable<?, ?> getParsedJndiParams() - { - if (parsedJndiParams == null) - { - return ra.getParsedJndiParams(); - } - return parsedJndiParams; - } - - /** - * Set the resource adapter - * - * @param ra The resource adapter - * @throws ResourceException Thrown if incorrect resource adapter - */ - public void setResourceAdapter(final ResourceAdapter ra) throws ResourceException - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setResourceAdapter(" + ra + ")"); - } - - if (ra == null || !(ra instanceof HornetQResourceAdapter)) - { - throw new ResourceException("Resource adapter is " + ra); - } - - this.ra = (HornetQResourceAdapter) ra; - } - - /** - * Get the connection factory lookup - * - * @return The value - */ - public String getConnectionFactoryLookup() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getConnectionFactoryLookup() ->" + connectionFactoryLookup); - } - - return connectionFactoryLookup; - } - - /** - * Set the connection factory lookup - * - * @param value The value - */ - public void setConnectionFactoryLookup(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setConnectionFactoryLookup(" + value + ")"); - } - - connectionFactoryLookup = value; - } - - /** - * Get the destination - * - * @return The value - */ - public String getDestination() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getDestination()"); - } - - return destination; - } - - /** - * Set the destination - * - * @param value The value - */ - public void setDestination(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setDestination(" + value + ")"); - } - - destination = value; - } - - /** - * Get the destination lookup - * - * @return The value - */ - public String getDestinationLookup() - { - return getDestination(); - } - - /** - * Set the destination - * - * @param value The value - */ - public void setDestinationLookup(final String value) - { - setDestination(value); - setUseJNDI(true); - } - - /** - * Get the destination type - * - * @return The value - */ - public String getDestinationType() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getDestinationType()"); - } - - return destinationType; - } - - /** - * Set the destination type - * - * @param value The value - */ - public void setDestinationType(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setDestinationType(" + value + ")"); - } - - destinationType = value; - } - - /** - * Get the message selector - * - * @return The value - */ - public String getMessageSelector() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getMessageSelector()"); - } - - return messageSelector; - } - - /** - * Set the message selector - * - * @param value The value - */ - public void setMessageSelector(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setMessageSelector(" + value + ")"); - } - - messageSelector = value; - } - - /** - * Get the acknowledge mode - * - * @return The value - */ - public String getAcknowledgeMode() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getAcknowledgeMode()"); - } - - if (Session.DUPS_OK_ACKNOWLEDGE == acknowledgeMode) - { - return "Dups-ok-acknowledge"; - } - else - { - return "Auto-acknowledge"; - } - } - - /** - * Set the acknowledge mode - * - * @param value The value - */ - public void setAcknowledgeMode(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setAcknowledgeMode(" + value + ")"); - } - - if ("DUPS_OK_ACKNOWLEDGE".equalsIgnoreCase(value) || "Dups-ok-acknowledge".equalsIgnoreCase(value)) - { - acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE; - } - else if ("AUTO_ACKNOWLEDGE".equalsIgnoreCase(value) || "Auto-acknowledge".equalsIgnoreCase(value)) - { - acknowledgeMode = Session.AUTO_ACKNOWLEDGE; - } - else - { - throw new IllegalArgumentException("Unsupported acknowledgement mode " + value); - } - } - - /** - * @return the acknowledgement mode - */ - public int getAcknowledgeModeInt() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getAcknowledgeMode()"); - } - - return acknowledgeMode; - } - - /** - * Get the subscription durability - * - * @return The value - */ - public String getSubscriptionDurability() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getSubscriptionDurability()"); - } - - if (subscriptionDurability) - { - return "Durable"; - } - else - { - return "NonDurable"; - } - } - - /** - * Set the subscription durability - * - * @param value The value - */ - public void setSubscriptionDurability(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setSubscriptionDurability(" + value + ")"); - } - - subscriptionDurability = "Durable".equals(value); - } - - /** - * Get the status of subscription durability - * - * @return The value - */ - public boolean isSubscriptionDurable() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("isSubscriptionDurable()"); - } - - return subscriptionDurability; - } - - /** - * Get the subscription name - * - * @return The value - */ - public String getSubscriptionName() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getSubscriptionName()"); - } - - return subscriptionName; - } - - /** - * Set the subscription name - * - * @param value The value - */ - public void setSubscriptionName(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setSubscriptionName(" + value + ")"); - } - - subscriptionName = value; - } - - - /** - * @return the shareDurableSubscriptions - */ - public boolean isShareSubscriptions() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("isShareSubscriptions() = " + shareSubscriptions); - } - - return shareSubscriptions; - } - - /** - * @param shareSubscriptions the shareDurableSubscriptions to set - */ - public void setShareSubscriptions(boolean shareSubscriptions) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setShareSubscriptions(" + shareSubscriptions + ")"); - } - - this.shareSubscriptions = shareSubscriptions; - } - - /** - * Get the user - * - * @return The value - */ - public String getUser() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getUser()"); - } - - if (user == null) - { - return ra.getUserName(); - } - else - { - return user; - } - } - - /** - * Set the user - * - * @param value The value - */ - public void setUser(final String value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setUser(" + value + ")"); - } - - user = value; - } - - /** - * Get the password - * - * @return The value - */ - public String getPassword() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getPassword()"); - } - - if (password == null) - { - return ra.getPassword(); - } - else - { - return password; - } - } - - public String getOwnPassword() - { - return password; - } - - /** - * Set the password - * - * @param value The value - */ - public void setPassword(final String value) throws Exception - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setPassword(****)"); - } - - password = value; - } - - /** - * Get the number of max session - * - * @return The value - */ - public Integer getMaxSession() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getMaxSession()"); - } - - if (maxSession == null) - { - return DEFAULT_MAX_SESSION; - } - - return maxSession; - } - - /** - * Set the number of max session - * - * @param value The value - */ - public void setMaxSession(final Integer value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setMaxSession(" + value + ")"); - } - - maxSession = value; - } - - /** - * Get the transaction timeout - * - * @return The value - */ - public Integer getTransactionTimeout() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getTransactionTimeout()"); - } - - return transactionTimeout; - } - - /** - * Set the transaction timeout - * - * @param value The value - */ - public void setTransactionTimeout(final Integer value) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setTransactionTimeout(" + value + ")"); - } - - transactionTimeout = value; - } - - public Boolean isUseLocalTx() - { - if (localTx == null) - { - return ra.getUseLocalTx(); - } - else - { - return localTx; - } - } - - public void setUseLocalTx(final Boolean localTx) - { - this.localTx = localTx; - } - - public int getSetupAttempts() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getSetupAttempts()"); - } - - if (setupAttempts == null) - { - return ra.getSetupAttempts(); - } - else - { - return setupAttempts; - } - } - - public void setSetupAttempts(int setupAttempts) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setSetupAttempts(" + setupAttempts + ")"); - } - - this.setupAttempts = setupAttempts; - } - - public long getSetupInterval() - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("getSetupInterval()"); - } - - if (setupInterval == null) - { - return ra.getSetupInterval(); - } - else - { - return setupInterval; - } - } - - public void setSetupInterval(long setupInterval) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setSetupInterval(" + setupInterval + ")"); - } - - this.setupInterval = setupInterval; - } - - /** - * Validate - * - * @throws InvalidPropertyException Thrown if a validation exception occurs - */ - public void validate() throws InvalidPropertyException - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("validate()"); - } - - List<String> errorMessages = new ArrayList<String>(); - List<PropertyDescriptor> propsNotSet = new ArrayList<PropertyDescriptor>(); - - try - { - if (destination == null || destination.trim().equals("")) - { - propsNotSet.add(new PropertyDescriptor("destination", HornetQActivationSpec.class)); - errorMessages.add("Destination is mandatory."); - } - - if (destinationType != null && !Topic.class.getName().equals(destinationType) && !Queue.class.getName().equals(destinationType)) - { - propsNotSet.add(new PropertyDescriptor("destinationType", HornetQActivationSpec.class)); - errorMessages.add("If set, the destinationType must be either 'javax.jms.Topic' or 'javax.jms.Queue'."); - } - - if ((destinationType == null || destinationType.length() == 0 || Topic.class.getName().equals(destinationType)) && isSubscriptionDurable() && (subscriptionName == null || subscriptionName.length() == 0)) - { - propsNotSet.add(new PropertyDescriptor("subscriptionName", HornetQActivationSpec.class)); - errorMessages.add("If subscription is durable then subscription name must be specified."); - } - } - catch (IntrospectionException e) - { - e.printStackTrace(); - } - - if (propsNotSet.size() > 0) - { - StringBuffer b = new StringBuffer(); - b.append("Invalid settings:"); - for (Iterator<String> iter = errorMessages.iterator(); iter.hasNext();) - { - b.append(" "); - b.append(iter.next()); - } - InvalidPropertyException e = new InvalidPropertyException(b.toString()); - final PropertyDescriptor[] descriptors = propsNotSet.toArray(new PropertyDescriptor[propsNotSet.size()]); - e.setInvalidPropertyDescriptors(descriptors); - throw e; - } - } - - public String getConnectorClassName() - { - return strConnectorClassName; - } - - public void setConnectorClassName(final String connectorClassName) - { - if (HornetQActivationSpec.trace) - { - HornetQRALogger.LOGGER.trace("setConnectorClassName(" + connectorClassName + ")"); - } - - strConnectorClassName = connectorClassName; - - setParsedConnectorClassNames(HornetQRaUtils.parseConnectorConnectorConfig(connectorClassName)); - } - - /** - * @return the connectionParameters - */ - public String getConnectionParameters() - { - return strConnectionParameters; - } - - public void setConnectionParameters(final String configuration) - { - strConnectionParameters = configuration; - setParsedConnectionParameters(HornetQRaUtils.parseConfig(configuration)); - } - - /** - * Get a string representation - * - * @return The value - */ - @Override - public String toString() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(HornetQActivationSpec.class.getName()).append('('); - buffer.append("ra=").append(ra); - if (messageSelector != null) - { - buffer.append(" connectionFactoryLookup=").append(connectionFactoryLookup); - } - buffer.append(" destination=").append(destination); - buffer.append(" destinationType=").append(destinationType); - if (messageSelector != null) - { - buffer.append(" selector=").append(messageSelector); - } - buffer.append(" ack=").append(getAcknowledgeMode()); - buffer.append(" durable=").append(subscriptionDurability); - buffer.append(" clientID=").append(getClientID()); - if (subscriptionName != null) - { - buffer.append(" subscription=").append(subscriptionName); - } - buffer.append(" user=").append(user); - if (password != null) - { - buffer.append(" password=").append("****"); - } - buffer.append(" maxSession=").append(maxSession); - buffer.append(')'); - return buffer.toString(); - } - - // here for backwards compatibilty - public void setUseDLQ(final boolean b) - { - } - - public void setDLQJNDIName(final String name) - { - } - - public void setDLQHandler(final String handler) - { - } - - public void setDLQMaxResent(final int maxResent) - { - } - - public void setProviderAdapterJNDI(final String jndi) - { - } - - /** - * @param keepAlive the keepAlive to set - */ - public void setKeepAlive(boolean keepAlive) - { - } - - /** - * @param keepAliveMillis the keepAliveMillis to set - */ - public void setKeepAliveMillis(long keepAliveMillis) - { - } - - - public void setReconnectInterval(long interval) - { - } - - public void setMinSession(final Integer value) - { - } - - public void setMaxMessages(final Integer value) - { - } - - -}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQMessageHandler.java ---------------------------------------------------------------------- diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQMessageHandler.java b/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQMessageHandler.java deleted file mode 100644 index 45933fc..0000000 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/HornetQMessageHandler.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package org.apache.activemq.ra.inflow; - -import javax.jms.MessageListener; -import javax.resource.ResourceException; -import javax.resource.spi.endpoint.MessageEndpoint; -import javax.resource.spi.endpoint.MessageEndpointFactory; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import javax.transaction.xa.XAResource; -import java.util.UUID; - -import org.apache.activemq.api.core.ActiveMQException; -import org.apache.activemq.api.core.SimpleString; -import org.apache.activemq.api.core.client.ClientMessage; -import org.apache.activemq.api.core.client.ClientSession.QueueQuery; -import org.apache.activemq.api.core.client.ClientSessionFactory; -import org.apache.activemq.api.core.client.MessageHandler; -import org.apache.activemq.core.client.impl.ClientConsumerInternal; -import org.apache.activemq.core.client.impl.ClientSessionFactoryInternal; -import org.apache.activemq.core.client.impl.ClientSessionInternal; -import org.apache.activemq.jms.client.HornetQDestination; -import org.apache.activemq.jms.client.HornetQMessage; -import org.apache.activemq.ra.HornetQRALogger; -import org.apache.activemq.ra.HornetQResourceAdapter; -import org.apache.activemq.ra.HornetQXAResourceWrapper; -import org.apache.activemq.utils.FutureLatch; - -/** - * The message handler - * - * @author <a href="adr...@jboss.com">Adrian Brock</a> - * @author <a href="mailto:jesper.peder...@jboss.org">Jesper Pedersen</a> - * @author <a href="mailto:andy.tay...@jboss.org">Andy Taylor</a> - * @author <a href="mailto:mtay...@redhat.com">Martyn Taylor</a> - */ -public class HornetQMessageHandler implements MessageHandler -{ - /** - * Trace enabled - */ - private static boolean trace = HornetQRALogger.LOGGER.isTraceEnabled(); - /** - * The session - */ - private final ClientSessionInternal session; - - private ClientConsumerInternal consumer; - - /** - * The endpoint - */ - private MessageEndpoint endpoint; - - private final HornetQActivation activation; - - private boolean useLocalTx; - - private boolean transacted; - - private boolean useXA = false; - - private final int sessionNr; - - private final TransactionManager tm; - - private ClientSessionFactory cf; - - public HornetQMessageHandler(final HornetQActivation activation, - final TransactionManager tm, - final ClientSessionInternal session, - final ClientSessionFactory cf, - final int sessionNr) - { - this.activation = activation; - this.session = session; - this.cf = cf; - this.sessionNr = sessionNr; - this.tm = tm; - } - - public void setup() throws Exception - { - if (HornetQMessageHandler.trace) - { - HornetQRALogger.LOGGER.trace("setup()"); - } - - HornetQActivationSpec spec = activation.getActivationSpec(); - String selector = spec.getMessageSelector(); - - // Create the message consumer - SimpleString selectorString = selector == null || selector.trim().equals("") ? null : new SimpleString(selector); - if (activation.isTopic() && spec.isSubscriptionDurable()) - { - SimpleString queueName = new SimpleString(HornetQDestination.createQueueNameForDurableSubscription(true, - spec.getClientID(), - spec.getSubscriptionName())); - - QueueQuery subResponse = session.queueQuery(queueName); - - if (!subResponse.isExists()) - { - session.createQueue(activation.getAddress(), queueName, selectorString, true); - } - else - { - // The check for already exists should be done only at the first session - // As a deployed MDB could set up multiple instances in order to process messages in parallel. - if (sessionNr == 0 && subResponse.getConsumerCount() > 0) - { - if (!spec.isShareSubscriptions()) - { - throw new javax.jms.IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)"); - } - else if (HornetQRALogger.LOGGER.isDebugEnabled()) - { - HornetQRALogger.LOGGER.debug("the mdb on destination " + queueName + " already had " + - subResponse.getConsumerCount() + - " consumers but the MDB is configured to share subscriptions, so no exceptions are thrown"); - } - } - - SimpleString oldFilterString = subResponse.getFilterString(); - - boolean selectorChanged = selector == null && oldFilterString != null || - oldFilterString == null && - selector != null || - (oldFilterString != null && selector != null && !oldFilterString.toString() - .equals(selector)); - - SimpleString oldTopicName = subResponse.getAddress(); - - boolean topicChanged = !oldTopicName.equals(activation.getAddress()); - - if (selectorChanged || topicChanged) - { - // Delete the old durable sub - session.deleteQueue(queueName); - - // Create the new one - session.createQueue(activation.getAddress(), queueName, selectorString, true); - } - } - consumer = (ClientConsumerInternal) session.createConsumer(queueName, null, false); - } - else - { - SimpleString tempQueueName; - if (activation.isTopic()) - { - if (activation.getTopicTemporaryQueue() == null) - { - tempQueueName = new SimpleString(UUID.randomUUID().toString()); - session.createTemporaryQueue(activation.getAddress(), tempQueueName, selectorString); - activation.setTopicTemporaryQueue(tempQueueName); - } - else - { - tempQueueName = activation.getTopicTemporaryQueue(); - QueueQuery queueQuery = session.queueQuery(tempQueueName); - if (!queueQuery.isExists()) - { - // this is because we could be using remote servers (in cluster maybe) - // and the queue wasn't created on that node yet. - session.createTemporaryQueue(activation.getAddress(), tempQueueName, selectorString); - } - } - } - else - { - tempQueueName = activation.getAddress(); - } - consumer = (ClientConsumerInternal) session.createConsumer(tempQueueName, selectorString); - } - - // Create the endpoint, if we are transacted pass the session so it is enlisted, unless using Local TX - MessageEndpointFactory endpointFactory = activation.getMessageEndpointFactory(); - useLocalTx = !activation.isDeliveryTransacted() && activation.getActivationSpec().isUseLocalTx(); - transacted = activation.isDeliveryTransacted(); - if (activation.isDeliveryTransacted() && !activation.getActivationSpec().isUseLocalTx()) - { - XAResource xaResource = new HornetQXAResourceWrapper(session, - ((HornetQResourceAdapter) spec.getResourceAdapter()).getJndiName(), - ((ClientSessionFactoryInternal) cf).getLiveNodeId()); - endpoint = endpointFactory.createEndpoint(xaResource); - useXA = true; - } - else - { - endpoint = endpointFactory.createEndpoint(null); - useXA = false; - } - consumer.setMessageHandler(this); - } - - XAResource getXAResource() - { - return useXA ? session : null; - } - - public Thread interruptConsumer(FutureLatch future) - { - try - { - if (consumer != null) - { - return consumer.prepareForClose(future); - } - } - catch (Throwable e) - { - HornetQRALogger.LOGGER.warn("Error interrupting handler on endpoint " + endpoint + " handler=" + consumer); - } - return null; - } - - /** - * Stop the handler - */ - public void teardown() - { - if (HornetQMessageHandler.trace) - { - HornetQRALogger.LOGGER.trace("teardown()"); - } - - try - { - if (endpoint != null) - { - endpoint.release(); - endpoint = null; - } - } - catch (Throwable t) - { - HornetQRALogger.LOGGER.debug("Error releasing endpoint " + endpoint, t); - } - - try - { - consumer.close(); - if (activation.getTopicTemporaryQueue() != null) - { - // We need to delete temporary topics when the activation is stopped or messages will build up on the server - SimpleString tmpQueue = activation.getTopicTemporaryQueue(); - QueueQuery subResponse = session.queueQuery(tmpQueue); - if (subResponse.getConsumerCount() == 0) - { - // This is optional really, since we now use temporaryQueues, we could simply ignore this - // and the server temporary queue would remove this as soon as the queue was removed - session.deleteQueue(tmpQueue); - } - } - } - catch (Throwable t) - { - HornetQRALogger.LOGGER.debug("Error closing core-queue consumer", t); - } - - try - { - if (session != null) - { - session.close(); - } - } - catch (Throwable t) - { - HornetQRALogger.LOGGER.debug("Error releasing session " + session, t); - } - - try - { - if (cf != null) - { - cf.close(); - } - } - catch (Throwable t) - { - HornetQRALogger.LOGGER.debug("Error releasing session factory " + session, t); - } - } - - public void onMessage(final ClientMessage message) - { - if (HornetQMessageHandler.trace) - { - HornetQRALogger.LOGGER.trace("onMessage(" + message + ")"); - } - - HornetQMessage msg = HornetQMessage.createMessage(message, session); - boolean beforeDelivery = false; - - try - { - if (activation.getActivationSpec().getTransactionTimeout() > 0 && tm != null) - { - tm.setTransactionTimeout(activation.getActivationSpec().getTransactionTimeout()); - } - endpoint.beforeDelivery(HornetQActivation.ONMESSAGE); - beforeDelivery = true; - msg.doBeforeReceive(); - - //In the transacted case the message must be acked *before* onMessage is called - - if (transacted) - { - message.acknowledge(); - } - - ((MessageListener) endpoint).onMessage(msg); - - if (!transacted) - { - message.acknowledge(); - } - - try - { - endpoint.afterDelivery(); - } - catch (ResourceException e) - { - HornetQRALogger.LOGGER.unableToCallAfterDelivery(e); - return; - } - if (useLocalTx) - { - session.commit(); - } - - if (trace) - { - HornetQRALogger.LOGGER.trace("finished onMessage on " + message); - } - } - catch (Throwable e) - { - HornetQRALogger.LOGGER.errorDeliveringMessage(e); - // we need to call before/afterDelivery as a pair - if (beforeDelivery) - { - if (useXA && tm != null) - { - // This is the job for the container, - // however if the container throws an exception because of some other errors, - // there are situations where the container is not setting the rollback only - // this is to avoid a scenario where afterDelivery would kick in - try - { - Transaction tx = tm.getTransaction(); - if (tx != null) - { - tx.setRollbackOnly(); - } - } - catch (Exception e1) - { - HornetQRALogger.LOGGER.warn("unnable to clear the transaction", e1); - try - { - session.rollback(); - } - catch (ActiveMQException e2) - { - HornetQRALogger.LOGGER.warn("Unable to rollback", e2); - return; - } - } - } - - MessageEndpoint endToUse = endpoint; - try - { - // to avoid a NPE that would happen while the RA is in tearDown - if (endToUse != null) - { - endToUse.afterDelivery(); - } - } - catch (ResourceException e1) - { - HornetQRALogger.LOGGER.unableToCallAfterDelivery(e1); - } - } - if (useLocalTx || !activation.isDeliveryTransacted()) - { - try - { - session.rollback(true); - } - catch (ActiveMQException e1) - { - HornetQRALogger.LOGGER.unableToRollbackTX(); - } - } - } - finally - { - try - { - session.resetIfNeeded(); - } - catch (ActiveMQException e) - { - HornetQRALogger.LOGGER.unableToResetSession(); - } - } - - } - - public void start() throws ActiveMQException - { - session.start(); - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java ---------------------------------------------------------------------- diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java b/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java index cba59e2..057abe7 100644 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java @@ -17,10 +17,10 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Set; -import org.apache.activemq.jms.client.HornetQConnectionFactory; -import org.apache.activemq.jms.server.recovery.HornetQRegistryBase; +import org.apache.activemq.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.jms.server.recovery.ActiveMQRegistryBase; import org.apache.activemq.jms.server.recovery.XARecoveryConfig; -import org.apache.activemq.ra.HornetQRALogger; +import org.apache.activemq.ra.ActiveMQRALogger; import org.apache.activemq.utils.ClassloadingUtil; import org.apache.activemq.utils.ConcurrentHashSet; @@ -30,10 +30,10 @@ import org.apache.activemq.utils.ConcurrentHashSet; */ public final class RecoveryManager { - private HornetQRegistryBase registry; + private ActiveMQRegistryBase registry; private static final String RESOURCE_RECOVERY_CLASS_NAMES = "org.jboss.as.messaging.jms.AS7RecoveryRegistry;" - + "org.jboss.as.integration.hornetq.recovery.AS5RecoveryRegistry"; + + "org.jboss.as.integration.activemq.recovery.AS5RecoveryRegistry"; private final Set<XARecoveryConfig> resources = new ConcurrentHashSet<XARecoveryConfig>(); @@ -49,9 +49,9 @@ public final class RecoveryManager } } - public XARecoveryConfig register(HornetQConnectionFactory factory, String userName, String password) + public XARecoveryConfig register(ActiveMQConnectionFactory factory, String userName, String password) { - HornetQRALogger.LOGGER.debug("registering recovery for factory : " + factory); + ActiveMQRALogger.LOGGER.debug("registering recovery for factory : " + factory); XARecoveryConfig config = XARecoveryConfig.newConfig(factory, userName, password); resources.add(config); @@ -94,11 +94,11 @@ public final class RecoveryManager { try { - registry = (HornetQRegistryBase) safeInitNewInstance(locatorClasse); + registry = (ActiveMQRegistryBase) safeInitNewInstance(locatorClasse); } catch (Throwable e) { - HornetQRALogger.LOGGER.debug("unable to load recovery registry " + locatorClasse, e); + ActiveMQRALogger.LOGGER.debug("unable to load recovery registry " + locatorClasse, e); } if (registry != null) { @@ -108,7 +108,7 @@ public final class RecoveryManager if (registry != null) { - HornetQRALogger.LOGGER.debug("Recovery Registry located = " + registry); + ActiveMQRALogger.LOGGER.debug("Recovery Registry located = " + registry); } } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQ.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQ.java b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQ.java new file mode 100644 index 0000000..d2ffa67 --- /dev/null +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQ.java @@ -0,0 +1,191 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.apache.activemq.rest; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.ext.MessageBodyReader; +import javax.ws.rs.ext.Providers; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.reflect.Type; + +import org.apache.activemq.api.core.client.ClientMessage; +import org.apache.activemq.rest.util.HttpMessageHelper; +import org.jboss.resteasy.core.Headers; +import org.jboss.resteasy.spi.ResteasyProviderFactory; +import org.jboss.resteasy.util.GenericType; + +/** + * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> + * @version $Revision: 1 $ + */ +public class ActiveMQ +{ + + /** + * Sets the message body to a serialized + * byte array of the object. HTTP consumers will have to provide an Accept header to marshal the object + * + * @param message + * @param object + */ + public static void setEntity(ClientMessage message, Serializable object) + { + setEntity(message, object, null); + } + + /** + * Sets a message property to be the Content-Type passed in. Sets the message body to a serialized + * byte array of the object. + * + * @param message + * @param object + * @param contentType HTTP Content-Type header + */ + public static void setEntity(ClientMessage message, Serializable object, String contentType) + { + if (contentType != null) message.putStringProperty(HttpHeaderProperty.CONTENT_TYPE, contentType); + byte[] data; + try + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); + + ObjectOutputStream oos = new ObjectOutputStream(baos); + + oos.writeObject(object); + + oos.flush(); + + data = baos.toByteArray(); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + + message.getBodyBuffer().writeInt(data.length); + message.getBodyBuffer().writeBytes(data); + + } + + public static void setHttpHeader(ClientMessage message, String name, String value) + { + message.putStringProperty(HttpHeaderProperty.toPropertyName(name), value); + } + + + /** + * Get an HTTP header value from a JMS Message + * + * @param message + * @param name + * @return the HTTP header String + */ + public static String getHttpHeader(ClientMessage message, String name) + { + return message.getStringProperty(HttpHeaderProperty.toPropertyName(name)); + } + + /** + * Extract an object using a built-in RESTEasy JAX-RS MessageBodyReader + * + * @param message + * @param type + * @return + */ + public static <T> T getEntity(ClientMessage message, Class<T> type) + { + return getEntity(message, type, null, ResteasyProviderFactory.getInstance()); + } + + /** + * Extract an object using a built-in RESTEasy JAX-RS MessageBodyReader + * + * @param message + * @param type + * @param factory + * @return + */ + public static <T> T getEntity(ClientMessage message, Class<T> type, ResteasyProviderFactory factory) + { + return getEntity(message, type, null, factory); + } + + /** + * Extract an object using a built-in RESTEasy JAX-RS MessageBodyReader + * + * @param message + * @param type + * @param factory + * @return + * @throws UnknownMediaType + * @throws UnmarshalException + */ + public static <T> T getEntity(ClientMessage message, GenericType<T> type, ResteasyProviderFactory factory) throws UnknownMediaType, UnmarshalException + { + return getEntity(message, type.getType(), type.getGenericType(), factory); + } + + public static <T> T getEntity(ClientMessage msg, Class<T> type, Type genericType, ResteasyProviderFactory factory) + { + int size = msg.getBodySize(); + if (size <= 0) return null; + + byte[] body = new byte[size]; + msg.getBodyBuffer().readBytes(body); + + + String contentType = msg.getStringProperty(HttpHeaderProperty.CONTENT_TYPE); + if (contentType == null) + { + throw new UnknownMediaType("Message did not have a Content-Type header cannot extract entity"); + } + MediaType ct = MediaType.valueOf(contentType); + MessageBodyReader<T> reader = factory.getMessageBodyReader(type, genericType, null, ct); + if (reader == null) + { + throw new UnmarshalException("Unable to find a JAX-RS reader for type " + type.getName() + " and media type " + contentType); + } + + Providers current = ResteasyProviderFactory.getContextData(Providers.class); + ResteasyProviderFactory.pushContext(Providers.class, factory); + try + { + return reader.readFrom(type, genericType, null, ct, new Headers<String>(), new ByteArrayInputStream(body)); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + finally + { + ResteasyProviderFactory.popContextData(Providers.class); + if (current != null) ResteasyProviderFactory.pushContext(Providers.class, current); + } + } + + /** + * Was this ActiveMQ message generated from a REST call? + * + * @param msg + * @return + */ + public static boolean isHttpMessage(ClientMessage msg) + { + Boolean aBoolean = msg.getBooleanProperty(HttpMessageHelper.POSTED_AS_HTTP_MESSAGE); + return aBoolean != null && aBoolean.booleanValue() == true; + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestBundle.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestBundle.java b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestBundle.java new file mode 100644 index 0000000..16d20a7 --- /dev/null +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestBundle.java @@ -0,0 +1,31 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.apache.activemq.rest; + + +import org.jboss.logging.annotations.MessageBundle; + +/** + * @author <a href="mailto:andy.tay...@jboss.org">Andy Taylor</a> + * 3/12/12 + * + * Logger Code 19 + * + * each message id must be 6 digits long starting with 19, the 3rd digit should be 9 + * + * so 199000 to 199999 + */ +@MessageBundle(projectCode = "AMQ") +public class ActiveMQRestBundle +{ +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java new file mode 100644 index 0000000..473c8d5 --- /dev/null +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java @@ -0,0 +1,85 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package org.apache.activemq.rest; + +import org.apache.activemq.api.core.ActiveMQException; +import org.apache.activemq.rest.queue.push.xml.XmlLink; +import org.jboss.logging.BasicLogger; +import org.jboss.logging.Logger; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageLogger; + +/** + * @author <a href="mailto:andy.tay...@jboss.org">Andy Taylor</a> + * 3/15/12 + * + * Logger Code 19 + * + * each message id must be 6 digits long starting with 19, the 3rd digit donates the level so + * + * INF0 1 + * WARN 2 + * DEBUG 3 + * ERROR 4 + * TRACE 5 + * FATAL 6 + * + * so an INFO message would be 191000 to 191999 + */ +@MessageLogger(projectCode = "AMQ") +public interface ActiveMQRestLogger extends BasicLogger +{ + /** + * The twitter logger. + */ + ActiveMQRestLogger LOGGER = Logger.getMessageLogger(ActiveMQRestLogger.class, ActiveMQRestLogger.class.getPackage().getName()); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 181000, value = "Loading REST push store from: {0}", format = Message.Format.MESSAGE_FORMAT) + void loadingRestStore(String path); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 181001, value = "adding REST push registration: {0}", format = Message.Format.MESSAGE_FORMAT) + void addingPushRegistration(String id); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 181002, value = "Push consumer started for: {0}", format = Message.Format.MESSAGE_FORMAT) + void startingPushConsumer(XmlLink link); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 182000, value = "shutdown REST consumer because of timeout for: {0}", format = Message.Format.MESSAGE_FORMAT) + void shutdownRestConsumer(String id); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 182001, value = "shutdown REST subscription because of timeout for: {0}", format = Message.Format.MESSAGE_FORMAT) + void shutdownRestSubscription(String id); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 184000, value = "Failed to load push store {0}, it is probably corrupted", format = Message.Format.MESSAGE_FORMAT) + void errorLoadingStore(@Cause Exception e, String name); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 184001, value = "Error updating store", format = Message.Format.MESSAGE_FORMAT) + void errorUpdatingStore(@Cause Exception e); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 184002, value = "Failed to push message to {0} disabling push registration...", format = Message.Format.MESSAGE_FORMAT) + void errorPushingMessage(XmlLink link); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 184003, value = "Error deleting Subscriber queue", format = Message.Format.MESSAGE_FORMAT) + void errorDeletingSubscriberQueue(@Cause ActiveMQException e); +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestBundle.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestBundle.java b/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestBundle.java deleted file mode 100644 index 83bf74a..0000000 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestBundle.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package org.apache.activemq.rest; - - -import org.jboss.logging.annotations.MessageBundle; - -/** - * @author <a href="mailto:andy.tay...@jboss.org">Andy Taylor</a> - * 3/12/12 - * - * Logger Code 19 - * - * each message id must be 6 digits long starting with 19, the 3rd digit should be 9 - * - * so 199000 to 199999 - */ -@MessageBundle(projectCode = "HQ") -public class HornetQRestBundle -{ -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestLogger.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestLogger.java b/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestLogger.java deleted file mode 100644 index c706deb..0000000 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/HornetQRestLogger.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -package org.apache.activemq.rest; - -import org.apache.activemq.api.core.ActiveMQException; -import org.apache.activemq.rest.queue.push.xml.XmlLink; -import org.jboss.logging.BasicLogger; -import org.jboss.logging.Logger; -import org.jboss.logging.annotations.Cause; -import org.jboss.logging.annotations.LogMessage; -import org.jboss.logging.annotations.Message; -import org.jboss.logging.annotations.MessageLogger; - -/** - * @author <a href="mailto:andy.tay...@jboss.org">Andy Taylor</a> - * 3/15/12 - * - * Logger Code 19 - * - * each message id must be 6 digits long starting with 19, the 3rd digit donates the level so - * - * INF0 1 - * WARN 2 - * DEBUG 3 - * ERROR 4 - * TRACE 5 - * FATAL 6 - * - * so an INFO message would be 191000 to 191999 - */ -@MessageLogger(projectCode = "HQ") -public interface HornetQRestLogger extends BasicLogger -{ - /** - * The twitter logger. - */ - HornetQRestLogger LOGGER = Logger.getMessageLogger(HornetQRestLogger.class, HornetQRestLogger.class.getPackage().getName()); - - @LogMessage(level = Logger.Level.INFO) - @Message(id = 181000, value = "Loading REST push store from: {0}", format = Message.Format.MESSAGE_FORMAT) - void loadingRestStore(String path); - - @LogMessage(level = Logger.Level.INFO) - @Message(id = 181001, value = "adding REST push registration: {0}", format = Message.Format.MESSAGE_FORMAT) - void addingPushRegistration(String id); - - @LogMessage(level = Logger.Level.INFO) - @Message(id = 181002, value = "Push consumer started for: {0}", format = Message.Format.MESSAGE_FORMAT) - void startingPushConsumer(XmlLink link); - - @LogMessage(level = Logger.Level.WARN) - @Message(id = 182000, value = "shutdown REST consumer because of timeout for: {0}", format = Message.Format.MESSAGE_FORMAT) - void shutdownRestConsumer(String id); - - @LogMessage(level = Logger.Level.WARN) - @Message(id = 182001, value = "shutdown REST subscription because of timeout for: {0}", format = Message.Format.MESSAGE_FORMAT) - void shutdownRestSubscription(String id); - - @LogMessage(level = Logger.Level.ERROR) - @Message(id = 184000, value = "Failed to load push store {0}, it is probably corrupted", format = Message.Format.MESSAGE_FORMAT) - void errorLoadingStore(@Cause Exception e, String name); - - @LogMessage(level = Logger.Level.ERROR) - @Message(id = 184001, value = "Error updating store", format = Message.Format.MESSAGE_FORMAT) - void errorUpdatingStore(@Cause Exception e); - - @LogMessage(level = Logger.Level.ERROR) - @Message(id = 184002, value = "Failed to push message to {0} disabling push registration...", format = Message.Format.MESSAGE_FORMAT) - void errorPushingMessage(XmlLink link); - - @LogMessage(level = Logger.Level.ERROR) - @Message(id = 184003, value = "Error deleting Subscriber queue", format = Message.Format.MESSAGE_FORMAT) - void errorDeletingSubscriberQueue(@Cause ActiveMQException e); -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/Hornetq.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/Hornetq.java b/activemq-rest/src/main/java/org/apache/activemq/rest/Hornetq.java deleted file mode 100644 index 4f9e79d..0000000 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/Hornetq.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package org.apache.activemq.rest; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.Providers; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.reflect.Type; - -import org.apache.activemq.api.core.client.ClientMessage; -import org.apache.activemq.rest.util.HttpMessageHelper; -import org.jboss.resteasy.core.Headers; -import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.jboss.resteasy.util.GenericType; - -/** - * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> - * @version $Revision: 1 $ - */ -public class Hornetq -{ - - /** - * Sets the message body to a serialized - * byte array of the object. HTTP consumers will have to provide an Accept header to marshal the object - * - * @param message - * @param object - */ - public static void setEntity(ClientMessage message, Serializable object) - { - setEntity(message, object, null); - } - - /** - * Sets a message property to be the Content-Type passed in. Sets the message body to a serialized - * byte array of the object. - * - * @param message - * @param object - * @param contentType HTTP Content-Type header - */ - public static void setEntity(ClientMessage message, Serializable object, String contentType) - { - if (contentType != null) message.putStringProperty(HttpHeaderProperty.CONTENT_TYPE, contentType); - byte[] data; - try - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); - - ObjectOutputStream oos = new ObjectOutputStream(baos); - - oos.writeObject(object); - - oos.flush(); - - data = baos.toByteArray(); - } - catch (IOException e) - { - throw new RuntimeException(e); - } - - message.getBodyBuffer().writeInt(data.length); - message.getBodyBuffer().writeBytes(data); - - } - - public static void setHttpHeader(ClientMessage message, String name, String value) - { - message.putStringProperty(HttpHeaderProperty.toPropertyName(name), value); - } - - - /** - * Get an HTTP header value from a JMS Message - * - * @param message - * @param name - * @return the HTTP header String - */ - public static String getHttpHeader(ClientMessage message, String name) - { - return message.getStringProperty(HttpHeaderProperty.toPropertyName(name)); - } - - /** - * Extract an object using a built-in RESTEasy JAX-RS MessageBodyReader - * - * @param message - * @param type - * @return - */ - public static <T> T getEntity(ClientMessage message, Class<T> type) - { - return getEntity(message, type, null, ResteasyProviderFactory.getInstance()); - } - - /** - * Extract an object using a built-in RESTEasy JAX-RS MessageBodyReader - * - * @param message - * @param type - * @param factory - * @return - */ - public static <T> T getEntity(ClientMessage message, Class<T> type, ResteasyProviderFactory factory) - { - return getEntity(message, type, null, factory); - } - - /** - * Extract an object using a built-in RESTEasy JAX-RS MessageBodyReader - * - * @param message - * @param type - * @param factory - * @return - * @throws UnknownMediaType - * @throws UnmarshalException - */ - public static <T> T getEntity(ClientMessage message, GenericType<T> type, ResteasyProviderFactory factory) throws UnknownMediaType, UnmarshalException - { - return getEntity(message, type.getType(), type.getGenericType(), factory); - } - - public static <T> T getEntity(ClientMessage msg, Class<T> type, Type genericType, ResteasyProviderFactory factory) - { - int size = msg.getBodySize(); - if (size <= 0) return null; - - byte[] body = new byte[size]; - msg.getBodyBuffer().readBytes(body); - - - String contentType = msg.getStringProperty(HttpHeaderProperty.CONTENT_TYPE); - if (contentType == null) - { - throw new UnknownMediaType("Message did not have a Content-Type header cannot extract entity"); - } - MediaType ct = MediaType.valueOf(contentType); - MessageBodyReader<T> reader = factory.getMessageBodyReader(type, genericType, null, ct); - if (reader == null) - { - throw new UnmarshalException("Unable to find a JAX-RS reader for type " + type.getName() + " and media type " + contentType); - } - - Providers current = ResteasyProviderFactory.getContextData(Providers.class); - ResteasyProviderFactory.pushContext(Providers.class, factory); - try - { - return reader.readFrom(type, genericType, null, ct, new Headers<String>(), new ByteArrayInputStream(body)); - } - catch (IOException e) - { - throw new RuntimeException(e); - } - finally - { - ResteasyProviderFactory.popContextData(Providers.class); - if (current != null) ResteasyProviderFactory.pushContext(Providers.class, current); - } - } - - /** - * Was this HornetQ message generated from a REST call? - * - * @param msg - * @return - */ - public static boolean isHttpMessage(ClientMessage msg) - { - Boolean aBoolean = msg.getBooleanProperty(HttpMessageHelper.POSTED_AS_HTTP_MESSAGE); - return aBoolean != null && aBoolean.booleanValue() == true; - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/MessageServiceManager.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/MessageServiceManager.java b/activemq-rest/src/main/java/org/apache/activemq/rest/MessageServiceManager.java index 80b4c5d..c06af01 100644 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/MessageServiceManager.java +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/MessageServiceManager.java @@ -159,7 +159,7 @@ public class MessageServiceManager ServerLocator consumerLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig)); - HornetQRestLogger.LOGGER.debug("Created ServerLocator: " + consumerLocator); + ActiveMQRestLogger.LOGGER.debug("Created ServerLocator: " + consumerLocator); if (configuration.getConsumerWindowSize() != -1) { @@ -167,7 +167,7 @@ public class MessageServiceManager } ClientSessionFactory consumerSessionFactory = consumerLocator.createSessionFactory(); - HornetQRestLogger.LOGGER.debug("Created ClientSessionFactory: " + consumerSessionFactory); + ActiveMQRestLogger.LOGGER.debug("Created ClientSessionFactory: " + consumerSessionFactory); ServerLocator defaultLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig)); http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/integration/ActiveMQBootstrapListener.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/ActiveMQBootstrapListener.java b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/ActiveMQBootstrapListener.java new file mode 100644 index 0000000..b9e0657 --- /dev/null +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/ActiveMQBootstrapListener.java @@ -0,0 +1,55 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.apache.activemq.rest.integration; + +import org.apache.activemq.jms.server.embedded.EmbeddedJMS; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +/** + * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> + * @version $Revision: 1 $ + */ +public class ActiveMQBootstrapListener implements ServletContextListener +{ + private EmbeddedJMS jms; + + public void contextInitialized(ServletContextEvent contextEvent) + { + ServletContext context = contextEvent.getServletContext(); + jms = new EmbeddedJMS(); + jms.setRegistry(new ServletContextBindingRegistry(context)); + try + { + jms.start(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + public void contextDestroyed(ServletContextEvent servletContextEvent) + { + try + { + if (jms != null) jms.stop(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQ.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQ.java b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQ.java new file mode 100644 index 0000000..3aa8b47 --- /dev/null +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQ.java @@ -0,0 +1,92 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.apache.activemq.rest.integration; + +import org.apache.activemq.core.server.embedded.EmbeddedActiveMQ; +import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer; +import org.apache.activemq.rest.MessageServiceManager; +import org.jboss.resteasy.test.TestPortProvider; + +/** + * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> + * @version $Revision: 1 $ + */ +public class EmbeddedRestActiveMQ +{ + protected TJWSEmbeddedJaxrsServer tjws = new TJWSEmbeddedJaxrsServer(); + protected EmbeddedActiveMQ embeddedActiveMQ; + protected MessageServiceManager manager = new MessageServiceManager(); + + public EmbeddedRestActiveMQ() + { + int port = TestPortProvider.getPort(); + tjws.setPort(port); + tjws.setRootResourcePath(""); + tjws.setSecurityDomain(null); + initEmbeddedActiveMQ(); + } + + protected void initEmbeddedActiveMQ() + { + embeddedActiveMQ = new EmbeddedActiveMQ(); + } + + public TJWSEmbeddedJaxrsServer getTjws() + { + return tjws; + } + + public void setTjws(TJWSEmbeddedJaxrsServer tjws) + { + this.tjws = tjws; + } + + public EmbeddedActiveMQ getEmbeddedActiveMQ() + { + return embeddedActiveMQ; + } + + public MessageServiceManager getManager() + { + return manager; + } + + public void start() throws Exception + { + embeddedActiveMQ.start(); + tjws.start(); + manager.start(); + tjws.getDeployment().getRegistry().addSingletonResource(manager.getQueueManager().getDestination()); + tjws.getDeployment().getRegistry().addSingletonResource(manager.getTopicManager().getDestination()); + } + + public void stop() throws Exception + { + try + { + tjws.stop(); + } + catch (Exception e) + { + } + try + { + manager.stop(); + } + catch (Exception e) + { + } + embeddedActiveMQ.stop(); + } + +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQJMS.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQJMS.java b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQJMS.java new file mode 100644 index 0000000..419af8f --- /dev/null +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestActiveMQJMS.java @@ -0,0 +1,36 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package org.apache.activemq.rest.integration; + +import org.apache.activemq.jms.server.embedded.EmbeddedJMS; +import org.apache.activemq.spi.core.naming.BindingRegistry; + +/** + * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> + * @version $Revision: 1 $ + */ +public class EmbeddedRestActiveMQJMS extends EmbeddedRestActiveMQ +{ + @Override + protected void initEmbeddedActiveMQ() + { + embeddedActiveMQ = new EmbeddedJMS(); + } + + public BindingRegistry getRegistry() + { + if (embeddedActiveMQ == null) return null; + return ((EmbeddedJMS) embeddedActiveMQ).getRegistry(); + } + +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQ.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQ.java b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQ.java deleted file mode 100644 index fffcc8e..0000000 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQ.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package org.apache.activemq.rest.integration; - -import org.apache.activemq.core.server.embedded.EmbeddedHornetQ; -import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer; -import org.apache.activemq.rest.MessageServiceManager; -import org.jboss.resteasy.test.TestPortProvider; - -/** - * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> - * @version $Revision: 1 $ - */ -public class EmbeddedRestHornetQ -{ - protected TJWSEmbeddedJaxrsServer tjws = new TJWSEmbeddedJaxrsServer(); - protected EmbeddedHornetQ embeddedHornetQ; - protected MessageServiceManager manager = new MessageServiceManager(); - - public EmbeddedRestHornetQ() - { - int port = TestPortProvider.getPort(); - tjws.setPort(port); - tjws.setRootResourcePath(""); - tjws.setSecurityDomain(null); - initEmbeddedHornetQ(); - } - - protected void initEmbeddedHornetQ() - { - embeddedHornetQ = new EmbeddedHornetQ(); - } - - public TJWSEmbeddedJaxrsServer getTjws() - { - return tjws; - } - - public void setTjws(TJWSEmbeddedJaxrsServer tjws) - { - this.tjws = tjws; - } - - public EmbeddedHornetQ getEmbeddedHornetQ() - { - return embeddedHornetQ; - } - - public MessageServiceManager getManager() - { - return manager; - } - - public void start() throws Exception - { - embeddedHornetQ.start(); - tjws.start(); - manager.start(); - tjws.getDeployment().getRegistry().addSingletonResource(manager.getQueueManager().getDestination()); - tjws.getDeployment().getRegistry().addSingletonResource(manager.getTopicManager().getDestination()); - } - - public void stop() throws Exception - { - try - { - tjws.stop(); - } - catch (Exception e) - { - } - try - { - manager.stop(); - } - catch (Exception e) - { - } - embeddedHornetQ.stop(); - } - -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQJMS.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQJMS.java b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQJMS.java deleted file mode 100644 index 3284eb1..0000000 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/EmbeddedRestHornetQJMS.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package org.apache.activemq.rest.integration; - -import org.apache.activemq.jms.server.embedded.EmbeddedJMS; -import org.apache.activemq.spi.core.naming.BindingRegistry; - -/** - * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> - * @version $Revision: 1 $ - */ -public class EmbeddedRestHornetQJMS extends EmbeddedRestHornetQ -{ - @Override - protected void initEmbeddedHornetQ() - { - embeddedHornetQ = new EmbeddedJMS(); - } - - public BindingRegistry getRegistry() - { - if (embeddedHornetQ == null) return null; - return ((EmbeddedJMS)embeddedHornetQ).getRegistry(); - } - -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/integration/HornetqBootstrapListener.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/HornetqBootstrapListener.java b/activemq-rest/src/main/java/org/apache/activemq/rest/integration/HornetqBootstrapListener.java deleted file mode 100644 index f24038f..0000000 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/integration/HornetqBootstrapListener.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2005-2014 Red Hat, Inc. - * Red Hat licenses this file to you under the Apache License, version - * 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package org.apache.activemq.rest.integration; - -import org.apache.activemq.jms.server.embedded.EmbeddedJMS; - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -/** - * @author <a href="mailto:b...@burkecentral.com">Bill Burke</a> - * @version $Revision: 1 $ - */ -public class HornetqBootstrapListener implements ServletContextListener -{ - private EmbeddedJMS jms; - - public void contextInitialized(ServletContextEvent contextEvent) - { - ServletContext context = contextEvent.getServletContext(); - jms = new EmbeddedJMS(); - jms.setRegistry(new ServletContextBindingRegistry(context)); - try - { - jms.start(); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - public void contextDestroyed(ServletContextEvent servletContextEvent) - { - try - { - if (jms != null) jms.stop(); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/queue/AcknowledgedQueueConsumer.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/AcknowledgedQueueConsumer.java b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/AcknowledgedQueueConsumer.java index c3cefd5..9b00af2 100644 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/AcknowledgedQueueConsumer.java +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/AcknowledgedQueueConsumer.java @@ -30,7 +30,7 @@ import org.apache.activemq.api.core.client.ClientConsumer; import org.apache.activemq.api.core.client.ClientMessage; import org.apache.activemq.api.core.client.ClientSession; import org.apache.activemq.api.core.client.ClientSessionFactory; -import org.apache.activemq.rest.HornetQRestLogger; +import org.apache.activemq.rest.ActiveMQRestLogger; import org.apache.activemq.rest.util.Constants; import org.apache.activemq.rest.util.LinkStrategy; @@ -61,7 +61,7 @@ public class AcknowledgedQueueConsumer extends QueueConsumer @PathParam("index") long index, @Context UriInfo info) { - HornetQRestLogger.LOGGER.debug("Handling POST request for \"" + info.getPath() + "\""); + ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + info.getPath() + "\""); if (closed) { @@ -97,7 +97,7 @@ public class AcknowledgedQueueConsumer extends QueueConsumer @FormParam("acknowledge") boolean doAcknowledge, @Context UriInfo uriInfo) { - HornetQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\""); + ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\""); ping(0); String basePath = uriInfo.getMatchedURIs().get(1); http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumedMessage.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumedMessage.java b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumedMessage.java index a9d53d5..ac8b7d3 100644 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumedMessage.java +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumedMessage.java @@ -14,7 +14,7 @@ package org.apache.activemq.rest.queue; import org.apache.activemq.api.core.SimpleString; import org.apache.activemq.api.core.client.ClientMessage; -import org.apache.activemq.rest.HornetQRestLogger; +import org.apache.activemq.rest.ActiveMQRestLogger; import org.apache.activemq.rest.HttpHeaderProperty; import javax.ws.rs.core.Response; @@ -51,7 +51,7 @@ public abstract class ConsumedMessage continue; } builder.header(headerName, message.getStringProperty(k)); - HornetQRestLogger.LOGGER.debug("Adding " + headerName + "=" + message.getStringProperty(k)); + ActiveMQRestLogger.LOGGER.debug("Adding " + headerName + "=" + message.getStringProperty(k)); } } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/034adfbf/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumersResource.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumersResource.java b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumersResource.java index 9ad4546..f3a9e6f 100644 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumersResource.java +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/ConsumersResource.java @@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.api.core.ActiveMQException; import org.apache.activemq.api.core.client.ClientSessionFactory; -import org.apache.activemq.rest.HornetQRestLogger; +import org.apache.activemq.rest.ActiveMQRestLogger; import org.apache.activemq.rest.util.TimeoutTask; /** @@ -96,7 +96,7 @@ public class ConsumersResource implements TimeoutTask.Callback if (consumer == null) return false; if (System.currentTimeMillis() - consumer.getLastPingTime() > consumerTimeoutSeconds * 1000) { - HornetQRestLogger.LOGGER.shutdownRestConsumer(consumer.getId()); + ActiveMQRestLogger.LOGGER.shutdownRestConsumer(consumer.getId()); if (autoShutdown) { shutdown(consumer); @@ -138,7 +138,7 @@ public class ConsumersResource implements TimeoutTask.Callback @FormParam("selector") String selector, @Context UriInfo uriInfo) { - HornetQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\""); + ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\""); try { @@ -214,7 +214,7 @@ public class ConsumersResource implements TimeoutTask.Callback @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { - HornetQRestLogger.LOGGER.debug("Handling GET request for \"" + uriInfo.getPath() + "\""); + ActiveMQRestLogger.LOGGER.debug("Handling GET request for \"" + uriInfo.getPath() + "\""); return headConsumer(attributes, consumerId, uriInfo); } @@ -225,7 +225,7 @@ public class ConsumersResource implements TimeoutTask.Callback @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { - HornetQRestLogger.LOGGER.debug("Handling HEAD request for \"" + uriInfo.getPath() + "\""); + ActiveMQRestLogger.LOGGER.debug("Handling HEAD request for \"" + uriInfo.getPath() + "\""); QueueConsumer consumer = findConsumer(attributes, consumerId, uriInfo); Response.ResponseBuilder builder = Response.noContent(); @@ -313,7 +313,7 @@ public class ConsumersResource implements TimeoutTask.Callback @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) { - HornetQRestLogger.LOGGER.debug("Handling DELETE request for \"" + uriInfo.getPath() + "\""); + ActiveMQRestLogger.LOGGER.debug("Handling DELETE request for \"" + uriInfo.getPath() + "\""); QueueConsumer consumer = queueConsumers.remove(consumerId); if (consumer == null)