cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1085518 - in /cxf/sandbox/cxf-blueprint: core/src/main/java/org/apache/cxf/blueprint/core/ jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/ jaxrs/src/main/resources/ jaxrs/src/test/java/org/apache/cxf/blueprint/jaxrs/ jaxws/src/main/jav...
Date Fri, 25 Mar 2011 19:01:53 GMT
Author: joed
Date: Fri Mar 25 19:01:52 2011
New Revision: 1085518

URL: http://svn.apache.org/viewvc?rev=1085518&view=rev
Log:
Schema for jaxrs, jaxrs model parsing, classloader workarounds.

Added:
    cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JAXRSServiceFactoryBeanLocalLoading.java
    cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/ResourceUtils.java
Modified:
    cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/BaseCxfParser.java
    cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/BlueprintResourceFactory.java
    cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JaxrsServerParser.java
    cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/MetaDataBeans.java
    cxf/sandbox/cxf-blueprint/jaxrs/src/main/resources/jaxrs.xsd
    cxf/sandbox/cxf-blueprint/jaxrs/src/test/java/org/apache/cxf/blueprint/jaxrs/NsHandlerTest.java
    cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java

Modified: cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/BaseCxfParser.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/BaseCxfParser.java?rev=1085518&r1=1085517&r2=1085518&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/BaseCxfParser.java (original)
+++ cxf/sandbox/cxf-blueprint/core/src/main/java/org/apache/cxf/blueprint/core/BaseCxfParser.java Fri Mar 25 19:01:52 2011
@@ -263,6 +263,7 @@ public abstract class BaseCxfParser {
                                     bean.addProperty("bus", NSUtils.createRef(context, NSUtils.DEFAULT__BUNDLE_BUS));
                                 }
                             } else {
+
                                 mapAttribute(bean, element, name, val, context);
                             }
                         }
@@ -308,8 +309,40 @@ public abstract class BaseCxfParser {
         }
     }
 
-    protected void addBusWiringAttribute(MutableBeanMetadata bean) {
+    protected void addBusWiringAttribute(MutableBeanMetadata bean, ParserContext context, CxfBusRegistry cxfBusRegistry) {
         LOG.debug("Adding " + WIRE_BUS_ATTRIBUTE + " attribute " + BusWiringType.PROPERTY + " to bean " + bean);
+
+        ComponentDefinitionRegistry cdr = context.getComponentDefinitionRegistry();
+        ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");
+
+        Bundle blueprintBundle = null;
+        if (meta instanceof PassThroughMetadata) {
+            blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
+        }
+        if (blueprintBundle != null) {
+
+            if (!cdr.containsComponentDefinition(NSUtils.DEFAULT__BUNDLE_BUS)) {
+                //Create a bus
+                MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
+                factory.setId(".cxf.bus.passthrough.Factory" + UUID.randomUUID().toString());
+                factory.setObject(new NSUtils.PassThroughCallable<Object>(BusFactory.getThreadDefaultBus()));
+
+                MutableBeanMetadata busFactory = context.createMetadata(MutableBeanMetadata.class);
+                busFactory.setId(NSUtils.DEFAULT__BUNDLE_BUS);
+                busFactory.setRuntimeClass(Bus.class);
+                busFactory.setFactoryComponent(factory);
+                busFactory.setFactoryMethod("call");
+
+                context.getComponentDefinitionRegistry().registerComponentDefinition(busFactory);
+
+                if (!cxfBusRegistry.isRegistered(cdr)) {
+                    cxfBusRegistry.register(cdr, blueprintBundle);
+                }
+            }
+        }
+
+        bean.addProperty("bus", NSUtils.createRef(context, NSUtils.DEFAULT__BUNDLE_BUS));
+
         //TODO - is there an equivalent in BP?
         // /bean.getRawBeanDefinition().setAttribute(WIRE_BUS_ATTRIBUTE, type);
     }

Modified: cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/BlueprintResourceFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/BlueprintResourceFactory.java?rev=1085518&r1=1085517&r2=1085518&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/BlueprintResourceFactory.java (original)
+++ cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/BlueprintResourceFactory.java Fri Mar 25 19:01:52 2011
@@ -67,10 +67,10 @@ public class BlueprintResourceFactory im
     }
 
     public Object getInstance(Message m) {
-
         //TODO -- This is not the BP way.
         Object[] values = ResourceUtils.createConstructorArguments(c, m);
-        Object instance = null; //= values.length > 0 ? blueprintContainer.getBean(beanId, values) : ac.getBean(beanId);
+        //TODO Very springish...
+        Object instance = values.length > 0 ? blueprintContainer.getComponentInstance(beanId) : blueprintContainer.getComponentInstance(beanId);
         if (!isSingleton || m == null) {
             InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod);
         }

