cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject cxf-dosgi git commit: [DOSGI-245] Merge IntentHelper with IntentManager to create pure API package
Date Wed, 13 Jul 2016 06:52:25 GMT
Repository: cxf-dosgi
Updated Branches:
  refs/heads/master a19974dad -> 6cb485884


[DOSGI-245] Merge IntentHelper with IntentManager to create pure API package


Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/6cb48588
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/6cb48588
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/6cb48588

Branch: refs/heads/master
Commit: 6cb485884ade5d91e3c3bf6e0e02d0e68412e181
Parents: a19974d
Author: Christian Schneider <chris@die-schneider.net>
Authored: Wed Jul 13 08:52:10 2016 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Wed Jul 13 08:52:10 2016 +0200

----------------------------------------------------------------------
 .../cxf/dosgi/common/intent/IntentHelper.java   | 63 --------------------
 .../cxf/dosgi/common/intent/IntentManager.java  |  6 ++
 .../common/intent/impl/IntentManagerImpl.java   | 49 +++++++++++++--
 .../apache/cxf/dosgi/common/intent/packageinfo  | 19 ++++++
 .../cxf/dosgi/dsw/handlers/rest/RsProvider.java |  7 +--
 .../cxf/dosgi/dsw/handlers/ws/WsProvider.java   |  5 +-
 6 files changed, 74 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/6cb48588/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentHelper.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentHelper.java
