mirror of https://github.com/apache/activemq.git
It Compiles!
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@388205 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a6063c923
commit
5026a89b88
|
@ -1,169 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,11 +17,7 @@
|
|||
**/
|
||||
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;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
|
||||
/**
|
||||
* An interface to the ActiveMQContainerGBean for use by the
|
||||
|
@ -29,13 +25,10 @@ import org.apache.geronimo.management.geronimo.JMSBroker;
|
|||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
public interface ActiveMQContainer extends ActiveMQBroker {
|
||||
|
||||
public abstract BrokerContainer getBrokerContainer();
|
||||
public abstract BrokerAdmin getBrokerAdmin();
|
||||
public interface BrokerServiceGBean extends ActiveMQBroker {
|
||||
|
||||
public abstract BrokerService getBrokerContainer();
|
||||
public String getBrokerName();
|
||||
public String getJaasConfiguration();
|
||||
public Properties getSecurityRoles();
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
*
|
||||
* 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.URI;
|
||||
|
||||
import org.apache.activemq.broker.BrokerFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Default implementation of the ActiveMQ Message Server
|
||||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
public class BrokerServiceGBeanImpl implements GBeanLifecycle, BrokerServiceGBean {
|
||||
|
||||
private Log log = LogFactory.getLog(getClass().getName());
|
||||
|
||||
private String brokerName;
|
||||
private final URI brokerUri;
|
||||
private BrokerService brokerService;
|
||||
|
||||
public BrokerServiceGBeanImpl() {
|
||||
brokerName = null;
|
||||
brokerUri=null;
|
||||
}
|
||||
|
||||
public BrokerServiceGBeanImpl(String brokerName, URI brokerUri) {
|
||||
assert brokerName != null;
|
||||
this.brokerName = brokerName;
|
||||
this.brokerUri=brokerUri;
|
||||
}
|
||||
|
||||
public synchronized BrokerService getBrokerContainer() {
|
||||
return brokerService;
|
||||
}
|
||||
|
||||
public synchronized void doStart() throws Exception {
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(BrokerServiceGBeanImpl.class.getClassLoader());
|
||||
try {
|
||||
if (brokerService == null) {
|
||||
brokerService = createContainer();
|
||||
brokerService.start();
|
||||
}
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
}
|
||||
|
||||
protected BrokerService createContainer() throws Exception {
|
||||
if( brokerUri!=null ) {
|
||||
BrokerService answer = BrokerFactory.createBroker(brokerUri);
|
||||
brokerName = answer.getBrokerName();
|
||||
return answer;
|
||||
} else {
|
||||
BrokerService answer = new BrokerService();
|
||||
answer.setBrokerName(brokerName);
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doStop() throws Exception {
|
||||
if (brokerService != null) {
|
||||
BrokerService temp = brokerService;
|
||||
brokerService = null;
|
||||
temp.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doFail() {
|
||||
if (brokerService != null) {
|
||||
BrokerService temp = brokerService;
|
||||
brokerService = null;
|
||||
try {
|
||||
temp.stop();
|
||||
} catch (Exception e) {
|
||||
log.info("Caught while closing due to failure: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final GBeanInfo GBEAN_INFO;
|
||||
|
||||
static {
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Message Broker", BrokerServiceGBeanImpl.class, "JMSServer");
|
||||
infoFactory.addAttribute("brokerName", String.class, true);
|
||||
infoFactory.addAttribute("brokerUri", URI.class, true);
|
||||
infoFactory.addInterface(BrokerServiceGBean.class);
|
||||
infoFactory.setConstructor(new String[]{"brokerName, brokerUri"});
|
||||
GBEAN_INFO = infoFactory.getBeanInfo();
|
||||
}
|
||||
|
||||
public static GBeanInfo getGBeanInfo() {
|
||||
return GBEAN_INFO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the brokerName.
|
||||
*/
|
||||
public String getBrokerName() {
|
||||
return brokerName;
|
||||
}
|
||||
|
||||
public URI getBrokerUri() {
|
||||
return brokerUri;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,32 +20,26 @@ package org.activemq.gbean;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import org.apache.activemq.broker.TransportConnector;
|
||||
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 {
|
||||
public class TransportConnectorGBeanImpl implements GBeanLifecycle, ActiveMQConnector {
|
||||
private Log log = LogFactory.getLog(getClass().getName());
|
||||
|
||||
private BrokerConnector brokerConnector;
|
||||
private ActiveMQContainer container;
|
||||
private WireFormat wireFormat = new DefaultWireFormat();
|
||||
private TransportConnector transportConnector;
|
||||
private BrokerServiceGBean brokerService;
|
||||
|
||||
private String protocol;
|
||||
private String host;
|
||||
private int port;
|
||||
|
@ -53,8 +47,8 @@ public class ActiveMQConnectorGBean implements GBeanLifecycle, ActiveMQConnector
|
|||
private String query;
|
||||
private String urlAsStarted;
|
||||
|
||||
public ActiveMQConnectorGBean(ActiveMQContainer container, String protocol, String host, int port) {
|
||||
this.container = container;
|
||||
public TransportConnectorGBeanImpl(BrokerServiceGBean brokerService, String protocol, String host, int port) {
|
||||
this.brokerService = brokerService;
|
||||
this.protocol = protocol;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
|
@ -108,27 +102,23 @@ public class ActiveMQConnectorGBean implements GBeanLifecycle, ActiveMQConnector
|
|||
}
|
||||
}
|
||||
|
||||
public WireFormat getWireFormat() {
|
||||
return wireFormat;
|
||||
}
|
||||
|
||||
public void setWireFormat(WireFormat wireFormat) {
|
||||
this.wireFormat = wireFormat;
|
||||
}
|
||||
|
||||
public InetSocketAddress getListenAddress() {
|
||||
return brokerConnector == null ? null : brokerConnector.getServerChannel().getSocketAddress();
|
||||
try {
|
||||
return transportConnector.getServer().getSocketAddress();
|
||||
} catch (Throwable e) {
|
||||
log.debug("Failure to determine ListenAddress: "+e,e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doStart() throws Exception {
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(ActiveMQContainerGBean.class.getClassLoader());
|
||||
Thread.currentThread().setContextClassLoader(BrokerServiceGBeanImpl.class.getClassLoader());
|
||||
try {
|
||||
if (brokerConnector == null) {
|
||||
if (transportConnector == null) {
|
||||
urlAsStarted = getUrl();
|
||||
brokerConnector = createBrokerConnector(urlAsStarted);
|
||||
brokerConnector.start();
|
||||
ActiveMQConnectionFactory.registerBroker(urlAsStarted, brokerConnector);
|
||||
transportConnector = createBrokerConnector(urlAsStarted);
|
||||
transportConnector.start();
|
||||
}
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
|
@ -136,40 +126,38 @@ public class ActiveMQConnectorGBean implements GBeanLifecycle, ActiveMQConnector
|
|||
}
|
||||
|
||||
public synchronized void doStop() throws Exception {
|
||||
if (brokerConnector != null) {
|
||||
ActiveMQConnectionFactory.unregisterBroker(urlAsStarted);
|
||||
BrokerConnector temp = brokerConnector;
|
||||
brokerConnector = null;
|
||||
if (transportConnector != null) {
|
||||
TransportConnector temp = transportConnector;
|
||||
transportConnector = null;
|
||||
temp.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void doFail() {
|
||||
if (brokerConnector != null) {
|
||||
BrokerConnector temp = brokerConnector;
|
||||
brokerConnector = null;
|
||||
if (transportConnector != null) {
|
||||
TransportConnector temp = transportConnector;
|
||||
transportConnector = null;
|
||||
try {
|
||||
temp.stop();
|
||||
}
|
||||
catch (JMSException e) {
|
||||
catch (Exception 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);
|
||||
protected TransportConnector createBrokerConnector(String url) throws Exception {
|
||||
return brokerService.getBrokerContainer().addConnector(url);
|
||||
}
|
||||
|
||||
public static final GBeanInfo GBEAN_INFO;
|
||||
|
||||
static {
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Message Broker Connector", ActiveMQConnectorGBean.class, CONNECTOR_J2EE_TYPE);
|
||||
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Transport Connector", TransportConnectorGBeanImpl.class, CONNECTOR_J2EE_TYPE);
|
||||
infoFactory.addAttribute("url", String.class.getName(), false);
|
||||
infoFactory.addAttribute("wireFormat", WireFormat.class.getName(), false);
|
||||
infoFactory.addReference("activeMQContainer", ActiveMQContainer.class);
|
||||
infoFactory.addReference("brokerService", BrokerServiceGBean.class);
|
||||
infoFactory.addInterface(ActiveMQConnector.class, new String[]{"host","port","protocol","path","query"});
|
||||
infoFactory.setConstructor(new GConstructorInfo(new String[]{"activeMQContainer", "protocol", "host", "port"}));
|
||||
infoFactory.setConstructor(new GConstructorInfo(new String[]{"brokerService", "protocol", "host", "port"}));
|
||||
GBEAN_INFO = infoFactory.getBeanInfo();
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ import javax.management.MalformedObjectNameException;
|
|||
import org.activemq.gbean.ActiveMQManager;
|
||||
import org.activemq.gbean.ActiveMQBroker;
|
||||
import org.activemq.gbean.ActiveMQConnector;
|
||||
import org.activemq.gbean.ActiveMQConnectorGBean;
|
||||
import org.activemq.gbean.TransportConnectorGBeanImpl;
|
||||
import org.apache.geronimo.gbean.GBeanInfo;
|
||||
import org.apache.geronimo.gbean.GBeanInfoBuilder;
|
||||
import org.apache.geronimo.gbean.GBeanQuery;
|
||||
|
@ -41,7 +41,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
/**
|
||||
* Implementation of the ActiveMQ management interface. These are the ActiveMQ
|
||||
* mangement features available at runtime.
|
||||
* management features available at runtime.
|
||||
*
|
||||
* @version $Revision: 1.0$
|
||||
*/
|
||||
|
@ -66,8 +66,7 @@ public class ActiveMQManagerGBean implements ActiveMQManager {
|
|||
}
|
||||
|
||||
public String[] getSupportedProtocols() {
|
||||
// see files in modules/core/src/conf/META-INF/services/org/activemq/transport/server/
|
||||
return new String[]{"activeio","jabber","multicast","openwire","peer","stomp","tcp","udp","vm",};
|
||||
return new String[]{"tcp","vm","ssl", "udp", "nio"};
|
||||
}
|
||||
|
||||
public String[] getConnectors() {
|
||||
|
@ -112,7 +111,7 @@ public class ActiveMQManagerGBean implements ActiveMQManager {
|
|||
for (Iterator it = set.iterator(); it.hasNext();) {
|
||||
ObjectName name = (ObjectName) it.next(); // a single ActiveMQ connector
|
||||
GBeanData data = kernel.getGBeanData(name);
|
||||
Set refs = data.getReferencePatterns("activeMQContainer");
|
||||
Set refs = data.getReferencePatterns("brokerService");
|
||||
for (Iterator refit = refs.iterator(); refit.hasNext();) {
|
||||
ObjectName ref = (ObjectName) refit.next();
|
||||
if(ref.isPattern()) {
|
||||
|
@ -152,7 +151,7 @@ public class ActiveMQManagerGBean implements ActiveMQManager {
|
|||
for (Iterator it = set.iterator(); it.hasNext();) {
|
||||
ObjectName name = (ObjectName) it.next(); // a single ActiveMQ connector
|
||||
GBeanData data = kernel.getGBeanData(name);
|
||||
Set refs = data.getReferencePatterns("activeMQContainer");
|
||||
Set refs = data.getReferencePatterns("brokerService");
|
||||
for (Iterator refit = refs.iterator(); refit.hasNext();) {
|
||||
ObjectName ref = (ObjectName) refit.next();
|
||||
boolean match = false;
|
||||
|
@ -203,12 +202,12 @@ public class ActiveMQManagerGBean implements ActiveMQManager {
|
|||
throw new IllegalArgumentException("Unable to parse ObjectName '"+broker+"'");
|
||||
}
|
||||
ObjectName name = getConnectorName(brokerName, protocol, host, port, uniqueName);
|
||||
GBeanData connector = new GBeanData(name, ActiveMQConnectorGBean.GBEAN_INFO);
|
||||
GBeanData connector = new GBeanData(name, TransportConnectorGBeanImpl.GBEAN_INFO);
|
||||
//todo: if SSL is supported, need to add more properties or use a different GBean?
|
||||
connector.setAttribute("protocol", protocol);
|
||||
connector.setAttribute("host", host);
|
||||
connector.setAttribute("port", new Integer(port));
|
||||
connector.setReferencePattern("activeMQContainer", brokerName);
|
||||
connector.setReferencePattern("brokerService", brokerName);
|
||||
ObjectName config = Util.getConfiguration(kernel, brokerName);
|
||||
try {
|
||||
kernel.invoke(config, "addGBean", new Object[]{connector, Boolean.FALSE}, new String[]{GBeanData.class.getName(), boolean.class.getName()});
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* 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 {
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* 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 {
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* 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();
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* 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 {
|
||||
}
|
||||
}
|
|
@ -25,13 +25,13 @@ import junit.framework.TestCase;
|
|||
* @version $Revision: 1.0$
|
||||
*/
|
||||
public class ConnectorTest extends TestCase {
|
||||
public ActiveMQConnectorGBean test;
|
||||
public TransportConnectorGBeanImpl test;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
|
||||
public void testURLManipulation() {
|
||||
test = new ActiveMQConnectorGBean(null, "foo", "localhost", 1234);
|
||||
test = new TransportConnectorGBeanImpl(null, "foo", "localhost", 1234);
|
||||
assertEquals("foo://localhost:1234", test.getUrl());
|
||||
assertEquals("foo", test.getProtocol());
|
||||
assertEquals("localhost", test.getHost());
|
||||
|
@ -51,7 +51,7 @@ public class ConnectorTest extends TestCase {
|
|||
assertEquals("bar", test.getProtocol());
|
||||
assertEquals("0.0.0.0", test.getHost());
|
||||
assertEquals(8765, test.getPort());
|
||||
test = new ActiveMQConnectorGBean(null, "vm", "localhost", -1);
|
||||
test = new TransportConnectorGBeanImpl(null, "vm", "localhost", -1);
|
||||
assertEquals("vm://localhost", test.getUrl());
|
||||
assertEquals("vm", test.getProtocol());
|
||||
assertEquals("localhost", test.getHost());
|
||||
|
|
Loading…
Reference in New Issue