aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1703376 - in /aries/trunk/jpa/jpa-blueprint/src/main: java/org/apache/aries/jpa/blueprint/impl/ java/org/apache/aries/jpa/blueprint/supplier/impl/ resources/
Date Wed, 16 Sep 2015 10:06:46 GMT
Author: cschneider
Date: Wed Sep 16 10:06:46 2015
New Revision: 1703376

URL: http://svn.apache.org/r1703376
Log:
[ARIES-1403] Add correct namespace

Added:
    aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa20.xsd
      - copied, changed from r1703375, aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd
    aries/trunk/jpa/jpa-blueprint/src/main/resources/jpan10.xsd
      - copied, changed from r1703375, aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd
Removed:
    aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd
Modified:
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/ServiceProxy.java

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java?rev=1703376&r1=1703375&r2=1703376&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
(original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
Wed Sep 16 10:06:46 2015
@@ -30,9 +30,14 @@ public class Activator implements Bundle
     @Override
     public void start(BundleContext context) throws Exception {
         JpaNsHandler handler = new JpaNsHandler();
+        context.registerService(NamespaceHandler.class, handler, createProps(JpaNsHandler.NAMESPACE_JPAN_10));
+        context.registerService(NamespaceHandler.class, handler, createProps(JpaNsHandler.NAMESPACE_JPA_20));
+    }
+
+    private Dictionary<String, String> createProps(String namespace) {
         Dictionary<String, String> props = new Hashtable<String, String>();
-        props.put("osgi.service.blueprint.namespace", "http://aries.apache.org/xmlns/jpan/v1.0.0");
-        context.registerService(NamespaceHandler.class, handler, props);
+        props.put("osgi.service.blueprint.namespace", namespace);
+        return props;
     }
 
     @Override

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java?rev=1703376&r1=1703375&r2=1703376&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
(original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
Wed Sep 16 10:06:46 2015
@@ -42,6 +42,9 @@ import org.w3c.dom.Node;
 
 public class JpaNsHandler implements NamespaceHandler {
 
+    public static final String NAMESPACE_JPA_20 = "http://aries.apache.org/xmlns/jpan/v2.0.0";
+    public static final String NAMESPACE_JPAN_10 = "http://aries.apache.org/xmlns/jpan/v1.0.0";
+
     private void parseElement(Element elt, ComponentMetadata cm, ParserContext pc) {
         ComponentDefinitionRegistry cdr = pc.getComponentDefinitionRegistry();
 
@@ -78,7 +81,14 @@ public class JpaNsHandler implements Nam
     }
 
     public URL getSchemaLocation(String namespace) {
-        return this.getClass().getResource("/jpa10.xsd");
+        if (NAMESPACE_JPAN_10.equals(namespace)) {
+            // deprecated (remove in jpa 3)
+            return this.getClass().getResource("/jpan10.xsd");
+        } else if (NAMESPACE_JPA_20.equals(namespace)) {
+            return this.getClass().getResource("/jpa20.xsd");
+        } else {
+            throw new IllegalArgumentException("Unknown namespace for jpa: " + namespace);
+        }
     }
 
     @SuppressWarnings("rawtypes")

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/ServiceProxy.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/ServiceProxy.java?rev=1703376&r1=1703375&r2=1703376&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/ServiceProxy.java
(original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/ServiceProxy.java
Wed Sep 16 10:06:46 2015
@@ -28,13 +28,19 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.service.blueprint.container.ServiceUnavailableException;
 import org.osgi.util.tracker.ServiceTracker;
 
 public class ServiceProxy implements InvocationHandler {
+    private static final int SERVICE_TIMEOUT = 120000;
+
     @SuppressWarnings("rawtypes")
     private ServiceTracker tracker;
 
+    private String filterS;
+
     public ServiceProxy(BundleContext context, String filterS) {
+        this.filterS = filterS;
         tracker = new ServiceTracker<>(context, createFilter(filterS), null);
         tracker.open();
     }
@@ -49,7 +55,11 @@ public class ServiceProxy implements Inv
 
     private Object getService() {
         try {
-            return tracker.waitForService(10000);
+            Object serviceO = tracker.waitForService(SERVICE_TIMEOUT);
+            if (serviceO == null) {
+                throw new ServiceUnavailableException("No matching service found after timeout
of " + SERVICE_TIMEOUT + " ms", filterS);
+            }
+            return serviceO;
         } catch (InterruptedException e) {
             throw new IllegalStateException(e);
         }

Copied: aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa20.xsd (from r1703375, aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd)
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa20.xsd?p2=aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa20.xsd&p1=aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd&r1=1703375&r2=1703376&rev=1703376&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd (original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa20.xsd Wed Sep 16 10:06:46 2015
@@ -17,9 +17,9 @@
     limitations under the License.
 
 -->
-<xsd:schema xmlns="http://aries.apache.org/xmlns/jpan/v1.0.0"
+<xsd:schema xmlns="http://aries.apache.org/xmlns/jpa/v2.0.0"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-	targetNamespace="http://aries.apache.org/xmlns/jpan/v1.0.0"
+	targetNamespace="http://aries.apache.org/xmlns/jpa/v2.0.0"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified"
     version="1.0.0">

Copied: aries/trunk/jpa/jpa-blueprint/src/main/resources/jpan10.xsd (from r1703375, aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd)
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/resources/jpan10.xsd?p2=aries/trunk/jpa/jpa-blueprint/src/main/resources/jpan10.xsd&p1=aries/trunk/jpa/jpa-blueprint/src/main/resources/jpa10.xsd&r1=1703375&r2=1703376&rev=1703376&view=diff
==============================================================================
    (empty)



Mime
View raw message