mirror of https://github.com/apache/activemq.git
Moved the trunk code into the trunk sub directory
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@356307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40a7d3b6ac
commit
8f1763f078
|
@ -0,0 +1,8 @@
|
|||
target
|
||||
.classpath
|
||||
.project
|
||||
*.iws
|
||||
*.ipr
|
||||
*.iml
|
||||
build.properties
|
||||
bin
|
|
@ -0,0 +1,9 @@
|
|||
# -------------------------------------------------------------------
|
||||
# Build Properties
|
||||
# -------------------------------------------------------------------
|
||||
maven.multiproject.type=jar
|
||||
|
||||
maven.repo.remote=\
|
||||
http://www.ibiblio.org/maven,\
|
||||
http://dist.codehaus.org,\
|
||||
http://cvs.apache.org/repository
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE project>
|
||||
<project>
|
||||
<pomVersion>3</pomVersion>
|
||||
<extend>${basedir}/../../etc/project.xml</extend>
|
||||
|
||||
<name>ActiveMQ :: GBeans</name>
|
||||
<id>activemq-gbean</id>
|
||||
<shortDescription>Geronimo / GBean support</shortDescription>
|
||||
<description>ActiveMQ GBeans used for integration into Apache Geronimo</description>
|
||||
|
||||
<package>org.activemq.gbean</package>
|
||||
<packageGroups>
|
||||
<packageGroup>
|
||||
<title>Geronimo / GBean support</title>
|
||||
<packages>org.activemq.gbean</packages>
|
||||
</packageGroup>
|
||||
</packageGroups>
|
||||
|
||||
<!-- ============ -->
|
||||
<!-- Dependencies -->
|
||||
<!-- ============ -->
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>activemq</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
<version>${pom.currentVersion}</version>
|
||||
<properties>
|
||||
<eclipse.dependency>true</eclipse.dependency>
|
||||
</properties>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>activemq</groupId>
|
||||
<artifactId>activemq-gbean-management</artifactId>
|
||||
<version>${pom.currentVersion}</version>
|
||||
<properties>
|
||||
<eclipse.dependency>true</eclipse.dependency>
|
||||
</properties>
|
||||
</dependency>
|
||||
<dependency> <!-- Used for unit tests -->
|
||||
<groupId>activemq</groupId>
|
||||
<artifactId>activemq-core-test</artifactId>
|
||||
<version>${pom.currentVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>geronimo</groupId>
|
||||
<artifactId>geronimo-kernel</artifactId>
|
||||
<version>${geronimo_kernel_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>geronimo</groupId>
|
||||
<artifactId>geronimo-system</artifactId>
|
||||
<version>${geronimo_system_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>geronimo</groupId>
|
||||
<artifactId>geronimo-management</artifactId>
|
||||
<version>${geronimo_management_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>geronimo</groupId>
|
||||
<artifactId>geronimo-j2ee</artifactId>
|
||||
<version>${geronimo_j2ee_version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>activeio</groupId>
|
||||
<artifactId>activeio</artifactId>
|
||||
<version>${activeio_version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mx4j</groupId>
|
||||
<artifactId>mx4j</artifactId>
|
||||
<version>${mx4j_version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,179 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Protique Ltd
|
||||
*
|
||||
* Licensed 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.activemq.gbean;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.geronimo.gbean.GBeanInfo;
|
||||
import org.apache.geronimo.gbean.GBeanInfoBuilder;
|
||||
import org.apache.geronimo.gbean.GBeanLifecycle;
|
||||
import org.apache.geronimo.gbean.GConstructorInfo;
|
||||
import org.apache.geronimo.kernel.Kernel;
|
||||
import org.activemq.ActiveMQConnectionFactory;
|
||||
import org.activemq.broker.BrokerConnector;
|
||||
import org.activemq.broker.impl.BrokerConnectorImpl;
|
||||
import org.activemq.io.WireFormat;
|
||||
import org.activemq.io.impl.DefaultWireFormat;
|
||||
|
||||
/**
|
||||
* Default implementation of the ActiveMQ connector
|
||||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
public class ActiveMQConnectorGBean implements GBeanLifecycle, ActiveMQConnector {
|
||||
private Log log = LogFactory.getLog(getClass().getName());
|
||||
|
||||
private BrokerConnector brokerConnector;
|
||||
private ActiveMQContainer container;
|
||||
private WireFormat wireFormat = new DefaultWireFormat();
|
||||
private String protocol;
|
||||
private String host;
|
||||
private int port;
|
||||
private String path;
|
||||
private String query;
|
||||
private String urlAsStarted;
|
||||
|
||||
public ActiveMQConnectorGBean(ActiveMQContainer container, String protocol, String host, int port) {
|
||||
this.container = container;
|
||||
this.protocol = protocol;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
try {
|
||||
return new URI(protocol, null, host, port, path, query, null).toString();
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalStateException("Attributes don't form a valid URI: "+protocol+"://"+host+":"+port+"/"+path+"?"+query);
|
||||
}
|
||||
}
|
||||
|
||||
public WireFormat getWireFormat() {
|
||||
return wireFormat;
|
||||
}
|
||||
|
||||
public void setWireFormat(WireFormat wireFormat) {
|
||||
this.wireFormat = wireFormat;
|
||||
}
|
||||
|
||||
public InetSocketAddress getListenAddress() {
|
||||
return brokerConnector == null ? null : brokerConnector.getServerChannel().getSocketAddress();
|
||||
}
|
||||
|
||||
public synchronized void doStart() throws Exception {
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(ActiveMQContainerGBean.class.getClassLoader());
|
||||
try {
|
||||
if (brokerConnector == null) {
|
||||
urlAsStarted = getUrl();
|
||||
brokerConnector = createBrokerConnector(urlAsStarted);
|
||||
brokerConnector.start();
|
||||
ActiveMQConnectionFactory.registerBroker(urlAsStarted, brokerConnector);
|
||||
}
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doStop() throws Exception {
|
||||
if (brokerConnector != null) {
|
||||
ActiveMQConnectionFactory.unregisterBroker(urlAsStarted);
|
||||
BrokerConnector temp = brokerConnector;
|
||||
brokerConnector = null;
|
||||
temp.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doFail() {
|
||||
if (brokerConnector != null) {
|
||||
BrokerConnector temp = brokerConnector;
|
||||
brokerConnector = null;
|
||||
try {
|
||||
temp.stop();
|
||||
}
|
||||
catch (JMSException e) {
|
||||
log.info("Caught while closing due to failure: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected BrokerConnector createBrokerConnector(String url) throws Exception {
|
||||
return new BrokerConnectorImpl(container.getBrokerContainer(), url, wireFormat);
|
||||
}
|
||||
|
||||
public static final GBeanInfo GBEAN_INFO;
|
||||
|
||||
static {
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Message Broker Connector", ActiveMQConnectorGBean.class, CONNECTOR_J2EE_TYPE);
|
||||
infoFactory.addAttribute("url", String.class.getName(), false);
|
||||
infoFactory.addAttribute("wireFormat", WireFormat.class.getName(), false);
|
||||
infoFactory.addReference("activeMQContainer", ActiveMQContainer.class);
|
||||
infoFactory.addInterface(ActiveMQConnector.class, new String[]{"host","port","protocol","path","query"});
|
||||
infoFactory.setConstructor(new GConstructorInfo(new String[]{"activeMQContainer", "protocol", "host", "port"}));
|
||||
GBEAN_INFO = infoFactory.getBeanInfo();
|
||||
}
|
||||
|
||||
public static GBeanInfo getGBeanInfo() {
|
||||
return GBEAN_INFO;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Protique Ltd
|
||||
*
|
||||
* Licensed 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.activemq.gbean;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.activemq.broker.BrokerAdmin;
|
||||
import org.activemq.broker.BrokerContainer;
|
||||
import org.apache.geronimo.management.geronimo.JMSBroker;
|
||||
|
||||
/**
|
||||
* An interface to the ActiveMQContainerGBean for use by the
|
||||
* ActiveMQConnectorGBean.
|
||||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
public interface ActiveMQContainer extends ActiveMQBroker {
|
||||
|
||||
public abstract BrokerContainer getBrokerContainer();
|
||||
public abstract BrokerAdmin getBrokerAdmin();
|
||||
|
||||
public String getBrokerName();
|
||||
public String getJaasConfiguration();
|
||||
public Properties getSecurityRoles();
|
||||
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Protique Ltd
|
||||
*
|
||||
* Licensed 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.activemq.gbean;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.jms.JMSException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.geronimo.gbean.GBeanInfo;
|
||||
import org.apache.geronimo.gbean.GBeanInfoBuilder;
|
||||
import org.apache.geronimo.gbean.GBeanLifecycle;
|
||||
import org.activemq.broker.BrokerAdmin;
|
||||
import org.activemq.broker.BrokerContainer;
|
||||
import org.activemq.broker.BrokerContext;
|
||||
import org.activemq.broker.impl.BrokerContainerImpl;
|
||||
import org.activemq.security.jassjacc.JassJaccSecurityAdapter;
|
||||
import org.activemq.security.jassjacc.PropertiesConfigLoader;
|
||||
import org.activemq.store.PersistenceAdapter;
|
||||
|
||||
/**
|
||||
* Default implementation of the ActiveMQ Message Server
|
||||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
public class ActiveMQContainerGBean implements GBeanLifecycle, ActiveMQContainer {
|
||||
|
||||
private Log log = LogFactory.getLog(getClass().getName());
|
||||
|
||||
private final String brokerName;
|
||||
|
||||
private BrokerContext context = BrokerContext.getInstance();
|
||||
private BrokerContainer container;
|
||||
|
||||
private final PersistenceAdapter persistenceAdapter;
|
||||
private final String jaasConfiguration;
|
||||
private final Properties securityRoles;
|
||||
|
||||
//default constructor for use as gbean endpoint.
|
||||
public ActiveMQContainerGBean() {
|
||||
brokerName = null;
|
||||
jaasConfiguration = null;
|
||||
securityRoles = null;
|
||||
persistenceAdapter=null;
|
||||
}
|
||||
|
||||
public ActiveMQContainerGBean(String brokerName, PersistenceAdapter persistenceAdapter, String jaasConfiguration, Properties securityRoles) {
|
||||
|
||||
assert brokerName != null;
|
||||
assert persistenceAdapter != null;
|
||||
|
||||
this.brokerName = brokerName;
|
||||
this.jaasConfiguration=jaasConfiguration;
|
||||
this.persistenceAdapter = persistenceAdapter;
|
||||
this.securityRoles = securityRoles;
|
||||
}
|
||||
|
||||
public synchronized BrokerContainer getBrokerContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.activemq.gbean.ActiveMQContainer#getBrokerAdmin()
|
||||
*/
|
||||
public BrokerAdmin getBrokerAdmin() {
|
||||
return container.getBroker().getBrokerAdmin();
|
||||
}
|
||||
|
||||
public synchronized void doStart() throws Exception {
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(ActiveMQContainerGBean.class.getClassLoader());
|
||||
try {
|
||||
if (container == null) {
|
||||
container = createContainer();
|
||||
container.start();
|
||||
}
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doStop() throws Exception {
|
||||
if (container != null) {
|
||||
BrokerContainer temp = container;
|
||||
container = null;
|
||||
temp.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doFail() {
|
||||
if (container != null) {
|
||||
BrokerContainer temp = container;
|
||||
container = null;
|
||||
try {
|
||||
temp.stop();
|
||||
}
|
||||
catch (JMSException e) {
|
||||
log.info("Caught while closing due to failure: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected BrokerContainer createContainer() throws Exception {
|
||||
BrokerContainerImpl answer = new BrokerContainerImpl(brokerName, context);
|
||||
answer.setPersistenceAdapter( persistenceAdapter );
|
||||
if( jaasConfiguration != null ) {
|
||||
answer.setSecurityAdapter(new JassJaccSecurityAdapter(jaasConfiguration));
|
||||
}
|
||||
if( securityRoles != null ) {
|
||||
// Install JACC configuration.
|
||||
PropertiesConfigLoader loader = new PropertiesConfigLoader(brokerName, securityRoles);
|
||||
loader.installSecurity();
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
public static final GBeanInfo GBEAN_INFO;
|
||||
|
||||
static {
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Message Broker", ActiveMQContainerGBean.class, "JMSServer");
|
||||
infoFactory.addAttribute("brokerName", String.class, true);
|
||||
infoFactory.addReference("persistenceAdapter", PersistenceAdapter.class);
|
||||
infoFactory.addAttribute("jaasConfiguration", String.class, true);
|
||||
infoFactory.addAttribute("securityRoles", Properties.class, true);
|
||||
infoFactory.addInterface(ActiveMQContainer.class);
|
||||
infoFactory.setConstructor(new String[]{"brokerName", "persistenceAdapter", "jaasConfiguration", "securityRoles"});
|
||||
GBEAN_INFO = infoFactory.getBeanInfo();
|
||||
}
|
||||
|
||||
public static GBeanInfo getGBeanInfo() {
|
||||
return GBEAN_INFO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the brokerName.
|
||||
*/
|
||||
public String getBrokerName() {
|
||||
return brokerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the jassConfiguration.
|
||||
*/
|
||||
public String getJaasConfiguration() {
|
||||
return jaasConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the securityRoles.
|
||||
*/
|
||||
public Properties getSecurityRoles() {
|
||||
return securityRoles;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,11 @@
|
|||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>
|
||||
The JMS container using GBeaps for deployment in Geronimo or other JSR 77/88 based containers
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
103
activemq-gbean/src/java/org/activemq/store/cache/SimpleCachePersistenceAdapterGBean.java
vendored
Executable file
103
activemq-gbean/src/java/org/activemq/store/cache/SimpleCachePersistenceAdapterGBean.java
vendored
Executable file
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Hiram Chirino
|
||||
*
|
||||
* Licensed 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.activemq.store.cache;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import org.apache.geronimo.gbean.GBeanInfo;
|
||||
import org.apache.geronimo.gbean.GBeanInfoBuilder;
|
||||
import org.apache.geronimo.gbean.GBeanLifecycle;
|
||||
import org.activemq.store.MessageStore;
|
||||
import org.activemq.store.PersistenceAdapter;
|
||||
import org.activemq.store.TopicMessageStore;
|
||||
import org.activemq.store.TransactionStore;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SimpleCachePersistenceAdapterGBean implements GBeanLifecycle, PersistenceAdapter {
|
||||
|
||||
private final PersistenceAdapter longTermPersistence;
|
||||
private SimpleCachePersistenceAdapter persistenceAdapter;
|
||||
private final int cacheSize;
|
||||
|
||||
public SimpleCachePersistenceAdapterGBean() {
|
||||
this(null, 0);
|
||||
}
|
||||
|
||||
public SimpleCachePersistenceAdapterGBean(PersistenceAdapter longTermPersistence, int cacheSize) {
|
||||
this.longTermPersistence = longTermPersistence;
|
||||
this.cacheSize = cacheSize;
|
||||
}
|
||||
|
||||
public void doStart() throws Exception {
|
||||
persistenceAdapter = new SimpleCachePersistenceAdapter();
|
||||
persistenceAdapter.setLongTermPersistence(longTermPersistence);
|
||||
persistenceAdapter.setCacheSize(cacheSize);
|
||||
persistenceAdapter.start();
|
||||
}
|
||||
|
||||
public void doStop() throws Exception {
|
||||
persistenceAdapter.stop();
|
||||
persistenceAdapter = null;
|
||||
}
|
||||
|
||||
public void doFail() {
|
||||
}
|
||||
|
||||
public static final GBeanInfo GBEAN_INFO;
|
||||
static {
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Persistence Cache", SimpleCachePersistenceAdapterGBean.class, "JMSPersistence");
|
||||
infoFactory.addReference("longTermPersistence", PersistenceAdapter.class);
|
||||
infoFactory.addAttribute("cacheSize", int.class, true);
|
||||
infoFactory.addInterface(PersistenceAdapter.class);
|
||||
infoFactory.setConstructor(new String[]{"longTermPersistence", "cacheSize"});
|
||||
GBEAN_INFO = infoFactory.getBeanInfo();
|
||||
}
|
||||
public static GBeanInfo getGBeanInfo() {
|
||||
return GBEAN_INFO;
|
||||
}
|
||||
|
||||
public void beginTransaction() throws JMSException {
|
||||
persistenceAdapter.beginTransaction();
|
||||
}
|
||||
public void commitTransaction() throws JMSException {
|
||||
persistenceAdapter.commitTransaction();
|
||||
}
|
||||
public MessageStore createQueueMessageStore(String destinationName) throws JMSException {
|
||||
return persistenceAdapter.createQueueMessageStore(destinationName);
|
||||
}
|
||||
public TopicMessageStore createTopicMessageStore(String destinationName) throws JMSException {
|
||||
return persistenceAdapter.createTopicMessageStore(destinationName);
|
||||
}
|
||||
public TransactionStore createTransactionStore() throws JMSException {
|
||||
return persistenceAdapter.createTransactionStore();
|
||||
}
|
||||
public Map getInitialDestinations() {
|
||||
return persistenceAdapter.getInitialDestinations();
|
||||
}
|
||||
public void rollbackTransaction() {
|
||||
persistenceAdapter.rollbackTransaction();
|
||||
}
|
||||
public void start() throws JMSException {
|
||||
}
|
||||
public void stop() throws JMSException {
|
||||
}
|
||||
}
|
100
activemq-gbean/src/java/org/activemq/store/jdbc/JDBCPersistenceAdapterGBean.java
Executable file
100
activemq-gbean/src/java/org/activemq/store/jdbc/JDBCPersistenceAdapterGBean.java
Executable file
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Hiram Chirino
|
||||
*
|
||||
* Licensed 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.activemq.store.jdbc;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.geronimo.gbean.GBeanInfo;
|
||||
import org.apache.geronimo.gbean.GBeanInfoBuilder;
|
||||
import org.apache.geronimo.gbean.GBeanLifecycle;
|
||||
import org.activemq.store.MessageStore;
|
||||
import org.activemq.store.PersistenceAdapter;
|
||||
import org.activemq.store.TopicMessageStore;
|
||||
import org.activemq.store.TransactionStore;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class JDBCPersistenceAdapterGBean implements GBeanLifecycle, PersistenceAdapter {
|
||||
|
||||
JDBCPersistenceAdapter pa;
|
||||
private final ResourceManager resourceManager;
|
||||
|
||||
public JDBCPersistenceAdapterGBean() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public JDBCPersistenceAdapterGBean(ResourceManager dataSource) {
|
||||
this.resourceManager = dataSource;
|
||||
}
|
||||
|
||||
public void doStart() throws Exception {
|
||||
pa = new JDBCPersistenceAdapter();
|
||||
pa.setDataSource((DataSource) resourceManager.$getResource());
|
||||
pa.start();
|
||||
}
|
||||
|
||||
public void doStop() throws Exception {
|
||||
pa.stop();
|
||||
pa = null;
|
||||
}
|
||||
|
||||
public void doFail() {
|
||||
}
|
||||
|
||||
public static final GBeanInfo GBEAN_INFO;
|
||||
static {
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ JDBC Persistence", JDBCPersistenceAdapterGBean.class, "JMSPersistence");
|
||||
infoFactory.addReference("dataSource", ResourceManager.class);
|
||||
infoFactory.addInterface(PersistenceAdapter.class);
|
||||
infoFactory.setConstructor(new String[]{"dataSource"});
|
||||
GBEAN_INFO = infoFactory.getBeanInfo();
|
||||
}
|
||||
public static GBeanInfo getGBeanInfo() {
|
||||
return GBEAN_INFO;
|
||||
}
|
||||
|
||||
public void beginTransaction() throws JMSException {
|
||||
pa.beginTransaction();
|
||||
}
|
||||
public void commitTransaction() throws JMSException {
|
||||
pa.commitTransaction();
|
||||
}
|
||||
public MessageStore createQueueMessageStore(String destinationName) throws JMSException {
|
||||
return pa.createQueueMessageStore(destinationName);
|
||||
}
|
||||
public TopicMessageStore createTopicMessageStore(String destinationName) throws JMSException {
|
||||
return pa.createTopicMessageStore(destinationName);
|
||||
}
|
||||
public TransactionStore createTransactionStore() throws JMSException {
|
||||
return pa.createTransactionStore();
|
||||
}
|
||||
public Map getInitialDestinations() {
|
||||
return pa.getInitialDestinations();
|
||||
}
|
||||
public void rollbackTransaction() {
|
||||
pa.rollbackTransaction();
|
||||
}
|
||||
public void start() throws JMSException {
|
||||
}
|
||||
public void stop() throws JMSException {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Hiram Chirino
|
||||
*
|
||||
* Licensed 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.activemq.store.jdbc;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface ResourceManager {
|
||||
public Object $getResource();
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Hiram Chirino
|
||||
*
|
||||
* Licensed 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.activemq.store.journal;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import org.apache.geronimo.gbean.GBeanInfo;
|
||||
import org.apache.geronimo.gbean.GBeanInfoBuilder;
|
||||
import org.apache.geronimo.gbean.GBeanLifecycle;
|
||||
import org.apache.geronimo.system.serverinfo.ServerInfo;
|
||||
import org.activemq.store.MessageStore;
|
||||
import org.activemq.store.PersistenceAdapter;
|
||||
import org.activemq.store.TopicMessageStore;
|
||||
import org.activemq.store.TransactionStore;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class JournalPersistenceAdapterGBean implements GBeanLifecycle, PersistenceAdapter {
|
||||
|
||||
private final PersistenceAdapter longTermPersistence;
|
||||
private final ServerInfo serverInfo;
|
||||
private final String directory;
|
||||
private JournalPersistenceAdapter persistenceAdapter;
|
||||
private final String journalType;
|
||||
|
||||
public JournalPersistenceAdapterGBean() {
|
||||
this(null, null, null, null);
|
||||
}
|
||||
|
||||
public JournalPersistenceAdapterGBean(ServerInfo serverInfo, PersistenceAdapter longTermPersistence, String directory, String journalType) {
|
||||
this.serverInfo = serverInfo;
|
||||
this.longTermPersistence = longTermPersistence;
|
||||
this.directory = directory;
|
||||
this.journalType = journalType;
|
||||
}
|
||||
|
||||
public void doStart() throws Exception {
|
||||
persistenceAdapter = new JournalPersistenceAdapter();
|
||||
persistenceAdapter.setLongTermPersistence(longTermPersistence);
|
||||
persistenceAdapter.setDirectory(serverInfo.resolve(directory));
|
||||
persistenceAdapter.setJournalType(journalType);
|
||||
persistenceAdapter.start();
|
||||
}
|
||||
|
||||
public void doStop() throws Exception {
|
||||
persistenceAdapter.stop();
|
||||
persistenceAdapter = null;
|
||||
}
|
||||
|
||||
public void doFail() {
|
||||
}
|
||||
|
||||
public static final GBeanInfo GBEAN_INFO;
|
||||
static {
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Persistence Journal", JournalPersistenceAdapterGBean.class, "JMSPersistence");
|
||||
infoFactory.addReference("serverInfo", ServerInfo.class);
|
||||
infoFactory.addReference("longTermPersistence", PersistenceAdapter.class);
|
||||
infoFactory.addAttribute("directory", String.class, true);
|
||||
infoFactory.addAttribute("journalType", String.class, true);
|
||||
infoFactory.addInterface(PersistenceAdapter.class);
|
||||
infoFactory.setConstructor(new String[]{"serverInfo", "longTermPersistence", "directory", "journalType"});
|
||||
GBEAN_INFO = infoFactory.getBeanInfo();
|
||||
}
|
||||
public static GBeanInfo getGBeanInfo() {
|
||||
return GBEAN_INFO;
|
||||
}
|
||||
|
||||
public void beginTransaction() throws JMSException {
|
||||
persistenceAdapter.beginTransaction();
|
||||
}
|
||||
public void commitTransaction() throws JMSException {
|
||||
persistenceAdapter.commitTransaction();
|
||||
}
|
||||
|
||||
public MessageStore createQueueMessageStore(String destinationName) throws JMSException {
|
||||
return persistenceAdapter.createQueueMessageStore(destinationName);
|
||||
}
|
||||
public TopicMessageStore createTopicMessageStore(String destinationName) throws JMSException {
|
||||
return persistenceAdapter.createTopicMessageStore(destinationName);
|
||||
}
|
||||
public TransactionStore createTransactionStore() throws JMSException {
|
||||
return persistenceAdapter.createTransactionStore();
|
||||
}
|
||||
public Map getInitialDestinations() {
|
||||
return persistenceAdapter.getInitialDestinations();
|
||||
}
|
||||
public void rollbackTransaction() {
|
||||
persistenceAdapter.rollbackTransaction();
|
||||
}
|
||||
public void start() throws JMSException {
|
||||
}
|
||||
public void stop() throws JMSException {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2004 Protique Ltd
|
||||
*
|
||||
* Licensed 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.activemq.gbean;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests to ensure that URL parsing and updating doesn't blow up
|
||||
*
|
||||
* @version $Revision: 1.0$
|
||||
*/
|
||||
public class ConnectorTest extends TestCase {
|
||||
public ActiveMQConnectorGBean test;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
|
||||
public void testURLManipulation() {
|
||||
test = new ActiveMQConnectorGBean(null, "foo", "localhost", 1234);
|
||||
assertEquals("foo://localhost:1234", test.getUrl());
|
||||
assertEquals("foo", test.getProtocol());
|
||||
assertEquals("localhost", test.getHost());
|
||||
assertEquals(1234, test.getPort());
|
||||
test.setHost("0.0.0.0");
|
||||
assertEquals("foo://0.0.0.0:1234", test.getUrl());
|
||||
assertEquals("foo", test.getProtocol());
|
||||
assertEquals("0.0.0.0", test.getHost());
|
||||
assertEquals(1234, test.getPort());
|
||||
test.setPort(8765);
|
||||
assertEquals("foo://0.0.0.0:8765", test.getUrl());
|
||||
assertEquals("foo", test.getProtocol());
|
||||
assertEquals("0.0.0.0", test.getHost());
|
||||
assertEquals(8765, test.getPort());
|
||||
test.setProtocol("bar");
|
||||
assertEquals("bar://0.0.0.0:8765", test.getUrl());
|
||||
assertEquals("bar", test.getProtocol());
|
||||
assertEquals("0.0.0.0", test.getHost());
|
||||
assertEquals(8765, test.getPort());
|
||||
test = new ActiveMQConnectorGBean(null, "vm", "localhost", -1);
|
||||
assertEquals("vm://localhost", test.getUrl());
|
||||
assertEquals("vm", test.getProtocol());
|
||||
assertEquals("localhost", test.getHost());
|
||||
assertEquals(-1, test.getPort());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue