Author: chirino
Date: Thu Mar 23 08:40:24 2006
New Revision: 388205
URL: http://svn.apache.org/viewcvs?rev=388205&view=rev
Log:
It Compiles!
Added:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBean.java
- copied, changed from r388193,
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainer.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBeanImpl.java
- copied, changed from r388193,
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainerGBean.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/TransportConnectorGBeanImpl.java
(with props)
Removed:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQConnectorGBean.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainer.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainerGBean.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/store/cache/SimpleCachePersistenceAdapterGBean.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/store/jdbc/JDBCPersistenceAdapterGBean.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/store/jdbc/ResourceManager.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/store/journal/JournalPersistenceAdapterGBean.java
Modified:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/management/ActiveMQManagerGBean.java
incubator/activemq/trunk/sandbox/activemq-gbean/src/test/java/org/activemq/gbean/ConnectorTest.java
Copied:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBean.java
(from r388193,
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainer.java)
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBean.java?p2=incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBean.java&p1=incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainer.java&r1=388193&r2=388205&rev=388205&view=diff
==============================================================================
---
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainer.java
(original)
+++
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBean.java
Thu Mar 23 08:40:24 2006
@@ -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 @@
*
* @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();
+
}
Copied:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBeanImpl.java
(from r388193,
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainerGBean.java)
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBeanImpl.java?p2=incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBeanImpl.java&p1=incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainerGBean.java&r1=388193&r2=388205&rev=388205&view=diff
==============================================================================
---
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/ActiveMQContainerGBean.java
(original)
+++
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/BrokerServiceGBeanImpl.java
Thu Mar 23 08:40:24 2006
@@ -17,127 +17,97 @@
**/
package org.activemq.gbean;
-import java.util.Properties;
-import javax.jms.JMSException;
+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;
-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 {
+public class BrokerServiceGBeanImpl implements GBeanLifecycle,
BrokerServiceGBean {
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;
+ private String brokerName;
+ private final URI brokerUri;
+ private BrokerService brokerService;
- //default constructor for use as gbean endpoint.
- public ActiveMQContainerGBean() {
+ public BrokerServiceGBeanImpl() {
brokerName = null;
- jaasConfiguration = null;
- securityRoles = null;
- persistenceAdapter=null;
+ brokerUri=null;
}
- public ActiveMQContainerGBean(String brokerName, PersistenceAdapter
persistenceAdapter, String jaasConfiguration, Properties securityRoles) {
-
+ public BrokerServiceGBeanImpl(String brokerName, URI brokerUri) {
assert brokerName != null;
- assert persistenceAdapter != null;
-
this.brokerName = brokerName;
- this.jaasConfiguration=jaasConfiguration;
- this.persistenceAdapter = persistenceAdapter;
- this.securityRoles = securityRoles;
- }
-
- public synchronized BrokerContainer getBrokerContainer() {
- return container;
+ this.brokerUri=brokerUri;
}
- /**
- * @see org.activemq.gbean.ActiveMQContainer#getBrokerAdmin()
- */
- public BrokerAdmin getBrokerAdmin() {
- return container.getBroker().getBrokerAdmin();
+ public synchronized BrokerService getBrokerContainer() {
+ return brokerService;
}
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);
- }
+ 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 (container != null) {
- BrokerContainer temp = container;
- container = null;
+ if (brokerService != null) {
+ BrokerService temp = brokerService;
+ brokerService = null;
temp.stop();
}
}
public synchronized void doFail() {
- if (container != null) {
- BrokerContainer temp = container;
- container = null;
+ if (brokerService != null) {
+ BrokerService temp = brokerService;
+ brokerService = null;
try {
temp.stop();
- }
- catch (JMSException e) {
+ } catch (Exception 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");
+ GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("ActiveMQ Message
Broker", BrokerServiceGBeanImpl.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"});
+ infoFactory.addAttribute("brokerUri", URI.class, true);
+ infoFactory.addInterface(BrokerServiceGBean.class);
+ infoFactory.setConstructor(new String[]{"brokerName, brokerUri"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
@@ -151,19 +121,10 @@
public String getBrokerName() {
return brokerName;
}
-
- /**
- * @return Returns the jassConfiguration.
- */
- public String getJaasConfiguration() {
- return jaasConfiguration;
- }
-
- /**
- * @return Returns the securityRoles.
- */
- public Properties getSecurityRoles() {
- return securityRoles;
- }
+
+ public URI getBrokerUri() {
+ return brokerUri;
+ }
+
}
Added:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/TransportConnectorGBeanImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/TransportConnectorGBeanImpl.java?rev=388205&view=auto
==============================================================================
---
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/TransportConnectorGBeanImpl.java
(added)
+++
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/TransportConnectorGBeanImpl.java
Thu Mar 23 08:40:24 2006
@@ -0,0 +1,167 @@
+/**
+ *
+ * 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 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;
+
+/**
+ * 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;
+ }
+}
Propchange:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/TransportConnectorGBeanImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/TransportConnectorGBeanImpl.java
------------------------------------------------------------------------------
svn:executable = *
Modified:
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/management/ActiveMQManagerGBean.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/management/ActiveMQManagerGBean.java?rev=388205&r1=388204&r2=388205&view=diff
==============================================================================
---
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/management/ActiveMQManagerGBean.java
(original)
+++
incubator/activemq/trunk/sandbox/activemq-gbean/src/main/java/org/activemq/gbean/management/ActiveMQManagerGBean.java
Thu Mar 23 08:40:24 2006
@@ -27,7 +27,7 @@
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 @@
/**
* 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 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 @@
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 @@
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 @@
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()});
Modified:
incubator/activemq/trunk/sandbox/activemq-gbean/src/test/java/org/activemq/gbean/ConnectorTest.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/sandbox/activemq-gbean/src/test/java/org/activemq/gbean/ConnectorTest.java?rev=388205&r1=388204&r2=388205&view=diff
==============================================================================
---
incubator/activemq/trunk/sandbox/activemq-gbean/src/test/java/org/activemq/gbean/ConnectorTest.java
(original)
+++
incubator/activemq/trunk/sandbox/activemq-gbean/src/test/java/org/activemq/gbean/ConnectorTest.java
Thu Mar 23 08:40:24 2006
@@ -25,13 +25,13 @@
* @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 @@
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());