activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r784236 - 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/org/apache/...
Date Fri, 12 Jun 2009 19:00:59 GMT
Author: chirino
Date: Fri Jun 12 19:00:59 2009
New Revision: 784236

URL: http://svn.apache.org/viewvc?rev=784236&view=rev
Log:
small tweaks to the start of the jaxb package for broker configuraiton.


Added:
    activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/jaxb/
      - copied from r784192, activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/
Removed:
    activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactoryHandler.java
    activemq/sandbox/activemq-flow/activemq-broker/src/main/resources/org/apache/activemq/apollo/broker/jaxb/
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/BrokerFactory.java
    activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/MessageBroker.java
    activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java
    activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.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=784236&r1=784235&r2=784236&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/pom.xml (original)
+++ activemq/sandbox/activemq-flow/activemq-broker/pom.xml Fri Jun 12 19:00:59 2009
@@ -112,6 +112,7 @@
   
   <profiles>
     <profile>
+      <id>jdk-1.5</id>
       <activation>
         <jdk>1.5</jdk>
       </activation>

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=784236&r1=784235&r2=784236&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 19:00:59 2009
@@ -53,8 +53,6 @@
 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;

Modified: 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=784236&r1=784235&r2=784236&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/broker/BrokerFactory.java
Fri Jun 12 19:00:59 2009
@@ -27,12 +27,17 @@
 
     private static final FactoryFinder BROKER_FACTORY_HANDLER_FINDER = new FactoryFinder("META-INF/services/org/apache/activemq/apollo/broker/");
 
+    public interface Handler {
+        MessageBroker createBroker(URI brokerURI) throws Exception;
+    }
+
+    
     private BrokerFactory() {        
     }
     
-    public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException
{
+    public static Handler createHandler(String type) throws IOException {
         try {
-            return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type);
+            return (Handler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type);
         } catch (Throwable e) {
             throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e);
         }
@@ -61,7 +66,7 @@
         if (brokerURI.getScheme() == null) {
             throw new IllegalArgumentException("Invalid broker URI, no scheme specified:
" + brokerURI);
         }
-        BrokerFactoryHandler handler = createBrokerFactoryHandler(brokerURI.getScheme());
+        Handler handler = createHandler(brokerURI.getScheme());
         MessageBroker broker = handler.createBroker(brokerURI);
         if (startBroker) {
             broker.start();

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=784236&r1=784235&r2=784236&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 19:00:59 2009
@@ -22,9 +22,6 @@
 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;
@@ -35,7 +32,6 @@
 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;

Modified: 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=784236&r1=784235&r2=784236&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java
Fri Jun 12 19:00:59 2009
@@ -17,20 +17,35 @@
 package org.apache.activemq.apollo.jaxb;
 
 import java.net.URI;
+import java.net.URL;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 
-import org.apache.activemq.apollo.broker.BrokerFactoryHandler;
+import org.apache.activemq.apollo.broker.BrokerFactory;
 import org.apache.activemq.apollo.broker.MessageBroker;
+import org.apache.activemq.util.URISupport;
 
-public class JAXBBrokerFactory implements BrokerFactoryHandler {
+public class JAXBBrokerFactory implements BrokerFactory.Handler {
 
 	public MessageBroker createBroker(URI brokerURI) throws Exception {
-		JAXBContext context = JAXBContext.newInstance(MessageBroker.class);
+		JAXBContext context = JAXBContext.newInstance(Broker.class);
 		Unmarshaller unmarshaller = context.createUnmarshaller();
-		unmarshaller.unmarshal(brokerURI.toURL());
-		return null;
+
+		URL configURL;
+		brokerURI = URISupport.stripScheme(brokerURI);
+		String scheme = brokerURI.getScheme();
+		if( scheme==null || "file".equals(scheme) ) {
+			configURL = URISupport.changeScheme(brokerURI, "file").toURL();
+		} else if( "classpath".equals(scheme) ) {
+			configURL = Thread.currentThread().getContextClassLoader().getResource(brokerURI.getSchemeSpecificPart());
+		} else {
+			configURL = URISupport.changeScheme(brokerURI, scheme).toURL();
+		}		
+		
+		Broker config = (Broker) unmarshaller.unmarshal(configURL);
+		return config.createMessageBroker();
 	}
 
+
 }

Modified: 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=784236&r1=784235&r2=784236&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
(original)
+++ activemq/sandbox/activemq-flow/activemq-broker/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
Fri Jun 12 19:00:59 2009
@@ -50,9 +50,9 @@
 	}
 
     protected MessageBroker createBroker() throws Exception {
-        String uri = "org/apache/activemq/apollo/jaxb/activemq.xml";
+    	URI uri = new URI("jaxb:classpath: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));
+        return BrokerFactory.createBroker(uri);
     }
 	
 }

Modified: activemq/sandbox/activemq-flow/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/pom.xml?rev=784236&r1=784235&r2=784236&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/pom.xml (original)
+++ activemq/sandbox/activemq-flow/pom.xml Fri Jun 12 19:00:59 2009
@@ -72,7 +72,12 @@
     <regexp-version>1.3</regexp-version>
     <rome-version>0.8</rome-version>
     <slf4j-version>1.5.0</slf4j-version>
+    
+    <jaxb-api-version>2.1</jaxb-api-version>
+    <jaxb-version>2.1.6</jaxb-version>
+    <stax-api-version>1.0.1</stax-api-version>
     <stax-version>1.2.0</stax-version>
+    
     <xalan-version>2.6.0</xalan-version>
     <xmlbeans-version>2.0.0-beta1</xmlbeans-version>
     <xmlpull-version>1.1.3.4d_b4_min</xmlpull-version>
@@ -382,7 +387,7 @@
       <dependency>
         <groupId>javax.xml.bind</groupId>
         <artifactId>jaxb-api</artifactId>
-        <version>2.1</version>
+        <version>${jaxb-api-version}</version>
         <exclusions>
           <exclusion>
             <groupId>javax.xml</groupId>
@@ -393,7 +398,7 @@
       <dependency>
         <groupId>com.sun.xml.bind</groupId>
         <artifactId>jaxb-impl</artifactId>
-        <version>2.1.6</version>
+        <version>${jaxb-version}</version>
         <exclusions>
           <exclusion>
             <groupId>javax.jws</groupId>
@@ -605,7 +610,7 @@
       <dependency>
         <groupId>stax</groupId>
         <artifactId>stax-api</artifactId>
-        <version>1.0.1</version>
+        <version>${stax-api-version}</version>
       </dependency>
       <dependency>
         <groupId>stax</groupId>



Mime
View raw message