Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 11903 invoked from network); 31 Mar 2011 23:55:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 Mar 2011 23:55:24 -0000 Received: (qmail 94335 invoked by uid 500); 31 Mar 2011 23:55:24 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 94298 invoked by uid 500); 31 Mar 2011 23:55:24 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 94288 invoked by uid 99); 31 Mar 2011 23:55:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Mar 2011 23:55:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Mar 2011 23:55:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D7F862388A3B; Thu, 31 Mar 2011 23:55:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1087511 - in /cxf/trunk: distribution/karaf/features/src/main/resources/ rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/ rt/frontend/jaxrs/src/main/re... Date: Thu, 31 Mar 2011 23:55:01 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110331235501.D7F862388A3B@eris.apache.org> Author: dkulp Date: Thu Mar 31 23:55:01 2011 New Revision: 1087511 URL: http://svn.apache.org/viewvc?rev=1087511&view=rev Log: Fix features. Get jaxrs:server blueprint version working Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/BlueprintResourceFactory.java (with props) cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java (with props) cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSClientFactoryBeanDefinitionParser.java (with props) cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSServerFactoryBeanDefinitionParser.java (with props) cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/ cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/ cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml (with props) cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/ cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd (with props) Modified: cxf/trunk/distribution/karaf/features/src/main/resources/features.xml cxf/trunk/rt/frontend/jaxrs/pom.xml cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Modified: cxf/trunk/distribution/karaf/features/src/main/resources/features.xml URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/features/src/main/resources/features.xml?rev=1087511&r1=1087510&r2=1087511&view=diff ============================================================================== --- cxf/trunk/distribution/karaf/features/src/main/resources/features.xml (original) +++ cxf/trunk/distribution/karaf/features/src/main/resources/features.xml Thu Mar 31 23:55:01 2011 @@ -33,8 +33,8 @@ mvn:org.apache.geronimo.specs/geronimo-servlet_3.0_spec/${cxf.geronimo.servlet.version} - - cxf-specs + + cxf-specs mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/${cxf.jaxb.bundle.version} mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc/${cxf.jaxb.bundle.version} @@ -82,7 +82,7 @@ mvn:org.apache.abdera/abdera-extensions-json/${cxf.abdera.version} mvn:org.apache.abdera/abdera-client/${cxf.abdera.version} mvn:org.apache.abdera/abdera-server/${cxf.abdera.version} - jaxb + cxf-jaxb mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlsec/${cxf.xmlsec.bundle.version} @@ -103,6 +103,7 @@ mvn:org.codehaus.woodstox/stax2-api/${cxf.woodstox.stax2-api.version} mvn:org.codehaus.woodstox/woodstox-core-asl/${cxf.woodstox.core.version} + cxf-jaxb spring-dm http war @@ -110,7 +111,6 @@ spring-jms wss4j jetty7 - jaxb abdera mvn:org.apache.neethi/neethi/${cxf.neethi.version} Modified: cxf/trunk/rt/frontend/jaxrs/pom.xml URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/pom.xml?rev=1087511&r1=1087510&r2=1087511&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/pom.xml (original) +++ cxf/trunk/rt/frontend/jaxrs/pom.xml Thu Mar 31 23:55:01 2011 @@ -34,6 +34,14 @@ + org.apache.aries.blueprint + org.apache.aries.blueprint.core + + + org.osgi + org.osgi.core + + junit junit test Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=1087511&r1=1087510&r2=1087511&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Thu Mar 31 23:55:01 2011 @@ -27,6 +27,7 @@ import java.util.Map; import javax.ws.rs.core.Application; +import org.apache.cxf.Bus; import org.apache.cxf.BusException; import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.endpoint.EndpointException; @@ -112,13 +113,30 @@ public class JAXRSServerFactoryBean exte serviceFactory.setEnableStaticResolution(enableStatic); } + + /** + * Creates the JAX-RS Server instance + * @return the server + */ + public void init() { + if (server == null) { + create(); + } + } + /** * Creates the JAX-RS Server instance * @return the server */ public Server create() { + ClassLoader origLoader = Thread.currentThread().getContextClassLoader(); try { - serviceFactory.setBus(getBus()); + Bus bus = getBus(); + ClassLoader loader = bus.getExtension(ClassLoader.class); + if (loader != null) { + Thread.currentThread().setContextClassLoader(loader); + } + serviceFactory.setBus(bus); checkResources(true); if (serviceFactory.getService() == null) { serviceFactory.setServiceName(getServiceName()); @@ -168,6 +186,8 @@ public class JAXRSServerFactoryBean exte throw new ServiceConstructionException(e); } catch (Exception e) { throw new ServiceConstructionException(e); + } finally { + Thread.currentThread().setContextClassLoader(origLoader); } return server; Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/BlueprintResourceFactory.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/BlueprintResourceFactory.java?rev=1087511&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/BlueprintResourceFactory.java (added) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/BlueprintResourceFactory.java Thu Mar 31 23:55:01 2011 @@ -0,0 +1,109 @@ +/** + * 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.jaxrs.blueprint; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +import org.apache.aries.blueprint.reflect.MetadataUtil; +import org.apache.cxf.common.util.ClassHelper; +import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; +import org.apache.cxf.jaxrs.utils.InjectionUtils; +import org.apache.cxf.jaxrs.utils.ResourceUtils; +import org.apache.cxf.message.Message; +import org.osgi.service.blueprint.container.BlueprintContainer; +import org.osgi.service.blueprint.reflect.BeanMetadata; + +public class BlueprintResourceFactory implements ResourceProvider { + + private BlueprintContainer blueprintContainer; + private Constructor c; + private String beanId; + private Method postConstructMethod; + private Method preDestroyMethod; + private boolean isSingleton; + + public BlueprintResourceFactory() { + + } + + public BlueprintResourceFactory(String name) { + beanId = name; + } + + private void init() { + Class type = ClassHelper.getRealClassFromClass(blueprintContainer.getComponentInstance(beanId) + .getClass()); + if (Proxy.isProxyClass(type)) { + type = ClassHelper.getRealClass(blueprintContainer.getComponentInstance(beanId)); + } + c = ResourceUtils.findResourceConstructor(type, !isSingleton()); + if (c == null) { + throw new RuntimeException("Resource class " + type + " has no valid constructor"); + } + postConstructMethod = ResourceUtils.findPostConstructMethod(type); + preDestroyMethod = ResourceUtils.findPreDestroyMethod(type); + + Object component = blueprintContainer.getComponentMetadata(beanId); + if (component instanceof BeanMetadata) { + BeanMetadata local = (BeanMetadata) component; + isSingleton = MetadataUtil.isSingletonScope(local); + } + } + + public Object getInstance(Message m) { + //TODO -- This is not the BP way. + Object[] values = ResourceUtils.createConstructorArguments(c, m); + //TODO Very springish... + Object instance = values.length > 0 ? blueprintContainer.getComponentInstance(beanId) + : blueprintContainer.getComponentInstance(beanId); + if (!isSingleton || m == null) { + InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod); + } + return instance; + } + + public boolean isSingleton() { + return isSingleton; + } + + public void releaseInstance(Message m, Object o) { + if (!isSingleton) { + InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod); + } + } + + public void setBeanId(String serviceBeanId) { + this.beanId = serviceBeanId; + } + + Constructor getBeanConstructor() { + return c; + } + + public Class getResourceClass() { + return c.getDeclaringClass(); + } + + public void setBlueprintContainer(BlueprintContainer blueprintContainer) { + this.blueprintContainer = blueprintContainer; + init(); + } +} Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/BlueprintResourceFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/BlueprintResourceFactory.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java?rev=1087511&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java (added) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java Thu Mar 31 23:55:01 2011 @@ -0,0 +1,74 @@ +/** + * 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.jaxrs.blueprint; + +import java.net.URL; +import java.util.Set; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import org.apache.aries.blueprint.NamespaceHandler; +import org.apache.aries.blueprint.ParserContext; +import org.osgi.service.blueprint.container.BlueprintContainer; +import org.osgi.service.blueprint.reflect.ComponentMetadata; +import org.osgi.service.blueprint.reflect.Metadata; + +/** + * + */ +public class JAXRSBPNamespaceHandler implements NamespaceHandler { + private BlueprintContainer blueprintContainer; + + public JAXRSBPNamespaceHandler() { + } + + public URL getSchemaLocation(String namespace) { + return getClass().getClassLoader().getResource("/schemas/blueprint/jaxrs.xsd"); + } + + + public Metadata parse(Element element, ParserContext context) { + String s = element.getLocalName(); + if ("server".equals(s)) { + return new JAXRSServerFactoryBeanDefinitionParser().parse(element, context); + } else if ("client".equals(s)) { + return new JAXRSClientFactoryBeanDefinitionParser().parse(element, context); + } + return null; + } + + public Set getManagedClasses() { + return null; + } + public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) { + return null; + } + + + public BlueprintContainer getBlueprintContainer() { + return blueprintContainer; + } + + public void setBlueprintContainer(BlueprintContainer blueprintContainer) { + this.blueprintContainer = blueprintContainer; + } + +} Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSBPNamespaceHandler.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSClientFactoryBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSClientFactoryBeanDefinitionParser.java?rev=1087511&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSClientFactoryBeanDefinitionParser.java (added) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSClientFactoryBeanDefinitionParser.java Thu Mar 31 23:55:01 2011 @@ -0,0 +1,104 @@ +/** + * 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.jaxrs.blueprint; + +import java.util.List; + +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.configuration.blueprint.SimpleBPBeanDefinitionParser; +import org.apache.cxf.jaxrs.blueprint.JAXRSServerFactoryBeanDefinitionParser.PassThroughCallable; +import org.apache.cxf.jaxrs.client.Client; +import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; +import org.apache.cxf.jaxrs.model.UserResource; +import org.apache.cxf.jaxrs.utils.ResourceUtils; + + + +public class JAXRSClientFactoryBeanDefinitionParser extends SimpleBPBeanDefinitionParser { + + public JAXRSClientFactoryBeanDefinitionParser() { + super(JAXRSClientFactoryBean.class); + } + @Override + public String getFactorySuffix() { + return ".proxyFactory"; + } + public String getFactoryCreateType(Element element) { + return Client.class.getName(); + } + + @Override + protected boolean hasBusProperty() { + return true; + } + + + @Override + protected void mapAttribute(MutableBeanMetadata bean, + Element e, String name, + String val, ParserContext context) { + if ("serviceName".equals(name)) { + QName q = parseQName(e, val); + bean.addProperty(name, this.createValue(context, q)); + } else { + mapToProperty(bean, name, val, context); + } + } + + @Override + protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) { + if ("properties".equals(name) || "headers".equals(name)) { + bean.addProperty(name, this.parseMapData(ctx, bean, el)); + } else if ("executor".equals(name)) { + setFirstChildAsProperty(el, ctx, bean, "serviceFactory.executor"); + } else if ("binding".equals(name)) { + setFirstChildAsProperty(el, ctx, bean, "bindingConfig"); + } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) + || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name)) { + bean.addProperty(name, parseListData(ctx, bean, el)); + } else if ("features".equals(name) || "providers".equals(name) + || "schemaLocations".equals(name) || "modelBeans".equals(name)) { + bean.addProperty(name, parseListData(ctx, bean, el)); + } else if ("model".equals(name)) { + List 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.setObject(new PassThroughCallable(res)); + + MutableBeanMetadata resourceBean = ctx.createMetadata(MutableBeanMetadata.class); + resourceBean.setFactoryComponent(factory); + resourceBean.setFactoryMethod("call"); + list.addValue(resourceBean); + } + bean.addProperty("modelBeans", list); + } else { + setFirstChildAsProperty(el, ctx, bean, name); + } + } + +} Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSClientFactoryBeanDefinitionParser.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSClientFactoryBeanDefinitionParser.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSServerFactoryBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSServerFactoryBeanDefinitionParser.java?rev=1087511&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSServerFactoryBeanDefinitionParser.java (added) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSServerFactoryBeanDefinitionParser.java Thu Mar 31 23:55:01 2011 @@ -0,0 +1,148 @@ +/** + * 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.jaxrs.blueprint; + +import java.util.List; +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.configuration.blueprint.SimpleBPBeanDefinitionParser; +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; +import org.apache.cxf.jaxrs.model.UserResource; +import org.apache.cxf.jaxrs.utils.ResourceUtils; +import org.osgi.service.blueprint.reflect.Metadata; + + + +public class JAXRSServerFactoryBeanDefinitionParser extends SimpleBPBeanDefinitionParser { + + public JAXRSServerFactoryBeanDefinitionParser() { + super(JAXRSServerFactoryBean.class); + } + @Override + protected void mapAttribute(MutableBeanMetadata bean, + Element e, String name, + String val, ParserContext context) { + if ("beanNames".equals(name)) { + String[] values = val.split(" "); + MutableCollectionMetadata tempFactories = context.createMetadata(MutableCollectionMetadata.class); + for (String v : values) { + String theValue = v.trim(); + if (theValue.length() > 0) { + + MutablePassThroughMetadata factory + = context.createMetadata(MutablePassThroughMetadata.class); + factory.setObject(new PassThroughCallable(new BlueprintResourceFactory(v))); + + MutableBeanMetadata resourceBean = context.createMetadata(MutableBeanMetadata.class); + resourceBean.setRuntimeClass(BlueprintResourceFactory.class); + resourceBean.setFactoryComponent(factory); + resourceBean.setFactoryMethod("call"); + resourceBean.setInitMethod("init"); + + tempFactories.addValue(resourceBean); + } + } + bean.addProperty("tempFactories", tempFactories); + } else if ("serviceName".equals(name)) { + QName q = parseQName(e, val); + bean.addProperty(name, createValue(context, q)); + } else { + mapToProperty(bean, name, val, context); + } + } + + @Override + protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) { + if ("properties".equals(name) + || "extensionMappings".equals(name) + || "languageMappings".equals(name)) { + bean.addProperty(name, this.parseMapData(ctx, bean, el)); + } else if ("executor".equals(name)) { + setFirstChildAsProperty(el, ctx, bean, "serviceFactory.executor"); + } else if ("invoker".equals(name)) { + setFirstChildAsProperty(el, ctx, bean, "serviceFactory.invoker"); + } else if ("binding".equals(name)) { + setFirstChildAsProperty(el, ctx, bean, "bindingConfig"); + } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) + || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name)) { + bean.addProperty(name, this.parseListData(ctx, bean, el)); + } else if ("features".equals(name) || "schemaLocations".equals(name) + || "providers".equals(name) || "serviceBeans".equals(name) + || "modelBeans".equals(name)) { + bean.addProperty(name, this.parseListData(ctx, bean, el)); + } else if ("serviceFactories".equals(name)) { + bean.addProperty("resourceProviders", this.parseListData(ctx, bean, el)); + } else if ("model".equals(name)) { + List 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.setObject(new PassThroughCallable(res)); + + MutableBeanMetadata resourceBean = ctx.createMetadata(MutableBeanMetadata.class); + resourceBean.setFactoryComponent(factory); + resourceBean.setFactoryMethod("call"); + list.addValue(resourceBean); + } + bean.addProperty("modelBeans", list); + } else { + setFirstChildAsProperty(el, ctx, bean, name); + } + } + + + @Override + public Metadata parse(Element element, ParserContext context) { + MutableBeanMetadata bean = (MutableBeanMetadata)super.parse(element, context); + bean.setInitMethod("init"); + + // We don't really want to delay the registration of our Server + bean.setActivation(MutableBeanMetadata.ACTIVATION_EAGER); + return bean; + } + + + @Override + protected boolean hasBusProperty() { + return true; + } + + public static class PassThroughCallable implements Callable { + + private T value; + + public PassThroughCallable(T value) { + this.value = value; + } + + public T call() throws Exception { + return value; + } + } + +} Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSServerFactoryBeanDefinitionParser.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/blueprint/JAXRSServerFactoryBeanDefinitionParser.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml?rev=1087511&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml (added) +++ cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml Thu Mar 31 23:55:01 2011 @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/resources/OSGI-INF/blueprint/cxf-jaxrs.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd?rev=1087511&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd (added) +++ cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd Thu Mar 31 23:55:01 2011 @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd ------------------------------------------------------------------------------ svn:mime-type = text/xml