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 2014/05/01 17:49:46 UTC
[8/9] Pull aries-blueprint support out
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/pom.xml b/rt/aries-blueprint/pom.xml
new file mode 100644
index 0000000..f188cb5
--- /dev/null
+++ b/rt/aries-blueprint/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache CXF Aries Blueprint Support</name>
+ <description>Apache CXF Aries Blueprint Support</description>
+ <url>http://cxf.apache.org</url>
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <properties>
+ <cxf.bundle.activator>org.apache.cxf.configuration.blueprint.internal.CXFActivator</cxf.bundle.activator>
+ <cxf.osgi.export>
+ !org.apache.cxf.configuration.blueprint.internal,
+ org.apache.cxf.configuration.blueprint.*,
+ org.apache.cxf.bus.blueprint.*
+ </cxf.osgi.export>
+ <cxf.osgi.import>
+ org.apache.aries*;version="${cxf.aries.version.range}";resolution:=optional
+ </cxf.osgi.import>
+ <!-- keep in sync with services exported in activator -->
+ <cxf.export.service>
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/core",
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/beans",
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/parameterized-types",
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/security"
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://schemas.xmlsoap.org/wsdl/",
+ </cxf.export.service>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
new file mode 100644
index 0000000..70b547e
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
@@ -0,0 +1,214 @@
+/**
+ * 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.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.aries.blueprint.ExtendedBeanMetadata;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.apache.cxf.bus.extension.ExtensionManagerImpl;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.NoSuchComponentException;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+
+/**
+ *
+ */
+public class BlueprintBeanLocator implements ConfiguredBeanLocator {
+ private static final Logger LOG = LogUtils.getL7dLogger(BlueprintBeanLocator.class);
+ ConfiguredBeanLocator orig;
+ BlueprintContainer container;
+ BundleContext context;
+
+ public BlueprintBeanLocator(ConfiguredBeanLocator orig,
+ BlueprintContainer cont,
+ BundleContext context) {
+ this.orig = orig;
+ this.container = cont;
+ this.context = context;
+ if (orig instanceof ExtensionManagerImpl) {
+ List<String> names = new ArrayList<String>(container.getComponentIds());
+ ((ExtensionManagerImpl)orig).removeBeansOfNames(names);
+ }
+ }
+
+ static Class<?> getClassForMetaData(BlueprintContainer container, ComponentMetadata cmd) {
+ Class<?> cls = null;
+ if (cmd instanceof BeanMetadata) {
+ BeanMetadata bm = (BeanMetadata)cmd;
+ if (bm instanceof ExtendedBeanMetadata) {
+ cls = ((ExtendedBeanMetadata)bm).getRuntimeClass();
+ }
+ if (cls == null && container instanceof ExtendedBlueprintContainer && bm.getClassName() != null) {
+ try {
+ cls = ((ExtendedBlueprintContainer)container).loadClass(bm.getClassName());
+ } catch (ClassNotFoundException cnfe) {
+ //ignore
+ }
+ }
+ }
+ return cls;
+ }
+ private Class<?> getClassForMetaData(ComponentMetadata cmd) {
+ return getClassForMetaData(container, cmd);
+ }
+ private ComponentMetadata getComponentMetadata(String id) {
+ try {
+ return container.getComponentMetadata(id);
+ } catch (NoSuchComponentException nsce) {
+ return null;
+ }
+ }
+
+ public <T> T getBeanOfType(String name, Class<T> type) {
+
+ ComponentMetadata cmd = getComponentMetadata(name);
+ Class<?> cls = getClassForMetaData(cmd);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ return type.cast(container.getComponentInstance(name));
+ }
+ return orig.getBeanOfType(name, type);
+ }
+ /** {@inheritDoc}*/
+ public List<String> getBeanNamesOfType(Class<?> type) {
+ Set<String> names = new LinkedHashSet<String>();
+ for (String s : container.getComponentIds()) {
+ ComponentMetadata cmd = container.getComponentMetadata(s);
+ Class<?> cls = getClassForMetaData(cmd);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ names.add(s);
+ }
+ }
+ names.addAll(orig.getBeanNamesOfType(type));
+ return new ArrayList<String>(names);
+ }
+
+ /** {@inheritDoc}*/
+ public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
+ List<T> list = new ArrayList<T>();
+
+ for (String s : container.getComponentIds()) {
+ ComponentMetadata cmd = container.getComponentMetadata(s);
+ Class<?> cls = getClassForMetaData(cmd);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ list.add(type.cast(container.getComponentInstance(s)));
+ }
+ }
+ if (list.isEmpty()) {
+ try {
+ ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
+ if (refs != null) {
+ for (ServiceReference r : refs) {
+ list.add(type.cast(context.getService(r)));
+ }
+ }
+ } catch (Exception ex) {
+ //ignore, just don't support the OSGi services
+ LOG.info("Try to find the Bean with type:" + type
+ + " from OSGi services and get error: " + ex);
+ }
+ }
+ list.addAll(orig.getBeansOfType(type));
+
+ return list;
+ }
+
+ /** {@inheritDoc}*/
+ public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
+ List<String> names = new ArrayList<String>();
+ boolean loaded = false;
+ for (String s : container.getComponentIds()) {
+ ComponentMetadata cmd = container.getComponentMetadata(s);
+ Class<?> cls = getClassForMetaData(cmd);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ names.add(s);
+ }
+ }
+ Collections.reverse(names);
+ for (String s : names) {
+ ComponentMetadata cmd = container.getComponentMetadata(s);
+ Class<?> beanType = getClassForMetaData(cmd);
+ Class<? extends T> t = beanType.asSubclass(type);
+ if (listener.loadBean(s, t)) {
+ Object o = container.getComponentInstance(s);
+ if (listener.beanLoaded(s, type.cast(o))) {
+ return true;
+ }
+ loaded = true;
+ }
+ }
+
+ try {
+ ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
+ if (refs != null) {
+ for (ServiceReference r : refs) {
+ Object o2 = context.getService(r);
+ Class<? extends T> t = o2.getClass().asSubclass(type);
+ if (listener.loadBean(t.getName(), t)) {
+ if (listener.beanLoaded(t.getName(), type.cast(o2))) {
+ return true;
+ }
+ loaded = true;
+ }
+ }
+ }
+ } catch (Exception ex) {
+ //ignore, just don't support the OSGi services
+ LOG.info("Try to find the Bean with type:" + type
+ + " from OSGi services and get error: " + ex);
+ }
+ return orig.loadBeansOfType(type, listener) || loaded;
+ }
+
+ public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) {
+ ComponentMetadata cmd = getComponentMetadata(beanName);
+ if (cmd instanceof BeanMetadata) {
+ BeanMetadata br = (BeanMetadata)cmd;
+ for (BeanProperty s : br.getProperties()) {
+ if (propertyName.equals(s.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return orig.hasConfiguredPropertyValue(beanName, propertyName, value);
+ }
+
+ public boolean hasBeanOfName(String name) {
+ ComponentMetadata cmd = getComponentMetadata(name);
+ if (cmd instanceof BeanMetadata) {
+ return true;
+ }
+ return orig.hasBeanOfName(name);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
new file mode 100644
index 0000000..9842ad3
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
@@ -0,0 +1,77 @@
+/**
+ * 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.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.resource.ClassLoaderResolver;
+import org.apache.cxf.resource.ResourceManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+
+/**
+ *
+ */
+public class BlueprintBus extends ExtensionManagerBus {
+ BundleContext context;
+ BlueprintContainer container;
+
+ public BlueprintBus() {
+ // Using the BlueprintBus Classloader to load the extensions
+ super(null, null, BlueprintBus.class.getClassLoader());
+ }
+
+ public void loadAdditionalFeatures() {
+ super.loadAdditionalFeatures();
+ }
+
+ public void setBundleContext(final BundleContext c) {
+ context = c;
+ ClassLoader bundleClassLoader =
+ AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return new BundleDelegatingClassLoader(c.getBundle(),
+ this.getClass().getClassLoader());
+ }
+ });
+ super.setExtension(bundleClassLoader, ClassLoader.class);
+ // Setup the resource resolver with the bundle classloader
+ ResourceManager rm = super.getExtension(ResourceManager.class);
+ rm.addResourceResolver(new ClassLoaderResolver(bundleClassLoader));
+ super.setExtension(c, BundleContext.class);
+ }
+ public void setBlueprintContainer(BlueprintContainer con) {
+ container = con;
+ setExtension(new ConfigurerImpl(con), Configurer.class);
+ setExtension(new BlueprintBeanLocator(getExtension(ConfiguredBeanLocator.class), container, context),
+ ConfiguredBeanLocator.class);
+ }
+ public String getId() {
+ if (id == null) {
+ id = context.getBundle().getSymbolicName() + "-"
+ + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
+ }
+ return id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
new file mode 100644
index 0000000..7f5d27c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
@@ -0,0 +1,30 @@
+/**
+ * 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;
+
+public interface BlueprintNameSpaceHandlerFactory {
+ /**
+ * Creates aries blueprint NamespaceHandler.
+ * The return type is untyped as aries blueprint is an
+ * optional import
+ *
+ * @return handler
+ */
+ Object createNamespaceHandler();
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
new file mode 100644
index 0000000..8c00dc3
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
@@ -0,0 +1,133 @@
+/**
+ * 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.io.IOException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A ClassLoader delegating to a given OSGi bundle.
+ */
+public class BundleDelegatingClassLoader extends ClassLoader {
+
+ private final Bundle bundle;
+ private final ClassLoader classLoader;
+
+ public BundleDelegatingClassLoader(Bundle bundle) {
+ this(bundle, null);
+ }
+
+ public BundleDelegatingClassLoader(Bundle bundle, ClassLoader classLoader) {
+ this.bundle = bundle;
+ this.classLoader = classLoader;
+ }
+
+ protected Class<?> findClass(final String name) throws ClassNotFoundException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws ClassNotFoundException {
+ return bundle.loadClass(name);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ Exception cause = e.getException();
+
+ if (cause instanceof ClassNotFoundException) {
+ throw (ClassNotFoundException)cause;
+ } else {
+ throw (RuntimeException)cause;
+ }
+ }
+ }
+
+ protected URL findResource(final String name) {
+ URL resource = AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return bundle.getResource(name);
+ }
+ });
+ if (classLoader != null && resource == null) {
+ resource = classLoader.getResource(name);
+ }
+ return resource;
+ }
+
+ protected Enumeration<URL> findResources(final String name) throws IOException {
+ Enumeration<URL> urls;
+ try {
+ urls = AccessController.doPrivileged(new PrivilegedExceptionAction<Enumeration<URL>>() {
+ @SuppressWarnings("unchecked")
+ public Enumeration<URL> run() throws IOException {
+ return bundle.getResources(name);
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ Exception cause = e.getException();
+
+ if (cause instanceof IOException) {
+ throw (IOException)cause;
+ } else {
+ throw (RuntimeException)cause;
+ }
+ }
+
+ if (urls == null) {
+ urls = Collections.enumeration(new ArrayList<URL>());
+ }
+
+ return urls;
+ }
+
+ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ Class<?> clazz;
+ try {
+ clazz = findClass(name);
+ } catch (ClassNotFoundException cnfe) {
+ if (classLoader != null) {
+ try {
+ clazz = classLoader.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ throw new ClassNotFoundException(name + " from bundle " + bundle.getBundleId()
+ + " (" + bundle.getSymbolicName() + ")", cnfe);
+ }
+ } else {
+ throw new ClassNotFoundException(name + " from bundle " + bundle.getBundleId()
+ + " (" + bundle.getSymbolicName() + ")", cnfe);
+ }
+ }
+ if (resolve) {
+ resolveClass(clazz);
+ }
+ return clazz;
+ }
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
new file mode 100644
index 0000000..2ea3559
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
@@ -0,0 +1,68 @@
+/**
+ * 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.common.util.StringUtils;
+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";
+ String id = element.hasAttribute("id") ? element.getAttribute("id") : null;
+ MutableBeanMetadata cxfBean = getBus(context, bname);
+ parseAttributes(element, context, cxfBean);
+ parseChildElements(element, context, cxfBean);
+ context.getComponentDefinitionRegistry().removeComponentDefinition(bname);
+ if (!StringUtils.isEmpty(id)) {
+ cxfBean.addProperty("id", createValue(context, id));
+ }
+ return cxfBean;
+ }
+ protected void processBusAttribute(Element element, ParserContext ctx,
+ MutableBeanMetadata bean, String val) {
+ //nothing
+ }
+ 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));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
new file mode 100644
index 0000000..128fee4
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
@@ -0,0 +1,179 @@
+/**
+ * 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.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.Configurable;
+import org.apache.cxf.configuration.Configurer;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.NoSuchComponentException;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+
+/**
+ *
+ */
+public class ConfigurerImpl implements Configurer {
+ private static final Logger LOG = LogUtils.getL7dLogger(ConfigurerImpl.class);
+ BlueprintContainer container;
+
+ private final Map<String, List<MatcherHolder>> wildCardBeanDefinitions
+ = new HashMap<String, List<MatcherHolder>>();
+
+ static class MatcherHolder {
+ Matcher matcher;
+ String wildCardId;
+ public MatcherHolder(String orig, Matcher matcher) {
+ wildCardId = orig;
+ this.matcher = matcher;
+ }
+ }
+
+
+ public ConfigurerImpl(BlueprintContainer con) {
+ container = con;
+ initializeWildcardMap();
+ }
+ private boolean isWildcardBeanName(String bn) {
+ return bn.indexOf('*') != -1 || bn.indexOf('?') != -1
+ || (bn.indexOf('(') != -1 && bn.indexOf(')') != -1);
+ }
+
+ private void initializeWildcardMap() {
+ for (String s : container.getComponentIds()) {
+ if (isWildcardBeanName(s)) {
+ ComponentMetadata cmd = container.getComponentMetadata(s);
+ Class<?> cls = BlueprintBeanLocator.getClassForMetaData(container, cmd);
+ if (cls != null) {
+ String orig = s;
+ if (s.charAt(0) == '*') {
+ //old wildcard
+ s = "." + s.replaceAll("\\.", "\\.");
+ }
+ Matcher matcher = Pattern.compile(s).matcher("");
+ List<MatcherHolder> m = wildCardBeanDefinitions.get(cls.getName());
+ if (m == null) {
+ m = new ArrayList<MatcherHolder>();
+ wildCardBeanDefinitions.put(cls.getName(), m);
+ }
+ MatcherHolder holder = new MatcherHolder(orig, matcher);
+ m.add(holder);
+ }
+ }
+ }
+ }
+
+ public void configureBean(Object beanInstance) {
+ configureBean(null, beanInstance, true);
+ }
+
+ public void configureBean(String bn, Object beanInstance) {
+ configureBean(bn, beanInstance, true);
+ }
+ public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) {
+ if (null == bn) {
+ bn = getBeanName(beanInstance);
+ }
+
+ if (null == bn) {
+ return;
+ }
+ if (checkWildcards) {
+ configureWithWildCard(bn, beanInstance);
+ }
+
+ if (container instanceof ExtendedBlueprintContainer) {
+ ComponentMetadata cm = null;
+ try {
+ cm = container.getComponentMetadata(bn);
+ } catch (NoSuchComponentException nsce) {
+ cm = null;
+ }
+ if (cm instanceof BeanMetadata) {
+ ((ExtendedBlueprintContainer)container).injectBeanInstance((BeanMetadata)cm, beanInstance);
+ }
+ }
+ }
+
+ private void configureWithWildCard(String bn, Object beanInstance) {
+ if (!wildCardBeanDefinitions.isEmpty()) {
+ Class<?> clazz = beanInstance.getClass();
+ while (!Object.class.equals(clazz)) {
+ String className = clazz.getName();
+ List<MatcherHolder> matchers = wildCardBeanDefinitions.get(className);
+ if (matchers != null) {
+ for (MatcherHolder m : matchers) {
+ synchronized (m.matcher) {
+ m.matcher.reset(bn);
+ if (m.matcher.matches()) {
+ configureBean(m.wildCardId, beanInstance, false);
+ return;
+ }
+ }
+ }
+ }
+ clazz = clazz.getSuperclass();
+ }
+ }
+ }
+
+ protected String getBeanName(Object beanInstance) {
+ if (beanInstance instanceof Configurable) {
+ return ((Configurable)beanInstance).getBeanName();
+ }
+ String beanName = null;
+ Method m = null;
+ try {
+ m = beanInstance.getClass().getDeclaredMethod("getBeanName", (Class[])null);
+ } catch (NoSuchMethodException ex) {
+ try {
+ m = beanInstance.getClass().getMethod("getBeanName", (Class[])null);
+ } catch (NoSuchMethodException e) {
+ //ignore
+ }
+ }
+ if (m != null) {
+ try {
+ beanName = (String)(m.invoke(beanInstance));
+ } catch (Exception ex) {
+ LogUtils.log(LOG, Level.WARNING, "ERROR_DETERMINING_BEAN_NAME_EXC", ex);
+ }
+ }
+
+ if (null == beanName) {
+ LogUtils.log(LOG, Level.FINE, "COULD_NOT_DETERMINE_BEAN_NAME_MSG",
+ beanInstance.getClass().getName());
+ }
+
+ return beanName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
new file mode 100644
index 0000000..ed8f59a
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
@@ -0,0 +1,26 @@
+#
+#
+# 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.
+#
+#
+NO_MATCHING_BEAN_MSG = Could not find a definition for bean with id {0} - no injection will be performed.
+COULD_NOT_DETERMINE_BEAN_NAME_MSG = Could not determine bean name for instance of class {0}.
+ERROR_DETERMINING_BEAN_NAME_EXC = Failed to determine bean name.
+JAXB_PROPERTY_EDITOR_EXC = Property editor failed to bind element {0}.
+WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG = Configuration bean with id {0} that uses a ''*'' or wildcard must have a class attribute.
+ONE_WILDCARD_BEAN_ID_PER_CLASS_MSG = A wildcard configuration bean with id {0} already exists for class {1}. The wildcard bean with id {2} will be ignored.
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
new file mode 100644
index 0000000..390b76c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
@@ -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.bus.blueprint;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.cxf.common.logging.LogUtils;
+import org.osgi.framework.BundleContext;
+
+public final class NamespaceHandlerRegisterer {
+ private static final Logger LOG = LogUtils.getL7dLogger(NamespaceHandlerRegisterer.class);
+
+ private NamespaceHandlerRegisterer() {
+ }
+
+ public static void register(BundleContext bc, BlueprintNameSpaceHandlerFactory factory,
+ String... namespaces) {
+ try {
+ Object handler = factory.createNamespaceHandler();
+ for (String namespace : namespaces) {
+ Dictionary<String, String> properties = new Hashtable<String, String>();
+ properties.put("osgi.service.blueprint.namespace", namespace);
+ bc.registerService(NamespaceHandler.class.getName(), handler, properties);
+ LOG.info("Registered blueprint namespace handler for " + namespace);
+ }
+ } catch (Throwable e) {
+ LOG.log(Level.WARNING, "Aries Blueprint packages not available. So namespaces will not be registered", e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
new file mode 100644
index 0000000..6be1e3c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
@@ -0,0 +1,439 @@
+/**
+ * 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 java.io.StringReader;
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+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.MutableCollectionMetadata;
+import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
+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.jaxb.JAXBContextCache;
+import org.apache.cxf.common.jaxb.JAXBContextCache.CachedContextAndSchemas;
+import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.staxutils.StaxUtils;
+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";
+
+ private JAXBContext jaxbContext;
+ private Set<Class<?>> jaxbClasses;
+
+ protected boolean hasBusProperty() {
+ return false;
+ }
+
+ public Metadata createValue(ParserContext context, QName qName) {
+ MutableBeanMetadata v = context.createMetadata(MutableBeanMetadata.class);
+ v.setRuntimeClass(QName.class);
+ v.addArgument(createValue(context, qName.getNamespaceURI()), null, 0);
+ v.addArgument(createValue(context, qName.getLocalPart()), null, 1);
+ return v;
+ }
+
+ protected Metadata parseListData(ParserContext context,
+ ComponentMetadata enclosingComponent,
+ Element element) {
+ MutableCollectionMetadata m
+ = (MutableCollectionMetadata) context.parseElement(CollectionMetadata.class,
+ enclosingComponent, element);
+ m.setCollectionClass(List.class);
+ return m;
+ }
+
+ 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 {
+ //Rely on BP to handle these ones.
+ bean.addProperty(propertyName, ctx.parseElement(Metadata.class, bean, first));
+ }
+ } else {
+ bean.addProperty(propertyName, ctx.parseElement(Metadata.class, bean, first));
+ }
+ }
+
+ 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 ("name".equals(name)) {
+ processNameAttribute(element, ctx, bean, val);
+ } else if ("bus".equals(name)) {
+ processBusAttribute(element, ctx, bean, val);
+ } else if (!"id".equals(name) && isAttribute(pre, name)) {
+ mapAttribute(bean, element, name, val, ctx);
+ }
+ }
+ }
+ return setBus;
+ }
+ protected void processBusAttribute(Element element, ParserContext ctx,
+ MutableBeanMetadata bean, String val) {
+ if (this.hasBusProperty()) {
+ bean.addProperty("bus", getBusRef(ctx, val));
+ } else {
+ bean.addArgument(getBusRef(ctx, val), null, 0);
+ }
+ }
+
+ protected void processNameAttribute(Element element,
+ ParserContext ctx,
+ MutableBeanMetadata bean,
+ String val) {
+ //nothing
+ }
+ 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 PassThroughMetadata createPassThrough(ParserContext context, Object value) {
+ MutablePassThroughMetadata v = context.createMetadata(MutablePassThroughMetadata.class);
+ v.setObject(value);
+ return v;
+ }
+
+ 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 (!cdr.containsComponentDefinition(InterceptorTypeConverter.class.getName())) {
+ MutablePassThroughMetadata md = context.createMetadata(MutablePassThroughMetadata.class);
+ md.setObject(new InterceptorTypeConverter());
+
+ md.setId(InterceptorTypeConverter.class.getName());
+ context.getComponentDefinitionRegistry().registerTypeConverter(md);
+ }
+ if (blueprintBundle != null && !cdr.containsComponentDefinition(name)) {
+ //Create a bus
+
+ MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
+ bus.setId(name);
+ bus.setRuntimeClass(BlueprintBus.class);
+ bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+ bus.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
+ bus.setDestroyMethod("shutdown");
+ bus.setInitMethod("initialize");
+
+ context.getComponentDefinitionRegistry().registerComponentDefinition(bus);
+
+ return bus;
+ }
+ return (MutableBeanMetadata) cdr.getComponentDefinition(name);
+ }
+
+ protected RefMetadata getBusRef(ParserContext context, String name) {
+ if ("cxf".equals(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);
+ }
+ }
+
+ protected void mapElementToJaxbProperty(ParserContext ctx,
+ MutableBeanMetadata bean, Element parent,
+ QName name,
+ String propertyName,
+ Class<?> c) {
+ Element data = DOMUtils.getFirstChildWithName(parent, name);
+ if (data == null) {
+ return;
+ }
+
+ mapElementToJaxbProperty(ctx, bean, data, propertyName, c);
+ }
+
+ public static class JAXBBeanFactory {
+ final JAXBContext ctx;
+ final Class<?> cls;
+ public JAXBBeanFactory(JAXBContext c, Class<?> c2) {
+ ctx = c;
+ cls = c2;
+ }
+
+
+ public Object createJAXBBean(String v) {
+ XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(v));
+ try {
+ Object o = ctx.createUnmarshaller().unmarshal(reader, cls);
+ if (o instanceof JAXBElement<?>) {
+ JAXBElement<?> el = (JAXBElement<?>)o;
+ o = el.getValue();
+ }
+ return o;
+ } catch (JAXBException e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ reader.close();
+ } catch (XMLStreamException e) {
+ //ignore
+ }
+ }
+ }
+ }
+
+ protected void mapElementToJaxbProperty(ParserContext ctx,
+ MutableBeanMetadata bean,
+ Element data,
+ String propertyName,
+ Class<?> c) {
+ try {
+ XMLStreamWriter xmlWriter = null;
+ try {
+ StringWriter writer = new StringWriter();
+ xmlWriter = StaxUtils.createXMLStreamWriter(writer);
+ StaxUtils.copy(data, xmlWriter);
+ xmlWriter.flush();
+
+
+ MutableBeanMetadata factory = ctx.createMetadata(MutableBeanMetadata.class);
+ factory.setClassName(c.getName());
+ factory.setFactoryComponent(createPassThrough(ctx, new JAXBBeanFactory(getContext(c), c)));
+ factory.setFactoryMethod("createJAXBBean");
+ factory.addArgument(createValue(ctx, writer.toString()), String.class.getName(), 0);
+ bean.addProperty(propertyName, factory);
+
+ } catch (Exception ex) {
+ Unmarshaller u = getContext(c).createUnmarshaller();
+ Object obj;
+ if (c != null) {
+ obj = u.unmarshal(data, c);
+ } else {
+ obj = u.unmarshal(data);
+ }
+ if (obj instanceof JAXBElement<?>) {
+ JAXBElement<?> el = (JAXBElement<?>)obj;
+ obj = el.getValue();
+ }
+ if (obj != null) {
+ MutablePassThroughMetadata value = ctx.createMetadata(MutablePassThroughMetadata.class);
+ value.setObject(obj);
+ bean.addProperty(propertyName, value);
+ }
+ } finally {
+ StaxUtils.close(xmlWriter);
+ }
+ } catch (JAXBException e) {
+ throw new RuntimeException("Could not parse configuration.", e);
+ }
+ }
+
+
+ protected synchronized JAXBContext getContext(Class<?> cls) {
+ if (jaxbContext == null || jaxbClasses == null || !jaxbClasses.contains(cls)) {
+ try {
+ Set<Class<?>> tmp = new HashSet<Class<?>>();
+ if (jaxbClasses != null) {
+ tmp.addAll(jaxbClasses);
+ }
+ JAXBContextCache.addPackage(tmp, PackageUtils.getPackageName(cls),
+ cls == null
+ ? getClass().getClassLoader()
+ : cls.getClassLoader());
+ if (cls != null) {
+ boolean hasOf = false;
+ for (Class<?> c : tmp) {
+ if (c.getPackage() == cls.getPackage()
+ && "ObjectFactory".equals(c.getSimpleName())) {
+ hasOf = true;
+ }
+ }
+ if (!hasOf) {
+ tmp.add(cls);
+ }
+ }
+ JAXBContextCache.scanPackages(tmp);
+ CachedContextAndSchemas ccs
+ = JAXBContextCache.getCachedContextAndSchemas(tmp, null, null, null, false);
+ jaxbClasses = ccs.getClasses();
+ jaxbContext = ccs.getContext();
+ } catch (JAXBException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return jaxbContext;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
new file mode 100644
index 0000000..fca633c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
@@ -0,0 +1,42 @@
+/**
+ * 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.apache.cxf.interceptor.Interceptor;
+import org.osgi.service.blueprint.container.Converter;
+import org.osgi.service.blueprint.container.ReifiedType;
+
+/**
+ *
+ */
+public class InterceptorTypeConverter implements Converter {
+
+ /** {@inheritDoc}*/
+ public boolean canConvert(Object sourceObject, ReifiedType targetType) {
+ return sourceObject instanceof Interceptor
+ && targetType.getRawClass().isInstance(sourceObject);
+ }
+
+ /** {@inheritDoc}*/
+ public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
+ return sourceObject;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
new file mode 100644
index 0000000..77ce8b3
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
@@ -0,0 +1,87 @@
+/**
+ * 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.BeanProperty;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+/**
+ *
+ */
+public class SimpleBPBeanDefinitionParser extends AbstractBPBeanDefinitionParser {
+ protected Class<?> cls;
+
+ public SimpleBPBeanDefinitionParser(Class<?> cls) {
+ this.cls = cls;
+ }
+
+ public String getFactorySuffix() {
+ return null;
+ }
+ public String getFactoryCreateType(Element element) {
+ return null;
+ }
+
+ public String getId(Element element, ParserContext context) {
+ return element.hasAttribute("id") ? element.getAttribute("id") : null;
+ }
+
+ public Metadata parse(Element element, ParserContext context) {
+
+ MutableBeanMetadata cxfBean = context.createMetadata(MutableBeanMetadata.class);
+ cxfBean.setRuntimeClass(cls);
+ String fact = getFactorySuffix();
+ if (fact == null) {
+ cxfBean.setId(getId(element, context));
+ } else {
+ cxfBean.setId(getId(element, context) + fact);
+ }
+ parseAttributes(element, context, cxfBean);
+ parseChildElements(element, context, cxfBean);
+ if (hasBusProperty()) {
+ boolean foundBus = false;
+ for (BeanProperty bp : cxfBean.getProperties()) {
+ if ("bus".equals(bp.getName())) {
+ foundBus = true;
+ }
+ }
+ if (!foundBus) {
+ cxfBean.addProperty("bus", getBusRef(context, "cxf"));
+ }
+ }
+ if (fact != null) {
+ context.getComponentDefinitionRegistry().registerComponentDefinition(cxfBean);
+
+ MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
+ bean.setId(getId(element, context));
+ bean.setFactoryComponent(cxfBean);
+ bean.setFactoryMethod("create");
+ bean.setClassName(getFactoryCreateType(element));
+ return bean;
+ }
+ return cxfBean;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java
new file mode 100644
index 0000000..67d713e
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java
@@ -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.configuration.blueprint.internal;
+
+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.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.cxf.bus.blueprint.BusDefinitionParser;
+import org.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser;
+import org.apache.cxf.feature.FastInfosetFeature;
+import org.apache.cxf.feature.LoggingFeature;
+import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+/**
+ *
+ */
+public class CXFAPINamespaceHandler implements NamespaceHandler {
+
+ public URL getSchemaLocation(String namespace) {
+ String location = null;
+
+ if ("http://cxf.apache.org/configuration/beans".equals(namespace)) {
+ location = "schemas/configuration/cxf-beans.xsd";
+ } else if ("http://cxf.apache.org/configuration/parameterized-types".equals(namespace)) {
+ location = "schemas/configuration/parameterized-types.xsd";
+ } else if ("http://cxf.apache.org/configuration/security".equals(namespace)) {
+ location = "schemas/configuration/security.xsd";
+ } else if ("http://schemas.xmlsoap.org/wsdl/".equals(namespace)) {
+ location = "schemas/wsdl/wsdl.xsd";
+ } else if ("http://www.w3.org/2005/08/addressing".equals(namespace)) {
+ location = "schemas/wsdl/ws-addr.xsd";
+ } else if ("http://schemas.xmlsoap.org/ws/2004/08/addressing".equals(namespace)) {
+ location = "schemas/wsdl/addressing.xsd";
+ } else if ("http://cxf.apache.org/blueprint/core".equals(namespace)) {
+ location = "schemas/blueprint/core.xsd";
+ }
+ if (location != null) {
+ return getClass().getClassLoader().getResource(location);
+ }
+ return null;
+ }
+
+
+ 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);
+ } else if ("workqueue".equals(s)) {
+ return new SimpleBPBeanDefinitionParser(AutomaticWorkQueueImpl.class) {
+ public String getId(Element element, ParserContext context) {
+ String id = element.hasAttribute("id") ? element.getAttribute("id") : null;
+ if (id == null) {
+ id = "cxf.workqueue.";
+ id += element.hasAttribute("name") ? element.getAttribute("name") : "def";
+ }
+ return id;
+ }
+
+ protected void processNameAttribute(Element element, ParserContext ctx,
+ MutableBeanMetadata bean, String val) {
+ bean.addProperty("name", createValue(ctx, val));
+ }
+ } .parse(element, context);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ 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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java
new file mode 100644
index 0000000..52cdd82
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java
@@ -0,0 +1,62 @@
+/**
+ * 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.internal;
+
+import org.apache.cxf.bus.blueprint.BlueprintNameSpaceHandlerFactory;
+import org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Is called in OSGi on start and stop of the cxf bundle.
+ * Manages
+ * - CXFBundleListener
+ * - Attaching ManagedWorkqueues to config admin service
+ * - OsgiBusListener
+ * - Blueprint namespaces
+ */
+public class CXFActivator implements BundleActivator {
+
+ /** {@inheritDoc}*/
+ public void start(BundleContext context) throws Exception {
+
+ BlueprintNameSpaceHandlerFactory factory = new BlueprintNameSpaceHandlerFactory() {
+
+ @Override
+ public Object createNamespaceHandler() {
+ return new CXFAPINamespaceHandler();
+ }
+ };
+ NamespaceHandlerRegisterer.register(context, factory,
+ "http://cxf.apache.org/blueprint/core",
+ "http://cxf.apache.org/configuration/beans",
+ "http://cxf.apache.org/configuration/parameterized-types",
+ "http://cxf.apache.org/configuration/security",
+ "http://schemas.xmlsoap.org/wsdl/",
+ "http://www.w3.org/2005/08/addressing",
+ "http://schemas.xmlsoap.org/ws/2004/08/addressing");
+
+ }
+
+ /** {@inheritDoc}*/
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd b/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd
new file mode 100644
index 0000000..3b3c144
--- /dev/null
+++ b/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd
@@ -0,0 +1,160 @@
+<?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"
+ xmlns:ptp="http://cxf.apache.org/configuration/parameterized-types"
+
+ 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:import namespace="http://cxf.apache.org/configuration/parameterized-types"
+ schemaLocation="http://cxf.apache.org/schemas/configuration/parameterized-types.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="workqueue">
+ <xsd:annotation>
+ <xsd:documentation>
+ Configuration for workqueues that CXF uses
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence />
+ <xsd:attribute name="highWaterMark" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="lowWaterMark" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="initialSize" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="queueSize" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="dequeueTimeout" type="ptp:ParameterizedLong" use="optional"/>
+ </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:annotation>
+ <xsd:documentation>
+ Name of the bus that is being configured. Defaults to "cxf", but can
+ be used to specify a different bus to allow for multiple Bus instances
+ within an application.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="id" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Unique identifier for the particular Bus instance. Mostly used by the
+ JMX management and OSGi service registry to provide some level of
+ persitent naming to the Bus instances. The default is "cxf" + random number.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java b/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java
new file mode 100644
index 0000000..dd0dd3c
--- /dev/null
+++ b/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java
@@ -0,0 +1,42 @@
+/**
+ * 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.internal;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class CXFAPINamespaceHandlerTest extends Assert {
+ @Test
+ public void testGetSchemaLocation() {
+ CXFAPINamespaceHandler handler = new CXFAPINamespaceHandler();
+
+ assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/beans"));
+ assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/parameterized-types"));
+ assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/security"));
+ assertNotNull(handler.getSchemaLocation("http://schemas.xmlsoap.org/wsdl/"));
+ assertNotNull(handler.getSchemaLocation("http://www.w3.org/2005/08/addressing"));
+ assertNotNull(handler.getSchemaLocation("http://schemas.xmlsoap.org/ws/2004/08/addressing"));
+ assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/blueprint/core"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/bindings/coloc/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/coloc/pom.xml b/rt/bindings/coloc/pom.xml
index 9d8b1c5..c4e7b05 100644
--- a/rt/bindings/coloc/pom.xml
+++ b/rt/bindings/coloc/pom.xml
@@ -52,6 +52,13 @@
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/bindings/object/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/object/pom.xml b/rt/bindings/object/pom.xml
index ed7a2be..e4a89a1 100644
--- a/rt/bindings/object/pom.xml
+++ b/rt/bindings/object/pom.xml
@@ -54,6 +54,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/bindings/soap/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/pom.xml b/rt/bindings/soap/pom.xml
index fba8cd6..10a05d5 100644
--- a/rt/bindings/soap/pom.xml
+++ b/rt/bindings/soap/pom.xml
@@ -63,6 +63,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/features/clustering/pom.xml
----------------------------------------------------------------------
diff --git a/rt/features/clustering/pom.xml b/rt/features/clustering/pom.xml
index dac027a..fca832b 100644
--- a/rt/features/clustering/pom.xml
+++ b/rt/features/clustering/pom.xml
@@ -64,6 +64,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/frontend/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/pom.xml b/rt/frontend/jaxrs/pom.xml
index 6b2948b..0c4b050 100644
--- a/rt/frontend/jaxrs/pom.xml
+++ b/rt/frontend/jaxrs/pom.xml
@@ -105,6 +105,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
<groupId>${cxf.servlet-api.group}</groupId>
<artifactId>${cxf.servlet-api.artifact}</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/frontend/jaxws/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/pom.xml b/rt/frontend/jaxws/pom.xml
index 20ea597..cff30a1 100644
--- a/rt/frontend/jaxws/pom.xml
+++ b/rt/frontend/jaxws/pom.xml
@@ -107,6 +107,14 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/frontend/simple/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/pom.xml b/rt/frontend/simple/pom.xml
index d80ec4c..55831f0 100644
--- a/rt/frontend/simple/pom.xml
+++ b/rt/frontend/simple/pom.xml
@@ -80,6 +80,13 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-xml</artifactId>
<version>${project.version}</version>
<scope>test</scope>