You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/03/29 21:43:23 UTC
svn commit: r1086700 [1/2] - in /cxf/trunk: parent/ rt/core/
rt/core/src/main/java/org/apache/cxf/bus/blueprint/
rt/core/src/main/java/org/apache/cxf/configuration/blueprint/
rt/core/src/main/resources/OSGI-INF/
rt/core/src/main/resources/OSGI-INF/blue...
Author: dkulp
Date: Tue Mar 29 19:43:22 2011
New Revision: 1086700
URL: http://svn.apache.org/viewvc?rev=1086700&view=rev
Log:
Start porting Johan Edstom's blueprint stuff onto trunk
Added:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java (with props)
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java (with props)
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/CXFCoreNamespaceHandler.java (with props)
cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/
cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java (with props)
cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java (with props)
cxf/trunk/rt/core/src/main/resources/OSGI-INF/
cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/
cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml (with props)
cxf/trunk/rt/core/src/main/resources/schemas/blueprint/
cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd (with props)
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/EndpointDefinitionParser.java (with props)
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/JAXWSBPNamespaceHandler.java (with props)
cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/
cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/
cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml (with props)
cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/blueprint/
cxf/trunk/rt/frontend/jaxws/src/main/resources/schemas/blueprint/jaxws.xsd (with props)
Removed:
cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/spring/cxf-transport-osgi.xml
Modified:
cxf/trunk/parent/pom.xml
cxf/trunk/rt/core/pom.xml
cxf/trunk/rt/frontend/jaxws/pom.xml
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
cxf/trunk/rt/transports/http/src/main/resources/META-INF/spring/osgiservlet.xml
Modified: cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1086700&r1=1086699&r2=1086700&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Tue Mar 29 19:43:22 2011
@@ -86,6 +86,8 @@
<cxf.xmlschema.version>2.0</cxf.xmlschema.version>
<cxf.jibx.version>1.2.3</cxf.jibx.version>
<cxf.axiom.version>1.2.10</cxf.axiom.version>
+ <cxf.aries.version>0.3</cxf.aries.version>
+ <cxf.osgi.version>4.2.0</cxf.osgi.version>
<cxf.checkstyle.extension />
<cxf.spring.validation.mode>VALIDATION_AUTO</cxf.spring.validation.mode>
@@ -363,7 +365,18 @@
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ <version>${cxf.aries.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${cxf.osgi.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
@@ -522,6 +535,7 @@
+
</exclusions>
</dependency>
<dependency>
Modified: cxf/trunk/rt/core/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/pom.xml?rev=1086700&r1=1086699&r2=1086700&view=diff
==============================================================================
--- cxf/trunk/rt/core/pom.xml (original)
+++ cxf/trunk/rt/core/pom.xml Tue Mar 29 19:43:22 2011
@@ -33,7 +33,14 @@
</parent>
<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>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
@@ -46,8 +53,8 @@
</dependency>
<dependency>
- <groupId>org.apache.ws.xmlschema</groupId>
- <artifactId>xmlschema-core</artifactId>
+ <groupId>org.apache.ws.xmlschema</groupId>
+ <artifactId>xmlschema-core</artifactId>
</dependency>
<dependency>
@@ -61,10 +68,10 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <optional>true</optional>
- </dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>xml-resolver</groupId>
Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java (added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java Tue Mar 29 19:43:22 2011
@@ -0,0 +1,43 @@
+/**
+ * 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.bus.blueprint;
+
+
+import org.apache.aries.blueprint.utils.BundleDelegatingClassLoader;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ */
+public class BlueprintBus extends ExtensionManagerBus {
+ BundleContext context;
+
+ public BlueprintBus() {
+ }
+
+ public void setBundleContext(BundleContext c) {
+ context = c;
+ super.setExtension(new BundleDelegatingClassLoader(c.getBundle(),
+ this.getClass().getClassLoader()),
+ ClassLoader.class);
+ //setExtension(new ConfigurerImpl(c), Configurer.class);
+ }
+}
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java (added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java Tue Mar 29 19:43:22 2011
@@ -0,0 +1,60 @@
+/**
+ * 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.bus.blueprint;
+
+
+import org.w3c.dom.Element;
+
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+public class BusDefinitionParser
+ extends AbstractBPBeanDefinitionParser {
+
+ public BusDefinitionParser() {
+ }
+
+ public Metadata parse(Element element, ParserContext context) {
+ String bname = element.hasAttribute("bus") ? element.getAttribute("bus") : "cxf";
+ MutableBeanMetadata cxfBean = getBus(context, bname);
+ parseAttributes(element, context, cxfBean);
+ parseChildElements(element, context, cxfBean);
+ context.getComponentDefinitionRegistry().removeComponentDefinition(bname);
+ return cxfBean;
+ }
+
+ protected boolean hasBusProperty() {
+ return false;
+ }
+
+
+ @Override
+ protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) {
+ if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name)
+ || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name)
+ || "features".equals(name)) {
+ bean.addProperty(name, parseListData(ctx, bean, el));
+ } else if ("properties".equals(name)) {
+ bean.addProperty(name, parseMapData(ctx, bean, el));
+ }
+ }
+}
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/CXFCoreNamespaceHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/CXFCoreNamespaceHandler.java?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/CXFCoreNamespaceHandler.java (added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/CXFCoreNamespaceHandler.java Tue Mar 29 19:43:22 2011
@@ -0,0 +1,81 @@
+/**
+ * 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.bus.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.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser;
+import org.apache.cxf.feature.FastInfosetFeature;
+import org.apache.cxf.feature.LoggingFeature;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+/**
+ *
+ */
+public class CXFCoreNamespaceHandler implements NamespaceHandler {
+ private BlueprintContainer blueprintContainer;
+
+
+ public URL getSchemaLocation(String namespace) {
+ return getClass().getClassLoader().getResource("/schemas/blueprint/core.xsd");
+ }
+
+
+ public Metadata parse(Element element, ParserContext context) {
+ String s = element.getLocalName();
+ if ("bus".equals(s)) {
+ //parse bus
+ return new BusDefinitionParser().parse(element, context);
+ } else if ("logging".equals(s)) {
+ //logging feature
+ return new SimpleBPBeanDefinitionParser(LoggingFeature.class).parse(element, context);
+ } else if ("fastinfoset".equals(s)) {
+ //fastinfosetfeature
+ return new SimpleBPBeanDefinitionParser(FastInfosetFeature.class).parse(element, context);
+ }
+ return null;
+ }
+
+ public Set<Class> getManagedClasses() {
+ //probably should have the various stuff in cxf-api in here?
+ 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/core/src/main/java/org/apache/cxf/bus/blueprint/CXFCoreNamespaceHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/CXFCoreNamespaceHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java (added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java Tue Mar 29 19:43:22 2011
@@ -0,0 +1,280 @@
+/**
+ * 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.configuration.blueprint;
+
+
+import javax.xml.namespace.QName;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.aries.blueprint.PassThroughMetadata;
+import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.aries.blueprint.mutable.MutableRefMetadata;
+import org.apache.aries.blueprint.mutable.MutableValueMetadata;
+import org.apache.cxf.bus.blueprint.BlueprintBus;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.helpers.DOMUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+
+public abstract class AbstractBPBeanDefinitionParser {
+ private static final String XMLNS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
+ private static final String COMPONENT_ID = "component-id";
+
+ protected boolean hasBusProperty() {
+ return false;
+ }
+
+ public Metadata createValue(ParserContext context, QName qName) {
+ MutableValueMetadata v = context.createMetadata(MutableValueMetadata.class);
+ v.setType(QName.class.getName());
+ v.setStringValue(qName.toString());
+ return v;
+ }
+
+ protected Metadata parseListData(ParserContext context,
+ ComponentMetadata enclosingComponent,
+ Element element) {
+ return context.parseElement(CollectionMetadata.class,
+ enclosingComponent,
+ element);
+ }
+ protected Metadata parseMapData(ParserContext context,
+ ComponentMetadata enclosingComponent,
+ Element element) {
+ return context.parseElement(MapMetadata.class,
+ enclosingComponent,
+ element);
+ }
+
+ protected void setFirstChildAsProperty(Element element,
+ ParserContext ctx,
+ MutableBeanMetadata bean,
+ String propertyName) {
+
+ Element first = DOMUtils.getFirstElement(element);
+
+ if (first == null) {
+ throw new IllegalStateException(propertyName + " property must have child elements!");
+ }
+
+ String id;
+ if (first.getNamespaceURI().equals(XMLNS_BLUEPRINT)) {
+ String name = first.getLocalName();
+ if ("ref".equals(name)) {
+ id = first.getAttribute(COMPONENT_ID);
+ if (id == null) {
+ throw new IllegalStateException("<ref> elements must have a \"component-id\" attribute!");
+ }
+ bean.addProperty(propertyName, createRef(ctx, id));
+ } else {
+ if ("bean".equals(name)) {
+ //TODO FIX beans and refs
+ // / BeanDefinitionHolder bdh = ctx.getDelegate().parseBeanDefinitionElement(first);
+ // child = bdh.getBeanDefinition();
+ // bean.addPropertyValue(propertyName, child);
+ } else {
+ throw new UnsupportedOperationException(
+ "Elements with the name " + name
+ + " are not currently "
+ + "supported as sub elements of "
+ + element.getLocalName());
+ }
+ }
+ } else {
+ throw new UnsupportedOperationException(
+ "Elements with the name " + first.getLocalName()
+ + " are not currently "
+ + "supported as sub elements of " + element.getLocalName());
+ }
+ }
+
+ public QName parseQName(Element element, String t) {
+ String t1 = t;
+ String ns = null;
+ String pre = null;
+ String local = null;
+
+ if (t1.startsWith("{")) {
+ int i = t1.indexOf('}');
+ if (i == -1) {
+ throw new RuntimeException("Namespace bracket '{' must having a closing bracket '}'.");
+ }
+
+ ns = t1.substring(1, i);
+ t1 = t1.substring(i + 1);
+ }
+
+ int colIdx = t1.indexOf(':');
+ if (colIdx == -1) {
+ local = t1;
+ pre = "";
+
+ ns = DOMUtils.getNamespace(element, "");
+ } else {
+ pre = t1.substring(0, colIdx);
+ local = t1.substring(colIdx + 1);
+
+ ns = DOMUtils.getNamespace(element, pre);
+ }
+
+ return new QName(ns, local, pre);
+ }
+
+ protected boolean parseAttributes(Element element, ParserContext ctx, MutableBeanMetadata bean) {
+ NamedNodeMap atts = element.getAttributes();
+ boolean setBus = false;
+ for (int i = 0; i < atts.getLength(); i++) {
+ Attr node = (Attr) atts.item(i);
+ String val = node.getValue();
+ String pre = node.getPrefix();
+ String name = node.getLocalName();
+ String prefix = node.getPrefix();
+
+ // Don't process namespaces
+ if (isNamespace(name, prefix)) {
+ continue;
+ }
+
+ if ("createdFromAPI".equals(name) || "abstract".equals(name)) {
+ bean.setScope(BeanMetadata.SCOPE_PROTOTYPE);
+ } else if ("depends-on".equals(name)) {
+ bean.addDependsOn(val);
+ } else if (!"id".equals(name) && !"name".equals(name) && isAttribute(pre, name)) {
+ if ("bus".equals(name)) {
+ if (this.hasBusProperty()) {
+ bean.addProperty("bus", getBusRef(ctx, val));
+ } else {
+ bean.addArgument(getBusRef(ctx, val), null, 0);
+ }
+ } else {
+ mapAttribute(bean, element, name, val, ctx);
+ }
+ }
+ }
+ return setBus;
+ }
+
+ protected void mapAttribute(MutableBeanMetadata bean,
+ Element e, String name,
+ String val, ParserContext context) {
+ mapToProperty(bean, name, val, context);
+ }
+
+ protected boolean isAttribute(String pre, String name) {
+ return !"xmlns".equals(name)
+ && (pre == null || !pre.equals("xmlns"))
+ && !"abstract".equals(name)
+ && !"lazy-init".equals(name) && !"id"
+ .equals(name);
+ }
+
+ protected boolean isNamespace(String name, String prefix) {
+ return "xmlns".equals(prefix) || prefix == null && "xmlns".equals(name);
+ }
+
+ protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) {
+ }
+
+ protected void mapToProperty(MutableBeanMetadata bean,
+ String propertyName,
+ String val,
+ ParserContext context) {
+ if ("id".equals(propertyName)) {
+ return;
+ }
+
+ if (!StringUtils.isEmpty(val)) {
+ if (val.startsWith("#")) {
+ bean.addProperty(propertyName, createRef(context, val.substring(1)));
+ } else {
+ bean.addProperty(propertyName, createValue(context, val));
+ }
+ }
+ }
+ public static ValueMetadata createValue(ParserContext context, String value) {
+ MutableValueMetadata v = context.createMetadata(MutableValueMetadata.class);
+ v.setStringValue(value);
+ return v;
+ }
+
+ public static RefMetadata createRef(ParserContext context, String value) {
+ MutableRefMetadata r = context.createMetadata(MutableRefMetadata.class);
+ r.setComponentId(value);
+ return r;
+ }
+ public static MutableBeanMetadata createObjectOfClass(ParserContext context, String value) {
+ MutableBeanMetadata v = context.createMetadata(MutableBeanMetadata.class);
+ v.setClassName(value);
+ return v;
+ }
+
+ protected MutableBeanMetadata getBus(ParserContext context,
+ String name) {
+ ComponentDefinitionRegistry cdr = context.getComponentDefinitionRegistry();
+ ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");
+
+ Bundle blueprintBundle = null;
+ if (meta instanceof PassThroughMetadata) {
+ blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
+ }
+ if (blueprintBundle != null
+ && !cdr.containsComponentDefinition(name)) {
+ //Create a bus
+
+ //FIXME - mgmt stuff, configuration stuff, etc...
+ MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
+ bus.setId(name);
+ bus.setRuntimeClass(BlueprintBus.class);
+ bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+ bus.setDestroyMethod("shutdown");
+ bus.setInitMethod("initialize");
+
+ context.getComponentDefinitionRegistry().registerComponentDefinition(bus);
+ return bus;
+ }
+ return (MutableBeanMetadata)cdr.getComponentDefinition(name);
+ }
+ protected RefMetadata getBusRef(ParserContext context,
+ String name) {
+
+ getBus(context, name);
+ return createRef(context, name);
+ }
+
+ protected void parseChildElements(Element element, ParserContext ctx, MutableBeanMetadata bean) {
+ Element el = DOMUtils.getFirstElement(element);
+ while (el != null) {
+ String name = el.getLocalName();
+ mapElement(ctx, bean, el, name);
+ el = DOMUtils.getNextElement(el);
+ }
+ }
+
+
+}
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java (added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java Tue Mar 29 19:43:22 2011
@@ -0,0 +1,51 @@
+/**
+ * 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.configuration.blueprint;
+
+import org.w3c.dom.Element;
+
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+/**
+ *
+ */
+public class SimpleBPBeanDefinitionParser extends AbstractBPBeanDefinitionParser {
+ Class<?> cls;
+
+ public SimpleBPBeanDefinitionParser(Class<?> cls) {
+ this.cls = cls;
+ }
+
+ public String getId(Element element) {
+ return element.hasAttribute("id") ? element.getAttribute("id") : null;
+ }
+
+ public Metadata parse(Element element, ParserContext context) {
+ MutableBeanMetadata cxfBean = context.createMetadata(MutableBeanMetadata.class);
+ cxfBean.setRuntimeClass(cls);
+ cxfBean.setId(getId(element));
+ parseAttributes(element, context, cxfBean);
+ parseChildElements(element, context, cxfBean);
+ return cxfBean;
+ }
+
+}
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml (added)
+++ cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml Tue Mar 29 19:43:22 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/core"/>
+ </service-properties>
+ <bean class="org.apache.cxf.bus.blueprint.CXFCoreNamespaceHandler"/>
+ </service>
+</blueprint>
\ No newline at end of file
Propchange: cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/rt/core/src/main/resources/OSGI-INF/blueprint/cxf-core.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd (added)
+++ cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd Tue Mar 29 19:43:22 2011
@@ -0,0 +1,123 @@
+<?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: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/core"
+ 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:annotation>
+ <xsd:documentation>
+ This schema defines beans representing the CXF bus and its core features.
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:element name="logging">
+ <xsd:annotation>
+ <xsd:documentation>
+ The logging feature enables you to log the content of inbound and outbound messages and faults.
+ The content is logged by all log handlers configured in your java.util.logging configuration file,
+ provided the log level for classes org.apache.cxf.interceptor.LoggingInInterceptor and
+ org.apache.cxf.interceptor.LoggingOutInterceptor is at least INFO.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence />
+ <xsd:attribute name="limit" type="xsd:int" use="optional" default="102400"/>
+ <xsd:attribute name="id" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="fastinfoset">
+ <xsd:annotation>
+ <xsd:documentation>
+ The fastinfoset feature enables you to turn on using fastinfoset encoding of
+ xml payloads.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence />
+ <xsd:attribute name="force" type="xsd:boolean" use="optional" default="false"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="bus">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element name="features" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of features that are applied to the bus.
+ Child elements of this element must be beans whose bean class extends
+ org.apache.cxf.AbstractFeature, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all inbound message interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all inbound fault interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all outbound message interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all outbound fault interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="properties" type="beans:Tmap" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>Specifies a map of properties that are passed to the bus.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
+ <xsd:attribute name="bus" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Propchange: cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/rt/core/src/main/resources/schemas/blueprint/core.xsd
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: cxf/trunk/rt/frontend/jaxws/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/pom.xml?rev=1086700&r1=1086699&r2=1086700&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/pom.xml (original)
+++ cxf/trunk/rt/frontend/jaxws/pom.xml Tue Mar 29 19:43:22 2011
@@ -37,6 +37,14 @@
</properties>
<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>
@@ -54,9 +62,9 @@
</dependency>
<dependency>
- <groupId>xml-resolver</groupId>
- <artifactId>xml-resolver</artifactId>
- </dependency>
+ <groupId>xml-resolver</groupId>
+ <artifactId>xml-resolver</artifactId>
+ </dependency>
<dependency>
<groupId>asm</groupId>
@@ -166,19 +174,19 @@
</configuration>
</execution>
<execution>
- <id>add-spi</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>add-resource</goal>
- </goals>
- <configuration>
- <resources>
- <resource>
- <directory>${basedir}/src/main/${cxf.spi-dir}</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
+ <id>add-spi</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>add-resource</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/${cxf.spi-dir}</directory>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
</executions>
</plugin>
@@ -195,10 +203,10 @@
<artifactId>geronimo-jaxws_2.2_spec</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<properties>
<cxf.spi-dir>spi-2.2</cxf.spi-dir>
@@ -239,23 +247,23 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
- <execution>
- <id>create-endorsed-dir</id>
- <phase>validate</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaxws_2.2_spec</artifactId>
- <outputDirectory>${basedir}/target/endorsed</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
+ <execution>
+ <id>create-endorsed-dir</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxws_2.2_spec</artifactId>
+ <outputDirectory>${basedir}/target/endorsed</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
</plugins>
<pluginManagement>
@@ -298,10 +306,10 @@
</properties>
<dependencies>
<dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-activation_1.1_spec</artifactId>
@@ -319,17 +327,17 @@
<artifactId>saaj-api</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaxws_2.2_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>${cxf.saaj.impl.groupId}</groupId>
- <artifactId>${cxf.saaj.impl.artifactId}</artifactId>
- </dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxws_2.2_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${cxf.saaj.impl.groupId}</groupId>
+ <artifactId>${cxf.saaj.impl.artifactId}</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=1086700&r1=1086699&r2=1086700&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Tue Mar 29 19:43:22 2011
@@ -311,7 +311,14 @@ public class EndpointImpl extends javax.
ServerImpl serv = null;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
+ if (bus != null) {
+ ClassLoader newLoader = bus.getExtension(ClassLoader.class);
+ if (newLoader != null) {
+ Thread.currentThread().setContextClassLoader(newLoader);
+ }
+ }
serv = getServer(addr);
if (addr != null) {
EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
@@ -341,6 +348,8 @@ public class EndpointImpl extends javax.
}
throw new WebServiceException(ex);
+ } finally {
+ Thread.currentThread().setContextClassLoader(loader);
}
}
@@ -352,102 +361,113 @@ public class EndpointImpl extends javax.
if (server == null) {
checkProperties();
- // Initialize the endpointName so we can do configureObject
- QName origEpn = endpointName;
- if (endpointName == null) {
- JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getImplementorClass());
- endpointName = implInfo.getEndpointName();
- }
-
- if (serviceFactory != null) {
- serverFactory.setServiceFactory(serviceFactory);
- }
-
- /*if (serviceName != null) {
- serverFactory.getServiceFactory().setServiceName(serviceName);
- }*/
-
- configureObject(this);
- endpointName = origEpn;
-
- // Set up the server factory
- serverFactory.setAddress(addr);
- serverFactory.setStart(false);
- serverFactory.setEndpointName(endpointName);
- serverFactory.setServiceBean(implementor);
- serverFactory.setBus(bus);
- serverFactory.setFeatures(getFeatures());
- serverFactory.setInvoker(invoker);
- serverFactory.setSchemaLocations(schemaLocations);
- if (serverFactory.getProperties() != null) {
- serverFactory.getProperties().putAll(properties);
- } else {
- serverFactory.setProperties(properties);
- }
-
- // Be careful not to override any serverfactory settings as a user might
- // have supplied their own.
- if (getWsdlLocation() != null) {
- serverFactory.setWsdlURL(getWsdlLocation());
- }
-
- if (bindingUri != null) {
- serverFactory.setBindingId(bindingUri);
- }
-
- if (serviceName != null) {
- serverFactory.getServiceFactory().setServiceName(serviceName);
- }
-
- if (implementorClass != null) {
- serverFactory.setServiceClass(implementorClass);
- }
-
- if (executor != null) {
- serverFactory.getServiceFactory().setExecutor(executor);
- }
- if (handlers.size() > 0) {
- serverFactory.addHandlers(handlers);
- }
-
- configureObject(serverFactory);
-
- server = serverFactory.create();
-
- org.apache.cxf.endpoint.Endpoint endpoint = getEndpoint();
- if (in != null) {
- endpoint.getInInterceptors().addAll(in);
- }
- if (out != null) {
- endpoint.getOutInterceptors().addAll(out);
- }
- if (inFault != null) {
- endpoint.getInFaultInterceptors().addAll(inFault);
- }
- if (outFault != null) {
- endpoint.getOutFaultInterceptors().addAll(outFault);
- }
-
- if (properties != null) {
- endpoint.putAll(properties);
- }
-
- configureObject(endpoint.getService());
- configureObject(endpoint);
- this.service = endpoint.getService();
-
- if (getWsdlLocation() == null) {
- //hold onto the wsdl location so cache won't clear till we go away
- setWsdlLocation(serverFactory.getWsdlURL());
- }
-
- if (serviceName == null) {
- setServiceName(serverFactory.getServiceFactory().getServiceQName());
- }
- if (endpointName == null) {
- endpointName = endpoint.getEndpointInfo().getName();
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ if (bus != null) {
+ ClassLoader newLoader = bus.getExtension(ClassLoader.class);
+ if (newLoader != null) {
+ Thread.currentThread().setContextClassLoader(newLoader);
+ }
+ }
+
+ // Initialize the endpointName so we can do configureObject
+ QName origEpn = endpointName;
+ if (endpointName == null) {
+ JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getImplementorClass());
+ endpointName = implInfo.getEndpointName();
+ }
+
+ if (serviceFactory != null) {
+ serverFactory.setServiceFactory(serviceFactory);
+ }
+
+ /*if (serviceName != null) {
+ serverFactory.getServiceFactory().setServiceName(serviceName);
+ }*/
+
+ configureObject(this);
+ endpointName = origEpn;
+
+ // Set up the server factory
+ serverFactory.setAddress(addr);
+ serverFactory.setStart(false);
+ serverFactory.setEndpointName(endpointName);
+ serverFactory.setServiceBean(implementor);
+ serverFactory.setBus(bus);
+ serverFactory.setFeatures(getFeatures());
+ serverFactory.setInvoker(invoker);
+ serverFactory.setSchemaLocations(schemaLocations);
+ if (serverFactory.getProperties() != null) {
+ serverFactory.getProperties().putAll(properties);
+ } else {
+ serverFactory.setProperties(properties);
+ }
+
+ // Be careful not to override any serverfactory settings as a user might
+ // have supplied their own.
+ if (getWsdlLocation() != null) {
+ serverFactory.setWsdlURL(getWsdlLocation());
+ }
+
+ if (bindingUri != null) {
+ serverFactory.setBindingId(bindingUri);
+ }
+
+ if (serviceName != null) {
+ serverFactory.getServiceFactory().setServiceName(serviceName);
+ }
+
+ if (implementorClass != null) {
+ serverFactory.setServiceClass(implementorClass);
+ }
+
+ if (executor != null) {
+ serverFactory.getServiceFactory().setExecutor(executor);
+ }
+ if (handlers.size() > 0) {
+ serverFactory.addHandlers(handlers);
+ }
+
+ configureObject(serverFactory);
+
+ server = serverFactory.create();
+
+ org.apache.cxf.endpoint.Endpoint endpoint = getEndpoint();
+ if (in != null) {
+ endpoint.getInInterceptors().addAll(in);
+ }
+ if (out != null) {
+ endpoint.getOutInterceptors().addAll(out);
+ }
+ if (inFault != null) {
+ endpoint.getInFaultInterceptors().addAll(inFault);
+ }
+ if (outFault != null) {
+ endpoint.getOutFaultInterceptors().addAll(outFault);
+ }
+
+ if (properties != null) {
+ endpoint.putAll(properties);
+ }
+
+ configureObject(endpoint.getService());
+ configureObject(endpoint);
+ this.service = endpoint.getService();
+
+ if (getWsdlLocation() == null) {
+ //hold onto the wsdl location so cache won't clear till we go away
+ setWsdlLocation(serverFactory.getWsdlURL());
+ }
+
+ if (serviceName == null) {
+ setServiceName(serverFactory.getServiceFactory().getServiceQName());
+ }
+ if (endpointName == null) {
+ endpointName = endpoint.getEndpointInfo().getName();
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(loader);
}
-
}
return (ServerImpl) server;
}
Added: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/EndpointDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/EndpointDefinitionParser.java?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/EndpointDefinitionParser.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/EndpointDefinitionParser.java Tue Mar 29 19:43:22 2011
@@ -0,0 +1,161 @@
+/**
+ * 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.jaxws.blueprint;
+
+import java.util.StringTokenizer;
+import java.util.UUID;
+import javax.xml.namespace.QName;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.jaxws.spi.ProviderImpl;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+class EndpointDefinitionParser extends AbstractBPBeanDefinitionParser {
+ private static final Class<?> EP_CLASS;
+ static {
+ Class<?> cls = EndpointImpl.class;
+ try {
+ if (ProviderImpl.isJaxWs22()) {
+ cls = ClassLoaderUtils
+ .loadClass("org.apache.cxf.jaxws22.JAXWS22EndpointImpl",
+ EndpointDefinitionParser.class);
+ }
+ } catch (Throwable t) {
+ cls = EndpointImpl.class;
+ }
+ EP_CLASS = cls;
+ }
+ public static String getIdOrName(Element elem) {
+ String id = elem.getAttribute("id");
+
+ if (null == id || "".equals(id)) {
+ String names = elem.getAttribute("name");
+ if (null != names) {
+ StringTokenizer st = new StringTokenizer(names, ",");
+ if (st.countTokens() > 0) {
+ id = st.nextToken();
+ }
+ }
+ }
+ return id;
+ }
+
+ public Metadata parse(Element element, ParserContext context) {
+ //Endpoint definition
+ MutableBeanMetadata cxfBean = context.createMetadata(MutableBeanMetadata.class);
+
+ //Add a blueprintContainer ref
+
+ //cxfBean.addProperty("blueprintContainer", NSUtils.createRef(context, "blueprintContainer"));
+ //cxfBean.addProperty("bundleContext", NSUtils.createRef(context, "blueprintBundleContext"));
+ if (!StringUtils.isEmpty(getIdOrName(element))) {
+ cxfBean.setId(getIdOrName(element));
+ } else {
+ cxfBean.setId("cxf.endpoint." + UUID.randomUUID().toString());
+ }
+ cxfBean.setRuntimeClass(EP_CLASS);
+
+ boolean isAbstract = false;
+ boolean publish = true;
+ NamedNodeMap atts = element.getAttributes();
+
+ String bus = null;
+ Metadata impl = null;
+
+ for (int i = 0; i < atts.getLength(); i++) {
+ Attr node = (Attr) atts.item(i);
+ String val = node.getValue();
+ String pre = node.getPrefix();
+ String name = node.getLocalName();
+ if ("createdFromAPI".equals(name) || "abstract".equals(name)) {
+ cxfBean.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
+ isAbstract = true;
+ } else if ("publish".equals(name)) {
+ publish = Boolean.parseBoolean(val);
+ } else if ("bus".equals(name)) {
+ bus = val;
+ } else if (isAttribute(pre, name)) {
+ if ("endpointName".equals(name) || "serviceName".equals(name)) {
+ QName q = parseQName(element, val);
+ cxfBean.addProperty(name, createValue(context, q));
+ } else if ("depends-on".equals(name)) {
+ cxfBean.addDependsOn(val);
+ } else if ("implementor".equals(name)) {
+ if (val.startsWith("#")) {
+ impl = createRef(context, val.substring(1));
+ } else {
+ impl = createObjectOfClass(context, val);
+ }
+ } else if (!"name".equals(name)) {
+ cxfBean.addProperty(name, createValue(context, val));
+ }
+ }
+ }
+
+ Element elem = DOMUtils.getFirstElement(element);
+ while (elem != null) {
+ String name = elem.getLocalName();
+ if ("properties".equals(name)) {
+ Metadata map = parseMapData(context, cxfBean, elem);
+ cxfBean.addProperty(name, map);
+ } else if ("binding".equals(name)) {
+ setFirstChildAsProperty(elem, context, cxfBean, "bindingConfig");
+ } else if ("inInterceptors".equals(name)
+ || "inFaultInterceptors".equals(name)
+ || "outInterceptors".equals(name)
+ || "outFaultInterceptors".equals(name)
+ || "features".equals(name)
+ || "schemaLocations".equals(name)
+ || "handlers".equals(name)) {
+ Metadata list = parseListData(context, cxfBean, elem);
+ cxfBean.addProperty(name, list);
+ } else if ("implementor".equals(name)) {
+ impl = context.parseElement(Metadata.class, cxfBean, elem);
+ } else {
+ setFirstChildAsProperty(elem, context, cxfBean, name);
+ }
+ elem = DOMUtils.getNextElement(elem);
+ }
+ if (StringUtils.isEmpty(bus)) {
+ bus = "cxf";
+ }
+ cxfBean.addArgument(this.getBusRef(context, bus), Bus.class.getName(), 0);
+ cxfBean.addArgument(impl, Object.class.getName(), 1);
+ if (!isAbstract) {
+ if (publish) {
+ cxfBean.setInitMethod("publish");
+ }
+ cxfBean.setDestroyMethod("stop");
+ }
+ // We don't want to delay the registration of our Server
+ cxfBean.setActivation(MutableBeanMetadata.ACTIVATION_EAGER);
+ return cxfBean;
+ }
+}
Propchange: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/EndpointDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/EndpointDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/JAXWSBPNamespaceHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/JAXWSBPNamespaceHandler.java?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/JAXWSBPNamespaceHandler.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/JAXWSBPNamespaceHandler.java Tue Mar 29 19:43:22 2011
@@ -0,0 +1,76 @@
+/**
+ * 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.jaxws.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 JAXWSBPNamespaceHandler implements NamespaceHandler {
+ private BlueprintContainer blueprintContainer;
+
+ public JAXWSBPNamespaceHandler() {
+ }
+
+ public URL getSchemaLocation(String namespace) {
+ return getClass().getClassLoader().getResource("/schemas/blueprint/jaxws.xsd");
+ }
+
+
+ public Metadata parse(Element element, ParserContext context) {
+ String s = element.getLocalName();
+ if ("endpoint".equals(s)) {
+ return new EndpointDefinitionParser().parse(element, context);
+ } else if ("server".equals(s)) {
+ //TODO
+ } else if ("client".equals(s)) {
+ //TODO
+ }
+ 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/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/JAXWSBPNamespaceHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/blueprint/JAXWSBPNamespaceHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml?rev=1086700&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml Tue Mar 29 19:43:22 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/jaxws"/>
+ </service-properties>
+ <bean class="org.apache.cxf.jaxws.blueprint.JAXWSBPNamespaceHandler"/>
+ </service>
+</blueprint>
\ No newline at end of file
Propchange: cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/rt/frontend/jaxws/src/main/resources/OSGI-INF/blueprint/cxf-jaxws.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml