aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1630916 - in /aries/trunk/transaction/transaction-jms: pom.xml src/main/java/org/apache/aries/transaction/jms/internal/Activator.java src/main/resources/OSGI-INF/blueprint/transaction-jms.xml
Date Fri, 10 Oct 2014 14:42:33 GMT
Author: gnodet
Date: Fri Oct 10 14:42:33 2014
New Revision: 1630916

URL: http://svn.apache.org/r1630916
Log:
[ARIES-1261] Remove blueprint dependency from aries transaction jms

Added:
    aries/trunk/transaction/transaction-jms/src/main/java/org/apache/aries/transaction/jms/internal/Activator.java
Removed:
    aries/trunk/transaction/transaction-jms/src/main/resources/OSGI-INF/blueprint/transaction-jms.xml
Modified:
    aries/trunk/transaction/transaction-jms/pom.xml

Modified: aries/trunk/transaction/transaction-jms/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-jms/pom.xml?rev=1630916&r1=1630915&r2=1630916&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-jms/pom.xml (original)
+++ aries/trunk/transaction/transaction-jms/pom.xml Fri Oct 10 14:42:33 2014
@@ -50,11 +50,19 @@
         <aries.osgi.private.pkg>
             org.apache.aries.transaction.jms.internal
         </aries.osgi.private.pkg>
+        <aries.osgi.activator>
+            org.apache.aries.transaction.jms.internal.Activator
+        </aries.osgi.activator>
         <lastReleaseVersion>1.0.0</lastReleaseVersion>
     </properties>
 
     <dependencies>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.aries.transaction</groupId>
             <artifactId>org.apache.aries.transaction.manager</artifactId>
             <version>1.1.1-SNAPSHOT</version>

Added: aries/trunk/transaction/transaction-jms/src/main/java/org/apache/aries/transaction/jms/internal/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-jms/src/main/java/org/apache/aries/transaction/jms/internal/Activator.java?rev=1630916&view=auto
==============================================================================
--- aries/trunk/transaction/transaction-jms/src/main/java/org/apache/aries/transaction/jms/internal/Activator.java
(added)
+++ aries/trunk/transaction/transaction-jms/src/main/java/org/apache/aries/transaction/jms/internal/Activator.java
Fri Oct 10 14:42:33 2014
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2014 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.aries.transaction.jms.internal;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.xbean.blueprint.context.impl.XBeanNamespaceHandler;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+
+    private ServiceRegistration nshReg;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        // Expose blueprint namespace handler if xbean is present
+        try {
+            nshReg = JmsNamespaceHandler.register(context);
+        } catch (NoClassDefFoundError e) {
+            LOGGER.warn("Unable to register JMS blueprint namespace handler (xbean-blueprint
not available).");
+        } catch (Exception e) {
+            LOGGER.error("Unable to register JMS blueprint namespace handler", e);
+        }
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        if (nshReg != null) {
+            safeUnregisterService(nshReg);
+        }
+    }
+
+    static void safeUnregisterService(ServiceRegistration reg) {
+        if (reg != null) {
+            try {
+                reg.unregister();
+            } catch (IllegalStateException e) {
+                //This can be safely ignored
+            }
+        }
+    }
+
+    static class JmsNamespaceHandler {
+
+        public static ServiceRegistration register(BundleContext context) throws Exception
{
+            XBeanNamespaceHandler nsh = new XBeanNamespaceHandler(
+                    "http://aries.apache.org/xmlns/transaction-jms/2.0",
+                    "org.apache.aries.transaction.jms.xsd",
+                    context.getBundle(),
+                    "META-INF/services/org/apache/xbean/spring/http/aries.apache.org/xmlns/transaction-jms/2.0"
+            );
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            props.put("osgi.service.blueprint.namespace", "http://aries.apache.org/xmlns/transaction-jms/2.0");
+            return context.registerService(NamespaceHandler.class.getName(), nsh, props);
+        }
+    }
+}



Mime
View raw message