Author: sergeyb
Date: Mon Jan 16 23:18:22 2012
New Revision: 1232225

URL: http://svn.apache.org/viewvc?rev=1232225&view=rev
Log:
Adding support for custom CXF interceptors and features for WS & RS handlers

Modified:
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
    
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java
 Mon Jan 16 23:18:22 2012
@@ -18,8 +18,20 @@
   */
 package org.apache.cxf.dosgi.dsw;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.osgi.framework.BundleContext;
+
 public final class ClassUtils {
-    private ClassUtils() {}
+       private static final Logger LOG = 
LogUtils.getL7dLogger(ClassUtils.class);
+       
+       private ClassUtils() {}
     
     public static Class<?> getInterfaceClass(Object service, String 
interfaceName) {
         return getInterfaceClass(service.getClass(), interfaceName);
@@ -80,4 +92,41 @@ public final class ClassUtils {
                }
        return null;
     }
+    
+public static List<Object> loadProviderClasses(BundleContext callingContext, 
Map sd, String propName) {
+       
+       Object serviceProviders = sd.get(propName);
+        if (serviceProviders != null) {
+            if (serviceProviders.getClass().isArray()) {
+                if (serviceProviders.getClass().getComponentType() == 
String.class) {
+                       return loadProviders(callingContext, 
(String[])serviceProviders);
+                } else {
+                    return Arrays.asList((Object[])serviceProviders);
+                }
+            } else {
+                String[] classNames = serviceProviders.toString().split(",");
+                return loadProviders(callingContext, classNames);
+            }
+        } else {
+               return Collections.emptyList();
+        }
+    }
+    
+    private static List<Object> loadProviders(BundleContext callingContext,
+                                      String[] classNames) {
+       List<Object> providers = new ArrayList<Object>();
+        for (String className : classNames) {
+            try {
+                String realName = className.trim();
+                if (realName.length() > 0) {
+                    Class<?> pClass = 
callingContext.getBundle().loadClass(realName);
+                    providers.add(pClass.newInstance());
+                }
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                LOG.warning("Provider " + className.trim() + " can not be 
loaded or created");
+            }
+        }
+        return providers;
+    }
 }

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
 Mon Jan 16 23:18:22 2012
@@ -38,9 +38,9 @@ public class Constants {
     // WSDL
     public static final String WSDL_CONFIG_TYPE = "wsdl";
     public static final String WSDL_CONFIG_PREFIX = 
"osgi.remote.configuration" + "." + WSDL_CONFIG_TYPE;
-    public static final String SERVICE_NAMESPACE = WSDL_CONFIG_PREFIX + 
".service.ns";
-    public static final String SERVICE_NAME = WSDL_CONFIG_PREFIX + 
".service.name";
-    public static final String PORT_NAME = WSDL_CONFIG_PREFIX + ".port.name";
+    public static final String WSDL_SERVICE_NAMESPACE = WSDL_CONFIG_PREFIX + 
".service.ns";
+    public static final String WSDL_SERVICE_NAME = WSDL_CONFIG_PREFIX + 
".service.name";
+    public static final String WSDL_PORT_NAME = WSDL_CONFIG_PREFIX + 
".port.name";
     public static final String WSDL_LOCATION = WSDL_CONFIG_PREFIX + 
".location";
     public static final String WSDL_HTTP_SERVICE_CONTEXT = WSDL_CONFIG_PREFIX 
+ ".httpservice.context";
     // Provider prefix
@@ -52,17 +52,28 @@ public class Constants {
     public static final String WS_PORT_PROPERTY = WS_CONFIG_TYPE + ".port";
     public static final String WS_HTTP_SERVICE_CONTEXT = WS_CONFIG_TYPE + 
".httpservice.context";
     public static final String WS_FRONTEND_PROP_KEY = WS_CONFIG_TYPE + 
".frontend";
+    public static final String WS_IN_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + 
".in.interceptors";
+    public static final String WS_OUT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + 
".out.interceptors";
+    public static final String WS_CONTEXT_PROPS_PROP_KEY = WS_CONFIG_TYPE + 
".context.properties";
+    public static final String WS_FEATURES_PROP_KEY = WS_CONFIG_TYPE + 
".features";
     public static final String WS_DATABINDING_PROP_KEY = WS_CONFIG_TYPE + 
".databinding";
-    
+    public static final String WS_WSDL_SERVICE_NAMESPACE =  WS_CONFIG_TYPE + 
".service.ns";
+    public static final String WS_WSDL_SERVICE_NAME =  WS_CONFIG_TYPE + 
".service.name";
+    public static final String WS_WSDL_PORT_NAME =  WS_CONFIG_TYPE + 
".port.name";
+    public static final String WS_WSDL_LOCATION =  WS_CONFIG_TYPE + 
".location";
     // Rest
     public static final String RS_CONFIG_TYPE = PROVIDER_PREFIX + ".rs";
     public static final String RS_ADDRESS_PROPERTY = RS_CONFIG_TYPE + 
".address";
     public static final String RS_HTTP_SERVICE_CONTEXT = RS_CONFIG_TYPE + 
".httpservice.context";
     public static final String RS_DATABINDING_PROP_KEY = RS_CONFIG_TYPE + 
".databinding";
+    public static final String RS_IN_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + 
".in.interceptors";
+    public static final String RS_OUT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + 
".out.interceptors";
+    public static final String RS_CONTEXT_PROPS_PROP_KEY = RS_CONFIG_TYPE + 
".context.properties";
+    public static final String RS_FEATURES_PROP_KEY = RS_CONFIG_TYPE + 
".features";
     public static final String RS_PROVIDER_PROP_KEY = RS_CONFIG_TYPE + 
".provider";
     public static final String RS_PROVIDER_EXPECTED_PROP_KEY = 
RS_PROVIDER_PROP_KEY + ".expected";
     public static final String RS_PROVIDER_GLOBAL_PROP_KEY = 
RS_PROVIDER_PROP_KEY + ".globalquery";
-    
+    public static final String RS_WADL_LOCATION = RS_CONFIG_TYPE + 
".wadl.location";
     // POJO (old value for WS)
     public static final String WS_CONFIG_TYPE_OLD = "pojo";
     public static final String WS_CONFIG_OLD_PREFIX = 
"osgi.remote.configuration." + WS_CONFIG_TYPE_OLD;

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
 Mon Jan 16 23:18:22 2012
@@ -18,6 +18,7 @@
   */
 package org.apache.cxf.dosgi.dsw.handlers;
 
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -29,8 +30,12 @@ import java.util.Map;
 import java.util.Set;
 import java.util.logging.Logger;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.binding.BindingConfiguration;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.dosgi.dsw.ClassUtils;
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
@@ -38,6 +43,8 @@ import org.apache.cxf.endpoint.AbstractE
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.osgi.framework.BundleContext;
@@ -102,6 +109,82 @@ public abstract class AbstractPojoConfig
         return appliedIntents.toArray(new String[0]);
     }
 
+    protected void setWsdlProperties(ServerFactoryBean factory, BundleContext 
dswContext, 
+               Map sd) {
+       String location = OsgiUtils.getProperty(sd, Constants.WS_WSDL_LOCATION);
+       if (location != null) {
+               URL wsdlURL = dswContext.getBundle().getResource(location);
+               if (wsdlURL != null) {
+                   factory.setWsdlURL(wsdlURL.toString());
+               }
+               QName serviceName = getServiceQName(null, sd, 
+                               Constants.WS_WSDL_SERVICE_NAMESPACE, 
Constants.WS_WSDL_SERVICE_NAME);
+               if (serviceName != null) {
+                       factory.setServiceName(serviceName);
+                   QName portName = 
getPortQName(serviceName.getNamespaceURI(), sd, Constants.WS_WSDL_PORT_NAME);
+                   if (portName != null) {
+                       factory.setEndpointName(portName);
+                   }
+               }
+       }
+    }
+    
+    protected QName getServiceQName(Class<?> iClass, Map sd, String 
nsPropName, String namePropName) {
+       String serviceNs = OsgiUtils.getProperty(sd, nsPropName);
+       String serviceName = OsgiUtils.getProperty(sd, namePropName);
+       if (iClass == null && (serviceNs == null || serviceName == null)) {
+               return null;
+       }
+       if (serviceNs == null) {
+            serviceNs = PackageUtils.getNamespace(
+                            PackageUtils.getPackageName(iClass));
+        }
+        if (serviceName == null) {
+               serviceName = iClass.getSimpleName();   
+        }
+        return new QName(serviceNs, serviceName);
+    }
+    
+    protected QName getPortQName(String ns, Map sd, String propName) {
+       String portName = OsgiUtils.getProperty(sd, propName);
+        if (portName == null) {
+               return null;    
+        }
+        return new QName(ns, portName);
+    }
+    
+    protected void addInterceptors(AbstractEndpointFactory factory, 
BundleContext callingContext, 
+               Map sd, String propName) {
+
+        List<Object> providers = 
ClassUtils.loadProviderClasses(callingContext, sd, propName); 
+        boolean in = propName.contains("in.interceptors");
+        for (int i = 0; i < providers.size(); i++) {
+               Interceptor<?> interceptor = (Interceptor<?>)providers.get(i);  
+               if (in) {
+                       factory.getInInterceptors().add(interceptor);
+               } else {
+                       factory.getOutInterceptors().add(interceptor);
+               }
+        }
+    }
+    
+    protected void addFeatures(AbstractEndpointFactory factory, BundleContext 
callingContext, 
+               Map sd, String propName) {
+
+        List<Object> providers = 
ClassUtils.loadProviderClasses(callingContext, sd, propName); 
+        if (providers.size() > 0) {
+               factory.getFeatures().addAll(CastUtils.cast(providers, 
AbstractFeature.class));
+        }
+    }
+    
+    protected void addContextProperties(AbstractEndpointFactory factory, 
BundleContext callingContext, 
+               Map sd, String propName) {
+       Map<String, Object> props = (Map<String, Object>)sd.get(propName);
+        if (props != null) {
+               factory.getProperties(true).putAll(props);
+        }
+    }
+    
     private boolean processIntent(Set<String> appliedIntents,
                                   List<AbstractFeature> features,
                                   AbstractEndpointFactory factory, String 
intentName,

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
 Mon Jan 16 23:18:22 2012
@@ -102,6 +102,10 @@ public class HttpServiceConfigurationTyp
             }
             String frontEndImpl = 
(String)serviceReference.getProperty(Constants.WS_FRONTEND_PROP_KEY);
             ClientProxyFactoryBean factory = 
createClientProxyFactoryBean(frontEndImpl);
+            addInterceptors(factory.getClientFactoryBean(), callingContext, 
sd.getProperties(), Constants.WS_IN_INTERCEPTORS_PROP_KEY);
+            addInterceptors(factory.getClientFactoryBean(), callingContext, 
sd.getProperties(), Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
+            addFeatures(factory.getClientFactoryBean(), callingContext, 
sd.getProperties(), Constants.WS_FEATURES_PROP_KEY);
+            addContextProperties(factory.getClientFactoryBean(), 
callingContext, sd.getProperties(), Constants.WS_CONTEXT_PROPS_PROP_KEY);
             factory.setServiceClass(iClass);
             factory.setAddress(address);
             factory.getServiceFactory().setDataBinding(databinding);
@@ -152,8 +156,11 @@ public class HttpServiceConfigurationTyp
         factory.getServiceFactory().setDataBinding(databinding);
         factory.setServiceBean(serviceBean);
 
-        
-
+        addInterceptors(factory, callingContext, sd, 
Constants.WS_IN_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, 
Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
+        addFeatures(factory, callingContext, sd, 
Constants.WS_FEATURES_PROP_KEY);
+        addContextProperties(factory, callingContext, sd, 
Constants.WS_CONTEXT_PROPS_PROP_KEY);
+        setWsdlProperties(factory, dswContext, sd);
         
         ClassLoader oldClassLoader = 
Thread.currentThread().getContextClassLoader();
         try {

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
 Mon Jan 16 23:18:22 2012
@@ -65,13 +65,17 @@ public class JaxRSHttpServiceConfigurati
             factory.setServiceClass(iClass);
             factory.setResourceProvider(iClass, new 
SingletonResourceProvider(serviceBean));
         }
-
+        
         factory.setAddress("/");
         List<Object> providers = JaxRSUtils.getProviders(callingContext, 
dswContext, sd);
         if (providers != null && providers.size() > 0) {
             factory.setProviders(providers);
         }
-
+        addInterceptors(factory, callingContext, sd, 
Constants.RS_IN_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, 
Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
+        addFeatures(factory, callingContext, sd, 
Constants.RS_FEATURES_PROP_KEY);
+        addContextProperties(factory, callingContext, sd, 
Constants.RS_CONTEXT_PROPS_PROP_KEY);
+        
         String address = constructAddress(dswContext, contextRoot);
 
         ClassLoader oldClassLoader = 
Thread.currentThread().getContextClassLoader();

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
 Mon Jan 16 23:18:22 2012
@@ -65,6 +65,11 @@ public class JaxRSPojoConfigurationTypeH
             JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
             bean.setAddress(address);
 
+            addInterceptors(bean, callingContext, sd.getProperties(), 
Constants.RS_IN_INTERCEPTORS_PROP_KEY);
+            addInterceptors(bean, callingContext, sd.getProperties(), 
Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
+            addFeatures(bean, callingContext, sd.getProperties(), 
Constants.RS_FEATURES_PROP_KEY);
+            addContextProperties(bean, callingContext, sd.getProperties(), 
Constants.RS_CONTEXT_PROPS_PROP_KEY);
+            
             List<UserResource> resources = JaxRSUtils.getModel(callingContext, 
iClass);
             if (resources != null) {
                 bean.setModelBeansWithServiceClass(resources, iClass);
@@ -119,7 +124,16 @@ public class JaxRSPojoConfigurationTypeH
             factory.setProviders(providers);
         }
 
-
+        addInterceptors(factory, callingContext, sd, 
Constants.RS_IN_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, 
Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
+        addFeatures(factory, callingContext, sd, 
Constants.RS_FEATURES_PROP_KEY);
+        addContextProperties(factory, callingContext, sd, 
Constants.RS_CONTEXT_PROPS_PROP_KEY);
+
+        String location = OsgiUtils.getProperty(sd, 
Constants.RS_WADL_LOCATION);
+       if (location != null) {
+               factory.setDocLocation(location);
+       }
+        
         ClassLoader oldClassLoader = 
Thread.currentThread().getContextClassLoader();
         try {
             String[] intents = new String[] {

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
 Mon Jan 16 23:18:22 2012
@@ -22,12 +22,12 @@ package org.apache.cxf.dosgi.dsw.handler
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.dosgi.dsw.ClassUtils;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.provider.AegisElementProvider;
@@ -63,19 +63,11 @@ public class JaxRSUtils {
         if 
("aegis".equals(sd.get(org.apache.cxf.dosgi.dsw.Constants.RS_DATABINDING_PROP_KEY)))
 {
             providers.add(new AegisElementProvider());
         }
-        Object serviceProviders = 
sd.get(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_PROP_KEY);
-        if (serviceProviders != null) {
-            if (serviceProviders.getClass().isArray()) {
-                if (serviceProviders.getClass().getComponentType() == 
String.class) {
-                    loadProviders(callingContext, providers, 
(String[])serviceProviders);
-                } else {
-                    
providers.addAll(Arrays.asList((Object[])serviceProviders));
-                }
-            } else {
-                String[] classNames = serviceProviders.toString().split(",");
-                loadProviders(callingContext, providers, classNames);
-            }
-        }
+        
+        providers.addAll(
+                       ClassUtils.loadProviderClasses(callingContext, 
+                                               sd, 
+                                               
org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_PROP_KEY));
 
         Object globalQueryProp = 
sd.get(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_GLOBAL_PROP_KEY);
         boolean globalQueryRequired = globalQueryProp == null || 
OsgiUtils.toBoolean(globalQueryProp);
@@ -105,21 +97,7 @@ public class JaxRSUtils {
         return providers;
     }
 
-    private static void loadProviders(BundleContext callingContext, 
List<Object> providers,
-                                      String[] classNames) {
-        for (String className : classNames) {
-            try {
-                String realName = className.trim();
-                if (realName.length() > 0) {
-                    Class<?> pClass = 
callingContext.getBundle().loadClass(realName);
-                    providers.add(pClass.newInstance());
-                }
-            } catch (Exception ex) {
-                ex.printStackTrace();
-                LOG.warning("JAXRS Provider " + className.trim() + " can not 
be loaded or created");
-            }
-        }
-    }
+    
 
     public static List<UserResource> getModel(BundleContext callingContext, 
Class<?> iClass) {
         String classModel = MODEL_FOLDER + iClass.getSimpleName() + 
"-model.xml";

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
 Mon Jan 16 23:18:22 2012
@@ -72,6 +72,11 @@ public class PojoConfigurationTypeHandle
             factory.setAddress(address);
             factory.getServiceFactory().setDataBinding(databinding);
 
+            addInterceptors(factory.getClientFactoryBean(), callingContext, 
sd.getProperties(), Constants.WS_IN_INTERCEPTORS_PROP_KEY);
+            addInterceptors(factory.getClientFactoryBean(), callingContext, 
sd.getProperties(), Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
+            addFeatures(factory.getClientFactoryBean(), callingContext, 
sd.getProperties(), Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
+            addContextProperties(factory.getClientFactoryBean(), 
callingContext, sd.getProperties(), Constants.WS_FEATURES_PROP_KEY);
+            
             applyIntents(dswContext, callingContext, factory.getFeatures(), 
factory.getClientFactoryBean(),
                          sd.getProperties());
 
@@ -115,6 +120,11 @@ public class PojoConfigurationTypeHandle
         factory.getServiceFactory().setDataBinding(databinding);
         factory.setServiceBean(serviceBean);
 
+        addInterceptors(factory, callingContext, sd, 
Constants.WS_IN_INTERCEPTORS_PROP_KEY);
+        addInterceptors(factory, callingContext, sd, 
Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
+        addFeatures(factory, callingContext, sd, 
Constants.WS_FEATURES_PROP_KEY);
+        addContextProperties(factory, callingContext, sd, 
Constants.WS_CONTEXT_PROPS_PROP_KEY);
+        setWsdlProperties(factory, dswContext, sd);
         ClassLoader oldClassLoader = 
Thread.currentThread().getContextClassLoader();
         try {
             String[] intents = applyIntents(dswContext, callingContext, 
factory.getFeatures(), factory, sd);
@@ -140,7 +150,8 @@ public class PojoConfigurationTypeHandle
         
     }
 
-
+    
+    
 
     protected String getPojoAddress(Map sd, Class<?> iClass) {
         String address = OsgiUtils.getProperty(sd, 
RemoteConstants.ENDPOINT_ID);

Modified: 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
URL: 
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java?rev=1232225&r1=1232224&r2=1232225&view=diff
==============================================================================
--- 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
 (original)
+++ 
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
 Mon Jan 16 23:18:22 2012
@@ -78,17 +78,18 @@ public class WsdlConfigurationTypeHandle
         LOG.info("Creating a " + sd.getInterfaces().toArray()[0] + " client, 
wsdl address is "
                  + OsgiUtils.getProperty(sd, Constants.WSDL_CONFIG_PREFIX));
         
-        String serviceNs = OsgiUtils.getProperty(sd, 
Constants.SERVICE_NAMESPACE);
+        String serviceNs = OsgiUtils.getProperty(sd, 
Constants.WSDL_SERVICE_NAMESPACE);
         if (serviceNs == null) {
             serviceNs = PackageUtils.getNamespace(
                             PackageUtils.getPackageName(iClass));
         }
-        String serviceName = OsgiUtils.getProperty(sd, Constants.SERVICE_NAME);
+        String serviceName = OsgiUtils.getProperty(sd, 
Constants.WSDL_SERVICE_NAME);
         if (serviceName == null) {
                serviceName = iClass.getSimpleName();   
         }
-        QName serviceQname = getServiceQName(iClass, sd.getProperties());
-        QName portQname = getPortQName(serviceQname.getNamespaceURI(), 
sd.getProperties());
+        QName serviceQname = getServiceQName(iClass, sd.getProperties(),
+                       Constants.WSDL_SERVICE_NAMESPACE, 
Constants.WSDL_SERVICE_NAME);
+        QName portQname = getPortQName(serviceQname.getNamespaceURI(), 
sd.getProperties(), Constants.WSDL_PORT_NAME);
         Service service = createWebService(wsdlAddress, serviceQname);
         Object proxy = getProxy(
             portQname == null ? service.getPort(iClass) : 
service.getPort(portQname, iClass), 
@@ -103,27 +104,6 @@ public class WsdlConfigurationTypeHandle
         return Service.create(wsdlAddress, serviceQname);
     }
 
-    private QName getServiceQName(Class<?> iClass, Map sd) {
-       String serviceNs = OsgiUtils.getProperty(sd, 
Constants.SERVICE_NAMESPACE);
-        if (serviceNs == null) {
-            serviceNs = PackageUtils.getNamespace(
-                            PackageUtils.getPackageName(iClass));
-        }
-        String serviceName = OsgiUtils.getProperty(sd, Constants.SERVICE_NAME);
-        if (serviceName == null) {
-               serviceName = iClass.getSimpleName();   
-        }
-        return new QName(serviceNs, serviceName);
-    }
-    
-    private QName getPortQName(String ns, Map sd) {
-       String portName = OsgiUtils.getProperty(sd, Constants.PORT_NAME);
-        if (portName == null) {
-               return null;    
-        }
-        return new QName(ns, portName);
-    }
-    
     public void createServer(ExportRegistrationImpl exportRegistration,
                                BundleContext dswContext,
                                BundleContext callingContext,
@@ -170,10 +150,11 @@ public class WsdlConfigurationTypeHandle
         factory.getServiceFactory().setDataBinding(databinding);
         factory.setServiceBean(serviceBean);
 
-        QName serviceQname = getServiceQName(iClass, sd);
+        QName serviceQname = getServiceQName(iClass, sd,
+                       Constants.WSDL_SERVICE_NAMESPACE, 
Constants.WSDL_SERVICE_NAME);
         factory.setServiceName(serviceQname);
         
-        QName portQname = getPortQName(serviceQname.getNamespaceURI(), sd);
+        QName portQname = getPortQName(serviceQname.getNamespaceURI(), sd, 
Constants.WSDL_PORT_NAME);
         if (portQname != null) {
                factory.setEndpointName(portQname);
         }


Reply via email to