diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/FutureResponse.java b/activemq-core/src/main/java/org/apache/activemq/transport/FutureResponse.java index 9e831f3421..44daf7f6be 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/FutureResponse.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/FutureResponse.java @@ -37,17 +37,15 @@ public class FutureResponse { } public Response getResult() throws IOException { - while (true) { - try { - return (Response) responseSlot.take(); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - if (log.isDebugEnabled()) { - log.debug("Operation interupted: " + e, e); - } - // throw new InterruptedIOException("Interrupted."); + try { + return (Response) responseSlot.take(); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + if (log.isDebugEnabled()) { + log.debug("Operation interupted: " + e, e); } + throw new InterruptedIOException("Interrupted."); } } @@ -60,13 +58,10 @@ public class FutureResponse { } public void set(Response result) throws InterruptedIOException { - try { - responseSlot.put(result); - } catch (InterruptedException e) { - throw new InterruptedIOException("Interrupted."); + if( responseSlot.offer(result) ) { + if( responseCallback !=null ) { + responseCallback.onCompletion(this); + } } - if( responseCallback !=null ) { - responseCallback.onCompletion(this); - } } } diff --git a/activemq-gbean-management/pom.xml b/activemq-gbean-management/pom.xml deleted file mode 100644 index 768fcd1efb..0000000000 --- a/activemq-gbean-management/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - 4.0.0 - - - incubator-activemq - activemq-parent - 4.1-SNAPSHOT - ../pom.xml - - - activemq-gbean-management - ActiveMQ :: GBean Interfaces - - - src/main/java - - - - - - geronimo - geronimo-management - 1.2-SNAPSHOT - - - - backport-util-concurrent - backport-util-concurrent - - - log4j - log4j - - - diff --git a/activemq-gbean-management/project.properties b/activemq-gbean-management/project.properties deleted file mode 100755 index c7670b384c..0000000000 --- a/activemq-gbean-management/project.properties +++ /dev/null @@ -1,9 +0,0 @@ -# ------------------------------------------------------------------- -# Build Properties -# ------------------------------------------------------------------- -maven.multiproject.type=jar - -maven.repo.remote=\ -http://www.ibiblio.org/maven,\ -http://dist.codehaus.org,\ -http://people.apache.org/repository diff --git a/activemq-gbean-management/project.xml b/activemq-gbean-management/project.xml deleted file mode 100755 index 2b63aa0a22..0000000000 --- a/activemq-gbean-management/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - 3 - ${basedir}/../etc/project.xml - - ActiveMQ :: GBean Interfaces - activemq-gbean-management - Geronimo / GBean management support - ActiveMQ management interfaces used for integration into Apache Geronimo - - org.activemq.gbean - - - Geronimo / GBean management support - org.activemq.gbean - - - - - - - - - geronimo - geronimo-management - ${geronimo_management_version} - - - - diff --git a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQBroker.java b/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQBroker.java deleted file mode 100644 index 7b0e08f1a0..0000000000 --- a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQBroker.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -import org.apache.geronimo.management.geronimo.JMSBroker; - -/** - * The management interface for the ActiveMQ broker GBean. - * This is separate from ActiveMQContainer because that interface has hard - * links to code in activemq-core, yet we still want to be able to - * distinguish ActiveMQ brokers from non-ActiveMQ JMS brokers. - * - * @version $Revision: 1.0$ - */ -public interface ActiveMQBroker extends JMSBroker { -} diff --git a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQConnector.java b/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQConnector.java deleted file mode 100644 index 7afb11d3b9..0000000000 --- a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQConnector.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -import org.apache.geronimo.management.geronimo.JMSConnector; - -/** - * The GBean interface for the ActiveMQ network connector GBean - * - * @version $Revision: 1.0$ - */ -public interface ActiveMQConnector extends JMSConnector { - public final static String CONNECTOR_J2EE_TYPE = "JMSConnector"; - - // Additional stuff you can add to an ActiveMQ connector URI - public String getPath(); - public void setPath(String path); - public String getQuery(); - public void setQuery(String query); -} diff --git a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQManager.java b/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQManager.java deleted file mode 100644 index 316269383d..0000000000 --- a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/ActiveMQManager.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -import org.apache.geronimo.management.geronimo.JMSManager; - -/** - * The GBean interface for the ActiveMQ management GBean. This defines the - * features that should be available to the management interface at runtime. - * - * @version $Revision: 1.0$ - */ -public interface ActiveMQManager extends JMSManager { -} diff --git a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/package.html b/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/package.html deleted file mode 100755 index f7d94b0e17..0000000000 --- a/activemq-gbean-management/src/main/java/org/apache/activemq/gbean/package.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - -

- The management API for ActiveMQ, when run in a - container like Geronimo -

- - - diff --git a/activemq-gbean/pom.xml b/activemq-gbean/pom.xml deleted file mode 100644 index 966850ecea..0000000000 --- a/activemq-gbean/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - 4.0.0 - - - incubator-activemq - activemq-parent - 4.1-SNAPSHOT - ../pom.xml - - - activemq-gbean - ActiveMQ :: GBeans - - - - - ${pom.groupId} - activemq-core - - - ${pom.groupId} - activemq-gbean-management - - - ${pom.groupId} - activeio-core - - - - - geronimo - geronimo-kernel - 1.2-SNAPSHOT - - - geronimo - geronimo-system - 1.2-SNAPSHOT - - - geronimo - geronimo-management - 1.2-SNAPSHOT - - - geronimo - geronimo-j2ee - 1.2-SNAPSHOT - - - - commons-logging - commons-logging - - - mx4j - mx4j - - - junit - junit - test - - - - - src/main/java - src/test - - - maven-surefire-plugin - - - **/*Test.* - - - - - - - - - diff --git a/activemq-gbean/project.properties b/activemq-gbean/project.properties deleted file mode 100755 index c7670b384c..0000000000 --- a/activemq-gbean/project.properties +++ /dev/null @@ -1,9 +0,0 @@ -# ------------------------------------------------------------------- -# Build Properties -# ------------------------------------------------------------------- -maven.multiproject.type=jar - -maven.repo.remote=\ -http://www.ibiblio.org/maven,\ -http://dist.codehaus.org,\ -http://people.apache.org/repository diff --git a/activemq-gbean/project.xml b/activemq-gbean/project.xml deleted file mode 100755 index 11aa746ed4..0000000000 --- a/activemq-gbean/project.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - 3 - ${basedir}/../etc/project.xml - - ActiveMQ :: GBeans - activemq-gbean - Geronimo / GBean support - ActiveMQ GBeans used for integration into Apache Geronimo - - org.activemq.gbean - - - Geronimo / GBean support - org.activemq.gbean - - - - - - - - - - ${pom.groupId} - activemq-core - ${pom.currentVersion} - - true - - - - ${pom.groupId} - activeio-core - ${activeio_version} - - - - ${pom.groupId} - activemq-gbean-management - ${pom.currentVersion} - - true - - - - ${pom.groupId} - activemq-core-test - ${pom.currentVersion} - - - - geronimo - geronimo-kernel - ${geronimo_kernel_version} - - - geronimo - geronimo-system - ${geronimo_system_version} - - - geronimo - geronimo-management - ${geronimo_management_version} - - - geronimo - geronimo-j2ee - ${geronimo_j2ee_version} - - - - - mx4j - mx4j - ${mx4j_version} - - - - diff --git a/activemq-gbean/src/main/java/org/apache/activemq/gbean/BrokerServiceGBean.java b/activemq-gbean/src/main/java/org/apache/activemq/gbean/BrokerServiceGBean.java deleted file mode 100755 index 6669daf6b3..0000000000 --- a/activemq-gbean/src/main/java/org/apache/activemq/gbean/BrokerServiceGBean.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.gbean.ActiveMQBroker; - -/** - * An interface to the ActiveMQContainerGBean for use by the - * ActiveMQConnectorGBean. - * - * @version $Revision: 1.1.1.1 $ - */ -public interface BrokerServiceGBean extends ActiveMQBroker { - - public abstract BrokerService getBrokerContainer(); - public String getBrokerName(); - - -} \ No newline at end of file diff --git a/activemq-gbean/src/main/java/org/apache/activemq/gbean/BrokerServiceGBeanImpl.java b/activemq-gbean/src/main/java/org/apache/activemq/gbean/BrokerServiceGBeanImpl.java deleted file mode 100755 index a2d0f2dd5d..0000000000 --- a/activemq-gbean/src/main/java/org/apache/activemq/gbean/BrokerServiceGBeanImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -import java.net.URI; - -import javax.sql.DataSource; - -import org.apache.activemq.broker.BrokerFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.store.DefaultPersistenceAdapterFactory; -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.system.serverinfo.ServerInfo; - - -/** - * 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 String brokerUri; - private BrokerService brokerService; - private ServerInfo serverInfo; - private String dataDirectory; - private DataSourceReference dataSource; - - public BrokerServiceGBeanImpl() { - } - - 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(); - } - DefaultPersistenceAdapterFactory persistenceFactory = (DefaultPersistenceAdapterFactory) brokerService.getPersistenceFactory(); - persistenceFactory.setDataDirectory(serverInfo.resolve(dataDirectory)); - persistenceFactory.setDataSource((DataSource) dataSource.$getResource()); - brokerService.start(); - } finally { - Thread.currentThread().setContextClassLoader(old); - } - } - - protected BrokerService createContainer() throws Exception { - if( brokerUri!=null ) { - BrokerService answer = BrokerFactory.createBroker(new URI(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.addReference("serverInfo", ServerInfo.class); - infoFactory.addAttribute("brokerName", String.class, true); - infoFactory.addAttribute("brokerUri", String.class, true); - infoFactory.addAttribute("dataDirectory", String.class, true); - infoFactory.addReference("dataSource", DataSourceReference.class); - 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 String getBrokerUri() { - return brokerUri; - } - - public void setBrokerName(String brokerName) { - this.brokerName = brokerName; - } - - public void setBrokerUri(String brokerUri) { - this.brokerUri = brokerUri; - } - - public ServerInfo getServerInfo() { - return serverInfo; - } - - public void setServerInfo(ServerInfo serverInfo) { - this.serverInfo = serverInfo; - } - - public String getDataDirectory() { - return dataDirectory; - } - - public void setDataDirectory(String dataDir) { - this.dataDirectory = dataDir; - } - - public DataSourceReference getDataSource() { - return dataSource; - } - - public void setDataSource(DataSourceReference dataSource) { - this.dataSource = dataSource; - } - - -} \ No newline at end of file diff --git a/activemq-gbean/src/main/java/org/apache/activemq/gbean/DataSourceReference.java b/activemq-gbean/src/main/java/org/apache/activemq/gbean/DataSourceReference.java deleted file mode 100644 index b02352af72..0000000000 --- a/activemq-gbean/src/main/java/org/apache/activemq/gbean/DataSourceReference.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -public interface DataSourceReference { - public Object $getResource(); -} diff --git a/activemq-gbean/src/main/java/org/apache/activemq/gbean/TransportConnectorGBeanImpl.java b/activemq-gbean/src/main/java/org/apache/activemq/gbean/TransportConnectorGBeanImpl.java deleted file mode 100755 index ad5ec9919e..0000000000 --- a/activemq-gbean/src/main/java/org/apache/activemq/gbean/TransportConnectorGBeanImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -import java.net.InetSocketAddress; -import java.net.URI; -import java.net.URISyntaxException; - -import org.apache.activemq.broker.TransportConnector; -import org.apache.activemq.gbean.ActiveMQConnector; -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; - -/** - * Default implementation of the ActiveMQ connector - * - * @version $Revision: 1.1.1.1 $ - */ -public class TransportConnectorGBeanImpl implements GBeanLifecycle, ActiveMQConnector { - private Log log = LogFactory.getLog(getClass().getName()); - - private TransportConnector transportConnector; - private BrokerServiceGBean brokerService; - - private String protocol; - private String host; - private int port; - private String path; - private String query; - private String urlAsStarted; - - public TransportConnectorGBeanImpl(BrokerServiceGBean brokerService, String protocol, String host, int port) { - this.brokerService = brokerService; - 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 InetSocketAddress getListenAddress() { - 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(BrokerServiceGBeanImpl.class.getClassLoader()); - try { - if (transportConnector == null) { - urlAsStarted = getUrl(); - transportConnector = createBrokerConnector(urlAsStarted); - transportConnector.start(); - } - } finally { - Thread.currentThread().setContextClassLoader(old); - } - } - - public synchronized void doStop() throws Exception { - if (transportConnector != null) { - TransportConnector temp = transportConnector; - transportConnector = null; - temp.stop(); - } - } - - public synchronized void doFail() { - if (transportConnector != null) { - TransportConnector temp = transportConnector; - transportConnector = null; - try { - temp.stop(); - } - catch (Exception e) { - log.info("Caught while closing due to failure: " + e, e); - } - } - } - - protected TransportConnector createBrokerConnector(String url) throws Exception { - return brokerService.getBrokerContainer().addConnector(url); - } - - public static final GBeanInfo GBEAN_INFO; - - static { - GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Transport Connector", TransportConnectorGBeanImpl.class, CONNECTOR_J2EE_TYPE); - infoFactory.addAttribute("url", String.class.getName(), false); - infoFactory.addReference("brokerService", BrokerServiceGBean.class); - infoFactory.addInterface(ActiveMQConnector.class, new String[]{"host","port","protocol","path","query"}); - infoFactory.setConstructor(new GConstructorInfo(new String[]{"brokerService", "protocol", "host", "port"})); - GBEAN_INFO = infoFactory.getBeanInfo(); - } - - public static GBeanInfo getGBeanInfo() { - return GBEAN_INFO; - } -} diff --git a/activemq-gbean/src/main/java/org/apache/activemq/gbean/management/ActiveMQManagerGBean.java b/activemq-gbean/src/main/java/org/apache/activemq/gbean/management/ActiveMQManagerGBean.java deleted file mode 100644 index 2755662e07..0000000000 --- a/activemq-gbean/src/main/java/org/apache/activemq/gbean/management/ActiveMQManagerGBean.java +++ /dev/null @@ -1,281 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean.management; - -import java.util.Set; -import java.util.Iterator; -import java.util.ArrayList; -import java.util.List; -import java.util.Hashtable; -import javax.management.ObjectName; -import javax.management.MalformedObjectNameException; -import org.apache.geronimo.gbean.GBeanInfo; -import org.apache.geronimo.gbean.GBeanInfoBuilder; -import org.apache.geronimo.gbean.GBeanQuery; -import org.apache.geronimo.gbean.GBeanData; -import org.apache.geronimo.kernel.Kernel; -import org.apache.geronimo.kernel.GBeanNotFoundException; -import org.apache.geronimo.j2ee.management.impl.Util; -import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; -import org.apache.activemq.gbean.ActiveMQBroker; -import org.apache.activemq.gbean.ActiveMQConnector; -import org.apache.activemq.gbean.ActiveMQManager; -import org.apache.activemq.gbean.TransportConnectorGBeanImpl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Implementation of the ActiveMQ management interface. These are the ActiveMQ - * management features available at runtime. - * - * @version $Revision: 1.0$ - */ -public class ActiveMQManagerGBean implements ActiveMQManager { - private static final Log log = LogFactory.getLog(ActiveMQManagerGBean.class.getName()); - private Kernel kernel; - - public ActiveMQManagerGBean(Kernel kernel) { - this.kernel = kernel; - } - - public String[] getContainers() { - GBeanQuery query = new GBeanQuery(null, ActiveMQBroker.class.getName()); - Set set = kernel.listGBeans(query); - String[] results = new String[set.size()]; - int i=0; - for (Iterator it = set.iterator(); it.hasNext();) { - ObjectName name = (ObjectName) it.next(); - results[i++] = name.getCanonicalName(); - } - return results; - } - - public String[] getSupportedProtocols() { - return new String[]{"tcp","vm","ssl", "udp", "nio"}; - } - - public String[] getConnectors() { - GBeanQuery query = new GBeanQuery(null, ActiveMQConnector.class.getName()); - Set set = kernel.listGBeans(query); - String[] results = new String[set.size()]; - int i=0; - for (Iterator it = set.iterator(); it.hasNext();) { - ObjectName name = (ObjectName) it.next(); - results[i++] = name.getCanonicalName(); - } - return results; - } - - public String[] getConnectors(String protocol) { - if(protocol == null) { - return getConnectors(); - } - GBeanQuery query = new GBeanQuery(null, ActiveMQConnector.class.getName()); - Set set = kernel.listGBeans(query); - List results = new ArrayList(); - for (Iterator it = set.iterator(); it.hasNext();) { - ObjectName name = (ObjectName) it.next(); - try { - String target = (String) kernel.getAttribute(name, "protocol"); - if(target != null && target.equals(protocol)) { - results.add(name.getCanonicalName()); - } - } catch (Exception e) { - log.error("Unable to look up protocol for connector '"+name+"'",e); - } - } - return (String[]) results.toArray(new String[results.size()]); - } - - public String[] getConnectorsForContainer(String broker) { - try { - ObjectName brokerName = ObjectName.getInstance(broker); - List results = new ArrayList(); - GBeanQuery query = new GBeanQuery(null, ActiveMQConnector.class.getName()); - Set set = kernel.listGBeans(query); // all ActiveMQ connectors - 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("brokerService"); - for (Iterator refit = refs.iterator(); refit.hasNext();) { - ObjectName ref = (ObjectName) refit.next(); - if(ref.isPattern()) { - Set matches = kernel.listGBeans(ref); - if(matches.size() != 1) { - log.error("Unable to compare a connector->container reference that's a pattern to a fixed container name: "+ref.getCanonicalName()); - } else { - ref = (ObjectName)matches.iterator().next(); - if(ref.equals(brokerName)) { - results.add(name.getCanonicalName()); - break; - } - } - } else { - if(ref.equals(brokerName)) { - results.add(name.getCanonicalName()); - break; - } - } - } - } - return (String[]) results.toArray(new String[results.size()]); - } catch (Exception e) { - throw new IllegalArgumentException("Unable to look up connectors for broker '"+broker+"': "+e); - } - } - - public String[] getConnectorsForContainer(String broker, String protocol) { - if(protocol == null) { - return getConnectorsForContainer(broker); - } - try { - ObjectName brokerName = ObjectName.getInstance(broker); - List results = new ArrayList(); - GBeanQuery query = new GBeanQuery(null, ActiveMQConnector.class.getName()); - Set set = kernel.listGBeans(query); // all ActiveMQ connectors - 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("brokerService"); - for (Iterator refit = refs.iterator(); refit.hasNext();) { - ObjectName ref = (ObjectName) refit.next(); - boolean match = false; - if(ref.isPattern()) { - Set matches = kernel.listGBeans(ref); - if(matches.size() != 1) { - log.error("Unable to compare a connector->container reference that's a pattern to a fixed container name: "+ref.getCanonicalName()); - } else { - ref = (ObjectName)matches.iterator().next(); - if(ref.equals(brokerName)) { - match = true; - } - } - } else { - if(ref.equals(brokerName)) { - match = true; - } - } - if(match) { - try { - String testProtocol = (String) kernel.getAttribute(name, "protocol"); - if(testProtocol != null && testProtocol.equals(protocol)) { - results.add(name.getCanonicalName()); - } - } catch (Exception e) { - log.error("Unable to look up protocol for connector '"+name+"'",e); - } - break; - } - } - } - return (String[]) results.toArray(new String[results.size()]); - } catch (Exception e) { - throw new IllegalArgumentException("Unable to look up connectors for broker '"+broker+"': "+e); - } - } - - /** - * Creates a new connector, and returns the ObjectName for it. Note that - * the connector may well require further customization before being fully - * functional (e.g. SSL settings for a secure connector). - */ - public String addConnector(String broker, String uniqueName, String protocol, String host, int port) { - ObjectName brokerName = null; - try { - brokerName = ObjectName.getInstance(broker); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Unable to parse ObjectName '"+broker+"'"); - } - ObjectName name = getConnectorName(brokerName, protocol, host, port, uniqueName); - 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("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()}); - } catch (Exception e) { - log.error("Unable to add GBean ", e); - return null; - } - return name.getCanonicalName(); - } - - public void removeConnector(String objectName) { - ObjectName name = null; - try { - name = ObjectName.getInstance(objectName); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Invalid object name '" + objectName + "': " + e.getMessage()); - } - try { - GBeanInfo info = kernel.getGBeanInfo(name); - boolean found = false; - Set intfs = info.getInterfaces(); - for (Iterator it = intfs.iterator(); it.hasNext();) { - String intf = (String) it.next(); - if (intf.equals(ActiveMQConnector.class.getName())) { - found = true; - } - } - if (!found) { - throw new GBeanNotFoundException(name); - } - ObjectName config = Util.getConfiguration(kernel, name); - kernel.invoke(config, "removeGBean", new Object[]{name}, new String[]{ObjectName.class.getName()}); - } catch (GBeanNotFoundException e) { - log.warn("No such GBean '" + objectName + "'"); //todo: what if we want to remove a failed GBean? - } catch (Exception e) { - log.error("Unable to remove GBean", e); - } - } - - /** - * Generate an ObjectName for a new connector GBean - */ - private ObjectName getConnectorName(ObjectName broker, String protocol, String host, int port, String uniqueName) { - Hashtable table = new Hashtable(); - table.put(NameFactory.J2EE_APPLICATION, broker.getKeyProperty(NameFactory.J2EE_APPLICATION)); - table.put(NameFactory.J2EE_SERVER, broker.getKeyProperty(NameFactory.J2EE_SERVER)); - table.put(NameFactory.J2EE_MODULE, broker.getKeyProperty(NameFactory.J2EE_MODULE)); - table.put(NameFactory.J2EE_TYPE, ActiveMQConnector.CONNECTOR_J2EE_TYPE); - String brokerName = broker.getKeyProperty(NameFactory.J2EE_NAME); - table.put("broker", brokerName); - table.put(NameFactory.J2EE_NAME, brokerName+"."+protocol+"."+host+(port > -1 ? "."+port : "")+"-"+uniqueName); - try { - return ObjectName.getInstance(broker.getDomain(), table); - } catch (MalformedObjectNameException e) { - throw new IllegalStateException("Never should have failed: " + e.getMessage()); - } - } - - public static final GBeanInfo GBEAN_INFO; - - static { - GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Manager", ActiveMQManagerGBean.class); - infoFactory.addAttribute("kernel", Kernel.class, false); - infoFactory.addInterface(ActiveMQManager.class); - infoFactory.setConstructor(new String[]{"kernel"}); - GBEAN_INFO = infoFactory.getBeanInfo(); - } - - public static GBeanInfo getGBeanInfo() { - return GBEAN_INFO; - } -} diff --git a/activemq-gbean/src/main/java/org/apache/activemq/gbean/package.html b/activemq-gbean/src/main/java/org/apache/activemq/gbean/package.html deleted file mode 100755 index a30d48d3de..0000000000 --- a/activemq-gbean/src/main/java/org/apache/activemq/gbean/package.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - -

- The JMS container using GBeaps for deployment in Geronimo or other JSR 77/88 based containers -

- - - diff --git a/activemq-gbean/src/test/java/org/apache/activemq/gbean/ConnectorTest.java b/activemq-gbean/src/test/java/org/apache/activemq/gbean/ConnectorTest.java deleted file mode 100644 index 6b520669df..0000000000 --- a/activemq-gbean/src/test/java/org/apache/activemq/gbean/ConnectorTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * Copyright 2005-2006 The Apache Software Foundation - * - * 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.apache.activemq.gbean; - -import org.apache.activemq.gbean.TransportConnectorGBeanImpl; - -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 TransportConnectorGBeanImpl test; - - protected void setUp() throws Exception { - } - - public void testURLManipulation() { - test = new TransportConnectorGBeanImpl(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 TransportConnectorGBeanImpl(null, "vm", "localhost", -1); - assertEquals("vm://localhost", test.getUrl()); - assertEquals("vm", test.getProtocol()); - assertEquals("localhost", test.getHost()); - assertEquals(-1, test.getPort()); - } -}