[CXF-5107] Remove old intentmanager methods
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 f854691..512b617 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
@@ -22,24 +22,17 @@
import java.util.Map;
import java.util.Set;
-import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-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)
- throws IntentUnsatisfiedException;
+ List<Object> getRequiredIntents(Set<String> requiredIntents);
+
<T> List<T> getIntents(Class<? extends T> type, List<Object> intents);
+
<T> T getIntent(Class<? extends T> type, List<Object> intents);
- List<Object> getIntents(Set<String> requiredIntents);
+
}
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/DefaultIntentsHandler.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/DefaultIntentsHandler.java
deleted file mode 100644
index 8242829..0000000
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/DefaultIntentsHandler.java
+++ /dev/null
@@ -1,49 +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.impl;
-
-import org.apache.cxf.binding.BindingConfiguration;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.dosgi.common.intent.IntentHandler;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DefaultIntentsHandler implements IntentHandler {
- static final Logger LOG = LoggerFactory.getLogger(IntentManagerImpl.class);
-
- @Override
- public boolean apply(AbstractEndpointFactory factory, String intentName, Object intent) {
- String prefix = "Applying intent: " + intentName + " via ";
- if (intent instanceof DataBinding) {
- DataBinding dataBinding = (DataBinding) intent;
- LOG.info(prefix + "data binding: " + dataBinding);
- factory.setDataBinding(dataBinding);
- return true;
- } else if (intent instanceof BindingConfiguration) {
- BindingConfiguration bindingCfg = (BindingConfiguration)intent;
- LOG.info(prefix + "binding config: " + bindingCfg);
- factory.setBindingConfig(bindingCfg);
- return true;
- } else {
- return false;
- }
- }
-
-}
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 b27f2c6..bbef774 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
@@ -28,12 +28,8 @@
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.util.OsgiUtils;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.feature.Feature;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
@@ -90,67 +86,9 @@
public synchronized void removeIntent(Object intent, String intentName) {
intentMap.remove(intentName);
}
-
- @SuppressWarnings("unchecked")
- @Override
- public synchronized void applyIntents(AbstractEndpointFactory factory,
- Set<String> requiredIntents,
- IntentHandler... handlers)
- throws IntentUnsatisfiedException {
- Set<String> missingIntents = getMissingIntents(requiredIntents);
- if (!missingIntents.isEmpty()) {
- throw new IntentUnsatisfiedException(missingIntents.iterator().next());
- }
- List<Feature> features = new ArrayList<Feature>();
- List<IntentHandler> allHandlers = new ArrayList<IntentHandler>();
- allHandlers.add(new DefaultIntentsHandler());
- allHandlers.addAll(Arrays.asList(handlers));
- for (String intentName : requiredIntents) {
- Object intent = intentMap.get(intentName);
- if (intent instanceof Callable<?>) {
- try {
- List<Object> intents = ((Callable<List<Object>>)intent).call();
- applyIntents(factory, features, intentName, intents, allHandlers);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } else {
- applyIntent(factory, features, intentName, intent, allHandlers);
- }
- }
- factory.setFeatures(features);
- }
- private void applyIntents(AbstractEndpointFactory factory,
- List<Feature> features,
- String intentName,
- List<Object> intents,
- List<IntentHandler> handlers) {
- for (Object intent : intents) {
- applyIntent(factory, features, intentName, intent, handlers);
- }
-
- }
-
- private void applyIntent(AbstractEndpointFactory factory, List<Feature> features, String intentName, Object intent,
- List<IntentHandler> handlers) {
- if (intent instanceof Feature) {
- Feature feature = (Feature)intent;
- LOG.info("Applying intent: " + intentName + " via feature: " + feature);
- features.add(feature);
- return;
- }
- for (IntentHandler handler : handlers) {
- if (handler.apply(factory, intentName, intent)) {
- return;
- }
- }
- LOG.info("No mapping for intent: " + intentName);
- throw new IntentUnsatisfiedException(intentName);
- }
-
@SuppressWarnings("unchecked")
- public synchronized List<Object> getIntents(Set<String> requiredIntents) {
+ public synchronized List<Object> getRequiredIntents(Set<String> requiredIntents) {
String[] intentNames = assertAllIntentsSupported(requiredIntents);
List<Object> intents = new ArrayList<Object>();
for (String intentName : intentNames) {
diff --git a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/ProviderIntentHandler.java b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/ProviderIntentHandler.java
deleted file mode 100644
index 3ecae6b..0000000
--- a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/ProviderIntentHandler.java
+++ /dev/null
@@ -1,43 +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.dsw.handlers.rest;
-
-import java.util.List;
-
-import org.apache.cxf.dosgi.common.intent.IntentHandler;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean;
-
-public class ProviderIntentHandler implements IntentHandler {
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- @Override
- public boolean apply(AbstractEndpointFactory factory, String intentName, Object intent) {
- if (!(factory instanceof AbstractJAXRSFactoryBean)) {
- throw new RuntimeException("RsIntentHandler only works on JAXRS factory");
- }
- AbstractJAXRSFactoryBean jaxrsFactory = (AbstractJAXRSFactoryBean)factory;
- List providers = jaxrsFactory.getProviders();
- providers.add(intent);
- return true;
- }
-
-}
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 350ab7f..b618050 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
@@ -91,7 +91,7 @@
Class[] interfaces,
EndpointDescription endpoint) {
Set<String> intentNames = intentManager.getImported(endpoint.getProperties());
- List<Object> intents = intentManager.getIntents(intentNames);
+ List<Object> intents = intentManager.getRequiredIntents(intentNames);
Class<?> iClass = interfaces[0];
String address = OsgiUtils.getProperty(endpoint, RsConstants.RS_ADDRESS_PROPERTY);
if (address == null) {
@@ -138,7 +138,7 @@
}
final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
Set<String> intentNames = intentManager.getExported(endpointProps);
- List<Object> intents = intentManager.getIntents(intentNames);
+ List<Object> intents = intentManager.getRequiredIntents(intentNames);
Bus bus = BusFactory.newInstance().createBus();
if (contextRoot != null) {
httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
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 9f0d873..3bc28ee 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
@@ -117,7 +117,7 @@
private void applyIntents(Map<String, Object> sd, ClientProxyFactoryBean factory) {
Set<String> intentNames = intentManager.getImported(sd);
- List<Object> intents = intentManager.getIntents(intentNames);
+ List<Object> intents = intentManager.getRequiredIntents(intentNames);
List<Feature> features = intentManager.getIntents(Feature.class, intents);
factory.setFeatures(features);
DataBinding dataBinding = intentManager.getIntent(DataBinding.class, intents);
@@ -144,8 +144,8 @@
String contextRoot = OsgiUtils.getProperty(endpointProps, WsConstants.WS_HTTP_SERVICE_CONTEXT);
final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
- Set<String> intents = intentManager.getExported(endpointProps);
- intentManager.assertAllIntentsSupported(intents);
+ Set<String> intentNames = intentManager.getExported(endpointProps);
+ List<Object> intents = intentManager.getRequiredIntents(intentNames);
Bus bus = createBus(sid, serviceContext, contextRoot);
factory.setDataBinding(getDataBinding(endpointProps, iClass));
factory.setBindingConfig(new SoapBindingConfiguration());
@@ -155,23 +155,20 @@
factory.setAddress(address);
addContextProperties(factory, endpointProps, WsConstants.WS_CONTEXT_PROPS_PROP_KEY);
WsdlSupport.setWsdlProperties(factory, serviceContext, endpointProps);
- applyIntents(endpointProps, factory);
- intentManager.applyIntents(factory, intents);
+ applyIntents(intents, factory);
String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
try {
EndpointDescription epd = createEndpointDesc(endpointProps,
new String[]{WsConstants.WS_CONFIG_TYPE},
- completeEndpointAddress, intents);
+ completeEndpointAddress, intentNames);
return createServerFromFactory(factory, epd);
} catch (Exception e) {
throw new RuntimeException("Error exporting service with adress " + completeEndpointAddress, e);
}
}
- private void applyIntents(Map<String, Object> sd, AbstractEndpointFactory factory) {
- Set<String> intentNames = intentManager.getExported(sd);
- List<Object> intents = intentManager.getIntents(intentNames);
+ private void applyIntents(List<Object> intents, AbstractEndpointFactory factory) {
List<Feature> features = intentManager.getIntents(Feature.class, intents);
factory.setFeatures(features);
DataBinding dataBinding = intentManager.getIntent(DataBinding.class, intents);