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 @@
<bundle
start-level='10'>mvn:org.apache.geronimo.specs/geronimo-servlet_3.0_spec/${cxf.geronimo.servlet.version}</bundle>
</feature>
- <feature name='jaxb' version='${cxf.jaxb.bundle.version}'>
- <feature version="${project.verion}">cxf-specs</feature>
+ <feature name='cxf-jaxb' version='${cxf.jaxb.bundle.version}'>
+ <feature version="${project.version}">cxf-specs</feature>
<bundle
start-level='20'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/${cxf.jaxb.bundle.version}</bundle>
<bundle
start-level='20'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc/${cxf.jaxb.bundle.version}</bundle>
</feature>
@@ -82,7 +82,7 @@
<bundle>mvn:org.apache.abdera/abdera-extensions-json/${cxf.abdera.version}</bundle>
<bundle>mvn:org.apache.abdera/abdera-client/${cxf.abdera.version}</bundle>
<bundle>mvn:org.apache.abdera/abdera-server/${cxf.abdera.version}</bundle-->
- <feature version='${cxf.jaxb.bundle.version}'>jaxb</feature>
+ <feature version='${cxf.jaxb.bundle.version}'>cxf-jaxb</feature>
</feature>
<feature name="wss4j" version="${cxf.wss4j.version}">
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlsec/${cxf.xmlsec.bundle.version}</bundle>
@@ -103,6 +103,7 @@
<bundle
start-level='20'>mvn:org.codehaus.woodstox/stax2-api/${cxf.woodstox.stax2-api.version}</bundle>
<bundle
start-level='20'>mvn:org.codehaus.woodstox/woodstox-core-asl/${cxf.woodstox.core.version}</bundle>
+ <feature version='${cxf.jaxb.bundle.version}'>cxf-jaxb</feature>
<feature version="${cxf.spring.osgi.version}">spring-dm</feature>
<feature version="${cxf.karaf.version}">http</feature>
<feature version="${cxf.karaf.version}">war</feature>
@@ -110,7 +111,6 @@
<feature version="${cxf.spring.version}">spring-jms</feature>
<feature version="${cxf.wss4j.version}">wss4j</feature>
<feature version="${cxf.jetty.version}">jetty7</feature>
- <feature version='${cxf.jaxb.bundle.version}'>jaxb</feature>
<feature version='${cxf.abdera.version}'>abdera</feature>
<bundle>mvn:org.apache.neethi/neethi/${cxf.neethi.version}</bundle>
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 @@
<dependencies>
<dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
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<Class> 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<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.setObject(new PassThroughCallable<Object>(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<Object>(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<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.setObject(new PassThroughCallable<Object>(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<T> implements Callable<T> {
+
+ 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 @@
+<!--
+ ~ /**
+ ~ * 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.
+ ~ */
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <service interface="org.apache.aries.blueprint.NamespaceHandler">
+ <service-properties>
+ <entry key="osgi.service.blueprint.namespace"
value="http://cxf.apache.org/blueprint/jaxrs"/>
+ </service-properties>
+ <bean class="org.apache.cxf.jaxrs.blueprint.JAXRSBPNamespaceHandler"/>
+ </service>
+</blueprint>
\ 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<xsd:schema xmlns="http://cxf.apache.org/blueprint/jaxrs"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:beans="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cxf-beans="http://cxf.apache.org/configuration/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ targetNamespace="http://cxf.apache.org/blueprint/jaxrs"
+ xmlns:tns="http://cxf.apache.org/blueprint/jaxrs"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified" >
+
+ <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0"
schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"/>
+ <xsd:import namespace="http://cxf.apache.org/configuration/beans"
schemaLocation="http://cxf.apache.org/schemas/configuration/cxf-beans.xsd"/>
+
+ <xsd:element name="server">
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="beans:Tcomponent">
+ <xsd:all>
+ <xsd:element name="executor" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="features" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="binding" type="xsd:anyType" minOccurs="0" />
+ <xsd:element name="dataBinding" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="inInterceptors" type="xsd:anyType"
minOccurs="0"/>
+ <xsd:element name="inFaultInterceptors" type="xsd:anyType"
minOccurs="0"/>
+ <xsd:element name="invoker" type="xsd:anyType" minOccurs="0"/>
+ <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="beans:Tmap" 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"/>
+ <xsd:element name="providers" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="extensionMappings" type="xsd:anyType"
minOccurs="0"/>
+ <xsd:element name="languageMappings" type="xsd:anyType"
minOccurs="0"/>
+ <xsd:element name="schemaLocations" type="schemasType"
minOccurs="0"/>
+ <xsd:element name="resourceComparator" type="xsd:anyType"
minOccurs="0"/>
+ </xsd:all>
+ <!-- xsd:attributeGroup ref="cxf-beans:beanAttributes"/-->
+ <xsd:attribute name="address" type="xsd:string" />
+ <xsd:attribute name="bus" type="xsd:string" />
+ <xsd:attribute name="serviceClass" type="xsd:string"/>
+ <xsd:attribute name="transportId" type="xsd:string"/>
+ <xsd:attribute name="modelRef" type="xsd:string" />
+ <xsd:attribute name="bindingId" type="xsd:string" />
+ <xsd:attribute name="staticSubresourceResolution"
type="xsd:boolean"/>
+ <xsd:attribute name="beanNames" type="xsd:string"/>
+ <xsd:attribute name="serviceName" type="xsd:QName"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="client">
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="beans:Tcomponent">
+ <xsd:all>
+ <xsd:element name="executor" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="features" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="binding" type="xsd:anyType" minOccurs="0" />
+ <xsd:element name="dataBinding" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="inInterceptors" type="xsd:anyType"
minOccurs="0"/>
+ <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="beans:Tmap" 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"/>
+ <xsd:element name="headers" type="xsd:anyType" minOccurs="0"/>
+ <xsd:element name="schemaLocations" type="schemasType"
minOccurs="0"/>
+ </xsd:all>
+ <!-- xsd:attributeGroup ref="cxf-beans:beanAttributes"/-->
+ <xsd:attribute name="address" type="xsd:string" />
+ <xsd:attribute name="serviceClass" type="xsd:string"/>
+ <xsd:attribute name="inheritHeaders" type="xsd:boolean"/>
+ <xsd:attribute name="bus" type="xsd:string" />
+ <xsd:attribute name="transportId" type="xsd:string"/>
+ <xsd:attribute name="bindingId" type="xsd:string" />
+ <xsd:attribute name="modelRef" type="xsd:string" />
+ <xsd:attribute name="username" type="xsd:string"/>
+ <xsd:attribute name="password" type="xsd:string"/>
+ <xsd:attribute name="serviceName" type="xsd:QName"/>
+ <xsd:attribute name="threadSafe" type="xsd:boolean"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="schemasType">
+ <xsd:sequence>
+ <xsd:element name="schemaLocation" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="model" type="tns:model"/>
+
+ <xsd:complexType name="model">
+ <xsd:sequence>
+ <xsd:element name="resource" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="operation" minOccurs="0"
maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="param" minOccurs="0"
maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="type">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="PATH"/>
+ <xsd:enumeration value="QUERY"/>
+ <xsd:enumeration value="MATRIX"/>
+ <xsd:enumeration value="HEADER"/>
+ <xsd:enumeration value="COOKIE"/>
+ <xsd:enumeration value="FORM"/>
+ <xsd:enumeration value="CONTEXT"/>
+ <xsd:enumeration value="REQUEST_BODY"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="defaultValue"
type="xsd:string"/>
+ <xsd:attribute name="encoded"
type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="path" type="xsd:string"/>
+ <xsd:attribute name="verb" type="xsd:string"/>
+ <xsd:attribute name="consumes" type="xsd:string"/>
+ <xsd:attribute name="produces" type="xsd:string"/>
+ <xsd:attribute name="oneway" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="path" type="xsd:string"/>
+ <xsd:attribute name="consumes" type="xsd:string"/>
+ <xsd:attribute name="produces" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:string"/>
+ </xsd:complexType>
+
+</xsd:schema>
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