merging 908182,908373 - https://issues.apache.org/activemq/browse/AMQ-2601 - Make amq blueprint friendly

git-svn-id: https://svn.apache.org/repos/asf/activemq/branches/activemq-5.3@916678 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2010-02-26 13:42:34 +00:00
parent 0c042c361e
commit a6d381f459
16 changed files with 173 additions and 69 deletions

View File

@ -49,6 +49,10 @@
<groupId>${pom.groupId}</groupId>
<artifactId>kahadb</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
</dependency>
</dependencies>
<build>
@ -78,6 +82,7 @@
<include>org.apache.geronimo.specs:geronimo-jms_1.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-jta_1.0.1B_spec</include>
<include>org.apache.geronimo.specs:geronimo-j2ee-management_1.0_spec</include>
<include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
<include>commons-logging:commons-logging-api</include>
</includes>
</artifactSet>

View File

@ -100,6 +100,11 @@
<groupId>${pom.groupId}</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<optional>true</optional>
</dependency>
<!-- testing helpers -->
<dependency>

View File

@ -19,6 +19,8 @@ package org.apache.activemq.camel.component;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@ -37,15 +39,14 @@ import org.apache.camel.component.jms.JmsQueueEndpoint;
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
/**
* A helper bean which populates a {@link CamelContext} with ActiveMQ Queue endpoints
*
* @version $Revision: 1.1 $
* @org.apache.xbean.XBean
*/
public class CamelEndpointLoader implements InitializingBean, DisposableBean, CamelContextAware {
public class CamelEndpointLoader implements CamelContextAware {
private static final transient Log LOG = LogFactory.getLog(CamelEndpointLoader.class);
private CamelContext camelContext;
private EnhancedConnection connection;
@ -59,6 +60,12 @@ public class CamelEndpointLoader implements InitializingBean, DisposableBean, Ca
this.camelContext = camelContext;
}
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
ObjectHelper.notNull(camelContext, "camelContext");
if (connection == null) {
@ -112,6 +119,13 @@ public class CamelEndpointLoader implements InitializingBean, DisposableBean, Ca
}
}
/**
*
* @throws Exception
* @org.apache.xbean.DestroyMethod
*/
@PreDestroy
public void destroy() throws Exception {
if (connection != null) {
connection.close();

View File

@ -135,6 +135,11 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jacc_1.1_spec</artifactId>
@ -174,11 +179,9 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
</dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
</dependency>
<!-- not really a dependency at all - just added optionally to get the generator working -->
<dependency>
@ -297,7 +300,7 @@
</dependencies>
<reporting>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -384,6 +387,28 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${felix-version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>org.apache.activemq.util.osgi.Activator</Bundle-Activator>
<Bundle-Name>${artifactId}</Bundle-Name>
<Bundle-SymbolicName>${activemq.osgi.symbolic.name}</Bundle-SymbolicName>
<Export-Package>${activemq.osgi.export}</Export-Package>
<Import-Package>${activemq.osgi.import}</Import-Package>
<DynamicImport-Package>${activemq.osgi.dynamic.import}</DynamicImport-Package>
<Private-Package>${activemq.osgi.private.pkg}</Private-Package>
<Implementation-Title>Apache ActiveMQ</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<_versionpolicy>[$(version;==;$(@)),$(version;=+;$(@)))</_versionpolicy>
<_failok>${servicemix.osgi.failok}</_failok>
</instructions>
</configuration>
</plugin>
<!-- Configure which tests are included/excuded -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>

View File

@ -32,6 +32,8 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@ -99,6 +101,7 @@ import org.apache.commons.logging.LogFactory;
* which can be used to configure the broker as its lazily created.
*
* @version $Revision: 1.1 $
* @org.apache.xbean.XBean
*/
public class BrokerService implements Service {
protected CountDownLatch slaveStartSignal = new CountDownLatch(1);
@ -430,6 +433,13 @@ public class BrokerService implements Service {
// Service interface
// -------------------------------------------------------------------------
/**
*
* @throws Exception
* @org. apache.xbean.InitMethod
*/
@PostConstruct
public void start() throws Exception {
if (stopped.get() || !started.compareAndSet(false, true)) {
// lets just ignore redundant start() calls
@ -505,6 +515,12 @@ public class BrokerService implements Service {
}
}
/**
*
* @throws Exception
* @org.apache .xbean.DestroyMethod
*/
@PreDestroy
public void stop() throws Exception {
if (!started.get()) {
return;

View File

@ -16,6 +16,8 @@
*/
package org.apache.activemq.broker.util;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
@ -23,16 +25,12 @@ import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.Service;
import org.apache.activemq.advisory.AdvisorySupport;
import org.apache.activemq.util.ServiceStopper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
/**
* An agent which listens to commands on a JMS destination
@ -40,7 +38,7 @@ import org.springframework.beans.factory.InitializingBean;
* @version $Revision$
* @org.apache.xbean.XBean
*/
public class CommandAgent implements Service, InitializingBean, DisposableBean, FactoryBean, ExceptionListener {
public class CommandAgent implements Service, ExceptionListener {
private static final Log LOG = LogFactory.getLog(CommandAgent.class);
private String brokerUrl = "vm://localhost";
@ -53,6 +51,12 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean,
private Session session;
private MessageConsumer consumer;
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void start() throws Exception {
session = getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
listener = new CommandMessageListener(session);
@ -64,6 +68,12 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean,
consumer.setMessageListener(listener);
}
/**
*
* @throws Exception
* @org.apache.xbean.DestroyMethod
*/
@PreDestroy
public void stop() throws Exception {
ServiceStopper stopper = new ServiceStopper();
if (consumer != null) {
@ -93,29 +103,6 @@ public class CommandAgent implements Service, InitializingBean, DisposableBean,
stopper.throwFirstException();
}
// the following methods ensure that we are created on startup and the
// lifecycles respected
// TODO there must be a simpler way?
public void afterPropertiesSet() throws Exception {
start();
}
public void destroy() throws Exception {
stop();
}
public Object getObject() throws Exception {
return this;
}
public Class getObjectType() {
return getClass();
}
public boolean isSingleton() {
return true;
}
// Properties
// -------------------------------------------------------------------------
public String getBrokerUrl() {

View File

@ -18,7 +18,7 @@ package org.apache.activemq.broker.util;
import java.io.IOException;
import java.util.Set;
import javax.annotation.PostConstruct;
import org.apache.activemq.broker.BrokerPluginSupport;
import org.apache.activemq.broker.Connection;
import org.apache.activemq.broker.ConnectionContext;
@ -45,7 +45,6 @@ import org.apache.activemq.command.TransactionId;
import org.apache.activemq.usage.Usage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
/**
* A simple Broker intercepter which allows you to enable/disable logging.
@ -53,8 +52,7 @@ import org.springframework.beans.factory.InitializingBean;
* @org.apache.xbean.XBean
*/
public class LoggingBrokerPlugin extends BrokerPluginSupport implements
InitializingBean {
public class LoggingBrokerPlugin extends BrokerPluginSupport {
private static final Log LOG = LogFactory.getLog(LoggingBrokerPlugin.class);
@ -66,6 +64,12 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport implements
private boolean logProducerEvents = false;
private boolean logInternalEvents = false;
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
LOG.info("Created LoggingBrokerPlugin: " + this.toString());
}

View File

@ -16,18 +16,19 @@
*/
package org.apache.activemq.filter;
import javax.annotation.PostConstruct;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.InitializingBean;
/**
* A base class for entry objects used to construct a destination based policy
* map.
*
* @version $Revision: 1.1 $
* @org.apache.xbean.XBean
*/
public abstract class DestinationMapEntry implements InitializingBean, Comparable {
public abstract class DestinationMapEntry implements Comparable {
private ActiveMQDestination destination;
@ -64,6 +65,12 @@ public abstract class DestinationMapEntry implements InitializingBean, Comparabl
this.destination = destination;
}
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
if (destination == null) {
throw new IllegalArgumentException("You must specify the 'destination' property");

View File

@ -16,8 +16,8 @@
*/
package org.apache.activemq.spring;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
/**
* A <a href="http://www.springframework.org/">Spring</a> enhanced connection
@ -29,11 +29,17 @@ import org.springframework.beans.factory.InitializingBean;
*
* @version $Revision: $
*/
public class ActiveMQConnectionFactory extends org.apache.activemq.ActiveMQConnectionFactory implements InitializingBean, BeanNameAware {
public class ActiveMQConnectionFactory extends org.apache.activemq.ActiveMQConnectionFactory implements BeanNameAware {
private String beanName;
private boolean useBeanNameAsClientIdPrefix;
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
if (isUseBeanNameAsClientIdPrefix() && getClientIDPrefix() == null) {
setClientIDPrefix(getBeanName());

View File

@ -16,8 +16,8 @@
*/
package org.apache.activemq.spring;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
/**
* A <a href="http://www.springframework.org/">Spring</a> enhanced XA connection
@ -29,11 +29,17 @@ import org.springframework.beans.factory.InitializingBean;
*
* @version $Revision: $
*/
public class ActiveMQXAConnectionFactory extends org.apache.activemq.ActiveMQXAConnectionFactory implements InitializingBean, BeanNameAware {
public class ActiveMQXAConnectionFactory extends org.apache.activemq.ActiveMQXAConnectionFactory implements BeanNameAware {
private String beanName;
private boolean useBeanNameAsClientIdPrefix;
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
if (isUseBeanNameAsClientIdPrefix() && getClientIDPrefix() == null) {
setClientIDPrefix(getBeanName());

View File

@ -24,13 +24,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import org.apache.activemq.broker.SslContext;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.Resource;
/**
@ -40,7 +39,7 @@ import org.springframework.core.io.Resource;
*
* @version $Revision$
*/
public class SpringSslContext extends SslContext implements InitializingBean {
public class SpringSslContext extends SslContext {
private String keyStoreType="jks";
private String trustStoreType="jks";
@ -55,6 +54,12 @@ public class SpringSslContext extends SslContext implements InitializingBean {
private String keyStorePassword;
private String trustStorePassword;
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
keyManagers.addAll(createKeyManagers());
trustManagers.addAll(createTrustManagers());

View File

@ -39,7 +39,7 @@ import org.osgi.framework.SynchronousBundleListener;
/**
* An OSGi bundle activator for ActiveMQ which adapts the {@link org.apache.activemq.util.FactoryFinder}
* to the OSGi enviorment.
* to the OSGi environment.
*
*/
public class Activator implements BundleActivator, SynchronousBundleListener, ObjectFactory {

View File

@ -18,6 +18,8 @@ package org.apache.activemq.xbean;
import java.io.IOException;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.usage.SystemUsage;
import org.apache.commons.logging.Log;
@ -45,7 +47,7 @@ import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
* {code}
* @version $Revision: 1.1 $
*/
public class XBeanBrokerService extends BrokerService implements InitializingBean, DisposableBean, ApplicationContextAware {
public class XBeanBrokerService extends BrokerService implements ApplicationContextAware {
private static final transient Log LOG = LogFactory.getLog(XBeanBrokerService.class);
private boolean start = true;
@ -55,6 +57,12 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
public XBeanBrokerService() {
}
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
ensureSystemUsageHasStore();
if (start) {
@ -89,6 +97,12 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
}
}
/**
*
* @throws Exception
* @org.apache.xbean.DestroyMethod
*/
@PreDestroy
public void destroy() throws Exception {
stop();
}

View File

@ -70,6 +70,11 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.0.1B_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>

View File

@ -16,15 +16,13 @@
*/
package org.apache.activemq.pool;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.jms.ConnectionFactory;
import javax.transaction.TransactionManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.pool.ObjectPoolFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.DisposableBean;
/**
* Simple factory bean used to create a jencks connection pool.
@ -43,8 +41,9 @@ import org.springframework.beans.factory.DisposableBean;
* the same value than its <code>resourceName</code> property. This will make sure the transaction manager
* maps correctly the connection factory to the recovery process.
*
* @org.apache.xbean.XBean
*/
public class PooledConnectionFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
public class PooledConnectionFactoryBean {
private static final Log LOGGER = LogFactory.getLog(PooledConnectionFactoryBean.class);
@ -56,18 +55,6 @@ public class PooledConnectionFactoryBean implements FactoryBean, InitializingBea
private String resourceName;
private ObjectPoolFactory poolFactory;
public Object getObject() throws Exception {
return pooledConnectionFactory;
}
public Class getObjectType() {
return ConnectionFactory.class;
}
public boolean isSingleton() {
return true;
}
public int getMaxConnections() {
return maxConnections;
}
@ -116,6 +103,12 @@ public class PooledConnectionFactoryBean implements FactoryBean, InitializingBea
this.poolFactory = poolFactory;
}
/**
*
* @throws Exception
* @org.apache.xbean.InitMethod
*/
@PostConstruct
public void afterPropertiesSet() throws Exception {
if (pooledConnectionFactory == null && transactionManager != null && resourceName != null) {
try {
@ -164,6 +157,12 @@ public class PooledConnectionFactoryBean implements FactoryBean, InitializingBea
}
}
/**
*
* @throws Exception
* @org.apache.xbean.DestroyMethod
*/
@PreDestroy
public void destroy() throws Exception {
if (pooledConnectionFactory != null) {
pooledConnectionFactory.stop();

View File

@ -379,6 +379,12 @@
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<version>1.1.1</version>
</dependency>
<!-- =============================== -->