deleted file mode 100644
index ca8dbac..0000000
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentHelper.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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.cxf.dosgi.common.intent;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.cxf.dosgi.common.util.OsgiUtils;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public final class IntentHelper {
-    private IntentHelper() {
-    }
-
-    public static Set<String> getExported(Map<String, Object> sd) {
-        Set<String> allIntents = new HashSet<String>();
-        Collection<String> intents = OsgiUtils
-            .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
-        if (intents != null) {
-            allIntents.addAll(parseIntents(intents));
-        }
-        Collection<String> intents2 = OsgiUtils
-            .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
-        if (intents2 != null) {
-            allIntents.addAll(parseIntents(intents2));
-        }
-        return allIntents;
-    }
-    
-    public static Set<String> getImported(Map<String, Object> sd) {
-        Collection<String> intents = OsgiUtils.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_INTENTS));
-        return intents == null ? new HashSet<String>() : new HashSet<String>(intents);
-    }
-    
-    private static Collection<String> parseIntents(Collection<String> intents)
{
-        List<String> parsed = new ArrayList<String>();
-        for (String intent : intents) {
-            parsed.addAll(Arrays.asList(intent.split("[ ]")));
-        }
-        return parsed;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/6cb48588/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
index e6609b5..fbbdcd3 100644
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.dosgi.common.intent;
 
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
@@ -26,7 +27,12 @@ import org.apache.cxf.endpoint.AbstractEndpointFactory;
 public interface IntentManager {
     String INTENT_NAME_PROP = "org.apache.cxf.dosgi.IntentName";
 
+    Set<String> getExported(Map<String, Object> sd);
+
+    Set<String> getImported(Map<String, Object> sd);
+
     String[] assertAllIntentsSupported(Set<String> reuiredIntents);
+
     void applyIntents(AbstractEndpointFactory factory, //
                       Set<String> requiredIntents, //
                       IntentHandler ... handlers)

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/6cb48588/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
b/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
index d40fcd4..5b3d556 100644
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
@@ -26,11 +26,13 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.Callable;
 
 import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
 import org.apache.cxf.dosgi.common.intent.IntentHandler;
 import org.apache.cxf.dosgi.common.intent.IntentManager;
 import org.apache.cxf.dosgi.common.intent.IntentProvider;
+import org.apache.cxf.dosgi.common.util.OsgiUtils;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
@@ -40,6 +42,7 @@ import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -88,6 +91,7 @@ public class IntentManagerImpl implements IntentManager {
         intentMap.remove(intentName);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public synchronized void applyIntents(AbstractEndpointFactory factory,
                                               Set<String> requiredIntents,
@@ -102,19 +106,26 @@ public class IntentManagerImpl implements IntentManager {
         allHandlers.addAll(Arrays.asList(handlers));
         for (String intentName : requiredIntents) {
             Object intent = intentMap.get(intentName);
-            if (intent instanceof IntentProvider) {
-                applyIntentProvider(factory, intentName, (IntentProvider)intent, allHandlers);
+            if (intent instanceof Callable<?>) {
+                try {
+                    List<Object> intents = ((Callable<List<Object>>)intent).call();
+                    applyIntents(factory, intentName, intents, allHandlers);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            } else if (intent instanceof IntentProvider) {
+                applyIntents(factory, intentName, ((IntentProvider)intent).getIntents(),
allHandlers);
             } else {
                 applyIntent(factory, intentName, intent, allHandlers);
             }
         }
     }
 
-    private void applyIntentProvider(AbstractEndpointFactory factory, 
+    private void applyIntents(AbstractEndpointFactory factory, 
                                      String intentName, 
-                                     IntentProvider intentProvider,
+                                     List<Object> intents,
                                      List<IntentHandler> handlers) {
-        for (Object intent : intentProvider.getIntents()) {
+        for (Object intent : intents) {
             applyIntent(factory, intentName, intent, handlers);
         }
         
@@ -174,5 +185,33 @@ public class IntentManagerImpl implements IntentManager {
         }
         return unsupportedIntents;
     }
+    
+    public Set<String> getExported(Map<String, Object> sd) {
+        Set<String> allIntents = new HashSet<String>();
+        Collection<String> intents = OsgiUtils
+            .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
+        if (intents != null) {
+            allIntents.addAll(parseIntents(intents));
+        }
+        Collection<String> intents2 = OsgiUtils
+            .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
+        if (intents2 != null) {
+            allIntents.addAll(parseIntents(intents2));
+        }
+        return allIntents;
+    }
+    
+    public Set<String> getImported(Map<String, Object> sd) {
+        Collection<String> intents = OsgiUtils.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_INTENTS));
+        return intents == null ? new HashSet<String>() : new HashSet<String>(intents);
+    }
+    
+    private static Collection<String> parseIntents(Collection<String> intents)
{
+        List<String> parsed = new ArrayList<String>();
+        for (String intent : intents) {
+            parsed.addAll(Arrays.asList(intent.split("[ ]")));
+        }
+        return parsed;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/6cb48588/common/src/main/java/org/apache/cxf/dosgi/common/intent/packageinfo
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/packageinfo b/common/src/main/java/org/apache/cxf/dosgi/common/intent/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/intent/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/6cb48588/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
----------------------------------------------------------------------
diff --git a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
index b3b254b..6c0fed9 100644
--- a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
+++ b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
@@ -33,7 +33,6 @@ import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentHelper;
 import org.apache.cxf.dosgi.common.intent.IntentManager;
 import org.apache.cxf.dosgi.common.proxy.ProxyFactory;
 import org.apache.cxf.dosgi.common.util.OsgiUtils;
@@ -81,7 +80,7 @@ public class RsProvider implements DistributionProvider {
                                  BundleContext consumerContext,
                                  Class[] interfaces,
                                  EndpointDescription endpoint) {
-        Set<String> intents = IntentHelper.getImported(endpoint.getProperties());
+        Set<String> intents = intentManager.getImported(endpoint.getProperties());
         intentManager.assertAllIntentsSupported(intents);
         Class<?> iClass = interfaces[0];
         String address = OsgiUtils.getProperty(endpoint, RsConstants.RS_ADDRESS_PROPERTY);
@@ -103,7 +102,7 @@ public class RsProvider implements DistributionProvider {
         }
         addContextProperties(factory, endpoint.getProperties(), RsConstants.RS_CONTEXT_PROPS_PROP_KEY);
         factory.setServiceClass(iClass);
-        Set<String> intents = IntentHelper.getImported(endpoint.getProperties());
+        Set<String> intents = intentManager.getImported(endpoint.getProperties());
         intentManager.applyIntents(factory, intents, new ProviderIntentHandler());
         // Apply providers
         factory.setProviders(factory.getProviders());
@@ -130,7 +129,7 @@ public class RsProvider implements DistributionProvider {
             }
         }
         final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
-        Set<String> intents = IntentHelper.getExported(endpointProps);
+        Set<String> intents = intentManager.getExported(endpointProps);
         intentManager.assertAllIntentsSupported(intents);
         Bus bus = BusFactory.newInstance().createBus();
         if (contextRoot != null) {

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/6cb48588/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
index 2550128..74649ad 100644
--- a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
+++ b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
@@ -37,7 +37,6 @@ import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.binding.soap.SoapBindingConfiguration;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentHelper;
 import org.apache.cxf.dosgi.common.intent.IntentManager;
 import org.apache.cxf.dosgi.common.proxy.ProxyFactory;
 import org.apache.cxf.dosgi.common.util.OsgiUtils;
@@ -107,7 +106,7 @@ public class WsProvider implements DistributionProvider {
             addContextProperties(factory.getClientFactoryBean(), sd, WsConstants.WS_CONTEXT_PROPS_PROP_KEY);
             WsdlSupport.setWsdlProperties(factory.getClientFactoryBean(), bundleContext,
sd);
 
-            Set<String> intents = IntentHelper.getImported(sd);
+            Set<String> intents = intentManager.getImported(sd);
             intentManager.assertAllIntentsSupported(intents);
             intentManager.applyIntents(factory.getClientFactoryBean(), intents);
 
@@ -131,7 +130,7 @@ public class WsProvider implements DistributionProvider {
         String contextRoot = OsgiUtils.getProperty(endpointProps, WsConstants.WS_HTTP_SERVICE_CONTEXT);
 
         final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
-        Set<String> intents = IntentHelper.getExported(endpointProps);
+        Set<String> intents = intentManager.getExported(endpointProps);
         intentManager.assertAllIntentsSupported(intents);
         Bus bus = createBus(sid, serviceContext, contextRoot);
         factory.setDataBinding(getDataBinding(endpointProps, iClass));


Mime
View raw message