Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7BA41200B3C for ; Wed, 13 Jul 2016 08:52:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7A2A1160A6E; Wed, 13 Jul 2016 06:52:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 51657160A57 for ; Wed, 13 Jul 2016 08:52:26 +0200 (CEST) Received: (qmail 82942 invoked by uid 500); 13 Jul 2016 06:52:25 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 82933 invoked by uid 99); 13 Jul 2016 06:52:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jul 2016 06:52:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2B04CED30C; Wed, 13 Jul 2016 06:52:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cschneider@apache.org To: commits@cxf.apache.org Message-Id: <2fec88ffe4a4489c85caaa447c4cab74@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf-dosgi git commit: [DOSGI-245] Merge IntentHelper with IntentManager to create pure API package Date: Wed, 13 Jul 2016 06:52:25 +0000 (UTC) archived-at: Wed, 13 Jul 2016 06:52:27 -0000 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 Authored: Wed Jul 13 08:52:10 2016 +0200 Committer: Christian Schneider 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 getExported(Map sd) { - Set allIntents = new HashSet(); - Collection intents = OsgiUtils - .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS)); - if (intents != null) { - allIntents.addAll(parseIntents(intents)); - } - Collection intents2 = OsgiUtils - .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA)); - if (intents2 != null) { - allIntents.addAll(parseIntents(intents2)); - } - return allIntents; - } - - public static Set getImported(Map sd) { - Collection intents = OsgiUtils.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_INTENTS)); - return intents == null ? new HashSet() : new HashSet(intents); - } - - private static Collection parseIntents(Collection intents) { - List parsed = new ArrayList(); - 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 getExported(Map sd); + + Set getImported(Map sd); + String[] assertAllIntentsSupported(Set reuiredIntents); + void applyIntents(AbstractEndpointFactory factory, // Set 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 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 intents = ((Callable>)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 intents, List 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 getExported(Map sd) { + Set allIntents = new HashSet(); + Collection intents = OsgiUtils + .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS)); + if (intents != null) { + allIntents.addAll(parseIntents(intents)); + } + Collection intents2 = OsgiUtils + .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA)); + if (intents2 != null) { + allIntents.addAll(parseIntents(intents2)); + } + return allIntents; + } + + public Set getImported(Map sd) { + Collection intents = OsgiUtils.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_INTENTS)); + return intents == null ? new HashSet() : new HashSet(intents); + } + + private static Collection parseIntents(Collection intents) { + List parsed = new ArrayList(); + 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 intents = IntentHelper.getImported(endpoint.getProperties()); + Set 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 intents = IntentHelper.getImported(endpoint.getProperties()); + Set 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 intents = IntentHelper.getExported(endpointProps); + Set 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 intents = IntentHelper.getImported(sd); + Set 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 intents = IntentHelper.getExported(endpointProps); + Set intents = intentManager.getExported(endpointProps); intentManager.assertAllIntentsSupported(intents); Bus bus = createBus(sid, serviceContext, contextRoot); factory.setDataBinding(getDataBinding(endpointProps, iClass));