Added: cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JAXRSServiceFactoryBeanLocalLoading.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JAXRSServiceFactoryBeanLocalLoading.java?rev=1085518&view=auto
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JAXRSServiceFactoryBeanLocalLoading.java (added)
+++ cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JAXRSServiceFactoryBeanLocalLoading.java Fri Mar 25 19:01:52 2011
@@ -0,0 +1,57 @@
+
+
+/*
+ * 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.blueprint.jaxrs;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.UserResource;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JAXRSServiceFactoryBeanLocalLoading extends JAXRSServiceFactoryBean {
+
+    private static final transient Logger LOG = LoggerFactory.getLogger(JAXRSServiceFactoryBeanLocalLoading.class);
+
+    public void setUserResources2(List<UserResource> resources, BundleContext bundleContext) {
+        LOG.debug("updating user resources.");
+        Map<String, UserResource> map = userResourcesAsMap(resources);
+        for (UserResource ur : resources) {
+            if (ur.getPath() != null) {
+                ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(map, ur, true, true, bundleContext);
+                if (cri != null) {
+                    classResourceInfos.add(cri);
+                }
+            }
+        }
+    }
+
+    private Map<String, UserResource> userResourcesAsMap(List<UserResource> resources) {
+        Map<String, UserResource> map = new HashMap<String, UserResource>();
+        for (UserResource ur : resources) {
+            map.put(ur.getName(), ur);
+        }
+        return map;
+    }
+}

Modified: cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JaxrsServerParser.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JaxrsServerParser.java?rev=1085518&r1=1085517&r2=1085518&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JaxrsServerParser.java (original)
+++ cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/JaxrsServerParser.java Fri Mar 25 19:01:52 2011
@@ -17,18 +17,21 @@
 
 package org.apache.cxf.blueprint.jaxrs;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
+import java.util.concurrent.Callable;
 import javax.xml.namespace.QName;
 import org.w3c.dom.Element;
 
 import org.apache.aries.blueprint.ParserContext;
 import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.aries.blueprint.mutable.MutableCollectionMetadata;
+import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
 import org.apache.cxf.blueprint.core.BaseCxfParser;
 import org.apache.cxf.blueprint.core.CxfBusRegistry;
 import org.apache.cxf.blueprint.core.NSUtils;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.jaxrs.model.UserResource;
 import org.osgi.service.blueprint.reflect.Metadata;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,14 +40,19 @@ public class JaxrsServerParser extends B
 
     private static final transient Logger LOG = LoggerFactory.getLogger(JaxrsServerParser.class);
 
+    CxfBusRegistry cxfBusRegistry;
+
     Metadata serverParser(Element element, ParserContext context, CxfBusRegistry registry) {
 
         MutableBeanMetadata cxfBean = context.createMetadata(MutableBeanMetadata.class);
 
+        this.cxfBusRegistry = registry;
         //Add a blueprintContainer ref
 
         cxfBean.addProperty("blueprintContainer", NSUtils.createRef(context, "blueprintContainer"));
 
+        cxfBean.addProperty("bundleContext", NSUtils.createRef(context, "blueprintBundleContext"));
+
         if (!StringUtils.isEmpty(NSUtils.getIdOrName(element))) {
             cxfBean.setId(NSUtils.getIdOrName(element));
         } else {
@@ -54,7 +62,7 @@ public class JaxrsServerParser extends B
 
         boolean setBus = parseAttributes(element, context, cxfBean, registry);
         if (!setBus && hasBusProperty()) {
-            addBusWiringAttribute(cxfBean);
+            addBusWiringAttribute(cxfBean, context, cxfBusRegistry);
         }
 
         parseChildElements(element, context, cxfBean);
@@ -66,18 +74,33 @@ public class JaxrsServerParser extends B
 
     @Override
     protected void mapAttribute(MutableBeanMetadata bean, Element e, String name, String val, ParserContext context) {
+        LOG.debug("Mapping attributes for Element " + e + " name " + name + " val " + val);
         if ("beanNames".equals(name)) {
             String[] values = val.split(" ");
-            List<BlueprintResourceFactory> tempFactories = new ArrayList<BlueprintResourceFactory>(values.length);
+            MutableCollectionMetadata tempFactories = context.createMetadata(MutableCollectionMetadata.class);
             for (String v : values) {
                 String theValue = v.trim();
+                LOG.debug("Working on bean {}", v);
                 if (theValue.length() > 0) {
-                    tempFactories.add(new BlueprintResourceFactory(theValue));
+
+                    MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
+                    factory.setId(".cxf.jaxrs.resource.beanNames" + UUID.randomUUID().toString());
+                    factory.setObject(new PassThroughCallable<Object>(new BlueprintResourceFactory(v)));
+
+                    MutableBeanMetadata resourceBean = context.createMetadata(MutableBeanMetadata.class);
+                    resourceBean.setId(".cxf.jaxrs.resource.beanNames" + UUID.randomUUID().toString());
+                    resourceBean.setRuntimeClass(BlueprintResourceFactory.class);
+                    resourceBean.setFactoryComponent(factory);
+                    resourceBean.setFactoryMethod("call");
+                    resourceBean.setInitMethod("init");
+
+                    context.getComponentDefinitionRegistry().registerComponentDefinition(resourceBean);
+
+                    tempFactories.addValue(resourceBean);
+                    LOG.debug("Added resourceBean {}", resourceBean);
                 }
             }
-
-            //TODO Add list value
-            // bean.addProperty("tempResourceProviders",  tempFactories);
+            bean.addProperty("tempFactories", tempFactories);
         } else {
             if ("serviceName".equals(name)) {
                 QName q = NSUtils.parseQName(e, val);
@@ -115,6 +138,9 @@ public class JaxrsServerParser extends B
                                 MutableBeanMetadata listbean = ctx.createMetadata(MutableBeanMetadata.class);
                                 Metadata list = parseListData(ctx, listbean, el);
                                 LOG.debug("List data parsed as " + list);
+                                if ("serviceBeans".equals(name)) {
+                                    name = "sBeans";
+                                }
                                 bean.addProperty(name, list);
                             } else {
                                 if ("serviceFactories".equals(name)) {
@@ -123,11 +149,24 @@ public class JaxrsServerParser extends B
                                     LOG.debug("List data parsed as " + list);
                                     bean.addProperty("resourceProviders", list);
                                 } else {
-                                    if ("model".equals(name)) {
-                                        MutableBeanMetadata listbean = ctx.createMetadata(MutableBeanMetadata.class);
-                                        Metadata list = parseListData(ctx, listbean, el);
-                                        LOG.debug("List data parsed as " + list);
 
+                                    if ("model".equals(name)) {
+                                        List<UserResource> resources = ResourceUtils.getResourcesFromElement(el);
+                                        MutableCollectionMetadata list = ctx.createMetadata(MutableCollectionMetadata.class);
+                                        list.setCollectionClass(List.class);
+                                        for (UserResource res : resources) {
+                                            MutablePassThroughMetadata factory = ctx.createMetadata(MutablePassThroughMetadata.class);
+                                            factory.setId(".cxf.jaxrs.userResource." + UUID.randomUUID().toString());
+                                            factory.setObject(new PassThroughCallable<Object>(res));
+
+                                            MutableBeanMetadata resourceBean = ctx.createMetadata(MutableBeanMetadata.class);
+                                            resourceBean.setId(".cxf.jaxrs.userResource" + UUID.randomUUID().toString());
+                                            resourceBean.setFactoryComponent(factory);
+                                            resourceBean.setFactoryMethod("call");
+                                            ctx.getComponentDefinitionRegistry().registerComponentDefinition(resourceBean);
+                                            list.addValue(resourceBean);
+                                        }
+                                        LOG.debug("ModelBeans " + list);
                                         bean.addProperty("modelBeans", list);
                                     } else {
                                         setFirstChildAsProperty(el, ctx, bean, name);
@@ -145,4 +184,17 @@ public class JaxrsServerParser extends B
     protected boolean hasBusProperty() {
         return true;
     }
+
+    public static class PassThroughCallable<T> implements Callable<T> {
+
+        private T value;
+
+        public PassThroughCallable(T value) {
+            this.value = value;
+        }
+
+        public T call() throws Exception {
+            return value;
+        }
+    }
 }

Modified: cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/MetaDataBeans.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/MetaDataBeans.java?rev=1085518&r1=1085517&r2=1085518&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/MetaDataBeans.java (original)
+++ cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/MetaDataBeans.java Fri Mar 25 19:01:52 2011
@@ -17,24 +17,66 @@
 
 package org.apache.cxf.blueprint.jaxrs;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.message.Message;
+import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MetaDataBeans {
 
     public static class CxfJaxrsServerBean extends JAXRSServerFactoryBean {
 
+        private static final transient Logger LOG = LoggerFactory.getLogger(CxfJaxrsServerBean.class);
+
         private BlueprintContainer blueprintContainer;
 
+        private BundleContext bundleContext;
+
+        private List tempFactories;
+
+        private List sBeans;
+
+        public void setsBeans(List sBeans) {
+            this.sBeans = sBeans;
+        }
+
         public CxfJaxrsServerBean() {
-            super();
+            super(new JAXRSServiceFactoryBeanLocalLoading());
         }
 
         public void init() {
+
+            for (Object o : sBeans) {
+                super.setServiceBean(o);
+            }
+
+            if (tempFactories != null) {
+                List<ResourceProvider> factories = new ArrayList<ResourceProvider>(tempFactories.size());
+                for (int i = 0; i < tempFactories.size(); i++) {
+                    BlueprintResourceFactory factory = (BlueprintResourceFactory) tempFactories.get(i);
+
+                    factories.add(factory);
+                }
+                tempFactories.clear();
+                super.setResourceProviders(factories);
+            }
+            if (getBus() == null) {
+                Bus bus = BusFactory.getThreadDefaultBus();
+                //BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+                setBus(bus);
+            }
+
             super.create();
         }
 
@@ -85,5 +127,47 @@ public class MetaDataBeans {
         public void setBlueprintContainer(BlueprintContainer blueprintContainer) {
             this.blueprintContainer = blueprintContainer;
         }
+
+        public List getTempFactories() {
+            return tempFactories;
+        }
+
+        public void setTempFactories(List tempFactories) {
+            this.tempFactories = tempFactories;
+        }
+
+        //Overrides
+
+        public void setModelBeans(UserResource... resources) {
+            setModelBeans(Arrays.asList(resources));
+        }
+
+        public void setModelBeans(List<UserResource> resources) {
+            JAXRSServiceFactoryBeanLocalLoading sfc = (JAXRSServiceFactoryBeanLocalLoading) serviceFactory;
+            sfc.setUserResources2(resources, bundleContext);
+        }
+
+        public void setModelBeansWithServiceClass(List<UserResource> resources, Class<?>... sClasses) {
+
+            serviceFactory.setUserResourcesWithServiceClass(resources, sClasses);
+        }
+
+        public void setModelRef(String modelRef) {
+            List<UserResource> resources = ResourceUtils.getUserResources(modelRef, getBus());
+            if (resources != null) {
+                serviceFactory.setUserResources(resources);
+            }
+        }
+
+        public void setModelRefWithServiceClass(String modelRef, Class<?>... sClasses) {
+            List<UserResource> resources = ResourceUtils.getUserResources(modelRef, getBus());
+            if (resources != null) {
+                serviceFactory.setUserResourcesWithServiceClass(resources, sClasses);
+            }
+        }
+
+        public void setBundleContext(BundleContext bundleContext) {
+            this.bundleContext = bundleContext;
+        }
     }
 }

Added: cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/ResourceUtils.java?rev=1085518&view=auto
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/ResourceUtils.java (added)
+++ cxf/sandbox/cxf-blueprint/jaxrs/src/main/java/org/apache/cxf/blueprint/jaxrs/ResourceUtils.java Fri Mar 25 19:01:52 2011
@@ -0,0 +1,628 @@
+
+
+/*
+ * 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.blueprint.jaxrs;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.Encoded;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.jaxb.JAXBUtils;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.MethodDispatcher;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.jaxrs.model.UserOperation;
+import org.apache.cxf.jaxrs.model.UserResource;
+import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.resource.ResourceManager;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class ResourceUtils {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ResourceUtils.class);
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(org.apache.cxf.jaxrs.utils.ResourceUtils.class);
+
+    private static final String CLASSPATH_PREFIX = "classpath:";
+
+    public static Method findPostConstructMethod(Class<?> c) {
+        if (Object.class == c || null == c) {
+            return null;
+        }
+        for (Method m : c.getDeclaredMethods()) {
+            if (m.getAnnotation(PostConstruct.class) != null) {
+                return m;
+            }
+        }
+        Method m = findPostConstructMethod(c.getSuperclass());
+        if (m != null) {
+            return m;
+        }
+        for (Class<?> i : c.getInterfaces()) {
+            m = findPostConstructMethod(i);
+            if (m != null) {
+                return m;
+            }
+        }
+        return null;
+    }
+
+    public static Method findPreDestroyMethod(Class<?> c) {
+        if (Object.class == c || null == c) {
+            return null;
+        }
+        for (Method m : c.getDeclaredMethods()) {
+            if (m.getAnnotation(PreDestroy.class) != null) {
+                return m;
+            }
+        }
+        Method m = findPreDestroyMethod(c.getSuperclass());
+        if (m != null) {
+            return m;
+        }
+        for (Class<?> i : c.getInterfaces()) {
+            m = findPreDestroyMethod(i);
+            if (m != null) {
+                return m;
+            }
+        }
+        return null;
+    }
+
+    public static ClassResourceInfo createClassResourceInfo(Map<String, UserResource> resources, UserResource model, boolean isRoot,
+                                                            boolean enableStatic, BundleContext bundleContext) {
+
+        Class<?> sClass = null;
+        try {
+            sClass = bundleContext.getBundle().loadClass(model.getName());
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException("Could not find " + e);
+        }
+        //loadClass(model.getName(),BundleCo);
+        return createServiceClassResourceInfo(resources, model, sClass, isRoot, enableStatic);
+    }
+
+    public static ClassResourceInfo createServiceClassResourceInfo(Map<String, UserResource> resources, UserResource model, Class<?> sClass,
+                                                                   boolean isRoot, boolean enableStatic) {
+        if (model == null) {
+            throw new RuntimeException("Resource class " + sClass.getName() + " has no model info");
+        }
+        ClassResourceInfo cri = new ClassResourceInfo(sClass, sClass, isRoot, enableStatic, true, model.getConsumes(), model.getProduces());
+        URITemplate t = URITemplate.createTemplate(model.getPath());
+        cri.setURITemplate(t);
+        MethodDispatcher md = new MethodDispatcher();
+        Map<String, UserOperation> ops = model.getOperationsAsMap();
+        for (Method m : cri.getServiceClass().getMethods()) {
+            UserOperation op = ops.get(m.getName());
+            if (op == null || op.getName() == null) {
+                continue;
+            }
+            OperationResourceInfo ori = new OperationResourceInfo(m, cri, URITemplate.createTemplate(op.getPath()), op.getVerb(), op.getConsumes(),
+                op.getProduces(), op.getParameters(), op.isOneway());
+            String rClassName = m.getReturnType().getName();
+            if (op.getVerb() == null) {
+                if (resources.containsKey(rClassName)) {
+                    ClassResourceInfo subCri = rClassName.equals(model.getName()) ? cri : createServiceClassResourceInfo(resources, resources.get(
+                        rClassName), m.getReturnType(), false, enableStatic);
+                    if (subCri != null) {
+                        cri.addSubClassResourceInfo(subCri);
+                        md.bind(ori, m);
+                    }
+                }
+            } else {
+                md.bind(ori, m);
+            }
+        }
+        cri.setMethodDispatcher(md);
+        return checkMethodDispatcher(cri) ? cri : null;
+    }
+
+    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass, final Class<?> sClass, boolean root, boolean enableStatic) {
+        ClassResourceInfo cri = new ClassResourceInfo(rClass, sClass, root, enableStatic);
+
+        if (root) {
+            URITemplate t = URITemplate.createTemplate(cri.getPath());
+            cri.setURITemplate(t);
+        }
+
+        evaluateResourceClass(cri, enableStatic);
+        return checkMethodDispatcher(cri) ? cri : null;
+    }
+
+    private static void evaluateResourceClass(ClassResourceInfo cri, boolean enableStatic) {
+        MethodDispatcher md = new MethodDispatcher();
+        for (Method m : cri.getServiceClass().getMethods()) {
+
+            Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(m);
+
+            String httpMethod = AnnotationUtils.getHttpMethodValue(annotatedMethod);
+            Path path = AnnotationUtils.getMethodAnnotation(annotatedMethod, Path.class);
+
+            if (httpMethod != null || path != null) {
+                md.bind(createOperationInfo(m, annotatedMethod, cri, path, httpMethod), m);
+                if (httpMethod == null) {
+                    // subresource locator
+                    Class<?> subClass = m.getReturnType();
+                    if (enableStatic) {
+                        ClassResourceInfo subCri = cri.findResource(subClass, subClass);
+                        if (subCri == null) {
+                            subCri = subClass == cri.getServiceClass() ? cri : createClassResourceInfo(subClass, subClass, false, enableStatic);
+                        }
+
+                        if (subCri != null) {
+                            cri.addSubClassResourceInfo(subCri);
+                        }
+                    }
+                }
+            }
+        }
+        cri.setMethodDispatcher(md);
+    }
+
+    public static Constructor findResourceConstructor(Class<?> resourceClass, boolean perRequest) {
+        List<Constructor> cs = new LinkedList<Constructor>();
+        for (Constructor c : resourceClass.getConstructors()) {
+            Class<?>[] params = c.getParameterTypes();
+            Annotation[][] anns = c.getParameterAnnotations();
+            boolean match = true;
+            for (int i = 0; i < params.length; i++) {
+                if (!perRequest) {
+                    if (AnnotationUtils.getAnnotation(anns[i], Context.class) == null || !AnnotationUtils.isContextClass(params[i])) {
+                        match = false;
+                        break;
+                    }
+                } else {
+                    if (!AnnotationUtils.isValidParamAnnotations(anns[i])) {
+                        match = false;
+                        break;
+                    }
+                }
+            }
+            if (match) {
+                cs.add(c);
+            }
+        }
+        Collections.sort(cs, new Comparator<Constructor>() {
+
+            public int compare(Constructor c1, Constructor c2) {
+                int p1 = c1.getParameterTypes().length;
+                int p2 = c2.getParameterTypes().length;
+                return p1 > p2 ? -1 : p1 < p2 ? 1 : 0;
+            }
+        });
+        return cs.size() == 0 ? null : cs.get(0);
+    }
+
+    public static List<Parameter> getParameters(Method resourceMethod) {
+        Annotation[][] paramAnns = resourceMethod.getParameterAnnotations();
+        if (paramAnns.length == 0) {
+            return CastUtils.cast(Collections.emptyList(), Parameter.class);
+        }
+        List<Parameter> params = new ArrayList<Parameter>(paramAnns.length);
+        for (int i = 0; i < paramAnns.length; i++) {
+            Parameter p = getParameter(i, paramAnns[i]);
+            params.add(p);
+        }
+        return params;
+    }
+
+    public static Parameter getParameter(int index, Annotation[] anns) {
+
+        Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
+        if (ctx != null) {
+            return new Parameter(ParameterType.CONTEXT, index, null);
+        }
+
+        boolean isEncoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
+        String dValue = AnnotationUtils.getDefaultParameterValue(anns);
+
+        Parameter p = null;
+
+        PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class);
+        if (a != null) {
+            p = new Parameter(ParameterType.PATH, index, a.value(), isEncoded, dValue);
+        }
+        if (p == null) {
+            QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
+            if (q != null) {
+                p = new Parameter(ParameterType.QUERY, index, q.value(), isEncoded, dValue);
+            }
+        }
+        if (p != null) {
+            return p;
+        }
+
+        MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
+        if (m != null) {
+            return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded, dValue);
+        }
+
+        FormParam f = AnnotationUtils.getAnnotation(anns, FormParam.class);
+        if (f != null) {
+            return new Parameter(ParameterType.FORM, index, f.value(), isEncoded, dValue);
+        }
+
+        HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
+        if (h != null) {
+            return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded, dValue);
+        }
+
+        p = null;
+        CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
+        if (c != null) {
+            p = new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded, dValue);
+        } else {
+            p = new Parameter(ParameterType.REQUEST_BODY, index, null);
+        }
+
+        return p;
+    }
+
+    private static OperationResourceInfo createOperationInfo(Method m, Method annotatedMethod, ClassResourceInfo cri, Path path, String httpMethod) {
+        OperationResourceInfo ori = new OperationResourceInfo(m, annotatedMethod, cri);
+        URITemplate t = URITemplate.createTemplate(path);
+        ori.setURITemplate(t);
+        ori.setHttpMethod(httpMethod);
+        return ori;
+    }
+
+    private static boolean checkMethodDispatcher(ClassResourceInfo cr) {
+        if (cr.getMethodDispatcher().getOperationResourceInfos().isEmpty()) {
+            LOG.warn(new org.apache.cxf.common.i18n.Message("NO_RESOURCE_OP_EXC", BUNDLE, cr.getServiceClass().getName()).toString());
+            return false;
+        }
+        return true;
+    }
+
+    private static Class<?> loadClass(String cName) {
+        try {
+            LOG.debug("Loading class " + cName);
+            return Thread.currentThread().getContextClassLoader().loadClass(cName);
+            //return ClassLoaderUtils.loadClass(cName.trim(), ResourceUtils.class);
+        } catch (ClassNotFoundException ex) {
+            throw new RuntimeException("No class " + cName.trim() + " can be found", ex);
+        }
+    }
+
+    public static List<UserResource> getUserResources(String loc, Bus bus) {
+        try {
+            LOG.debug("The bus is " + bus.getId());
+            InputStream is = ResourceUtils.getResourceStream(loc, bus);
+            if (is == null) {
+                return null;
+            }
+            return getUserResources(is);
+        } catch (Exception ex) {
+            LOG.warn("Problem with processing a user model at " + loc);
+        }
+
+        return null;
+    }
+
+    public static InputStream getResourceStream(String loc, Bus bus) throws Exception {
+        InputStream is = null;
+        if (loc.startsWith(CLASSPATH_PREFIX)) {
+            String path = loc.substring(CLASSPATH_PREFIX.length());
+
+            is = ResourceUtils.getClasspathResourceStream(path, ResourceUtils.class, bus);
+            if (is == null) {
+                LOG.warn("No classpath resource " + loc + " is available on classpath");
+                return null;
+            }
+        } else {
+            File f = new File(loc);
+            if (!f.exists()) {
+                LOG.warn("No file resource " + loc + " is available on local disk");
+                return null;
+            }
+            is = new FileInputStream(f);
+        }
+        return is;
+    }
+
+    public static InputStream getClasspathResourceStream(String path, Class<?> callingClass, Bus bus) {
+        InputStream is = ClassLoaderUtils.getResourceAsStream(path, callingClass);
+        if (is == null && bus != null) {
+            ResourceManager rm = bus.getExtension(ResourceManager.class);
+            if (rm != null) {
+                is = rm.getResourceAsStream(path);
+            }
+        }
+        return is;
+    }
+
+    public static List<UserResource> getUserResources(String loc) {
+        return getUserResources(loc, BusFactory.getThreadDefaultBus());
+    }
+
+    public static List<UserResource> getUserResources(InputStream is) throws Exception {
+        Document doc = DOMUtils.readXml(new InputStreamReader(is, "UTF-8"));
+        return getResourcesFromElement(doc.getDocumentElement());
+    }
+
+    public static List<UserResource> getResourcesFromElement(Element modelEl) {
+        List<UserResource> resources = new ArrayList<UserResource>();
+        List<Element> resourceEls = DOMUtils.findAllElementsByTagNameNS(modelEl, "http://cxf.apache.org/blueprint/jaxrs", "resource");
+        for (Element e : resourceEls) {
+            resources.add(getResourceFromElement(e));
+        }
+        return resources;
+    }
+
+    public static Map<Class<?>, Type> getAllRequestResponseTypes(List<ClassResourceInfo> cris, boolean jaxbOnly) {
+        Map<Class<?>, Type> types = new HashMap<Class<?>, Type>();
+        for (ClassResourceInfo resource : cris) {
+            getAllTypesForResource(resource, types, jaxbOnly);
+        }
+        return types;
+    }
+
+    private static void getAllTypesForResource(ClassResourceInfo resource, Map<Class<?>, Type> types, boolean jaxbOnly) {
+        for (OperationResourceInfo ori : resource.getMethodDispatcher().getOperationResourceInfos()) {
+            Class<?> cls = ori.getMethodToInvoke().getReturnType();
+            Type type = ori.getMethodToInvoke().getGenericReturnType();
+            if (jaxbOnly) {
+                checkJaxbType(cls, types);
+            } else {
+                types.put(cls, type);
+            }
+            for (Parameter pm : ori.getParameters()) {
+                if (pm.getType() == ParameterType.REQUEST_BODY) {
+                    Class<?> inType = ori.getMethodToInvoke().getParameterTypes()[pm.getIndex()];
+                    Type type2 = ori.getMethodToInvoke().getGenericParameterTypes()[pm.getIndex()];
+                    if (jaxbOnly) {
+                        checkJaxbType(inType, types);
+                    } else {
+                        types.put(inType, type2);
+                    }
+                }
+            }
+        }
+
+        for (ClassResourceInfo sub : resource.getSubResources()) {
+            if (sub != resource) {
+                getAllTypesForResource(sub, types, jaxbOnly);
+            }
+        }
+    }
+
+    private static void checkJaxbType(Class<?> type, Map<Class<?>, Type> types) {
+        JAXBElementProvider provider = new JAXBElementProvider();
+        if (!InjectionUtils.isPrimitive(type) && !JAXBElement.class.isAssignableFrom(type) && provider.isReadable(type, type, new Annotation[0],
+            MediaType.APPLICATION_XML_TYPE)) {
+            types.put(type, type);
+        }
+    }
+
+    private static UserResource getResourceFromElement(Element e) {
+        UserResource resource = new UserResource();
+        resource.setName(e.getAttribute("name"));
+        resource.setPath(e.getAttribute("path"));
+        resource.setConsumes(e.getAttribute("consumes"));
+        resource.setProduces(e.getAttribute("produces"));
+        List<Element> operEls = DOMUtils.findAllElementsByTagNameNS(e, "http://cxf.apache.org/blueprint/jaxrs", "operation");
+        List<UserOperation> opers = new ArrayList<UserOperation>(operEls.size());
+        for (Element operEl : operEls) {
+            opers.add(getOperationFromElement(operEl));
+        }
+        resource.setOperations(opers);
+        return resource;
+    }
+
+    private static UserOperation getOperationFromElement(Element e) {
+        UserOperation op = new UserOperation();
+        op.setName(e.getAttribute("name"));
+        op.setVerb(e.getAttribute("verb"));
+        op.setPath(e.getAttribute("path"));
+        op.setOneway(Boolean.parseBoolean(e.getAttribute("oneway")));
+        op.setConsumes(e.getAttribute("consumes"));
+        op.setProduces(e.getAttribute("produces"));
+        List<Element> paramEls = DOMUtils.findAllElementsByTagNameNS(e, "http://cxf.apache.org/blueprint/jaxrs", "param");
+        List<Parameter> params = new ArrayList<Parameter>(paramEls.size());
+        for (int i = 0; i < paramEls.size(); i++) {
+            Element paramEl = paramEls.get(i);
+            Parameter p = new Parameter(paramEl.getAttribute("type"), i, paramEl.getAttribute("name"));
+            p.setEncoded(Boolean.valueOf(paramEl.getAttribute("encoded")));
+            p.setDefaultValue(paramEl.getAttribute("defaultValue"));
+            params.add(p);
+        }
+        op.setParameters(params);
+        return op;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static Object[] createConstructorArguments(Constructor c, Message m) {
+        Class<?>[] params = c.getParameterTypes();
+        Annotation[][] anns = c.getParameterAnnotations();
+        Type[] genericTypes = c.getGenericParameterTypes();
+        MultivaluedMap<String, String> templateValues = m == null ? null : (MultivaluedMap) m.get(URITemplate.TEMPLATE_PARAMETERS);
+        Object[] values = new Object[params.length];
+        for (int i = 0; i < params.length; i++) {
+            if (AnnotationUtils.isContextClass(params[i])) {
+                values[i] = JAXRSUtils.createContextValue(m, genericTypes[i], params[i]);
+            } else {
+                Parameter p = ResourceUtils.getParameter(i, anns[i]);
+                values[i] = JAXRSUtils.createHttpParameterValue(p, params[i], genericTypes[i], m, templateValues, null);
+            }
+        }
+        return values;
+    }
+
+    public static JAXRSServerFactoryBean createApplication(Application app, boolean ignoreAppPath) {
+
+        Set<Object> singletons = app.getSingletons();
+        verifySingletons(singletons);
+
+        List<Class> resourceClasses = new ArrayList<Class>();
+        List<Object> providers = new ArrayList<Object>();
+        Map<Class, ResourceProvider> map = new HashMap<Class, ResourceProvider>();
+
+        // Note, app.getClasse() returns a list of per-resource classes
+        // or singleton provider classes
+        for (Class<?> c : app.getClasses()) {
+            if (isValidApplicationClass(c, singletons)) {
+                if (c.getAnnotation(Provider.class) != null) {
+                    try {
+                        providers.add(c.newInstance());
+                    } catch (Throwable ex) {
+                        throw new RuntimeException("Provider " + c.getName() + " can not be created", ex);
+                    }
+                } else {
+                    resourceClasses.add(c);
+                    map.put(c, new PerRequestResourceProvider(c));
+                }
+            }
+        }
+
+        // we can get either a provider or resource class here        
+        for (Object o : singletons) {
+            boolean isProvider = o.getClass().getAnnotation(Provider.class) != null;
+            if (isProvider) {
+                providers.add(o);
+            } else {
+                resourceClasses.add(o.getClass());
+                map.put(o.getClass(), new SingletonResourceProvider(o));
+            }
+        }
+
+        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
+        String address = "/";
+        if (!ignoreAppPath) {
+            ApplicationPath appPath = app.getClass().getAnnotation(ApplicationPath.class);
+            if (appPath != null) {
+                address = appPath.value().length() == 0 ? "/" : appPath.value();
+            }
+        }
+        bean.setAddress(address);
+        bean.setResourceClasses(resourceClasses);
+        bean.setProviders(providers);
+        for (Map.Entry<Class, ResourceProvider> entry : map.entrySet()) {
+            bean.setResourceProvider(entry.getKey(), entry.getValue());
+        }
+
+        return bean;
+    }
+
+    private static void verifySingletons(Set<Object> singletons) {
+        if (singletons.isEmpty()) {
+            return;
+        }
+        Set<String> map = new HashSet<String>();
+        for (Object s : singletons) {
+            if (map.contains(s.getClass().getName())) {
+                throw new RuntimeException("More than one instance of the same singleton class " + s.getClass().getName() + " is available");
+            } else {
+                map.add(s.getClass().getName());
+            }
+        }
+    }
+
+    public static boolean isValidResourceClass(Class<?> c) {
+        if (c.isInterface() || Modifier.isAbstract(c.getModifiers())) {
+            LOG.info("Ignoring invalid resource class " + c.getName());
+            return false;
+        }
+        return true;
+    }
+
+    private static boolean isValidApplicationClass(Class<?> c, Set<Object> singletons) {
+        if (!isValidResourceClass(c)) {
+            return false;
+        }
+        for (Object s : singletons) {
+            if (c == s.getClass()) {
+                LOG.info("Ignoring per-request resource class " + c.getName() + " as it is also registered as singleton");
+                return false;
+            }
+        }
+        return true;
+    }
+
+    //TODO : consider moving JAXBDataBinding.createContext to JAXBUtils
+    public static JAXBContext createJaxbContext(Set<Class<?>> classes, Class[] extraClass, Map<String, Object> contextProperties) {
+        if (classes == null || classes.isEmpty()) {
+            return null;
+        }
+        JAXBUtils.scanPackages(classes, extraClass, null);
+
+        JAXBContext ctx;
+        try {
+            ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), contextProperties);
+            return ctx;
+        } catch (JAXBException ex) {
+            LOG.debug("No JAXB context can be created");
+        }
+        return null;
+    }
+}

Modified: cxf/sandbox/cxf-blueprint/jaxrs/src/main/resources/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxrs/src/main/resources/jaxrs.xsd?rev=1085518&r1=1085517&r2=1085518&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxrs/src/main/resources/jaxrs.xsd (original)
+++ cxf/sandbox/cxf-blueprint/jaxrs/src/main/resources/jaxrs.xsd Fri Mar 25 19:01:52 2011
@@ -33,20 +33,53 @@
     </xsd:attribute>
   </xsd:complexType>
 
-  <xsd:complexType name="map">
-    <xsd:sequence>
-      <xsd:element name="entry" minOccurs="0"
-                   maxOccurs="unbounded">
-        <xsd:complexType>
-          <xsd:sequence>
-            <xsd:element name="key"/>
-            <xsd:element name="value"/>
-          </xsd:sequence>
-        </xsd:complexType>
-      </xsd:element>
+  <xsd:complexType name="Map">
+    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+      <xsd:element name="entry" type="entryType"/>
     </xsd:sequence>
   </xsd:complexType>
 
+  <xsd:complexType name="entryType">
+    <xsd:sequence/>
+
+    <xsd:attribute name="key" type="xsd:string">
+      <xsd:annotation>
+        <xsd:documentation><![CDATA[
+	Each map element must specify its key as attribute or as child element.
+	A key attribute is always a String value.
+				]]></xsd:documentation>
+      </xsd:annotation>
+    </xsd:attribute>
+    <!--
+    <xsd:attribute name="key-ref" type="xsd:string">
+      <xsd:annotation>
+        <xsd:documentation><![CDATA[
+	A short-cut alternative to a to a "key" element with a nested
+	"<ref bean='...'/>".
+				]]></xsd:documentation>
+      </xsd:annotation>
+
+
+    </xsd:attribute>
+    -->
+    <xsd:attribute name="value" type="xsd:string">
+      <xsd:annotation>
+        <xsd:documentation><![CDATA[
+	A short-cut alternative to a nested "<value>...</value>"
+	element.
+				]]></xsd:documentation>
+      </xsd:annotation>
+    </xsd:attribute>
+    <!--
+    <xsd:attribute name="value-ref" type="xsd:string">
+      <xsd:annotation>
+        <xsd:documentation><![CDATA[
+	A short-cut alternative to a nested "<ref bean='...'/>".
+				]]></xsd:documentation>
+      </xsd:annotation>
+    </xsd:attribute>
+        -->
+  </xsd:complexType>
   <xsd:element name="server">
     <xsd:complexType>
       <xsd:complexContent>
@@ -62,7 +95,7 @@
             <xsd:element name="serviceFactories" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
-            <xsd:element name="properties" type="map" minOccurs="0"/>
+            <xsd:element name="properties" type="Map" minOccurs="0"/>
             <xsd:element name="serviceBeans" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="modelBeans" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="model" type="model" minOccurs="0"/>
@@ -100,7 +133,7 @@
             <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
-            <xsd:element name="properties" type="map" minOccurs="0"/>
+            <xsd:element name="properties" type="Map" minOccurs="0"/>
             <xsd:element name="providers" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="modelBeans" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="model" type="model" minOccurs="0"/>

Modified: cxf/sandbox/cxf-blueprint/jaxrs/src/test/java/org/apache/cxf/blueprint/jaxrs/NsHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxrs/src/test/java/org/apache/cxf/blueprint/jaxrs/NsHandlerTest.java?rev=1085518&r1=1085517&r2=1085518&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxrs/src/test/java/org/apache/cxf/blueprint/jaxrs/NsHandlerTest.java (original)
+++ cxf/sandbox/cxf-blueprint/jaxrs/src/test/java/org/apache/cxf/blueprint/jaxrs/NsHandlerTest.java Fri Mar 25 19:01:52 2011
@@ -35,7 +35,7 @@ public class NsHandlerTest extends BaseN
         ComponentDefinitionRegistry cdr = parseCDR("org/apache/cxf/blueprint/jaxrs/cxf.xml");
 
         BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("customerService");
-        BeanProperty bp = (BeanProperty) comp.getProperties().get(1);
+        BeanProperty bp = (BeanProperty) comp.getProperties().get(2);
         ValueMetadata anon = (ValueMetadata) bp.getValue();
 
         assertTrue("http://localhost:9092/crm".equals(anon.getStringValue()));
@@ -47,7 +47,7 @@ public class NsHandlerTest extends BaseN
 
         BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("customerService");
 
-        BeanProperty bp = (BeanProperty) comp.getProperties().get(3);
+        BeanProperty bp = (BeanProperty) comp.getProperties().get(5);
         CollectionMetadata anon = (CollectionMetadata) bp.getValue();
 
         RefMetadata interceptor = (RefMetadata) anon.getValues().get(0);

Modified: cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java?rev=1085518&r1=1085517&r2=1085518&view=diff
==============================================================================
--- cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java (original)
+++ cxf/sandbox/cxf-blueprint/jaxws/src/main/java/org/apache/cxf/blueprint/jaxws/ServerDefinitionParser.java Fri Mar 25 19:01:52 2011
@@ -52,7 +52,7 @@ class ServerDefinitionParser extends Bas
 
         boolean setBus = parseAttributes(element, context, cxfBean, registry);
         if (!setBus && hasBusProperty()) {
-            addBusWiringAttribute(cxfBean);
+            addBusWiringAttribute(cxfBean, context, registry);
         }
         parseChildElements(element, context, cxfBean);
 



Mime
View raw message