You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by de...@apache.org on 2009/06/12 16:39:05 UTC
svn commit: r784138 - in /activemq/sandbox/activemq-flow: ./ activemq-broker/
activemq-broker/src/main/java/org/apache/activemq/apollo/broker/
activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/
activemq-broker/src/main/resources/META-INF/se...
Author: dejanb
Date: Fri Jun 12 14:39:04 2009
New Revision: 784138
URL: http://svn.apache.org/viewvc?rev=784138&view=rev
Log:
initial work on broker configuration and jaxb factory
Added:
activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java (with props)
activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactoryHandler.java
activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/
activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/META-INF/services/org/apache/activemq/apollo/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/META-INF/services/org/apache/activemq/apollo/broker/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/META-INF/services/org/apache/activemq/apollo/broker/jaxb
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/
activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/activemq.xml
activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/
activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/
activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
Modified:
activemq/sandbox/activemq-flow/activemq-broker/pom.xml
activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java
activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/MessageBroker.java
activemq/sandbox/activemq-flow/pom.xml
Modified: activemq/sandbox/activemq-flow/activemq-broker/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/pom.xml?rev=784138&r1=784137&r2=784138&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/pom.xml (original)
+++ activemq/sandbox/activemq-flow/activemq-broker/pom.xml Fri Jun 12 14:39:04 2009
@@ -30,6 +30,25 @@
<version>6.0-SNAPSHOT</version>
<name>ActiveMQ :: Broker</name>
+
+ <repositories>
+ <repository>
+ <id>maven2-repository.dev.java.net</id>
+ <name>Java.net Maven Repository </name>
+ <url>http://download.java.net/maven/2</url>
+ </repository>
+ <repository>
+ <id>codehaus</id>
+ <name>Codehaus Maven 2 Repository</name>
+ <url>http://repository.codehaus.org/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>maven2-repository.dev.java.net</id>
+ <url>http://download.java.net/maven/2</url>
+ </pluginRepository>
+ </pluginRepositories>
<dependencies>
@@ -90,5 +109,23 @@
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
</project>
Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java?rev=784138&r1=784137&r2=784138&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java (original)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerDatabase.java Fri Jun 12 14:39:04 2009
@@ -53,6 +53,8 @@
import org.apache.kahadb.util.LinkedNode;
import org.apache.kahadb.util.LinkedNodeList;
+import com.sun.xml.txw2.annotation.XmlElement;
+
public class BrokerDatabase extends AbstractLimitedFlowResource<BrokerDatabase.OperationBase> {
private static final boolean DEBUG = false;
Added: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java?rev=784138&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java (added)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java Fri Jun 12 14:39:04 2009
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apollo.broker;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.activemq.util.FactoryFinder;
+import org.apache.activemq.util.IOExceptionSupport;
+
+
+public final class BrokerFactory {
+
+ private static final FactoryFinder BROKER_FACTORY_HANDLER_FINDER = new FactoryFinder("META-INF/services/org/apache/activemq/apollo/broker/");
+
+ private BrokerFactory() {
+ }
+
+ public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException {
+ try {
+ return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type);
+ } catch (Throwable e) {
+ throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e);
+ }
+ }
+
+ /**
+ * Creates a broker from a URI configuration
+ *
+ * @param brokerURI the URI scheme to configure the broker
+ * @throws Exception
+ */
+ public static MessageBroker createBroker(URI brokerURI) throws Exception {
+ return createBroker(brokerURI, false);
+ }
+
+ /**
+ * Creates a broker from a URI configuration
+ *
+ * @param brokerURI the URI scheme to configure the broker
+ * @param startBroker whether or not the broker should have its
+ * {@link BrokerService#start()} method called after
+ * construction
+ * @throws Exception
+ */
+ public static MessageBroker createBroker(URI brokerURI, boolean startBroker) throws Exception {
+ if (brokerURI.getScheme() == null) {
+ throw new IllegalArgumentException("Invalid broker URI, no scheme specified: " + brokerURI);
+ }
+ BrokerFactoryHandler handler = createBrokerFactoryHandler(brokerURI.getScheme());
+ MessageBroker broker = handler.createBroker(brokerURI);
+ if (startBroker) {
+ broker.start();
+ }
+ return broker;
+ }
+
+ /**
+ * Creates a broker from a URI configuration
+ *
+ * @param brokerURI the URI scheme to configure the broker
+ * @throws Exception
+ */
+ public static MessageBroker createBroker(String brokerURI) throws Exception {
+ return createBroker(new URI(brokerURI));
+ }
+
+ /**
+ * Creates a broker from a URI configuration
+ *
+ * @param brokerURI the URI scheme to configure the broker
+ * @param startBroker whether or not the broker should have its
+ * {@link BrokerService#start()} method called after
+ * construction
+ * @throws Exception
+ */
+ public static MessageBroker createBroker(String brokerURI, boolean startBroker) throws Exception {
+ return createBroker(new URI(brokerURI), startBroker);
+ }
+
+}
Propchange: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactoryHandler.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactoryHandler.java?rev=784138&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactoryHandler.java (added)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactoryHandler.java Fri Jun 12 14:39:04 2009
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apollo.broker;
+
+import java.net.URI;
+
+
+public interface BrokerFactoryHandler {
+ MessageBroker createBroker(URI brokerURI) throws Exception;
+}
Modified: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/MessageBroker.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/MessageBroker.java?rev=784138&r1=784137&r2=784138&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/MessageBroker.java (original)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/MessageBroker.java Fri Jun 12 14:39:04 2009
@@ -22,6 +22,9 @@
import java.util.LinkedHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
import org.apache.activemq.apollo.Connection;
import org.apache.activemq.broker.store.Store;
import org.apache.activemq.dispatch.IDispatcher;
@@ -32,6 +35,7 @@
import org.apache.activemq.transport.TransportFactory;
import org.apache.activemq.transport.TransportServer;
+@XmlRootElement(name="broker")
public class MessageBroker implements TransportAcceptListener {
public static final int MAX_USER_PRIORITY = 10;
Added: activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java?rev=784138&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java (added)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java Fri Jun 12 14:39:04 2009
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apollo.jaxb;
+
+import java.net.URI;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.activemq.apollo.broker.BrokerFactoryHandler;
+import org.apache.activemq.apollo.broker.MessageBroker;
+
+public class JAXBBrokerFactory implements BrokerFactoryHandler {
+
+ public MessageBroker createBroker(URI brokerURI) throws Exception {
+ JAXBContext context = JAXBContext.newInstance(MessageBroker.class);
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ unmarshaller.unmarshal(brokerURI.toURL());
+ return null;
+ }
+
+}
Added: activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/META-INF/services/org/apache/activemq/apollo/broker/jaxb
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/META-INF/services/org/apache/activemq/apollo/broker/jaxb?rev=784138&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/META-INF/services/org/apache/activemq/apollo/broker/jaxb (added)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/META-INF/services/org/apache/activemq/apollo/broker/jaxb Fri Jun 12 14:39:04 2009
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You 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.
+## ---------------------------------------------------------------------------
+class=org.apache.activemq.apollo.jaxb.JAXBBrokerFactory
\ No newline at end of file
Added: activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/activemq.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/activemq.xml?rev=784138&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/activemq.xml (added)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/activemq.xml Fri Jun 12 14:39:04 2009
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<broker>
+</broker>
\ No newline at end of file
Added: activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java?rev=784138&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java Fri Jun 12 14:39:04 2009
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apollo.jaxb;
+
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.apollo.broker.BrokerFactory;
+import org.apache.activemq.apollo.broker.MessageBroker;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JAXBConfigTest extends TestCase {
+
+ private static final Log LOG = LogFactory.getLog(JAXBConfigTest.class);
+
+ MessageBroker broker;
+
+ @Before
+ public void setUp() throws Exception {
+ broker = createBroker();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testBrokerConfiguredCorrectly() throws Exception {
+
+ }
+
+ protected MessageBroker createBroker() throws Exception {
+ String uri = "org/apache/activemq/apollo/jaxb/activemq.xml";
+ LOG.info("Loading broker configuration from the classpath with URI: " + uri);
+ return BrokerFactory.createBroker(new URI("jaxb:" + uri));
+ }
+
+}
Modified: activemq/sandbox/activemq-flow/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/pom.xml?rev=784138&r1=784137&r2=784138&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/pom.xml (original)
+++ activemq/sandbox/activemq-flow/pom.xml Fri Jun 12 14:39:04 2009
@@ -913,6 +913,7 @@
<excludes>
<exclude>**/legacy/**</exclude>
<exclude>**/perf/**</exclude>
+ <exclude>**/jaxb/**</exclude>
</excludes>
</configuration>
</plugin>