You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2016/07/01 12:09:07 UTC
[1/5] cxf-dosgi git commit: [DOSGI-242] Refactor provider, Cleanup
Repository: cxf-dosgi
Updated Branches:
refs/heads/master 5d8bbd2bd -> 79bb9a437
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java
index cc15ea6..f20f878 100644
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java
@@ -25,20 +25,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
-@SuppressWarnings("deprecation")
+import junit.framework.TestCase;
+
public class OsgiUtilsTest extends TestCase {
public void testMultiValuePropertyAsString() {
@@ -63,79 +54,6 @@ public class OsgiUtilsTest extends TestCase {
assertNull(OsgiUtils.getMultiValueProperty(null));
}
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- public void testGetVersion() {
- IMocksControl c = EasyMock.createNiceControl();
- BundleContext bc = c.createMock(BundleContext.class);
- ServiceReference sref = c.createMock(ServiceReference.class);
- PackageAdmin pa = c.createMock(PackageAdmin.class);
- Bundle b = c.createMock(Bundle.class);
-
- EasyMock.expect(bc.getServiceReference(EasyMock.eq(PackageAdmin.class))).andReturn(sref);
- EasyMock.expect(bc.getService(EasyMock.eq(sref))).andReturn(pa);
-
- Class<?> iClass = CharSequence.class;
-
- c.replay();
- // version 0.0.0 because of missing bundle
-
- assertEquals("0.0.0", OsgiUtils.getVersion(iClass, bc));
-
- c.verify();
- c.reset();
- // version 1.2.3
-
- EasyMock.expect(bc.getServiceReference(EasyMock.eq(PackageAdmin.class))).andReturn(sref);
- EasyMock.expect(bc.getService(EasyMock.eq(sref))).andReturn(pa);
- EasyMock.expect(pa.getBundle(EasyMock.eq(iClass))).andReturn(b);
-
- ExportedPackage[] exP = new ExportedPackage[] {new MyExportedPackage(iClass.getPackage(), "1.2.3"),
- new MyExportedPackage(String.class.getPackage(), "4.5.6") };
-
- EasyMock.expect(pa.getExportedPackages(EasyMock.eq(b))).andReturn(exP).atLeastOnce();
-
- c.replay();
- assertEquals("1.2.3", OsgiUtils.getVersion(iClass, bc));
- c.verify();
- }
-
- private static class MyExportedPackage implements ExportedPackage {
-
- Package package1;
- String version;
-
- MyExportedPackage(Package package1, String version) {
- this.package1 = package1;
- this.version = version;
- }
-
- public Bundle getExportingBundle() {
- return null;
- }
-
- public Bundle[] getImportingBundles() {
- return null;
- }
-
- public String getName() {
- return package1.getName();
- }
-
- public String getSpecificationVersion() {
- return null;
- }
-
- public Version getVersion() {
- return new Version(version);
- }
-
- public boolean isRemovalPending() {
- return false;
- }
- }
-
public void testGetProperty() {
Map<String, Object> p = new HashMap<String, Object>();
p.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/decorator/bnd.bnd
----------------------------------------------------------------------
diff --git a/decorator/bnd.bnd b/decorator/bnd.bnd
new file mode 100644
index 0000000..499a137
--- /dev/null
+++ b/decorator/bnd.bnd
@@ -0,0 +1,3 @@
+Private-Package: org.apache.cxf.dosgi.dsw.decorator
+Bundle-Activator: org.apache.cxf.dosgi.dsw.decorator.Activator
+Export-Package: org.apache.cxf.xmlns.service_decoration._1_0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/decorator/pom.xml
----------------------------------------------------------------------
diff --git a/decorator/pom.xml b/decorator/pom.xml
index af14af3..e894925 100644
--- a/decorator/pom.xml
+++ b/decorator/pom.xml
@@ -35,76 +35,6 @@
<topDirectoryLocation>..</topDirectoryLocation>
</properties>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </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>org.apache.aries.rsa</groupId>
- <artifactId>org.apache.aries.rsa.spi</artifactId>
- <version>${aries.rsa.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-core</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-client</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-databinding-aegis</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-extension-providers</artifactId>
- <version>${cxf.version}</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>1.7.14</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
<build>
<plugins>
<plugin>
@@ -119,20 +49,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>
- !*
- </Export-Package>
- <Bundle-Activator>org.apache.cxf.dosgi.dsw.decorator.Activator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/pom.xml
----------------------------------------------------------------------
diff --git a/felix/pom.xml b/felix/pom.xml
deleted file mode 100644
index 0b8b759..0000000
--- a/felix/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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.
--->
-<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-dosgi-ri-felix</artifactId>
- <packaging>pom</packaging>
- <name>Distributed OSGi Temporary Private Felix Framework Build</name>
-
- <parent>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.8-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <properties>
- <topDirectoryLocation>..</topDirectoryLocation>
- </properties>
-
- <modules>
- <module>shell.tui</module>
- <module>profiles</module>
- </modules>
-
-</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/pom.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/pom.xml b/felix/profiles/pom.xml
deleted file mode 100644
index 4cc71fe..0000000
--- a/felix/profiles/pom.xml
+++ /dev/null
@@ -1,201 +0,0 @@
-<?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.
--->
-<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-dosgi-ri-felix-profiles</artifactId>
- <packaging>jar</packaging>
- <name>Distributed OSGi Felix Profiles</name>
-
- <parent>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.8-SNAPSHOT</version>
- <relativePath>../../parent/pom.xml</relativePath>
- </parent>
-
- <properties>
- <topDirectoryLocation>../..</topDirectoryLocation>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>${jetty.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>${jetty.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.stax-api-1.0</artifactId>
- <version>${servicemix.specs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.jaxb-api-2.1</artifactId>
- <version>${servicemix.specs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.jaxws-api-2.1</artifactId>
- <version>${servicemix.specs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.saaj-api-1.3</artifactId>
- <version>${servicemix.specs.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-javamail_1.4_spec</artifactId>
- <version>1.7.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-activation_1.1_spec</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
- <version>1.1.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_3.0_spec</artifactId>
- <version>1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
- <version>1.1.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ws.xmlschema</groupId>
- <artifactId>xmlschema-core</artifactId>
- <version>${xmlschema.bundle.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.xmlresolver</artifactId>
- <version>${xmlresolver.bundle.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.neethi</groupId>
- <artifactId>neethi</artifactId>
- <version>${neethi.bundle.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.wsdl4j</artifactId>
- <version>${wsdl4j.bundle.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.santuario</groupId>
- <artifactId>xmlsec</artifactId>
- <version>${xmlsec.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.jaxb-impl</artifactId>
- <version>${jaxbimpl.bundle.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.asm</artifactId>
- <version>${asm.bundle.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>woodstox-core-asl</artifactId>
- <version>${woodstox.bundle.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>${spring.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <version>${spring.osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-io</artifactId>
- <version>${spring.osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- <version>${spring.osgi.version}</version>
- </dependency>
-
- <!-- for maven filtering to happen -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>src/main/resources/</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/OSGI-INF/remote-service/alt-remote-services.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/OSGI-INF/remote-service/alt-remote-services.xml b/felix/profiles/resources/OSGI-INF/remote-service/alt-remote-services.xml
deleted file mode 100644
index 36409ce..0000000
--- a/felix/profiles/resources/OSGI-INF/remote-service/alt-remote-services.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
- <service-description>
- <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" />
- <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" />
-
- <property name="osgi.remote.interfaces" value="*" />
- <property name="osgi.remote.requires.intents" value="SOAP HTTP" />
- <property name="osgi.remote.configuration.type" value="pojo" />
- <property name="osgi.remote.configuration.pojo.address" value="http://localhost:9000/hello" />
- </service-description>
-</service-descriptions>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/OSGI-INF/remote-service/multi-services.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/OSGI-INF/remote-service/multi-services.xml b/felix/profiles/resources/OSGI-INF/remote-service/multi-services.xml
deleted file mode 100644
index 3d20c08..0000000
--- a/felix/profiles/resources/OSGI-INF/remote-service/multi-services.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
- <service-description>
- <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" />
- <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" />
- <property name="osgi.remote.interfaces">org.apache.cxf.dosgi.dsw.hooks.TestService,org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface</property>
- <property name="osgi.remote.requires.intents">SOAP HTTP</property>
- <property name="osgi.remote.configuration.type">pojo</property>
- <property name="osgi.remote.configuration.pojo.address"
- interface="org.apache.cxf.dosgi.dsw.hooks.TestService">
- http://localhost:9001/hello
- </property>
- <property name="osgi.remote.configuration.pojo.address"
- interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface">
- http://localhost:9002/hello
- </property>
- </service-description>
-</service-descriptions>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/OSGI-INF/remote-service/remote-services.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/OSGI-INF/remote-service/remote-services.xml b/felix/profiles/resources/OSGI-INF/remote-service/remote-services.xml
deleted file mode 100644
index 45b2a20..0000000
--- a/felix/profiles/resources/OSGI-INF/remote-service/remote-services.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
- <service-description>
- <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" />
- <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" />
-
- <property name="osgi.remote.interfaces">*</property>
- <property name="osgi.remote.requires.intents">SOAP HTTP</property>
- <property name="osgi.remote.configuration.type">pojo</property>
- <property name="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>
- </service-description>
-</service-descriptions>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/test-resources/rs1.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/test-resources/rs1.xml b/felix/profiles/resources/test-resources/rs1.xml
deleted file mode 100644
index f67a833..0000000
--- a/felix/profiles/resources/test-resources/rs1.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
- <service-description>
- <provide interface="SomeService" />
- <property name="osgi.remote.requires.intents">confidentiality</property>
- </service-description>
- <service-description>
- <provide interface="SomeOtherService" />
- <provide interface="WithSomeSecondInterface" />
- </service-description>
-</service-descriptions>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/test-resources/rs2.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/test-resources/rs2.xml b/felix/profiles/resources/test-resources/rs2.xml
deleted file mode 100644
index 098aa21..0000000
--- a/felix/profiles/resources/test-resources/rs2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?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.
--->
-
-<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
- <service-description>
- <provide interface="org.example.Service" />
- <property name="deployment.intents">confidentiality.message integrity</property>
- <property name="osgi.remote.interfaces">*</property>
- </service-description>
-</service-descriptions>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/test-resources/sd-1.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/test-resources/sd-1.xml b/felix/profiles/resources/test-resources/sd-1.xml
deleted file mode 100644
index 483b196..0000000
--- a/felix/profiles/resources/test-resources/sd-1.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<test>
- <some-other-tag/>
-</test>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/test-resources/sd.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/test-resources/sd.xml b/felix/profiles/resources/test-resources/sd.xml
deleted file mode 100644
index c7cebfb..0000000
--- a/felix/profiles/resources/test-resources/sd.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
- <service-decoration>
- <match interface="org.acme.foo.*">
- <match-property name="test.prop" value="xyz"/>
- <add-property name="test.too" value="ahaha" type="java.lang.String"/>
- </match>
- </service-decoration>
-</service-decorations>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/test-resources/sd0.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/test-resources/sd0.xml b/felix/profiles/resources/test-resources/sd0.xml
deleted file mode 100644
index 0ad0ad1..0000000
--- a/felix/profiles/resources/test-resources/sd0.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
-</service-decorations>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/test-resources/sd1.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/test-resources/sd1.xml b/felix/profiles/resources/test-resources/sd1.xml
deleted file mode 100644
index 6a5e811..0000000
--- a/felix/profiles/resources/test-resources/sd1.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
- <service-decoration>
- <match interface="org.test.A">
- <add-property name="A" value="B"/>
- <add-property name="C" value="2" type="java.lang.Integer"/>
- </match>
- </service-decoration>
-</service-decorations>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/resources/test-resources/sd2.xml
----------------------------------------------------------------------
diff --git a/felix/profiles/resources/test-resources/sd2.xml b/felix/profiles/resources/test-resources/sd2.xml
deleted file mode 100644
index fb6a93a..0000000
--- a/felix/profiles/resources/test-resources/sd2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<service-decorations xmlns="http://cxf.apache.org/xmlns/service-decoration/1.0.0">
- <service-decoration>
- <match interface="org.test.(B|C)">
- <match-property name="x" value="y"/>
- <add-property name="bool" value="true" type="java.lang.Boolean"/>
- </match>
- </service-decoration>
- <service-decoration>
- <match interface="org.test.(B|C)">
- <match-property name="x" value="z"/>
- <add-property name="bool" value="false" type="java.lang.Boolean"/>
- </match>
- </service-decoration>
-</service-decorations>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/src/main/java/felix/EmptyClass.java
----------------------------------------------------------------------
diff --git a/felix/profiles/src/main/java/felix/EmptyClass.java b/felix/profiles/src/main/java/felix/EmptyClass.java
deleted file mode 100644
index 58758f7..0000000
--- a/felix/profiles/src/main/java/felix/EmptyClass.java
+++ /dev/null
@@ -1,22 +0,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.
- */
-package felix;
-
-public class EmptyClass {
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/src/main/resources/client_bundles.txt
----------------------------------------------------------------------
diff --git a/felix/profiles/src/main/resources/client_bundles.txt b/felix/profiles/src/main/resources/client_bundles.txt
deleted file mode 100644
index 0bf6534..0000000
--- a/felix/profiles/src/main/resources/client_bundles.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-annotation_1.0_spec/1.1.1/geronimo-annotation_1.0_spec-1.1.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.1/geronimo-activation_1.1_spec-1.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.7.1/geronimo-javamail_1.4_spec-1.7.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-ws-metadata_2.0_spec/1.1.3/geronimo-ws-metadata_2.0_spec-1.1.3.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0/geronimo-servlet_3.0_spec-1.0.jar
-
-start file:${maven.repo.local}/org/apache/commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar
-
-start file:${maven.repo.local}/org/jdom/com.springsource.org.jdom/1.1.0/com.springsource.org.jdom-1.1.0.jar
-
-start file:${maven.repo.local}/org/jaxen/com.springsource.org.jaxen/1.1.1/com.springsource.org.jaxen-1.1.1.jar
-
-start file:${maven.repo.local}/org/springframework/spring-core/${spring.version}/spring-core-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-beans/${spring.version}/spring-beans-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-context/${spring.version}/spring-context-${spring.version}.jar
-
-start file:${maven.repo.local}/org/aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar
-
-start file:${maven.repo.local}/org/springframework/spring-aop/${spring.version}/spring-aop-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-expression/${spring.version}/spring-expression-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-asm/${spring.version}/spring-asm-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-core/${spring.osgi.version}/spring-osgi-core-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-extender/${spring.osgi.version}/spring-osgi-extender-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/eclipse/jetty/aggregate/jetty-all-server/${jetty.version}/jetty-all-server-${jetty.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.locator/${servicemix.specs.version}/org.apache.servicemix.specs.locator-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.saaj-api-1.3/${servicemix.specs.version}/org.apache.servicemix.specs.saaj-api-1.3-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.stax-api-1.0/${servicemix.specs.version}/org.apache.servicemix.specs.stax-api-1.0-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxb-api-2.1/${servicemix.specs.version}/org.apache.servicemix.specs.jaxb-api-2.1-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxws-api-2.1/${servicemix.specs.version}/org.apache.servicemix.specs.jaxws-api-2.1-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.jaxb-impl/${jaxbimpl.bundle.version}/org.apache.servicemix.bundles.jaxb-impl-${jaxbimpl.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.wsdl4j/${wsdl4j.bundle.version}/org.apache.servicemix.bundles.wsdl4j-${wsdl4j.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.xmlsec/${xmlsec.bundle.version}/org.apache.servicemix.bundles.xmlsec-${xmlsec.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.wss4j/${wss4j.bundle.version}/org.apache.servicemix.bundles.wss4j-${wss4j.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/sws/xmlschema/xmlschema-core/${xmlschema.bundle.version}/xmlschema-core-${xmlschema.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.asm/${asm.bundle.version}/org.apache.servicemix.bundles.asm-${asm.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.xmlresolver/${xmlresolver.bundle.version}/org.apache.servicemix.bundles.xmlresolver-${xmlresolver.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/neethi/neethi/${neethi.bundle.version}/neethi-${neethi.bundle.version}.jar
-
-start file:${maven.repo.local}/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar
-
-start file:${maven.repo.local}/org/codehaus/woodstox/woodstox-core-asl/${woodstox.bundle.version}/woodstox-core-asl-${woodstox.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.joda-time/1.5.2_4/org.apache.servicemix.bundles.joda-time-1.5.2_4.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.opensaml/2.4.1_1/org.apache.servicemix.bundles.opensaml-2.4.1_1.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-bundle-minimal/${cxf.version}/cxf-bundle-minimal-${cxf.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-discovery-local/${project.version}/cxf-dosgi-ri-discovery-local-${project.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-dsw-cxf/${project.version}/cxf-dosgi-ri-dsw-cxf-${project.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-samples-greeter-interface/${project.version}/cxf-dosgi-ri-samples-greeter-interface-${project.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-samples-greeter-client/${project.version}/cxf-dosgi-ri-samples-greeter-client-${project.version}.jar
-
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/src/main/resources/dosgi_bundles.txt
----------------------------------------------------------------------
diff --git a/felix/profiles/src/main/resources/dosgi_bundles.txt b/felix/profiles/src/main/resources/dosgi_bundles.txt
deleted file mode 100644
index 8506239..0000000
--- a/felix/profiles/src/main/resources/dosgi_bundles.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-annotation_1.0_spec/1.1.1/geronimo-annotation_1.0_spec-1.1.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.1/geronimo-activation_1.1_spec-1.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.7.1/geronimo-javamail_1.4_spec-1.7.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-ws-metadata_2.0_spec/1.1.3/geronimo-ws-metadata_2.0_spec-1.1.3.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0/geronimo-servlet_3.0_spec-1.0.jar
-
-start file:${maven.repo.local}/org/apache/commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar
-
-start file:${maven.repo.local}/org/jdom/com.springsource.org.jdom/1.1.0/com.springsource.org.jdom-1.1.0.jar
-
-start file:${maven.repo.local}/org/jaxen/com.springsource.org.jaxen/1.1.1/com.springsource.org.jaxen-1.1.1.jar
-
-start file:${maven.repo.local}/org/springframework/spring-core/${spring.version}/spring-core-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-beans/${spring.version}/spring-beans-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-context/${spring.version}/spring-context-${spring.version}.jar
-
-start file:${maven.repo.local}/org/aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar
-
-start file:${maven.repo.local}/org/springframework/spring-aop/${spring.version}/spring-aop-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-expression/${spring.version}/spring-expression-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-asm/${spring.version}/spring-asm-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-core/${spring.osgi.version}/spring-osgi-core-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-extender/${spring.osgi.version}/spring-osgi-extender-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/eclipse/jetty/aggregate/jetty-all-server/${jetty.version}/jetty-all-server-${jetty.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.locator/${servicemix.specs.version}/org.apache.servicemix.specs.locator-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.saaj-api-1.3/${servicemix.specs.version}/org.apache.servicemix.specs.saaj-api-1.3-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.stax-api-1.0/${servicemix.specs.version}/org.apache.servicemix.specs.stax-api-1.0-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxb-api-2.1/${servicemix.specs.version}/org.apache.servicemix.specs.jaxb-api-2.1-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxws-api-2.1/${servicemix.specs.version}/org.apache.servicemix.specs.jaxws-api-2.1-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.jaxb-impl/${jaxbimpl.bundle.version}/org.apache.servicemix.bundles.jaxb-impl-${jaxbimpl.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.wsdl4j/${wsdl4j.bundle.version}/org.apache.servicemix.bundles.wsdl4j-${wsdl4j.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.xmlsec/${xmlsec.bundle.version}/org.apache.servicemix.bundles.xmlsec-${xmlsec.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.wss4j/${wss4j.bundle.version}/org.apache.servicemix.bundles.wss4j-${wss4j.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/sws/xmlschema/xmlschema-core/${xmlschema.bundle.version}/xmlschema-core-${xmlschema.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.asm/${asm.bundle.version}/org.apache.servicemix.bundles.asm-${asm.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.xmlresolver/${xmlresolver.bundle.version}/org.apache.servicemix.bundles.xmlresolver-${xmlresolver.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/neethi/neethi/${neethi.bundle.version}/neethi-${neethi.bundle.version}.jar
-
-start file:${maven.repo.local}/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar
-
-start file:${maven.repo.local}/org/codehaus/woodstox/woodstox-core-asl/${woodstox.bundle.version}/woodstox-core-asl-${woodstox.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.joda-time/1.5.2_4/org.apache.servicemix.bundles.joda-time-1.5.2_4.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.opensaml/2.4.1_1/org.apache.servicemix.bundles.opensaml-2.4.1_1.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-bundle-minimal/${cxf.version}/cxf-bundle-minimal-${cxf.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-discovery-local/${project.version}/cxf-dosgi-ri-discovery-local-${project.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-dsw-cxf/${project.version}/cxf-dosgi-ri-dsw-cxf-${project.version}.jar
-
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/profiles/src/main/resources/server_bundles.txt
----------------------------------------------------------------------
diff --git a/felix/profiles/src/main/resources/server_bundles.txt b/felix/profiles/src/main/resources/server_bundles.txt
deleted file mode 100644
index b15a054..0000000
--- a/felix/profiles/src/main/resources/server_bundles.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-annotation_1.0_spec/1.1.1/geronimo-annotation_1.0_spec-1.1.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.1/geronimo-activation_1.1_spec-1.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.7.1/geronimo-javamail_1.4_spec-1.7.1.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-ws-metadata_2.0_spec/1.1.3/geronimo-ws-metadata_2.0_spec-1.1.3.jar
-
-start file:${maven.repo.local}/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0/geronimo-servlet_3.0_spec-1.0.jar
-
-start file:${maven.repo.local}/org/apache/commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar
-
-start file:${maven.repo.local}/org/jdom/com.springsource.org.jdom/1.1.0/com.springsource.org.jdom-1.1.0.jar
-
-start file:${maven.repo.local}/org/jaxen/com.springsource.org.jaxen/1.1.1/com.springsource.org.jaxen-1.1.1.jar
-
-start file:${maven.repo.local}/org/springframework/spring-core/${spring.version}/spring-core-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-beans/${spring.version}/spring-beans-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-context/${spring.version}/spring-context-${spring.version}.jar
-
-start file:${maven.repo.local}/org/aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar
-
-start file:${maven.repo.local}/org/springframework/spring-aop/${spring.version}/spring-aop-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-expression/${spring.version}/spring-expression-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/spring-asm/${spring.version}/spring-asm-${spring.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-core/${spring.osgi.version}/spring-osgi-core-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/springframework/osgi/spring-osgi-extender/${spring.osgi.version}/spring-osgi-extender-${spring.osgi.version}.jar
-
-start file:${maven.repo.local}/org/eclipse/jetty/aggregate/jetty-all-server/${jetty.version}/jetty-all-server-${jetty.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.locator/${servicemix.specs.version}/org.apache.servicemix.specs.locator-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.saaj-api-1.3/${servicemix.specs.version}/org.apache.servicemix.specs.saaj-api-1.3-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.stax-api-1.0/${servicemix.specs.version}/org.apache.servicemix.specs.stax-api-1.0-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxb-api-2.1/${servicemix.specs.version}/org.apache.servicemix.specs.jaxb-api-2.1-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/specs/org.apache.servicemix.specs.jaxws-api-2.1/${servicemix.specs.version}/org.apache.servicemix.specs.jaxws-api-2.1-${servicemix.specs.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.jaxb-impl/${jaxbimpl.bundle.version}/org.apache.servicemix.bundles.jaxb-impl-${jaxbimpl.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.wsdl4j/${wsdl4j.bundle.version}/org.apache.servicemix.bundles.wsdl4j-${wsdl4j.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.xmlsec/${xmlsec.bundle.version}/org.apache.servicemix.bundles.xmlsec-${xmlsec.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.wss4j/${wss4j.bundle.version}/org.apache.servicemix.bundles.wss4j-${wss4j.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/sws/xmlschema/xmlschema-core/${xmlschema.bundle.version}/xmlschema-core-${xmlschema.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.asm/${asm.bundle.version}/org.apache.servicemix.bundles.asm-${asm.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.xmlresolver/${xmlresolver.bundle.version}/org.apache.servicemix.bundles.xmlresolver-${xmlresolver.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/neethi/neethi/${neethi.bundle.version}/neethi-${neethi.bundle.version}.jar
-
-start file:${maven.repo.local}/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar
-
-start file:${maven.repo.local}/org/codehaus/woodstox/woodstox-core-asl/${woodstox.bundle.version}/woodstox-core-asl-${woodstox.bundle.version}.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.joda-time/1.5.2_4/org.apache.servicemix.bundles.joda-time-1.5.2_4.jar
-
-start file:${maven.repo.local}/org/apache/servicemix/bundles/org.apache.servicemix.bundles.opensaml/2.4.1_1/org.apache.servicemix.bundles.opensaml-2.4.1_1.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-bundle-minimal/${cxf.version}/cxf-bundle-minimal-${cxf.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-discovery-local/${project.version}/cxf-dosgi-ri-discovery-local-${project.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-dsw-cxf/${project.version}/cxf-dosgi-ri-dsw-cxf-${project.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-samples-greeter-interface/${project.version}/cxf-dosgi-ri-samples-greeter-interface-${project.version}.jar
-
-start file:${maven.repo.local}/org/apache/cxf/cxf-dosgi-ri-samples-greeter-impl/${project.version}/cxf-dosgi-ri-samples-greeter-impl-${project.version}.jar
-
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/remote-debug.txt
----------------------------------------------------------------------
diff --git a/felix/remote-debug.txt b/felix/remote-debug.txt
deleted file mode 100644
index 229262b..0000000
--- a/felix/remote-debug.txt
+++ /dev/null
@@ -1 +0,0 @@
--Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/shell.tui/LICENSE
----------------------------------------------------------------------
diff --git a/felix/shell.tui/LICENSE b/felix/shell.tui/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/felix/shell.tui/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/shell.tui/NOTICE
----------------------------------------------------------------------
diff --git a/felix/shell.tui/NOTICE b/felix/shell.tui/NOTICE
deleted file mode 100644
index d96621a..0000000
--- a/felix/shell.tui/NOTICE
+++ /dev/null
@@ -1,20 +0,0 @@
-Apache Felix Shell Textual Interface
-Copyright 2006-2008 The Apache Software Foundation
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright 2006 The OSGi Alliance.
-Licensed under the Apache License 2.0.
-
-
-III. License Summary
-- Apache License 2.0
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/shell.tui/pom.xml
----------------------------------------------------------------------
diff --git a/felix/shell.tui/pom.xml b/felix/shell.tui/pom.xml
deleted file mode 100644
index e0a6d6f..0000000
--- a/felix/shell.tui/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?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.
--->
-<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>
- <packaging>bundle</packaging>
- <name>Distributed OSGi Temporary Private Apache Felix Shell TUI Build</name>
- <description>A simple textual user interface for Felix' shell service.</description>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>felix-shell-extension</artifactId>
- <version>1.8-SNAPSHOT</version>
-
- <parent>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.8-SNAPSHOT</version>
- <relativePath>../../parent/pom.xml</relativePath>
- </parent>
-
- <properties>
- <maven.test.skip>true</maven.test.skip>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.shell</artifactId>
- <version>1.4.3</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <excludes>**/*.java</excludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Private-Package>org.apache.felix.shell.tui.*</Private-Package>
- <Bundle-Activator>org.apache.felix.shell.tui.Activator</Bundle-Activator>
- <Bundle-DocURL>http://oscar-osgi.sf.net/obr2/${project.artifactId}/</Bundle-DocURL>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
- <Import-Service>org.apache.felix.shell.ShellService</Import-Service>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/felix/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
----------------------------------------------------------------------
diff --git a/felix/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java b/felix/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
deleted file mode 100644
index c41ca32..0000000
--- a/felix/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
+++ /dev/null
@@ -1,187 +0,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.
- */
-package org.apache.felix.shell.tui;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.apache.felix.shell.ShellService;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-public class Activator implements BundleActivator {
-
- private static final String RUN_CMD = "run ";
-
- private BundleContext context;
- private ShellTuiRunnable shellRunnable;
- private Thread thread;
- private ServiceListener listener;
- private ServiceReference shellRef;
- private ShellService shell;
-
- public void start(BundleContext bcontext) {
- context = bcontext;
-
- // Listen for registering/unregistering impl service.
- listener = new ShellServiceListener();
- try {
- context.addServiceListener(listener,
- "(objectClass=" + org.apache.felix.shell.ShellService.class.getName() + ")");
- } catch (InvalidSyntaxException ex) {
- System.err.println("ShellTui: Cannot add service listener.");
- System.err.println("ShellTui: " + ex);
- }
-
- // Now try to manually initialize the impl service
- // since one might already be available.
- initializeService();
-
- // Start impl thread.
- shellRunnable = new ShellTuiRunnable();
- thread = new Thread(shellRunnable, "Felix Shell TUI");
- thread.start();
- }
-
- public void stop(BundleContext bcontext) {
- if (shellRunnable != null) {
- shellRunnable.stop();
- thread.interrupt();
- }
- if (listener != null) {
- context.removeServiceListener(listener);
- }
- uninitializeService();
- }
-
- private synchronized void initializeService() {
- if (shell != null) {
- return;
- }
- shellRef = context.getServiceReference(org.apache.felix.shell.ShellService.class.getName());
- if (shellRef == null) {
- return;
- }
- shell = (ShellService)context.getService(shellRef);
- }
-
- private synchronized void uninitializeService() {
- if (shellRef != null) {
- context.ungetService(shellRef);
- }
- shellRef = null;
- shell = null;
- }
-
- private class ShellServiceListener implements ServiceListener {
- public void serviceChanged(ServiceEvent event) {
- synchronized (Activator.this) {
- if (event.getType() == ServiceEvent.REGISTERED) {
- // Ignore additional services if we already have one.
- if (shellRef == null) {
- // Initialize the service if we don't have one.
- initializeService();
- }
- } else if (event.getType() == ServiceEvent.UNREGISTERING
- && event.getServiceReference().equals(shellRef)) {
- // Unget the service if it is unregistering.
- uninitializeService();
- // Try to get another service.
- initializeService();
- }
- }
- }
- }
-
- private class ShellTuiRunnable implements Runnable {
-
- private volatile boolean stop;
-
- public void stop() {
- stop = true;
- }
-
- public void run() {
- String line;
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-
- while (!stop) {
- System.out.print("-> ");
-
- try {
- line = in.readLine();
- } catch (IOException ex) {
- System.err.println("Could not read input, please try again.");
- continue;
- }
-
- synchronized (Activator.this) {
- if (shell == null) {
- System.out.println("No impl service available.");
- continue;
- }
-
- if (line == null) {
- continue;
- }
-
- line = line.trim();
-
- if (line.isEmpty()) {
- continue;
- }
-
- try {
- if (line.startsWith(RUN_CMD)) {
- String path = line.substring(RUN_CMD.length()).trim();
- System.out.println("loading commands from: " + path);
- File commands = new File(path);
- if (commands.exists()) {
- BufferedReader reader = new BufferedReader(new FileReader(commands));
- String command = reader.readLine().trim();
- while (command != null) {
- if (!command.isEmpty()) {
- System.out.println("\nexecuting: " + command);
- shell.executeCommand(command.trim(), System.out, System.err);
- }
- command = reader.readLine();
- }
- reader.close();
- } else {
- System.err.println(path + " not found");
- }
- } else {
- shell.executeCommand(line, System.out, System.err);
- }
- } catch (Exception ex) {
- System.err.println("ShellTui: " + ex);
- ex.printStackTrace();
- }
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index e30dc89..82bb30a 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -32,14 +32,9 @@
<osgi.compendium.version>4.3.1</osgi.compendium.version>
<aries.rsa.version>1.8.0</aries.rsa.version>
<cxf.version>3.1.6</cxf.version>
- <cxf.build-utils.version>3.1.0</cxf.build-utils.version>
<felix.version>5.4.0</felix.version>
- <spring.version>4.2.4.RELEASE</spring.version>
- <spring.osgi.version>1.2.1</spring.osgi.version>
<zookeeper.version>3.4.8</zookeeper.version>
-
<remote.service.admin.interfaces.version>1.0.0</remote.service.admin.interfaces.version>
-
<servicemix.specs.version>2.6.0</servicemix.specs.version>
<pax.web.version>1.0.11</pax.web.version>
<pax.logging.version>1.7.0</pax.logging.version>
@@ -57,6 +52,7 @@
<jaxbimpl.bundle.version>2.2.1.1_2</jaxbimpl.bundle.version>
<slf4j.version>1.7.14</slf4j.version>
<exam.version>4.8.0</exam.version>
+ <baseline.skip>true</baseline.skip>
</properties>
<dependencyManagement>
@@ -157,6 +153,46 @@
</dependency>
</dependencies>
</dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </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>org.apache.aries.rsa</groupId>
+ <artifactId>org.apache.aries.rsa.spi</artifactId>
+ <version>${aries.rsa.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.7.14</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
<build>
<defaultGoal>install</defaultGoal>
@@ -236,8 +272,24 @@
<extensions>true</extensions>
<configuration>
<obrRepository>NONE</obrRepository>
- <_include>-bnd.bnd</_include>
+ <instructions>
+ <Export-Package>!*</Export-Package>
+ <_include>-bnd.bnd</_include>
+ </instructions>
</configuration>
+ <executions>
+ <execution>
+ <id>baseline</id>
+ <goals>
+ <goal>baseline</goal>
+ </goals>
+ <configuration>
+ <comparisonVersion>${baseline}</comparisonVersion>
+ <skip>${baseline.skip}</skip>
+ <failOnError>true</failOnError>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/samples/ds/interface/bnd.bnd
----------------------------------------------------------------------
diff --git a/samples/ds/interface/bnd.bnd b/samples/ds/interface/bnd.bnd
new file mode 100644
index 0000000..0bf50d5
--- /dev/null
+++ b/samples/ds/interface/bnd.bnd
@@ -0,0 +1 @@
+Export-Package: org.apache.cxf.dosgi.samples.ds
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/samples/ds/interface/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/interface/pom.xml b/samples/ds/interface/pom.xml
index 4598db8..1952f06 100644
--- a/samples/ds/interface/pom.xml
+++ b/samples/ds/interface/pom.xml
@@ -20,11 +20,9 @@
<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>
- <groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-ds-interface</artifactId>
<packaging>bundle</packaging>
<name>Distributed OSGI Declarative Services Sample Interface</name>
- <version>1.9-SNAPSHOT</version>
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
@@ -36,22 +34,4 @@
<topDirectoryLocation>..</topDirectoryLocation>
</properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Name>${project.name}</Bundle-Name>
- <Bundle-Description>The interfaces of the Distributed OSGi with Declarative Services sample</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package />
- <Export-Package>org.apache.cxf.dosgi.samples.ds</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/samples/greeter/interface/bnd.bnd
----------------------------------------------------------------------
diff --git a/samples/greeter/interface/bnd.bnd b/samples/greeter/interface/bnd.bnd
new file mode 100644
index 0000000..241de97
--- /dev/null
+++ b/samples/greeter/interface/bnd.bnd
@@ -0,0 +1 @@
+Export-Package: org.apache.cxf.dosgi.samples.greeter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/samples/greeter_rest/interface/bnd.bnd
----------------------------------------------------------------------
diff --git a/samples/greeter_rest/interface/bnd.bnd b/samples/greeter_rest/interface/bnd.bnd
new file mode 100644
index 0000000..dad324a
--- /dev/null
+++ b/samples/greeter_rest/interface/bnd.bnd
@@ -0,0 +1 @@
+Export-Package: org.apache.cxf.dosgi.samples.greeter.rest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/samples/greeter_rest/interface/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter_rest/interface/pom.xml b/samples/greeter_rest/interface/pom.xml
index c312f43..91b33da 100644
--- a/samples/greeter_rest/interface/pom.xml
+++ b/samples/greeter_rest/interface/pom.xml
@@ -23,7 +23,6 @@
<artifactId>cxf-dosgi-ri-samples-greeter-rest-interface</artifactId>
<packaging>bundle</packaging>
<name>Distributed OSGI Greeter REST Interface</name>
- <version>1.9-SNAPSHOT</version>
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
@@ -33,23 +32,11 @@
</parent>
<properties>
- <bundle.import.package>javax.ws.rs,javax.xml.bind.annotation,*</bundle.import.package>
- <bundle.export.package>org.apache.cxf.dosgi.samples.greeter.rest</bundle.export.package>
- <topDirectoryLocation>..</topDirectoryLocation>
+ <topDirectoryLocation>../../..</topDirectoryLocation>
</properties>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.servicemix.specs</groupId>
<artifactId>org.apache.servicemix.specs.jsr339-api-m10</artifactId>
<version>${servicemix.specs.version}</version>
@@ -61,22 +48,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Name>CXF Distributed OSGi Greeter REST Demo Interface Bundle</Bundle-Name>
- <Bundle-Description>The interfaces of the CXF Distributed OSGi Greeter REST demo</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>${bundle.import.package}</Import-Package>
- <Export-Package>${bundle.export.package}</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/samples/security_filter/bnd.bnd
----------------------------------------------------------------------
diff --git a/samples/security_filter/bnd.bnd b/samples/security_filter/bnd.bnd
new file mode 100644
index 0000000..2056f10
--- /dev/null
+++ b/samples/security_filter/bnd.bnd
@@ -0,0 +1,2 @@
+Private-Package: org.apache.cxf.dosgi.samples.security
+Bundle-Activator: org.apache.cxf.dosgi.samples.security.Activator
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/samples/security_filter/pom.xml
----------------------------------------------------------------------
diff --git a/samples/security_filter/pom.xml b/samples/security_filter/pom.xml
index 3598cfc..1c6d0c6 100644
--- a/samples/security_filter/pom.xml
+++ b/samples/security_filter/pom.xml
@@ -16,7 +16,6 @@
<artifactId>cxf-dosgi-ri-samples-security</artifactId>
<packaging>bundle</packaging>
<name>Distributed OSGI Security Sample Bundle</name>
- <version>1.9-SNAPSHOT</version>
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
@@ -31,14 +30,6 @@
<dependencies>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_${servlet.version}_spec</artifactId>
<version>1.0</version>
@@ -48,30 +39,6 @@
<artifactId>org.apache.servicemix.specs.jsr311-api-1.0</artifactId>
<version>${servicemix.specs.version}</version>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Name>${project.name}</Bundle-Name>
- <Bundle-Description>An example Distributed OSGi
- endpoint that passes requests through a
- security filter</Bundle-Description>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Private-Package>org.apache.cxf.dosgi.samples.security</Private-Package>
- <Bundle-Activator>org.apache.cxf.dosgi.samples.security.Activator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
[5/5] cxf-dosgi git commit: [DOSGI-242] Refactor provider, Cleanup
Posted by cs...@apache.org.
[DOSGI-242] Refactor provider, Cleanup
Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/79bb9a43
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/79bb9a43
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/79bb9a43
Branch: refs/heads/master
Commit: 79bb9a437f1aba99e213ffc2d00d5f3300d9bcc0
Parents: 5d8bbd2
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Fri Jul 1 14:09:01 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Fri Jul 1 14:09:01 2016 +0200
----------------------------------------------------------------------
cxf-dsw/bnd.bnd | 3 +
cxf-dsw/pom.xml | 59 ---
.../org/apache/cxf/dosgi/dsw/Activator.java | 153 -------
.../org/apache/cxf/dosgi/dsw/Constants.java | 146 -------
.../AbstractPojoConfigurationTypeHandler.java | 243 -----------
.../dsw/handlers/CXFDistributionProvider.java | 6 +-
.../cxf/dosgi/dsw/handlers/ClassUtils.java | 142 -------
.../dosgi/dsw/handlers/HttpServiceManager.java | 176 --------
.../JaxRSPojoConfigurationTypeHandler.java | 201 ---------
.../cxf/dosgi/dsw/handlers/JaxRSUtils.java | 121 ------
.../cxf/dosgi/dsw/handlers/LocalHostUtil.java | 92 ----
.../handlers/PojoConfigurationTypeHandler.java | 172 --------
.../handlers/SecurityDelegatingHttpContext.java | 133 ------
.../cxf/dosgi/dsw/handlers/ServerWrapper.java | 49 ---
.../dsw/handlers/ServiceInvocationHandler.java | 100 -----
.../handlers/WsdlConfigurationTypeHandler.java | 160 -------
.../AbstractPojoConfigurationTypeHandler.java | 246 +++++++++++
.../pojo/PojoConfigurationTypeHandler.java | 173 ++++++++
.../handlers/pojo/ServiceInvocationHandler.java | 100 +++++
.../pojo/WsdlConfigurationTypeHandler.java | 161 +++++++
.../rest/JaxRSPojoConfigurationTypeHandler.java | 204 +++++++++
.../cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java | 122 ++++++
.../dsw/httpservice/HttpServiceManager.java | 176 ++++++++
.../dosgi/dsw/httpservice/LocalHostUtil.java | 92 ++++
.../SecurityDelegatingHttpContext.java | 133 ++++++
.../apache/cxf/dosgi/dsw/osgi/Activator.java | 153 +++++++
.../apache/cxf/dosgi/dsw/osgi/Constants.java | 146 +++++++
.../apache/cxf/dosgi/dsw/qos/IntentTracker.java | 2 +-
.../apache/cxf/dosgi/dsw/qos/IntentUtils.java | 2 +-
.../apache/cxf/dosgi/dsw/util/ClassUtils.java | 86 ++++
.../apache/cxf/dosgi/dsw/util/OsgiUtils.java | 54 ---
.../cxf/dosgi/dsw/util/ServerWrapper.java | 49 +++
.../org/apache/cxf/dosgi/dsw/ActivatorTest.java | 1 +
.../handlers/CXFDistributionProviderTest.java | 6 +-
.../cxf/dosgi/dsw/handlers/ClassUtilsTest.java | 20 +-
.../dsw/handlers/HttpServiceManagerTest.java | 125 ------
.../cxf/dosgi/dsw/handlers/JaxRSUtilsTest.java | 195 ---------
.../PojoConfigurationTypeHandlerTest.java | 422 ------------------
.../SecurityDelegatingHttpContextTest.java | 267 ------------
.../handlers/ServiceInvocationHandlerTest.java | 2 +
.../pojo/PojoConfigurationTypeHandlerTest.java | 424 +++++++++++++++++++
.../dosgi/dsw/handlers/rest/JaxRSUtilsTest.java | 195 +++++++++
.../dsw/hooks/CxfFindListenerHookTest.java | 341 ---------------
.../cxf/dosgi/dsw/hooks/CxfPublishHookTest.java | 299 -------------
.../dosgi/dsw/hooks/ServiceHookUtilsTest.java | 116 -----
.../apache/cxf/dosgi/dsw/hooks/TestService.java | 22 -
.../dsw/httpservice/HttpServiceManagerTest.java | 125 ++++++
.../SecurityDelegatingHttpContextTest.java | 267 ++++++++++++
.../cxf/dosgi/dsw/qos/IntentTrackerTest.java | 2 +-
.../cxf/dosgi/dsw/qos/IntentUtilsTest.java | 2 +-
.../cxf/dosgi/dsw/util/OsgiUtilsTest.java | 86 +---
decorator/bnd.bnd | 3 +
decorator/pom.xml | 84 ----
felix/pom.xml | 42 --
felix/profiles/pom.xml | 201 ---------
.../remote-service/alt-remote-services.xml | 32 --
.../OSGI-INF/remote-service/multi-services.xml | 38 --
.../OSGI-INF/remote-service/remote-services.xml | 32 --
felix/profiles/resources/test-resources/rs1.xml | 31 --
felix/profiles/resources/test-resources/rs2.xml | 28 --
.../profiles/resources/test-resources/sd-1.xml | 3 -
felix/profiles/resources/test-resources/sd.xml | 8 -
felix/profiles/resources/test-resources/sd0.xml | 2 -
felix/profiles/resources/test-resources/sd1.xml | 8 -
felix/profiles/resources/test-resources/sd2.xml | 14 -
.../src/main/java/felix/EmptyClass.java | 22 -
.../src/main/resources/client_bundles.txt | 82 ----
.../src/main/resources/dosgi_bundles.txt | 78 ----
.../src/main/resources/server_bundles.txt | 82 ----
felix/remote-debug.txt | 1 -
felix/shell.tui/LICENSE | 202 ---------
felix/shell.tui/NOTICE | 20 -
felix/shell.tui/pom.xml | 92 ----
.../org/apache/felix/shell/tui/Activator.java | 187 --------
parent/pom.xml | 64 ++-
samples/ds/interface/bnd.bnd | 1 +
samples/ds/interface/pom.xml | 20 -
samples/greeter/interface/bnd.bnd | 1 +
samples/greeter_rest/interface/bnd.bnd | 1 +
samples/greeter_rest/interface/pom.xml | 33 +-
samples/security_filter/bnd.bnd | 2 +
samples/security_filter/pom.xml | 33 --
82 files changed, 2942 insertions(+), 5277 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/bnd.bnd
----------------------------------------------------------------------
diff --git a/cxf-dsw/bnd.bnd b/cxf-dsw/bnd.bnd
new file mode 100644
index 0000000..b0ee3dc
--- /dev/null
+++ b/cxf-dsw/bnd.bnd
@@ -0,0 +1,3 @@
+Import-Package: javax.servlet;version='[2,4)', javax.servlet.http;version='[2,4)', *
+Private-Package: org.apache.cxf.dosgi.dsw.*
+Bundle-Activator: org.apache.cxf.dosgi.dsw.osgi.Activator
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/pom.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/pom.xml b/cxf-dsw/pom.xml
index 471922a..091dce9 100644
--- a/cxf-dsw/pom.xml
+++ b/cxf-dsw/pom.xml
@@ -37,26 +37,6 @@
<dependencies>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </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>org.apache.aries.rsa</groupId>
- <artifactId>org.apache.aries.rsa.spi</artifactId>
- <version>${aries.rsa.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>${cxf.version}</version>
@@ -93,44 +73,5 @@
<version>1.0</version>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>1.7.14</version>
- <scope>test</scope>
- </dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>
- javax.servlet*;version="[0.0,4)",
- *
- </Import-Package>
- <Export-Package>
- !*
- </Export-Package>
- <Bundle-Activator>org.apache.cxf.dosgi.dsw.Activator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
deleted file mode 100644
index 0abcf7a..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
+++ /dev/null
@@ -1,153 +0,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.
- */
-package org.apache.cxf.dosgi.dsw;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.dosgi.dsw.handlers.CXFDistributionProvider;
-import org.apache.cxf.dosgi.dsw.handlers.HttpServiceManager;
-import org.apache.cxf.dosgi.dsw.qos.DefaultIntentMapFactory;
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
-import org.apache.cxf.dosgi.dsw.qos.IntentMap;
-import org.apache.cxf.dosgi.dsw.qos.IntentTracker;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// registered as spring bean -> start / stop called accordingly
-public class Activator implements ManagedService, BundleActivator {
-
- private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
- private static final int DEFAULT_INTENT_TIMEOUT = 30000;
- private static final String CONFIG_SERVICE_PID = "cxf-dsw";
- private ServiceRegistration<?> rsaFactoryReg;
- private ServiceRegistration<?> decoratorReg;
- private IntentTracker intentTracker;
- private HttpServiceManager httpServiceManager;
- private BundleContext bc;
- private BundleListener bundleListener;
- private Dictionary<String, Object> curConfiguration;
- private Bus bus;
-
- public void start(BundleContext bundlecontext) throws Exception {
- LOG.debug("RemoteServiceAdmin Implementation is starting up");
- this.bc = bundlecontext;
- // Disable the fast infoset as it's not compatible (yet) with OSGi
- System.setProperty("org.apache.cxf.nofastinfoset", "true");
- curConfiguration = getDefaultConfig();
- init(curConfiguration);
- registerManagedService(bc);
- }
-
- private Dictionary<String, Object> getDefaultConfig() {
- return new Hashtable<String, Object>();
- }
-
- private synchronized void init(Dictionary<String, Object> config) {
- bus = BusFactory.newInstance().createBus();
-
- String httpBase = (String) config.get(org.apache.cxf.dosgi.dsw.Constants.HTTP_BASE);
- String cxfServletAlias = (String) config.get(org.apache.cxf.dosgi.dsw.Constants.CXF_SERVLET_ALIAS);
-
- IntentMap intentMap = new IntentMap(new DefaultIntentMapFactory().create());
- intentTracker = new IntentTracker(bc, intentMap);
- intentTracker.open();
- IntentManager intentManager = new IntentManagerImpl(intentMap, DEFAULT_INTENT_TIMEOUT);
- httpServiceManager = new HttpServiceManager(bc, httpBase, cxfServletAlias);
- DistributionProvider cxfProvider
- = new CXFDistributionProvider(bc, intentManager, httpServiceManager);
- Dictionary<String, Object> props = new Hashtable<String, Object>();
- String[] supportedIntents = intentMap.keySet().toArray(new String[] {});
- props.put("remote.intents.supported", supportedIntents);
- props.put("remote.configs.supported", cxfProvider.getSupportedTypes());
- rsaFactoryReg = bc.registerService(DistributionProvider.class.getName(), cxfProvider, props);
- }
-
- private synchronized void uninit() {
- if (decoratorReg != null) {
- decoratorReg.unregister();
- decoratorReg = null;
- }
- if (bundleListener != null) {
- bc.removeBundleListener(bundleListener);
- bundleListener = null;
- }
- if (rsaFactoryReg != null) {
- // This also triggers the unimport and unexport of the remote services
- rsaFactoryReg.unregister();
- rsaFactoryReg = null;
- }
- if (httpServiceManager != null) {
- httpServiceManager.close();
- httpServiceManager = null;
- }
- if (intentTracker != null) {
- intentTracker.close();
- intentTracker = null;
- }
- }
-
- private void registerManagedService(BundleContext bundlecontext) {
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put(Constants.SERVICE_PID, CONFIG_SERVICE_PID);
- // No need to store the registration. Will be unregistered in stop by framework
- bundlecontext.registerService(ManagedService.class.getName(), this, props);
- }
-
- public void stop(BundleContext context) throws Exception {
- LOG.debug("RemoteServiceAdmin Implementation is shutting down now");
- uninit();
- shutdownCXFBus();
- }
-
- /**
- * Causes also the shutdown of the embedded HTTP server
- */
- private void shutdownCXFBus() {
- if (bus != null) {
- LOG.debug("Shutting down the CXF Bus");
- bus.shutdown(true);
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public synchronized void updated(Dictionary config) throws ConfigurationException {
- LOG.debug("RemoteServiceAdmin Implementation configuration is updated with {}", config);
- // config is null if it doesn't exist, is being deleted or has not yet been loaded
- // in which case we run with defaults (just like we do manually when bundle is first started)
- Dictionary<String, Object> configMap = config == null ? getDefaultConfig() : config;
- if (!configMap.equals(curConfiguration)) { // only if something actually changed
- curConfiguration = configMap;
- uninit();
- init(configMap);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
deleted file mode 100644
index 218bec6..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
+++ /dev/null
@@ -1,146 +0,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.
- */
-package org.apache.cxf.dosgi.dsw;
-
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public final class Constants {
-
- // Constants from RFC 119, they should ultimately be picked up from an OSGi class.
- @Deprecated
- public static final String EXPORTED_INTERFACES = RemoteConstants.SERVICE_EXPORTED_INTERFACES;
- @Deprecated
- public static final String EXPORTED_INTERFACES_OLD = "osgi.remote.interfaces"; // for BW compatibility
-
- @Deprecated
- public static final String EXPORTED_CONFIGS = RemoteConstants.SERVICE_EXPORTED_CONFIGS;
- @Deprecated
- public static final String EXPORTED_CONFIGS_OLD = "osgi.remote.configuration.type"; // for BW compatibility
-
- @Deprecated
- public static final String EXPORTED_INTENTS = RemoteConstants.SERVICE_EXPORTED_INTENTS;
- @Deprecated
- public static final String EXPORTED_INTENTS_EXTRA = RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA;
- @Deprecated
- public static final String EXPORTED_INTENTS_OLD = "osgi.remote.requires.intents";
-
- @Deprecated
- public static final String IMPORTED = RemoteConstants.SERVICE_IMPORTED;
- @Deprecated
- public static final String IMPORTD_CONFIGS = RemoteConstants.SERVICE_IMPORTED_CONFIGS;
-
- @Deprecated
- public static final String INTENTS = RemoteConstants.SERVICE_INTENTS;
-
- // WSDL
- public static final String WSDL_CONFIG_TYPE = "wsdl";
- public static final String WSDL_CONFIG_PREFIX = "osgi.remote.configuration" + "." + WSDL_CONFIG_TYPE;
- public static final String WSDL_SERVICE_NAMESPACE = WSDL_CONFIG_PREFIX + ".service.ns";
- public static final String WSDL_SERVICE_NAME = WSDL_CONFIG_PREFIX + ".service.name";
- public static final String WSDL_PORT_NAME = WSDL_CONFIG_PREFIX + ".port.name";
- public static final String WSDL_LOCATION = WSDL_CONFIG_PREFIX + ".location";
- public static final String WSDL_HTTP_SERVICE_CONTEXT = WSDL_CONFIG_PREFIX + ".httpservice.context";
- // Provider prefix
- public static final String PROVIDER_PREFIX = "org.apache.cxf";
-
- // WS
- public static final String WS_CONFIG_TYPE = PROVIDER_PREFIX + ".ws";
- public static final String WS_ADDRESS_PROPERTY = WS_CONFIG_TYPE + ".address";
- public static final String WS_PORT_PROPERTY = WS_CONFIG_TYPE + ".port";
- public static final String WS_HTTP_SERVICE_CONTEXT = WS_CONFIG_TYPE + ".httpservice.context";
-
- public static final String WS_FRONTEND_PROP_KEY = WS_CONFIG_TYPE + ".frontend";
- public static final String WS_FRONTEND_JAXWS = "jaxws";
- public static final String WS_FRONTEND_SIMPLE = "simple";
-
- public static final String WS_IN_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.interceptors";
- public static final String WS_OUT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.interceptors";
- public static final String WS_OUT_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.fault.interceptors";
- public static final String WS_IN_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.fault.interceptors";
- public static final String WS_CONTEXT_PROPS_PROP_KEY = WS_CONFIG_TYPE + ".context.properties";
- public static final String WS_FEATURES_PROP_KEY = WS_CONFIG_TYPE + ".features";
-
- public static final String WS_DATABINDING_PROP_KEY = WS_CONFIG_TYPE + ".databinding";
- public static final String WS_DATABINDING_BEAN_PROP_KEY = WS_DATABINDING_PROP_KEY + ".bean";
- public static final String WS_DATA_BINDING_JAXB = "jaxb";
- public static final String WS_DATA_BINDING_AEGIS = "aegis";
-
- public static final String WS_WSDL_SERVICE_NAMESPACE = WS_CONFIG_TYPE + ".service.ns";
- public static final String WS_WSDL_SERVICE_NAME = WS_CONFIG_TYPE + ".service.name";
- public static final String WS_WSDL_PORT_NAME = WS_CONFIG_TYPE + ".port.name";
- public static final String WS_WSDL_LOCATION = WS_CONFIG_TYPE + ".wsdl.location";
- // Rest
- public static final String RS_CONFIG_TYPE = PROVIDER_PREFIX + ".rs";
- public static final String RS_ADDRESS_PROPERTY = RS_CONFIG_TYPE + ".address";
- public static final String RS_HTTP_SERVICE_CONTEXT = RS_CONFIG_TYPE + ".httpservice.context";
- public static final String RS_DATABINDING_PROP_KEY = RS_CONFIG_TYPE + ".databinding";
- public static final String RS_IN_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".in.interceptors";
- public static final String RS_OUT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".out.interceptors";
- public static final String RS_IN_FAULT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".in.fault.interceptors";
- public static final String RS_OUT_FAULT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".out.fault.interceptors";
- public static final String RS_CONTEXT_PROPS_PROP_KEY = RS_CONFIG_TYPE + ".context.properties";
- public static final String RS_FEATURES_PROP_KEY = RS_CONFIG_TYPE + ".features";
- public static final String RS_PROVIDER_PROP_KEY = RS_CONFIG_TYPE + ".provider";
- public static final String RS_PROVIDER_EXPECTED_PROP_KEY = RS_PROVIDER_PROP_KEY + ".expected";
- public static final String RS_PROVIDER_GLOBAL_PROP_KEY = RS_PROVIDER_PROP_KEY + ".globalquery";
- public static final String RS_WADL_LOCATION = RS_CONFIG_TYPE + ".wadl.location";
- // POJO (old value for WS)
- public static final String WS_CONFIG_TYPE_OLD = "pojo";
- public static final String WS_CONFIG_OLD_PREFIX = "osgi.remote.configuration." + WS_CONFIG_TYPE_OLD;
- public static final String WS_ADDRESS_PROPERTY_OLD = WS_CONFIG_OLD_PREFIX + ".address";
- public static final String WS_HTTP_SERVICE_CONTEXT_OLD = WS_CONFIG_OLD_PREFIX + ".httpservice.context";
-
- // Common Configuration Properties
- public static final String CHECK_BUNDLE = "check.bundle";
-
- // The following constants are not evaluated anymore
- @Deprecated
- public static final String DEFAULT_PORT_CONFIG = "default.port";
- @Deprecated
- public static final String DEFAULT_HOST_CONFIG = "default.host";
- @Deprecated
- public static final String DEFAULT_PORT_VALUE = "9000";
- @Deprecated
- public static final String DEFAULT_HOST_VALUE = "localhost";
- @Deprecated
- public static final String USE_MASTER_MAP = "use.master.map";
-
- // DSW Identification - TODO do we really need this one?
- public static final String DSW_CLIENT_ID = PROVIDER_PREFIX + ".remote.dsw.client";
-
- public static final String INTENT_NAME_PROP = "org.apache.cxf.dosgi.IntentName";
-
- /**
- * Prefix to create an absolute URL from a relative URL.
- * See HttpServiceManager.getAbsoluteAddress
- *
- * Defaults to: http://<host name>:8181
- */
- public static final String HTTP_BASE = "httpBase";
-
- /**
- * Name of the cxf servlet alias
- */
- public static final String CXF_SERVLET_ALIAS = "cxfServletAlias";
- public static final String DEFAULT_CXF_SERVLET_ALIAS = "/cxf";
-
- private Constants() {
- // never constructed
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
deleted file mode 100644
index d2c8929..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
+++ /dev/null
@@ -1,243 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.lang.reflect.Proxy;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
-import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.util.StringPlus;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
-import org.apache.cxf.frontend.ClientFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.interceptor.Interceptor;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public abstract class AbstractPojoConfigurationTypeHandler implements DistributionProvider {
- protected BundleContext bundleContext;
- protected IntentManager intentManager;
- protected HttpServiceManager httpServiceManager;
-
- public AbstractPojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- this.bundleContext = dswBC;
- this.intentManager = intentManager;
- this.httpServiceManager = httpServiceManager;
- }
-
- protected Object getProxy(Object serviceProxy, Class<?> iType) {
- return Proxy.newProxyInstance(iType.getClassLoader(), new Class[] {
- iType
- }, new ServiceInvocationHandler(serviceProxy, iType));
- }
-
- protected EndpointDescription createEndpointDesc(Map<String, Object> props,
- String[] importedConfigs,
- String address,
- String[] intents) {
- props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
- for (String configurationType : importedConfigs) {
- if (Constants.WS_CONFIG_TYPE.equals(configurationType)) {
- props.put(Constants.WS_ADDRESS_PROPERTY, address);
- } else if (Constants.RS_CONFIG_TYPE.equals(configurationType)) {
- props.put(Constants.RS_ADDRESS_PROPERTY, address);
- } else if (Constants.WS_CONFIG_TYPE_OLD.equals(configurationType)) {
- props.put(Constants.WS_ADDRESS_PROPERTY_OLD, address);
- props.put(Constants.WS_ADDRESS_PROPERTY, address);
- }
- }
- String[] sIntents = StringPlus.normalize(props.get(RemoteConstants.SERVICE_INTENTS));
- String[] allIntents = IntentUtils.mergeArrays(intents, sIntents);
- props.put(RemoteConstants.SERVICE_INTENTS, allIntents);
- props.put(RemoteConstants.ENDPOINT_ID, address);
- return new EndpointDescription(props);
- }
-
- protected void setCommonWsdlProperties(AbstractWSDLBasedEndpointFactory factory, BundleContext context,
- Map<String, Object> sd, boolean wsdlType) {
- String location = OsgiUtils.getProperty(sd, wsdlType ? Constants.WSDL_LOCATION : Constants.WS_WSDL_LOCATION);
- if (location != null) {
- URL wsdlURL = context.getBundle().getResource(location);
- if (wsdlURL != null) {
- factory.setWsdlURL(wsdlURL.toString());
- }
- QName serviceName = getServiceQName(null, sd,
- wsdlType ? Constants.WSDL_SERVICE_NAMESPACE : Constants.WS_WSDL_SERVICE_NAMESPACE,
- wsdlType ? Constants.WSDL_SERVICE_NAME : Constants.WS_WSDL_SERVICE_NAME);
- if (serviceName != null) {
- factory.setServiceName(serviceName);
- QName portName = getPortQName(serviceName.getNamespaceURI(), sd,
- wsdlType ? Constants.WSDL_PORT_NAME : Constants.WS_WSDL_PORT_NAME);
- if (portName != null) {
- factory.setEndpointName(portName);
- }
- }
- }
- }
-
- protected void setWsdlProperties(ServerFactoryBean factory, BundleContext callingContext, Map<String, Object> sd,
- boolean wsdlType) {
- setCommonWsdlProperties(factory, callingContext, sd, wsdlType);
- }
-
- protected void setClientWsdlProperties(ClientFactoryBean factory, BundleContext dswContext, Map<String, Object> sd,
- boolean wsdlType) {
- setCommonWsdlProperties(factory, dswContext, sd, wsdlType);
- }
-
- protected static QName getServiceQName(Class<?> iClass, Map<String, Object> sd, String nsPropName,
- String namePropName) {
- String serviceNs = OsgiUtils.getProperty(sd, nsPropName);
- String serviceName = OsgiUtils.getProperty(sd, namePropName);
- if (iClass == null && (serviceNs == null || serviceName == null)) {
- return null;
- }
- if (serviceNs == null) {
- serviceNs = PackageUtils.getNamespace(PackageUtils.getPackageName(iClass));
- }
- if (serviceName == null) {
- serviceName = iClass.getSimpleName();
- }
- return new QName(serviceNs, serviceName);
- }
-
- protected static QName getPortQName(String ns, Map<String, Object> sd, String propName) {
- String portName = OsgiUtils.getProperty(sd, propName);
- if (portName == null) {
- return null;
- }
- return new QName(ns, portName);
- }
-
- protected String getClientAddress(Map<String, Object> sd) {
- return OsgiUtils.getFirstNonEmptyStringProperty(sd, RemoteConstants.ENDPOINT_ID,
- Constants.WS_ADDRESS_PROPERTY,
- Constants.WS_ADDRESS_PROPERTY_OLD,
- Constants.RS_ADDRESS_PROPERTY);
- }
-
- protected String getServerAddress(Map<String, Object> sd, Class<?> iClass) {
- String address = getClientAddress(sd);
- return address == null ? httpServiceManager.getDefaultAddress(iClass) : address;
- }
-
- public String getServletContextRoot(Map<String, Object> sd) {
- return OsgiUtils.getFirstNonEmptyStringProperty(sd,
- Constants.WS_HTTP_SERVICE_CONTEXT,
- Constants.WS_HTTP_SERVICE_CONTEXT_OLD,
- Constants.WSDL_HTTP_SERVICE_CONTEXT,
- Constants.RS_HTTP_SERVICE_CONTEXT);
- }
-
-
- protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot) {
- Bus bus = BusFactory.newInstance().createBus();
- if (contextRoot != null) {
- httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
- }
- return bus;
- }
-
- protected Endpoint createServerFromFactory(ServerFactoryBean factory, EndpointDescription epd) {
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
- Server server = factory.create();
- return new ServerWrapper(epd, server);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- }
-
- protected static void addWsInterceptorsFeaturesProps(AbstractEndpointFactory factory, BundleContext callingContext,
- Map<String, Object> sd) {
- addInterceptors(factory, callingContext, sd, Constants.WS_IN_INTERCEPTORS_PROP_KEY);
- addInterceptors(factory, callingContext, sd, Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
- addInterceptors(factory, callingContext, sd, Constants.WS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
- addInterceptors(factory, callingContext, sd, Constants.WS_IN_FAULT_INTERCEPTORS_PROP_KEY);
- addFeatures(factory, callingContext, sd, Constants.WS_FEATURES_PROP_KEY);
- addContextProperties(factory, sd, Constants.WS_CONTEXT_PROPS_PROP_KEY);
- }
-
- static void addRsInterceptorsFeaturesProps(AbstractEndpointFactory factory, BundleContext callingContext,
- Map<String, Object> sd) {
- addInterceptors(factory, callingContext, sd, Constants.RS_IN_INTERCEPTORS_PROP_KEY);
- addInterceptors(factory, callingContext, sd, Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
- addInterceptors(factory, callingContext, sd, Constants.RS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
- addInterceptors(factory, callingContext, sd, Constants.RS_IN_FAULT_INTERCEPTORS_PROP_KEY);
- addFeatures(factory, callingContext, sd, Constants.RS_FEATURES_PROP_KEY);
- addContextProperties(factory, sd, Constants.RS_CONTEXT_PROPS_PROP_KEY);
- }
-
- private static void addInterceptors(AbstractEndpointFactory factory, BundleContext callingContext,
- Map<String, Object> sd, String propName) {
- List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName);
- boolean in = propName.contains("in.interceptors");
- boolean out = propName.contains("out.interceptors");
- boolean inFault = propName.contains("in.fault.interceptors");
- boolean outFault = propName.contains("out.fault.interceptors");
- for (Object provider : providers) {
- Interceptor<?> interceptor = (Interceptor<?>) provider;
- if (in) {
- factory.getInInterceptors().add(interceptor);
- } else if (out) {
- factory.getOutInterceptors().add(interceptor);
- } else if (inFault) {
- factory.getInFaultInterceptors().add(interceptor);
- } else if (outFault) {
- factory.getOutFaultInterceptors().add(interceptor);
- }
- }
- }
-
- private static void addFeatures(AbstractEndpointFactory factory, BundleContext callingContext,
- Map<String, Object> sd, String propName) {
- List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName);
- if (!providers.isEmpty()) {
- factory.getFeatures().addAll(CastUtils.cast(providers, AbstractFeature.class));
- }
- }
-
- private static void addContextProperties(AbstractEndpointFactory factory, Map<String, Object> sd, String propName) {
- @SuppressWarnings("unchecked")
- Map<String, Object> props = (Map<String, Object>)sd.get(propName);
- if (props != null) {
- factory.getProperties(true).putAll(props);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
index 9069de8..638e6ca 100644
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
@@ -30,7 +30,11 @@ import java.util.Set;
import org.apache.aries.rsa.spi.DistributionProvider;
import org.apache.aries.rsa.spi.Endpoint;
import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.handlers.pojo.PojoConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.handlers.pojo.WsdlConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.handlers.rest.JaxRSPojoConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
import org.apache.cxf.dosgi.dsw.qos.IntentManager;
import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
import org.apache.cxf.dosgi.dsw.util.StringPlus;
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtils.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtils.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtils.java
deleted file mode 100644
index cae19bd..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtils.java
+++ /dev/null
@@ -1,142 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.helpers.CastUtils;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class ClassUtils {
-
- private static final Logger LOG = LoggerFactory.getLogger(ClassUtils.class);
-
- private ClassUtils() {
- }
-
- public static Class<?> getInterfaceClass(Object service, String interfaceName) {
- return getInterfaceClass(service.getClass(), interfaceName);
- }
-
- private static Class<?> getInterfaceClass(Class<?> serviceClass, String interfaceName) {
- for (Class<?> iClass : serviceClass.getInterfaces()) {
- if (iClass.getName().equals(interfaceName)) {
- return iClass;
- }
- Class<?> intf = getInterfaceClass(iClass, interfaceName);
- if (intf != null) {
- return intf;
- }
- }
-
- if (serviceClass.getName().equals(interfaceName)) {
- return serviceClass;
- }
-
- Class<?> interfaceOnProxiedClass = getInterfaceClassOnSuperClasses(serviceClass, interfaceName);
- if (interfaceOnProxiedClass != null) {
- return interfaceOnProxiedClass;
- }
-
- return null;
- }
-
- /**
- * This method tries to deal specifically with classes that might have been proxied
- * eg. CGLIB proxies of which there might be a chain of proxies as different osgi frameworks
- * might be proxying the original service class that has been registered and then proxying the proxy.
- *
- * @param serviceClass
- * @param interfaceName
- * @return
- */
- private static Class<?> getInterfaceClassOnSuperClasses(Class<?> serviceClass, String interfaceName) {
- Class<?> superClass = serviceClass.getSuperclass();
- if (superClass != null) {
- for (Class<?> iClass : superClass.getInterfaces()) {
- if (iClass.getName().equals(interfaceName)) {
- return iClass;
- }
- Class<?> intf = getInterfaceClass(iClass, interfaceName);
- if (intf != null) {
- return intf;
- }
- }
- Class<?> foundOnSuperclass = getInterfaceClassOnSuperClasses(superClass, interfaceName);
- if (foundOnSuperclass != null) {
- return foundOnSuperclass;
- }
- }
- return null;
- }
-
- public static List<Object> loadProviderClasses(BundleContext callingContext,
- Map<String, Object> sd, String propName) {
- Object serviceProviders = sd.get(propName);
- if (serviceProviders != null) {
- if (serviceProviders.getClass().isArray()) {
- if (serviceProviders.getClass().getComponentType() == String.class) {
- return loadProviders(callingContext, (String[])serviceProviders);
- } else {
- return Arrays.asList((Object[])serviceProviders);
- }
- } else if (serviceProviders.getClass() == String.class) {
- String[] classNames = serviceProviders.toString().split(",");
- return loadProviders(callingContext, classNames);
- } else if (serviceProviders instanceof List) {
- List<Object> list = CastUtils.cast((List<?>)serviceProviders);
- if (!list.isEmpty()) {
- List<Object> providers;
- if (list.get(0).getClass() == String.class) {
- providers = loadProviders(callingContext, list.toArray(new String[]{}));
- } else {
- providers = list;
- }
- return providers;
- }
- } else {
- return Arrays.asList(serviceProviders);
- }
- }
- return Collections.emptyList();
-
- }
-
- private static List<Object> loadProviders(BundleContext callingContext, String[] classNames) {
- List<Object> providers = new ArrayList<Object>();
- for (String className : classNames) {
- try {
- String realName = className.trim();
- if (!realName.isEmpty()) {
- Class<?> pClass = callingContext.getBundle().loadClass(realName);
- providers.add(pClass.newInstance());
- }
- } catch (Exception ex) {
- LOG.warn("Provider " + className.trim() + " can not be loaded or created " + ex.getMessage(), ex);
- }
- }
- return providers;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
deleted file mode 100644
index eca5460..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
+++ /dev/null
@@ -1,176 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.transport.http.DestinationRegistry;
-import org.apache.cxf.transport.http.DestinationRegistryImpl;
-import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceException;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpContext;
-import org.osgi.service.http.HttpService;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HttpServiceManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(HttpServiceManager.class);
- private static final long SERVICE_LOOKUP_TIMEOUT = 10000;
- private ServiceTracker<HttpService, HttpService> tracker;
- private BundleContext bundleContext;
- private Map<Long, String> exportedAliases = Collections.synchronizedMap(new HashMap<Long, String>());
- private String httpBase;
- private String cxfServletAlias;
-
- public HttpServiceManager(BundleContext bundleContext, String httpBase, String cxfServletAlias) {
- this(bundleContext, httpBase, cxfServletAlias,
- new ServiceTracker<HttpService, HttpService>(bundleContext, HttpService.class, null));
- this.tracker.open();
- }
-
- // Only for tests
- public HttpServiceManager(BundleContext bundleContext,
- String httpBase, String cxfServletAlias,
- ServiceTracker<HttpService, HttpService> tracker) {
- this.bundleContext = bundleContext;
- this.tracker = tracker;
- this.httpBase = getWithDefault(httpBase, "http://" + LocalHostUtil.getLocalIp() + ":8181");
- this.cxfServletAlias = getWithDefault(cxfServletAlias, "/cxf");
- }
-
- private String getWithDefault(String value, String defaultValue) {
- return value == null ? defaultValue : value;
- }
-
- public Bus registerServlet(Bus bus, String contextRoot, BundleContext callingContext, Long sid) {
- bus.setExtension(new DestinationRegistryImpl(), DestinationRegistry.class);
- CXFNonSpringServlet cxf = new CXFNonSpringServlet();
- cxf.setBus(bus);
- try {
- HttpService httpService = getHttpService();
- httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(),
- getHttpContext(callingContext, httpService));
-
- registerUnexportHook(sid, contextRoot);
-
- LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
- } catch (Exception e) {
- throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet", e);
- }
- return bus;
- }
-
- protected HttpService getHttpService() {
- HttpService service = null;
- try {
- service = tracker.waitForService(SERVICE_LOOKUP_TIMEOUT);
- } catch (InterruptedException ex) {
- LOG.warn("waitForService interrupeted", ex);
- }
- if (service == null) {
- throw new RuntimeException("No HTTPService found");
- }
- return service;
- }
-
- private HttpContext getHttpContext(BundleContext bc, HttpService httpService) {
- HttpContext httpContext = httpService.createDefaultHttpContext();
- return new SecurityDelegatingHttpContext(bc, httpContext);
- }
-
- /**
- * This listens for service removal events and "un-exports" the service
- * from the HttpService.
- *
- * @param sref the service reference to track
- * @param alias the HTTP servlet context alias
- */
- private void registerUnexportHook(Long sid, String alias) {
- LOG.debug("Registering service listener for service with ID {}", sid);
-
- String previous = exportedAliases.put(sid, alias);
- if (previous != null) {
- LOG.warn("Overwriting service export for service with ID {}", sid);
- }
-
- try {
- Filter f = bundleContext.createFilter("(" + org.osgi.framework.Constants.SERVICE_ID + "=" + sid + ")");
- if (f != null) {
- bundleContext.addServiceListener(new UnregisterListener(), f.toString());
- } else {
- LOG.warn("Service listener could not be started. The service will not be automatically unexported.");
- }
- } catch (InvalidSyntaxException e) {
- LOG.warn("Service listener could not be started. The service will not be automatically unexported.", e);
- }
- }
-
- protected String getDefaultAddress(Class<?> type) {
- return "/" + type.getName().replace('.', '/');
- }
-
- protected String getAbsoluteAddress(String contextRoot, String relativeEndpointAddress) {
- if (relativeEndpointAddress.startsWith("http")) {
- return relativeEndpointAddress;
- }
- String effContextRoot = contextRoot == null ? cxfServletAlias : contextRoot;
- return this.httpBase + effContextRoot + relativeEndpointAddress;
- }
-
- public void close() {
- tracker.close();
- }
-
- private final class UnregisterListener implements ServiceListener {
-
- public void serviceChanged(ServiceEvent event) {
- if (!(event.getType() == ServiceEvent.UNREGISTERING)) {
- return;
- }
- final ServiceReference<?> sref = event.getServiceReference();
- final Long sid = (Long) sref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
- final String alias = exportedAliases.remove(sid);
- if (alias == null) {
- LOG.error("Unable to unexport HTTP servlet for service class '{}',"
- + " service-id {}: no servlet alias found",
- sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS), sid);
- return;
- }
- LOG.debug("Unexporting HTTP servlet for alias '{}'", alias);
- try {
- HttpService http = getHttpService();
- http.unregister(alias);
- } catch (Exception e) {
- LOG.warn("An exception occurred while unregistering service for HTTP servlet alias '{}'", alias, e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
deleted file mode 100644
index 8f4f152..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
+++ /dev/null
@@ -1,201 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.util.ProxyClassLoader;
-import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.client.Client;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
-
- private static final Logger LOG = LoggerFactory.getLogger(JaxRSPojoConfigurationTypeHandler.class);
-
- public JaxRSPojoConfigurationTypeHandler(BundleContext dswBC,
- IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- super(dswBC, intentManager, httpServiceManager);
- }
-
- public String[] getSupportedTypes() {
- return new String[] {Constants.RS_CONFIG_TYPE};
- }
-
- @SuppressWarnings("rawtypes")
- public Object importEndpoint(ClassLoader consumerLoader,
- BundleContext consumerContext,
- Class[] interfaces,
- EndpointDescription endpoint) {
- Class<?> iClass = interfaces[0];
- String address = getPojoAddress(endpoint, iClass);
- if (address == null) {
- LOG.warn("Remote address is unavailable");
- return null;
- }
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- return createJaxrsProxy(address, consumerContext, iClass, null, endpoint);
- } catch (Throwable e) {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
-
- try {
- ProxyClassLoader cl = new ProxyClassLoader(iClass.getClassLoader());
- cl.addLoader(Client.class.getClassLoader());
- return createJaxrsProxy(address, consumerContext, iClass, cl, endpoint);
- } catch (Throwable e) {
- LOG.warn("proxy creation failed", e);
- }
-
- return null;
- }
-
- protected Object createJaxrsProxy(String address,
- BundleContext callingContext,
- Class<?> iClass,
- ClassLoader loader,
- EndpointDescription endpoint) {
- JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
- bean.setAddress(address);
- if (loader != null) {
- bean.setClassLoader(loader);
- }
-
- addRsInterceptorsFeaturesProps(bean, callingContext, endpoint.getProperties());
-
- List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
- if (resources != null) {
- bean.setModelBeansWithServiceClass(resources, iClass);
- } else {
- bean.setServiceClass(iClass);
- }
- List<Object> providers = JaxRSUtils.getProviders(callingContext, endpoint.getProperties());
- if (providers != null && !providers.isEmpty()) {
- bean.setProviders(providers);
- }
- Thread.currentThread().setContextClassLoader(JAXRSClientFactoryBean.class.getClassLoader());
- return getProxy(bean.create(), iClass);
- }
-
- @SuppressWarnings("rawtypes")
- public Endpoint exportService(Object serviceBean,
- BundleContext callingContext,
- Map<String, Object> endpointProps,
- Class[] exportedInterfaces) throws IntentUnsatisfiedException {
- String contextRoot = getServletContextRoot(endpointProps);
- String address;
- Class<?> iClass = exportedInterfaces[0];
- if (contextRoot == null) {
- address = getServerAddress(endpointProps, iClass);
- } else {
- address = getClientAddress(endpointProps);
- if (address == null) {
- address = "/";
- }
- }
- final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
- Bus bus = createBus(sid, callingContext, contextRoot);
-
- LOG.info("Creating a " + iClass.getName()
- + " endpoint via JaxRSPojoConfigurationTypeHandler, address is " + address);
-
- JAXRSServerFactoryBean factory = createServerFactory(callingContext, endpointProps,
- iClass, serviceBean, address, bus);
- String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
-
- EndpointDescription epd = createEndpointDesc(endpointProps, new String[] {Constants.RS_CONFIG_TYPE},
- completeEndpointAddress, new String[] {"HTTP"});
-
- return createServerFromFactory(factory, epd);
- }
-
- private Endpoint createServerFromFactory(JAXRSServerFactoryBean factory,
- EndpointDescription epd) {
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
- Server server = factory.create();
- return new ServerWrapper(epd, server);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- }
-
- private JAXRSServerFactoryBean createServerFactory(BundleContext callingContext,
- Map<String, Object> sd,
- Class<?> iClass,
- Object serviceBean,
- String address,
- Bus bus) {
- JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
- factory.setBus(bus);
- List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
- if (resources != null) {
- factory.setModelBeansWithServiceClass(resources, iClass);
- factory.setServiceBeanObjects(serviceBean);
- } else {
- factory.setServiceClass(iClass);
- factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
- }
- factory.setAddress(address);
- List<Object> providers = JaxRSUtils.getProviders(callingContext, sd);
- if (providers != null && !providers.isEmpty()) {
- factory.setProviders(providers);
- }
- addRsInterceptorsFeaturesProps(factory, callingContext, sd);
- String location = OsgiUtils.getProperty(sd, Constants.RS_WADL_LOCATION);
- if (location != null) {
- URL wadlURL = callingContext.getBundle().getResource(location);
- if (wadlURL != null) {
- factory.setDocLocation(wadlURL.toString());
- }
- }
- return factory;
- }
-
- protected String getPojoAddress(EndpointDescription endpoint, Class<?> iClass) {
- String address = OsgiUtils.getProperty(endpoint, Constants.RS_ADDRESS_PROPERTY);
-
- if (address == null) {
- address = httpServiceManager.getDefaultAddress(iClass);
- if (address != null) {
- LOG.info("Using a default address: " + address);
- }
- }
- return address;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
deleted file mode 100644
index 6e78744..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
+++ /dev/null
@@ -1,121 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.apache.cxf.jaxrs.provider.aegis.AegisElementProvider;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class JaxRSUtils {
-
- public static final String MODEL_FOLDER = "/OSGI-INF/cxf/jaxrs/";
- public static final String DEFAULT_MODEL = "/OSGI-INF/cxf/jaxrs/model.xml";
- public static final String PROVIDERS_FILTER = "(|"
- + "(objectClass=javax.ws.rs.ext.MessageBodyReader)"
- + "(objectClass=javax.ws.rs.ext.MessageBodyWriter)"
- + "(objectClass=javax.ws.rs.ext.ExceptionMapper)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.RequestHandler)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseHandler)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.ParameterHandler)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseExceptionMapper)"
- + ")";
- private static final Logger LOG = LoggerFactory.getLogger(JaxRSUtils.class);
-
- private JaxRSUtils() {
- // never constructed
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- static List<Object> getProviders(BundleContext callingContext, Map<String, Object> sd) {
- List<Object> providers = new ArrayList<Object>();
- if ("aegis".equals(sd.get(org.apache.cxf.dosgi.dsw.Constants.RS_DATABINDING_PROP_KEY))) {
- providers.add(new AegisElementProvider());
- }
-
- providers.addAll(ClassUtils.loadProviderClasses(callingContext,
- sd,
- org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_PROP_KEY));
-
- Object globalQueryProp = sd.get(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_GLOBAL_PROP_KEY);
- boolean globalQueryRequired = globalQueryProp == null || OsgiUtils.toBoolean(globalQueryProp);
- if (!globalQueryRequired) {
- return providers;
- }
-
- boolean cxfProvidersOnly = OsgiUtils.getBooleanProperty(sd,
- org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_EXPECTED_PROP_KEY);
-
- try {
- ServiceReference[] refs = callingContext.getServiceReferences((String)null, PROVIDERS_FILTER);
- if (refs != null) {
- for (ServiceReference ref : refs) {
- if (!cxfProvidersOnly
- || OsgiUtils.toBoolean(ref
- .getProperty(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_PROP_KEY))) {
- providers.add(callingContext.getService(ref));
- }
- }
- }
- } catch (Exception ex) {
- LOG.debug("Problems finding JAXRS providers " + ex.getMessage(), ex);
- }
- return providers;
- }
-
- static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass) {
- String classModel = MODEL_FOLDER + iClass.getSimpleName() + "-model.xml";
- List<UserResource> list = getModel(callingContext, iClass, classModel);
- return list != null ? list : getModel(callingContext, iClass, DEFAULT_MODEL);
- }
-
- private static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass, String name) {
- InputStream r = iClass.getClassLoader().getResourceAsStream(name);
- if (r == null) {
- URL u = callingContext.getBundle().getResource(name);
- if (u != null) {
- try {
- r = u.openStream();
- } catch (Exception ex) {
- LOG.info("Problems opening a user model resource at " + u.toString());
- }
- }
- }
- if (r != null) {
- try {
- return ResourceUtils.getUserResources(r);
- } catch (Exception ex) {
- LOG.info("Problems reading a user model, it will be ignored");
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
deleted file mode 100644
index 50e2127..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
+++ /dev/null
@@ -1,92 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Utility methods to get the local address even on a linux host.
- */
-public final class LocalHostUtil {
-
- private LocalHostUtil() {
- // Util Class
- }
-
- /**
- * Returns an InetAddress representing the address of the localhost. Every
- * attempt is made to find an address for this host that is not the loopback
- * address. If no other address can be found, the loopback will be returned.
- *
- * @return InetAddress the address of localhost
- * @throws UnknownHostException if there is a problem determining the address
- */
- public static InetAddress getLocalHost() throws UnknownHostException {
- InetAddress localHost = InetAddress.getLocalHost();
- if (!localHost.isLoopbackAddress()) {
- return localHost;
- }
- InetAddress[] addrs = getAllLocalUsingNetworkInterface();
- for (InetAddress addr : addrs) {
- if (!addr.isLoopbackAddress() && !addr.getHostAddress().contains(":")) {
- return addr;
- }
- }
- return localHost;
- }
-
- /**
- * Utility method that delegates to the methods of NetworkInterface to
- * determine addresses for this machine.
- *
- * @return all addresses found from the NetworkInterfaces
- * @throws UnknownHostException if there is a problem determining addresses
- */
- private static InetAddress[] getAllLocalUsingNetworkInterface() throws UnknownHostException {
- try {
- List<InetAddress> addresses = new ArrayList<InetAddress>();
- Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
- while (e.hasMoreElements()) {
- NetworkInterface ni = e.nextElement();
- for (Enumeration<InetAddress> e2 = ni.getInetAddresses(); e2.hasMoreElements();) {
- addresses.add(e2.nextElement());
- }
- }
- return addresses.toArray(new InetAddress[] {});
- } catch (SocketException ex) {
- throw new UnknownHostException("127.0.0.1");
- }
- }
-
- public static String getLocalIp() {
- String localIP;
- try {
- localIP = getLocalHost().getHostAddress();
- } catch (Exception e) {
- localIP = "localhost";
- }
- return localIP;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
deleted file mode 100644
index bf92141..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
+++ /dev/null
@@ -1,172 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.util.Map;
-
-import javax.jws.WebService;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-import org.apache.cxf.Bus;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
-
- private static final Logger LOG = LoggerFactory.getLogger(PojoConfigurationTypeHandler.class);
-
- public PojoConfigurationTypeHandler(BundleContext dswBC,
- IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- super(dswBC, intentManager, httpServiceManager);
- }
-
- public String[] getSupportedTypes() {
- return new String[] {Constants.WS_CONFIG_TYPE, Constants.WS_CONFIG_TYPE_OLD};
- }
-
- @SuppressWarnings("rawtypes")
- public Object importEndpoint(ClassLoader consumerLoader,
- BundleContext consumerContext,
- Class[] interfaces,
- EndpointDescription endpoint) throws IntentUnsatisfiedException {
- Class<?> iClass = interfaces[0];
- Map<String, Object> sd = endpoint.getProperties();
- String address = getClientAddress(sd);
- if (address == null) {
- LOG.warn("Remote address is unavailable");
- // TODO: fire Event
- return null;
- }
-
- LOG.info("Creating a " + iClass.getName() + " client, endpoint address is " + address);
-
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- ClientProxyFactoryBean factory = createClientProxyFactoryBean(sd, iClass);
- factory.getServiceFactory().setDataBinding(getDataBinding(sd, iClass));
- factory.setServiceClass(iClass);
- factory.setAddress(address);
- addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), consumerContext, sd);
- setClientWsdlProperties(factory.getClientFactoryBean(), bundleContext, sd, false);
-
- intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd);
-
- Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
- return getProxy(factory.create(), iClass);
- } catch (Exception e) {
- LOG.warn("proxy creation failed", e);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- public Endpoint exportService(Object serviceO,
- BundleContext serviceContext,
- Map<String, Object> endpointProps,
- Class[] exportedInterfaces) throws IntentUnsatisfiedException {
- Class<?> iClass = exportedInterfaces[0];
- String address = getPojoAddress(endpointProps, iClass);
- ServerFactoryBean factory = createServerFactoryBean(endpointProps, iClass);
- factory.setDataBinding(getDataBinding(endpointProps, iClass));
- String contextRoot = getServletContextRoot(endpointProps);
-
- final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
- Bus bus = createBus(sid, serviceContext, contextRoot);
- factory.setBus(bus);
- factory.setServiceClass(iClass);
- factory.setAddress(address);
-
- factory.setServiceBean(serviceO);
- addWsInterceptorsFeaturesProps(factory, serviceContext, endpointProps);
- setWsdlProperties(factory, serviceContext, endpointProps, false);
- String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, endpointProps);
-
- String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
- EndpointDescription epd = createEndpointDesc(endpointProps,
- new String[]{Constants.WS_CONFIG_TYPE},
- completeEndpointAddress, intents);
- return createServerFromFactory(factory, epd);
- }
-
- private String getPojoAddress(Map<String, Object> sd, Class<?> iClass) {
- String address = getClientAddress(sd);
- if (address != null) {
- return address;
- }
-
- // If the property is not of type string this will cause an ClassCastException which
- // will be propagated to the ExportRegistration exception property.
- Object port = sd.get(Constants.WS_PORT_PROPERTY);
- if (port == null) {
- port = "9000";
- }
-
- address = "http://localhost:" + port + "/" + iClass.getName().replace('.', '/');
- LOG.info("Using a default address: " + address);
- return address;
- }
-
- private DataBinding getDataBinding(Map<String, Object> sd, Class<?> iClass) {
- Object dataBindingBeanProp = sd.get(Constants.WS_DATABINDING_BEAN_PROP_KEY);
- if (dataBindingBeanProp instanceof DataBinding) {
- return (DataBinding)dataBindingBeanProp;
- }
- return isJAXB(sd, iClass) ? new JAXBDataBinding() : new AegisDatabinding();
- }
-
- private boolean isJAXB(Map<String, Object> sd, Class<?> iClass) {
- String dataBindingName = (String)sd.get(Constants.WS_DATABINDING_PROP_KEY);
- return (iClass.getAnnotation(WebService.class) != null
- || Constants.WS_DATA_BINDING_JAXB.equals(dataBindingName))
- && !Constants.WS_DATA_BINDING_AEGIS.equals(dataBindingName);
- }
-
- // Isolated so that it can be substituted for testing
- protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return isJAXWS(sd, iClass) ? new JaxWsProxyFactoryBean() : new ClientProxyFactoryBean();
- }
-
- // Isolated so that it can be substituted for testing
- protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return isJAXWS(sd, iClass) ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
- }
-
- private boolean isJAXWS(Map<String, Object> sd, Class<?> iClass) {
- String frontEnd = (String)sd.get(Constants.WS_FRONTEND_PROP_KEY);
- return (iClass.getAnnotation(WebService.class) != null
- || Constants.WS_FRONTEND_JAXWS.equals(frontEnd))
- && !Constants.WS_FRONTEND_SIMPLE.equals(frontEnd);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContext.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContext.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContext.java
deleted file mode 100644
index 7e9710b..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContext.java
+++ /dev/null
@@ -1,133 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.io.IOException;
-import java.net.URL;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * <p>
- * An HttpContext that delegates to another HttpContext for all things other than security. This implementation handles
- * security by delegating to a {@link FilterChain} based on the set of {@link Filter}s registered with a
- * {@link #FILTER_PROP} property.
- * </p>
- * <p>
- * If the {@link BundleContext} contains a {@link #FILTER_REQUIRED_PROP} property with value "true", requests will not
- * be allowed until at least one {@link Filter} with a {@link #FILTER_PROP} property is registered.
- * </p>
- */
-public class SecurityDelegatingHttpContext implements HttpContext {
-
- public static final String FILTER_PROP = "org.apache.cxf.httpservice.filter";
- public static final String FILTER_REQUIRED_PROP = "org.apache.cxf.httpservice.requirefilter";
- private static final Logger LOG = LoggerFactory.getLogger(SecurityDelegatingHttpContext.class);
- private static final String FILTER_FILTER = "(" + FILTER_PROP + "=*)";
-
- BundleContext bundleContext;
- HttpContext delegate;
- boolean requireFilter;
-
- public SecurityDelegatingHttpContext(BundleContext bundleContext, HttpContext delegate) {
- this.bundleContext = bundleContext;
- this.delegate = delegate;
- requireFilter = Boolean.TRUE.toString().equalsIgnoreCase(bundleContext.getProperty(FILTER_REQUIRED_PROP));
- }
-
- public String getMimeType(String name) {
- return delegate.getMimeType(name);
- }
-
- public URL getResource(String name) {
- return delegate.getResource(name);
- }
-
- @SuppressWarnings({
- "unchecked", "rawtypes"
- })
- public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
- ServiceReference[] refs;
- try {
- refs = bundleContext.getServiceReferences(Filter.class.getName(), FILTER_FILTER);
- } catch (InvalidSyntaxException e) {
- LOG.warn(e.getMessage(), e);
- return false;
- }
- if (refs == null || refs.length == 0) {
- LOG.info("No filter registered.");
- return !requireFilter;
- }
- Filter[] filters = new Filter[refs.length];
- try {
- for (int i = 0; i < refs.length; i++) {
- filters[i] = (Filter)bundleContext.getService(refs[i]);
- }
- try {
- new Chain(filters).doFilter(request, response);
- return !response.isCommitted();
- } catch (ServletException e) {
- LOG.warn(e.getMessage(), e);
- return false;
- }
- } finally {
- for (int i = 0; i < refs.length; i++) {
- if (filters[i] != null) {
- bundleContext.ungetService(refs[i]);
- }
- }
- }
- }
-}
-
-/**
- * A {@link FilterChain} composed of {@link Filter}s with the
- */
-class Chain implements FilterChain {
-
- private static final Logger LOG = LoggerFactory.getLogger(Chain.class);
-
- int current;
- final Filter[] filters;
-
- Chain(Filter[] filters) {
- this.filters = filters;
- }
-
- public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
- if (current < filters.length && !response.isCommitted()) {
- Filter filter = filters[current++];
- LOG.info("doFilter() on {}", filter);
- filter.doFilter(request, response, this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java
deleted file mode 100644
index bcc4963..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java
+++ /dev/null
@@ -1,49 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.io.IOException;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.cxf.endpoint.Server;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-
-public class ServerWrapper implements Endpoint {
- private EndpointDescription desc;
- private Server server;
-
- public ServerWrapper(EndpointDescription desc, Server server) {
- this.desc = desc;
- this.server = server;
- }
-
- public Server getServer() {
- return this.server;
- }
-
- @Override
- public void close() throws IOException {
- this.server.destroy();
- }
-
- @Override
- public EndpointDescription description() {
- return this.desc;
- }
-}
[4/5] cxf-dosgi git commit: [DOSGI-242] Refactor provider, Cleanup
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java
deleted file mode 100644
index 6171a53..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java
+++ /dev/null
@@ -1,100 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.ServiceException;
-
-public class ServiceInvocationHandler implements InvocationHandler {
-
- private static final String REMOTE_EXCEPTION_TYPE = "REMOTE";
- private static final Collection<Method> OBJECT_METHODS = Arrays.asList(Object.class.getMethods());
-
- private Map<Method, List<Class<?>>> exceptionsMap = new HashMap<Method, List<Class<?>>>();
- private Object serviceObject;
-
- public ServiceInvocationHandler(Object serviceObject, Class<?> iType) {
- this.serviceObject = serviceObject;
- introspectType(iType);
- }
-
- public Object invoke(Object proxy, final Method m, Object[] params) throws Throwable {
- if (OBJECT_METHODS.contains(m)) {
- if (m.getName().equals("equals")) {
- params = new Object[] {Proxy.getInvocationHandler(params[0])};
- }
- return m.invoke(this, params);
- }
-
- ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- final Object[] paramsFinal = params;
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
- public Object run() throws Exception {
- return m.invoke(serviceObject, paramsFinal);
- }
- });
- } catch (Throwable ex) {
- Throwable theCause = ex.getCause() == null ? ex : ex.getCause();
- Throwable theCauseCause = theCause.getCause() == null ? theCause : theCause.getCause();
- List<Class<?>> excTypes = exceptionsMap.get(m);
- if (excTypes != null) {
- for (Class<?> type : excTypes) {
- if (type.isAssignableFrom(theCause.getClass())) {
- throw theCause;
- }
- if (type.isAssignableFrom(theCauseCause.getClass())) {
- throw theCauseCause;
- }
- }
- }
-
- throw new ServiceException(REMOTE_EXCEPTION_TYPE, theCause);
- } finally {
- Thread.currentThread().setContextClassLoader(oldCl);
- }
- }
-
- private void introspectType(Class<?> iType) {
- for (Method m : iType.getDeclaredMethods()) {
- for (Class<?> excType : m.getExceptionTypes()) {
- if (Exception.class.isAssignableFrom(excType)) {
- List<Class<?>> types = exceptionsMap.get(m);
- if (types == null) {
- types = new ArrayList<Class<?>>();
- exceptionsMap.put(m, types);
- }
- types.add(excType);
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
deleted file mode 100644
index 5bf16d7..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
+++ /dev/null
@@ -1,160 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
-import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
-
- private static final Logger LOG = LoggerFactory.getLogger(WsdlConfigurationTypeHandler.class);
-
- public WsdlConfigurationTypeHandler(BundleContext dswBC,
- IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- super(dswBC, intentManager, httpServiceManager);
- }
-
- public String[] getSupportedTypes() {
- return new String[] {Constants.WSDL_CONFIG_TYPE};
- }
-
- @SuppressWarnings("rawtypes")
- public Object importEndpoint(ClassLoader consumerLoader,
- BundleContext consumerContext,
- Class[] interfaces,
- EndpointDescription endpoint) {
- Class<?> iClass = interfaces[0];
- String wsdlAddressProp = getWsdlAddress(endpoint, iClass);
- if (wsdlAddressProp == null) {
- LOG.warn("WSDL address is unavailable");
- return null;
- }
-
- URL wsdlAddress;
- try {
- wsdlAddress = new URL(wsdlAddressProp);
- } catch (MalformedURLException ex) {
- LOG.warn("WSDL address is malformed");
- return null;
- }
-
- LOG.info("Creating a " + endpoint.getInterfaces().toArray()[0] + " client, wsdl address is "
- + OsgiUtils.getProperty(endpoint, Constants.WSDL_CONFIG_PREFIX));
-
- String serviceNs = OsgiUtils.getProperty(endpoint, Constants.WSDL_SERVICE_NAMESPACE);
- if (serviceNs == null) {
- serviceNs = PackageUtils.getNamespace(PackageUtils.getPackageName(iClass));
- }
- String serviceName = OsgiUtils.getProperty(endpoint, Constants.WSDL_SERVICE_NAME);
- if (serviceName == null) {
- serviceName = iClass.getSimpleName();
- }
- QName serviceQname = getServiceQName(iClass, endpoint.getProperties(),
- Constants.WSDL_SERVICE_NAMESPACE,
- Constants.WSDL_SERVICE_NAME);
- QName portQname = getPortQName(serviceQname.getNamespaceURI(),
- endpoint.getProperties(), Constants.WSDL_PORT_NAME);
- Service service = createWebService(wsdlAddress, serviceQname);
- Object proxy = getProxy(portQname == null ? service.getPort(iClass) : service.getPort(portQname, iClass),
- iClass);
- // MARC: FIXME!!!! getDistributionProvider().addRemoteService(serviceReference);
- return proxy;
- }
-
- // Isolated so that it can be overridden for test purposes.
- Service createWebService(URL wsdlAddress, QName serviceQname) {
- return Service.create(wsdlAddress, serviceQname);
- }
-
- @SuppressWarnings("rawtypes")
- public Endpoint exportService(Object serviceO,
- BundleContext serviceContext,
- Map<String, Object> sd,
- Class[] exportedInterfaces) {
- Class<?> iClass = exportedInterfaces[0];
- String location = OsgiUtils.getProperty(sd, Constants.WSDL_LOCATION);
- if (location == null) {
- throw new RuntimeException("WSDL location property is unavailable");
- }
- URL wsdlURL = serviceContext.getBundle().getResource(location);
- if (wsdlURL == null) {
- throw new RuntimeException("WSDL resource at " + location + " is unavailable");
- }
-
- String address = getServerAddress(sd, iClass);
- String contextRoot = getServletContextRoot(sd);
- if (address == null && contextRoot == null) {
- throw new RuntimeException("Remote address is unavailable");
- }
-
- LOG.info("Creating a " + iClass.getName() + " endpoint from CXF PublishHook, address is " + address);
-
- DataBinding databinding = new JAXBDataBinding();
- JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
- final Long sid = (Long) sd.get(RemoteConstants.ENDPOINT_SERVICE_ID);
- Bus bus = createBus(sid, serviceContext, contextRoot);
- factory.setBus(bus);
- factory.setServiceClass(iClass);
- factory.setAddress(address != null ? address : "/");
- factory.getServiceFactory().setDataBinding(databinding);
- factory.setServiceBean(serviceO);
-
- addWsInterceptorsFeaturesProps(factory, serviceContext, sd);
-
- setWsdlProperties(factory, serviceContext, sd, true);
-
- String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
-
- EndpointDescription epd = createEndpointDesc(sd,
- new String[]{Constants.WS_CONFIG_TYPE},
- address, intents);
- return createServerFromFactory(factory, epd);
- }
-
- private String getWsdlAddress(EndpointDescription endpoint, Class<?> iClass) {
- String address = OsgiUtils.getProperty(endpoint, Constants.WSDL_CONFIG_PREFIX);
- if (address == null) {
- address = httpServiceManager.getDefaultAddress(iClass);
- if (address != null) {
- address += "?wsdl";
- }
- }
- return address;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java
new file mode 100644
index 0000000..aa543e0
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java
@@ -0,0 +1,246 @@
+/**
+ * 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.dosgi.dsw.handlers.pojo;
+
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.aries.rsa.spi.DistributionProvider;
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
+import org.apache.cxf.dosgi.dsw.util.ClassUtils;
+import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.util.ServerWrapper;
+import org.apache.cxf.dosgi.dsw.util.StringPlus;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+
+public abstract class AbstractPojoConfigurationTypeHandler implements DistributionProvider {
+ protected BundleContext bundleContext;
+ protected IntentManager intentManager;
+ protected HttpServiceManager httpServiceManager;
+
+ public AbstractPojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager,
+ HttpServiceManager httpServiceManager) {
+ this.bundleContext = dswBC;
+ this.intentManager = intentManager;
+ this.httpServiceManager = httpServiceManager;
+ }
+
+ protected Object getProxy(Object serviceProxy, Class<?> iType) {
+ return Proxy.newProxyInstance(iType.getClassLoader(), new Class[] {
+ iType
+ }, new ServiceInvocationHandler(serviceProxy, iType));
+ }
+
+ protected EndpointDescription createEndpointDesc(Map<String, Object> props,
+ String[] importedConfigs,
+ String address,
+ String[] intents) {
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
+ for (String configurationType : importedConfigs) {
+ if (Constants.WS_CONFIG_TYPE.equals(configurationType)) {
+ props.put(Constants.WS_ADDRESS_PROPERTY, address);
+ } else if (Constants.RS_CONFIG_TYPE.equals(configurationType)) {
+ props.put(Constants.RS_ADDRESS_PROPERTY, address);
+ } else if (Constants.WS_CONFIG_TYPE_OLD.equals(configurationType)) {
+ props.put(Constants.WS_ADDRESS_PROPERTY_OLD, address);
+ props.put(Constants.WS_ADDRESS_PROPERTY, address);
+ }
+ }
+ String[] sIntents = StringPlus.normalize(props.get(RemoteConstants.SERVICE_INTENTS));
+ String[] allIntents = IntentUtils.mergeArrays(intents, sIntents);
+ props.put(RemoteConstants.SERVICE_INTENTS, allIntents);
+ props.put(RemoteConstants.ENDPOINT_ID, address);
+ return new EndpointDescription(props);
+ }
+
+ protected void setCommonWsdlProperties(AbstractWSDLBasedEndpointFactory factory, BundleContext context,
+ Map<String, Object> sd, boolean wsdlType) {
+ String location = OsgiUtils.getProperty(sd, wsdlType ? Constants.WSDL_LOCATION : Constants.WS_WSDL_LOCATION);
+ if (location != null) {
+ URL wsdlURL = context.getBundle().getResource(location);
+ if (wsdlURL != null) {
+ factory.setWsdlURL(wsdlURL.toString());
+ }
+ QName serviceName = getServiceQName(null, sd,
+ wsdlType ? Constants.WSDL_SERVICE_NAMESPACE : Constants.WS_WSDL_SERVICE_NAMESPACE,
+ wsdlType ? Constants.WSDL_SERVICE_NAME : Constants.WS_WSDL_SERVICE_NAME);
+ if (serviceName != null) {
+ factory.setServiceName(serviceName);
+ QName portName = getPortQName(serviceName.getNamespaceURI(), sd,
+ wsdlType ? Constants.WSDL_PORT_NAME : Constants.WS_WSDL_PORT_NAME);
+ if (portName != null) {
+ factory.setEndpointName(portName);
+ }
+ }
+ }
+ }
+
+ protected void setWsdlProperties(ServerFactoryBean factory, BundleContext callingContext, Map<String, Object> sd,
+ boolean wsdlType) {
+ setCommonWsdlProperties(factory, callingContext, sd, wsdlType);
+ }
+
+ protected void setClientWsdlProperties(ClientFactoryBean factory, BundleContext dswContext, Map<String, Object> sd,
+ boolean wsdlType) {
+ setCommonWsdlProperties(factory, dswContext, sd, wsdlType);
+ }
+
+ protected static QName getServiceQName(Class<?> iClass, Map<String, Object> sd, String nsPropName,
+ String namePropName) {
+ String serviceNs = OsgiUtils.getProperty(sd, nsPropName);
+ String serviceName = OsgiUtils.getProperty(sd, namePropName);
+ if (iClass == null && (serviceNs == null || serviceName == null)) {
+ return null;
+ }
+ if (serviceNs == null) {
+ serviceNs = PackageUtils.getNamespace(PackageUtils.getPackageName(iClass));
+ }
+ if (serviceName == null) {
+ serviceName = iClass.getSimpleName();
+ }
+ return new QName(serviceNs, serviceName);
+ }
+
+ protected static QName getPortQName(String ns, Map<String, Object> sd, String propName) {
+ String portName = OsgiUtils.getProperty(sd, propName);
+ if (portName == null) {
+ return null;
+ }
+ return new QName(ns, portName);
+ }
+
+ protected String getClientAddress(Map<String, Object> sd) {
+ return OsgiUtils.getFirstNonEmptyStringProperty(sd, RemoteConstants.ENDPOINT_ID,
+ Constants.WS_ADDRESS_PROPERTY,
+ Constants.WS_ADDRESS_PROPERTY_OLD,
+ Constants.RS_ADDRESS_PROPERTY);
+ }
+
+ protected String getServerAddress(Map<String, Object> sd, Class<?> iClass) {
+ String address = getClientAddress(sd);
+ return address == null ? httpServiceManager.getDefaultAddress(iClass) : address;
+ }
+
+ public String getServletContextRoot(Map<String, Object> sd) {
+ return OsgiUtils.getFirstNonEmptyStringProperty(sd,
+ Constants.WS_HTTP_SERVICE_CONTEXT,
+ Constants.WS_HTTP_SERVICE_CONTEXT_OLD,
+ Constants.WSDL_HTTP_SERVICE_CONTEXT,
+ Constants.RS_HTTP_SERVICE_CONTEXT);
+ }
+
+
+ protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot) {
+ Bus bus = BusFactory.newInstance().createBus();
+ if (contextRoot != null) {
+ httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
+ }
+ return bus;
+ }
+
+ protected Endpoint createServerFromFactory(ServerFactoryBean factory, EndpointDescription epd) {
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
+ Server server = factory.create();
+ return new ServerWrapper(epd, server);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ }
+
+ protected static void addWsInterceptorsFeaturesProps(AbstractEndpointFactory factory, BundleContext callingContext,
+ Map<String, Object> sd) {
+ addInterceptors(factory, callingContext, sd, Constants.WS_IN_INTERCEPTORS_PROP_KEY);
+ addInterceptors(factory, callingContext, sd, Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
+ addInterceptors(factory, callingContext, sd, Constants.WS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
+ addInterceptors(factory, callingContext, sd, Constants.WS_IN_FAULT_INTERCEPTORS_PROP_KEY);
+ addFeatures(factory, callingContext, sd, Constants.WS_FEATURES_PROP_KEY);
+ addContextProperties(factory, sd, Constants.WS_CONTEXT_PROPS_PROP_KEY);
+ }
+
+ protected static void addRsInterceptorsFeaturesProps(AbstractEndpointFactory factory, BundleContext callingContext,
+ Map<String, Object> sd) {
+ addInterceptors(factory, callingContext, sd, Constants.RS_IN_INTERCEPTORS_PROP_KEY);
+ addInterceptors(factory, callingContext, sd, Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
+ addInterceptors(factory, callingContext, sd, Constants.RS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
+ addInterceptors(factory, callingContext, sd, Constants.RS_IN_FAULT_INTERCEPTORS_PROP_KEY);
+ addFeatures(factory, callingContext, sd, Constants.RS_FEATURES_PROP_KEY);
+ addContextProperties(factory, sd, Constants.RS_CONTEXT_PROPS_PROP_KEY);
+ }
+
+ private static void addInterceptors(AbstractEndpointFactory factory, BundleContext callingContext,
+ Map<String, Object> sd, String propName) {
+ List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName);
+ boolean in = propName.contains("in.interceptors");
+ boolean out = propName.contains("out.interceptors");
+ boolean inFault = propName.contains("in.fault.interceptors");
+ boolean outFault = propName.contains("out.fault.interceptors");
+ for (Object provider : providers) {
+ Interceptor<?> interceptor = (Interceptor<?>) provider;
+ if (in) {
+ factory.getInInterceptors().add(interceptor);
+ } else if (out) {
+ factory.getOutInterceptors().add(interceptor);
+ } else if (inFault) {
+ factory.getInFaultInterceptors().add(interceptor);
+ } else if (outFault) {
+ factory.getOutFaultInterceptors().add(interceptor);
+ }
+ }
+ }
+
+ private static void addFeatures(AbstractEndpointFactory factory, BundleContext callingContext,
+ Map<String, Object> sd, String propName) {
+ List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName);
+ if (!providers.isEmpty()) {
+ factory.getFeatures().addAll(CastUtils.cast(providers, AbstractFeature.class));
+ }
+ }
+
+ private static void addContextProperties(AbstractEndpointFactory factory, Map<String, Object> sd, String propName) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> props = (Map<String, Object>)sd.get(propName);
+ if (props != null) {
+ factory.getProperties(true).putAll(props);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java
new file mode 100644
index 0000000..a0784fb
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java
@@ -0,0 +1,173 @@
+/**
+ * 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.dosgi.dsw.handlers.pojo;
+
+import java.util.Map;
+
+import javax.jws.WebService;
+
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
+import org.apache.cxf.Bus;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PojoConfigurationTypeHandler.class);
+
+ public PojoConfigurationTypeHandler(BundleContext dswBC,
+ IntentManager intentManager,
+ HttpServiceManager httpServiceManager) {
+ super(dswBC, intentManager, httpServiceManager);
+ }
+
+ public String[] getSupportedTypes() {
+ return new String[] {Constants.WS_CONFIG_TYPE, Constants.WS_CONFIG_TYPE_OLD};
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object importEndpoint(ClassLoader consumerLoader,
+ BundleContext consumerContext,
+ Class[] interfaces,
+ EndpointDescription endpoint) throws IntentUnsatisfiedException {
+ Class<?> iClass = interfaces[0];
+ Map<String, Object> sd = endpoint.getProperties();
+ String address = getClientAddress(sd);
+ if (address == null) {
+ LOG.warn("Remote address is unavailable");
+ // TODO: fire Event
+ return null;
+ }
+
+ LOG.info("Creating a " + iClass.getName() + " client, endpoint address is " + address);
+
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ ClientProxyFactoryBean factory = createClientProxyFactoryBean(sd, iClass);
+ factory.getServiceFactory().setDataBinding(getDataBinding(sd, iClass));
+ factory.setServiceClass(iClass);
+ factory.setAddress(address);
+ addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), consumerContext, sd);
+ setClientWsdlProperties(factory.getClientFactoryBean(), bundleContext, sd, false);
+
+ intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd);
+
+ Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
+ return getProxy(factory.create(), iClass);
+ } catch (Exception e) {
+ LOG.warn("proxy creation failed", e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Endpoint exportService(Object serviceO,
+ BundleContext serviceContext,
+ Map<String, Object> endpointProps,
+ Class[] exportedInterfaces) throws IntentUnsatisfiedException {
+ Class<?> iClass = exportedInterfaces[0];
+ String address = getPojoAddress(endpointProps, iClass);
+ ServerFactoryBean factory = createServerFactoryBean(endpointProps, iClass);
+ factory.setDataBinding(getDataBinding(endpointProps, iClass));
+ String contextRoot = getServletContextRoot(endpointProps);
+
+ final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+ Bus bus = createBus(sid, serviceContext, contextRoot);
+ factory.setBus(bus);
+ factory.setServiceClass(iClass);
+ factory.setAddress(address);
+
+ factory.setServiceBean(serviceO);
+ addWsInterceptorsFeaturesProps(factory, serviceContext, endpointProps);
+ setWsdlProperties(factory, serviceContext, endpointProps, false);
+ String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, endpointProps);
+
+ String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
+ EndpointDescription epd = createEndpointDesc(endpointProps,
+ new String[]{Constants.WS_CONFIG_TYPE},
+ completeEndpointAddress, intents);
+ return createServerFromFactory(factory, epd);
+ }
+
+ private String getPojoAddress(Map<String, Object> sd, Class<?> iClass) {
+ String address = getClientAddress(sd);
+ if (address != null) {
+ return address;
+ }
+
+ // If the property is not of type string this will cause an ClassCastException which
+ // will be propagated to the ExportRegistration exception property.
+ Object port = sd.get(Constants.WS_PORT_PROPERTY);
+ if (port == null) {
+ port = "9000";
+ }
+
+ address = "http://localhost:" + port + "/" + iClass.getName().replace('.', '/');
+ LOG.info("Using a default address: " + address);
+ return address;
+ }
+
+ private DataBinding getDataBinding(Map<String, Object> sd, Class<?> iClass) {
+ Object dataBindingBeanProp = sd.get(Constants.WS_DATABINDING_BEAN_PROP_KEY);
+ if (dataBindingBeanProp instanceof DataBinding) {
+ return (DataBinding)dataBindingBeanProp;
+ }
+ return isJAXB(sd, iClass) ? new JAXBDataBinding() : new AegisDatabinding();
+ }
+
+ private boolean isJAXB(Map<String, Object> sd, Class<?> iClass) {
+ String dataBindingName = (String)sd.get(Constants.WS_DATABINDING_PROP_KEY);
+ return (iClass.getAnnotation(WebService.class) != null
+ || Constants.WS_DATA_BINDING_JAXB.equals(dataBindingName))
+ && !Constants.WS_DATA_BINDING_AEGIS.equals(dataBindingName);
+ }
+
+ // Isolated so that it can be substituted for testing
+ protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXWS(sd, iClass) ? new JaxWsProxyFactoryBean() : new ClientProxyFactoryBean();
+ }
+
+ // Isolated so that it can be substituted for testing
+ protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXWS(sd, iClass) ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
+ }
+
+ private boolean isJAXWS(Map<String, Object> sd, Class<?> iClass) {
+ String frontEnd = (String)sd.get(Constants.WS_FRONTEND_PROP_KEY);
+ return (iClass.getAnnotation(WebService.class) != null
+ || Constants.WS_FRONTEND_JAXWS.equals(frontEnd))
+ && !Constants.WS_FRONTEND_SIMPLE.equals(frontEnd);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/ServiceInvocationHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/ServiceInvocationHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/ServiceInvocationHandler.java
new file mode 100644
index 0000000..3928c7d
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/ServiceInvocationHandler.java
@@ -0,0 +1,100 @@
+/**
+ * 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.dosgi.dsw.handlers.pojo;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.ServiceException;
+
+public class ServiceInvocationHandler implements InvocationHandler {
+
+ private static final String REMOTE_EXCEPTION_TYPE = "REMOTE";
+ private static final Collection<Method> OBJECT_METHODS = Arrays.asList(Object.class.getMethods());
+
+ private Map<Method, List<Class<?>>> exceptionsMap = new HashMap<Method, List<Class<?>>>();
+ private Object serviceObject;
+
+ public ServiceInvocationHandler(Object serviceObject, Class<?> iType) {
+ this.serviceObject = serviceObject;
+ introspectType(iType);
+ }
+
+ public Object invoke(Object proxy, final Method m, Object[] params) throws Throwable {
+ if (OBJECT_METHODS.contains(m)) {
+ if (m.getName().equals("equals")) {
+ params = new Object[] {Proxy.getInvocationHandler(params[0])};
+ }
+ return m.invoke(this, params);
+ }
+
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ final Object[] paramsFinal = params;
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ return m.invoke(serviceObject, paramsFinal);
+ }
+ });
+ } catch (Throwable ex) {
+ Throwable theCause = ex.getCause() == null ? ex : ex.getCause();
+ Throwable theCauseCause = theCause.getCause() == null ? theCause : theCause.getCause();
+ List<Class<?>> excTypes = exceptionsMap.get(m);
+ if (excTypes != null) {
+ for (Class<?> type : excTypes) {
+ if (type.isAssignableFrom(theCause.getClass())) {
+ throw theCause;
+ }
+ if (type.isAssignableFrom(theCauseCause.getClass())) {
+ throw theCauseCause;
+ }
+ }
+ }
+
+ throw new ServiceException(REMOTE_EXCEPTION_TYPE, theCause);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+ }
+
+ private void introspectType(Class<?> iType) {
+ for (Method m : iType.getDeclaredMethods()) {
+ for (Class<?> excType : m.getExceptionTypes()) {
+ if (Exception.class.isAssignableFrom(excType)) {
+ List<Class<?>> types = exceptionsMap.get(m);
+ if (types == null) {
+ types = new ArrayList<Class<?>>();
+ exceptionsMap.put(m, types);
+ }
+ types.add(excType);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java
new file mode 100644
index 0000000..b818354
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java
@@ -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.dosgi.dsw.handlers.pojo;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
+import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
+
+ private static final Logger LOG = LoggerFactory.getLogger(WsdlConfigurationTypeHandler.class);
+
+ public WsdlConfigurationTypeHandler(BundleContext dswBC,
+ IntentManager intentManager,
+ HttpServiceManager httpServiceManager) {
+ super(dswBC, intentManager, httpServiceManager);
+ }
+
+ public String[] getSupportedTypes() {
+ return new String[] {Constants.WSDL_CONFIG_TYPE};
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object importEndpoint(ClassLoader consumerLoader,
+ BundleContext consumerContext,
+ Class[] interfaces,
+ EndpointDescription endpoint) {
+ Class<?> iClass = interfaces[0];
+ String wsdlAddressProp = getWsdlAddress(endpoint, iClass);
+ if (wsdlAddressProp == null) {
+ LOG.warn("WSDL address is unavailable");
+ return null;
+ }
+
+ URL wsdlAddress;
+ try {
+ wsdlAddress = new URL(wsdlAddressProp);
+ } catch (MalformedURLException ex) {
+ LOG.warn("WSDL address is malformed");
+ return null;
+ }
+
+ LOG.info("Creating a " + endpoint.getInterfaces().toArray()[0] + " client, wsdl address is "
+ + OsgiUtils.getProperty(endpoint, Constants.WSDL_CONFIG_PREFIX));
+
+ String serviceNs = OsgiUtils.getProperty(endpoint, Constants.WSDL_SERVICE_NAMESPACE);
+ if (serviceNs == null) {
+ serviceNs = PackageUtils.getNamespace(PackageUtils.getPackageName(iClass));
+ }
+ String serviceName = OsgiUtils.getProperty(endpoint, Constants.WSDL_SERVICE_NAME);
+ if (serviceName == null) {
+ serviceName = iClass.getSimpleName();
+ }
+ QName serviceQname = getServiceQName(iClass, endpoint.getProperties(),
+ Constants.WSDL_SERVICE_NAMESPACE,
+ Constants.WSDL_SERVICE_NAME);
+ QName portQname = getPortQName(serviceQname.getNamespaceURI(),
+ endpoint.getProperties(), Constants.WSDL_PORT_NAME);
+ Service service = createWebService(wsdlAddress, serviceQname);
+ Object proxy = getProxy(portQname == null ? service.getPort(iClass) : service.getPort(portQname, iClass),
+ iClass);
+ // MARC: FIXME!!!! getDistributionProvider().addRemoteService(serviceReference);
+ return proxy;
+ }
+
+ // Isolated so that it can be overridden for test purposes.
+ Service createWebService(URL wsdlAddress, QName serviceQname) {
+ return Service.create(wsdlAddress, serviceQname);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Endpoint exportService(Object serviceO,
+ BundleContext serviceContext,
+ Map<String, Object> sd,
+ Class[] exportedInterfaces) {
+ Class<?> iClass = exportedInterfaces[0];
+ String location = OsgiUtils.getProperty(sd, Constants.WSDL_LOCATION);
+ if (location == null) {
+ throw new RuntimeException("WSDL location property is unavailable");
+ }
+ URL wsdlURL = serviceContext.getBundle().getResource(location);
+ if (wsdlURL == null) {
+ throw new RuntimeException("WSDL resource at " + location + " is unavailable");
+ }
+
+ String address = getServerAddress(sd, iClass);
+ String contextRoot = getServletContextRoot(sd);
+ if (address == null && contextRoot == null) {
+ throw new RuntimeException("Remote address is unavailable");
+ }
+
+ LOG.info("Creating a " + iClass.getName() + " endpoint from CXF PublishHook, address is " + address);
+
+ DataBinding databinding = new JAXBDataBinding();
+ JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+ final Long sid = (Long) sd.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+ Bus bus = createBus(sid, serviceContext, contextRoot);
+ factory.setBus(bus);
+ factory.setServiceClass(iClass);
+ factory.setAddress(address != null ? address : "/");
+ factory.getServiceFactory().setDataBinding(databinding);
+ factory.setServiceBean(serviceO);
+
+ addWsInterceptorsFeaturesProps(factory, serviceContext, sd);
+
+ setWsdlProperties(factory, serviceContext, sd, true);
+
+ String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
+
+ EndpointDescription epd = createEndpointDesc(sd,
+ new String[]{Constants.WS_CONFIG_TYPE},
+ address, intents);
+ return createServerFromFactory(factory, epd);
+ }
+
+ private String getWsdlAddress(EndpointDescription endpoint, Class<?> iClass) {
+ String address = OsgiUtils.getProperty(endpoint, Constants.WSDL_CONFIG_PREFIX);
+ if (address == null) {
+ address = httpServiceManager.getDefaultAddress(iClass);
+ if (address != null) {
+ address += "?wsdl";
+ }
+ }
+ return address;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java
new file mode 100644
index 0000000..49e9d39
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java
@@ -0,0 +1,204 @@
+/**
+ * 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.dosgi.dsw.handlers.rest;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.ProxyClassLoader;
+import org.apache.cxf.dosgi.dsw.handlers.pojo.AbstractPojoConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.util.ServerWrapper;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.model.UserResource;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
+
+ private static final Logger LOG = LoggerFactory.getLogger(JaxRSPojoConfigurationTypeHandler.class);
+
+ public JaxRSPojoConfigurationTypeHandler(BundleContext dswBC,
+ IntentManager intentManager,
+ HttpServiceManager httpServiceManager) {
+ super(dswBC, intentManager, httpServiceManager);
+ }
+
+ public String[] getSupportedTypes() {
+ return new String[] {Constants.RS_CONFIG_TYPE};
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object importEndpoint(ClassLoader consumerLoader,
+ BundleContext consumerContext,
+ Class[] interfaces,
+ EndpointDescription endpoint) {
+ Class<?> iClass = interfaces[0];
+ String address = getPojoAddress(endpoint, iClass);
+ if (address == null) {
+ LOG.warn("Remote address is unavailable");
+ return null;
+ }
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ return createJaxrsProxy(address, consumerContext, iClass, null, endpoint);
+ } catch (Throwable e) {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+
+ try {
+ ProxyClassLoader cl = new ProxyClassLoader(iClass.getClassLoader());
+ cl.addLoader(Client.class.getClassLoader());
+ return createJaxrsProxy(address, consumerContext, iClass, cl, endpoint);
+ } catch (Throwable e) {
+ LOG.warn("proxy creation failed", e);
+ }
+
+ return null;
+ }
+
+ protected Object createJaxrsProxy(String address,
+ BundleContext callingContext,
+ Class<?> iClass,
+ ClassLoader loader,
+ EndpointDescription endpoint) {
+ JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+ bean.setAddress(address);
+ if (loader != null) {
+ bean.setClassLoader(loader);
+ }
+
+ addRsInterceptorsFeaturesProps(bean, callingContext, endpoint.getProperties());
+
+ List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
+ if (resources != null) {
+ bean.setModelBeansWithServiceClass(resources, iClass);
+ } else {
+ bean.setServiceClass(iClass);
+ }
+ List<Object> providers = JaxRSUtils.getProviders(callingContext, endpoint.getProperties());
+ if (providers != null && !providers.isEmpty()) {
+ bean.setProviders(providers);
+ }
+ Thread.currentThread().setContextClassLoader(JAXRSClientFactoryBean.class.getClassLoader());
+ return getProxy(bean.create(), iClass);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Endpoint exportService(Object serviceBean,
+ BundleContext callingContext,
+ Map<String, Object> endpointProps,
+ Class[] exportedInterfaces) throws IntentUnsatisfiedException {
+ String contextRoot = getServletContextRoot(endpointProps);
+ String address;
+ Class<?> iClass = exportedInterfaces[0];
+ if (contextRoot == null) {
+ address = getServerAddress(endpointProps, iClass);
+ } else {
+ address = getClientAddress(endpointProps);
+ if (address == null) {
+ address = "/";
+ }
+ }
+ final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+ Bus bus = createBus(sid, callingContext, contextRoot);
+
+ LOG.info("Creating a " + iClass.getName()
+ + " endpoint via JaxRSPojoConfigurationTypeHandler, address is " + address);
+
+ JAXRSServerFactoryBean factory = createServerFactory(callingContext, endpointProps,
+ iClass, serviceBean, address, bus);
+ String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
+
+ EndpointDescription epd = createEndpointDesc(endpointProps, new String[] {Constants.RS_CONFIG_TYPE},
+ completeEndpointAddress, new String[] {"HTTP"});
+
+ return createServerFromFactory(factory, epd);
+ }
+
+ private Endpoint createServerFromFactory(JAXRSServerFactoryBean factory,
+ EndpointDescription epd) {
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
+ Server server = factory.create();
+ return new ServerWrapper(epd, server);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ }
+
+ private JAXRSServerFactoryBean createServerFactory(BundleContext callingContext,
+ Map<String, Object> sd,
+ Class<?> iClass,
+ Object serviceBean,
+ String address,
+ Bus bus) {
+ JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
+ factory.setBus(bus);
+ List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
+ if (resources != null) {
+ factory.setModelBeansWithServiceClass(resources, iClass);
+ factory.setServiceBeanObjects(serviceBean);
+ } else {
+ factory.setServiceClass(iClass);
+ factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
+ }
+ factory.setAddress(address);
+ List<Object> providers = JaxRSUtils.getProviders(callingContext, sd);
+ if (providers != null && !providers.isEmpty()) {
+ factory.setProviders(providers);
+ }
+ addRsInterceptorsFeaturesProps(factory, callingContext, sd);
+ String location = OsgiUtils.getProperty(sd, Constants.RS_WADL_LOCATION);
+ if (location != null) {
+ URL wadlURL = callingContext.getBundle().getResource(location);
+ if (wadlURL != null) {
+ factory.setDocLocation(wadlURL.toString());
+ }
+ }
+ return factory;
+ }
+
+ protected String getPojoAddress(EndpointDescription endpoint, Class<?> iClass) {
+ String address = OsgiUtils.getProperty(endpoint, Constants.RS_ADDRESS_PROPERTY);
+
+ if (address == null) {
+ address = httpServiceManager.getDefaultAddress(iClass);
+ if (address != null) {
+ LOG.info("Using a default address: " + address);
+ }
+ }
+ return address;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java
new file mode 100644
index 0000000..c03a29f
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java
@@ -0,0 +1,122 @@
+/**
+ * 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.dosgi.dsw.handlers.rest;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.dosgi.dsw.util.ClassUtils;
+import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
+import org.apache.cxf.jaxrs.model.UserResource;
+import org.apache.cxf.jaxrs.provider.aegis.AegisElementProvider;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class JaxRSUtils {
+
+ public static final String MODEL_FOLDER = "/OSGI-INF/cxf/jaxrs/";
+ public static final String DEFAULT_MODEL = "/OSGI-INF/cxf/jaxrs/model.xml";
+ public static final String PROVIDERS_FILTER = "(|"
+ + "(objectClass=javax.ws.rs.ext.MessageBodyReader)"
+ + "(objectClass=javax.ws.rs.ext.MessageBodyWriter)"
+ + "(objectClass=javax.ws.rs.ext.ExceptionMapper)"
+ + "(objectClass=org.apache.cxf.jaxrs.ext.RequestHandler)"
+ + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseHandler)"
+ + "(objectClass=org.apache.cxf.jaxrs.ext.ParameterHandler)"
+ + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseExceptionMapper)"
+ + ")";
+ private static final Logger LOG = LoggerFactory.getLogger(JaxRSUtils.class);
+
+ private JaxRSUtils() {
+ // never constructed
+ }
+
+ @SuppressWarnings({
+ "rawtypes", "unchecked"
+ })
+ static List<Object> getProviders(BundleContext callingContext, Map<String, Object> sd) {
+ List<Object> providers = new ArrayList<Object>();
+ if ("aegis".equals(sd.get(org.apache.cxf.dosgi.dsw.osgi.Constants.RS_DATABINDING_PROP_KEY))) {
+ providers.add(new AegisElementProvider());
+ }
+
+ providers.addAll(ClassUtils.loadProviderClasses(callingContext,
+ sd,
+ org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_PROP_KEY));
+
+ Object globalQueryProp = sd.get(org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_GLOBAL_PROP_KEY);
+ boolean globalQueryRequired = globalQueryProp == null || OsgiUtils.toBoolean(globalQueryProp);
+ if (!globalQueryRequired) {
+ return providers;
+ }
+
+ boolean cxfProvidersOnly = OsgiUtils.getBooleanProperty(sd,
+ org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_EXPECTED_PROP_KEY);
+
+ try {
+ ServiceReference[] refs = callingContext.getServiceReferences((String)null, PROVIDERS_FILTER);
+ if (refs != null) {
+ for (ServiceReference ref : refs) {
+ if (!cxfProvidersOnly
+ || OsgiUtils.toBoolean(ref
+ .getProperty(org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_PROP_KEY))) {
+ providers.add(callingContext.getService(ref));
+ }
+ }
+ }
+ } catch (Exception ex) {
+ LOG.debug("Problems finding JAXRS providers " + ex.getMessage(), ex);
+ }
+ return providers;
+ }
+
+ static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass) {
+ String classModel = MODEL_FOLDER + iClass.getSimpleName() + "-model.xml";
+ List<UserResource> list = getModel(callingContext, iClass, classModel);
+ return list != null ? list : getModel(callingContext, iClass, DEFAULT_MODEL);
+ }
+
+ private static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass, String name) {
+ InputStream r = iClass.getClassLoader().getResourceAsStream(name);
+ if (r == null) {
+ URL u = callingContext.getBundle().getResource(name);
+ if (u != null) {
+ try {
+ r = u.openStream();
+ } catch (Exception ex) {
+ LOG.info("Problems opening a user model resource at " + u.toString());
+ }
+ }
+ }
+ if (r != null) {
+ try {
+ return ResourceUtils.getUserResources(r);
+ } catch (Exception ex) {
+ LOG.info("Problems reading a user model, it will be ignored");
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManager.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManager.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManager.java
new file mode 100644
index 0000000..f6ebda1
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManager.java
@@ -0,0 +1,176 @@
+/**
+ * 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.dosgi.dsw.httpservice;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.http.DestinationRegistryImpl;
+import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HttpServiceManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(HttpServiceManager.class);
+ private static final long SERVICE_LOOKUP_TIMEOUT = 10000;
+ private ServiceTracker<HttpService, HttpService> tracker;
+ private BundleContext bundleContext;
+ private Map<Long, String> exportedAliases = Collections.synchronizedMap(new HashMap<Long, String>());
+ private String httpBase;
+ private String cxfServletAlias;
+
+ public HttpServiceManager(BundleContext bundleContext, String httpBase, String cxfServletAlias) {
+ this(bundleContext, httpBase, cxfServletAlias,
+ new ServiceTracker<HttpService, HttpService>(bundleContext, HttpService.class, null));
+ this.tracker.open();
+ }
+
+ // Only for tests
+ public HttpServiceManager(BundleContext bundleContext,
+ String httpBase, String cxfServletAlias,
+ ServiceTracker<HttpService, HttpService> tracker) {
+ this.bundleContext = bundleContext;
+ this.tracker = tracker;
+ this.httpBase = getWithDefault(httpBase, "http://" + LocalHostUtil.getLocalIp() + ":8181");
+ this.cxfServletAlias = getWithDefault(cxfServletAlias, "/cxf");
+ }
+
+ private String getWithDefault(String value, String defaultValue) {
+ return value == null ? defaultValue : value;
+ }
+
+ public Bus registerServlet(Bus bus, String contextRoot, BundleContext callingContext, Long sid) {
+ bus.setExtension(new DestinationRegistryImpl(), DestinationRegistry.class);
+ CXFNonSpringServlet cxf = new CXFNonSpringServlet();
+ cxf.setBus(bus);
+ try {
+ HttpService httpService = getHttpService();
+ httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(),
+ getHttpContext(callingContext, httpService));
+
+ registerUnexportHook(sid, contextRoot);
+
+ LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
+ } catch (Exception e) {
+ throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet", e);
+ }
+ return bus;
+ }
+
+ protected HttpService getHttpService() {
+ HttpService service = null;
+ try {
+ service = tracker.waitForService(SERVICE_LOOKUP_TIMEOUT);
+ } catch (InterruptedException ex) {
+ LOG.warn("waitForService interrupeted", ex);
+ }
+ if (service == null) {
+ throw new RuntimeException("No HTTPService found");
+ }
+ return service;
+ }
+
+ private HttpContext getHttpContext(BundleContext bc, HttpService httpService) {
+ HttpContext httpContext = httpService.createDefaultHttpContext();
+ return new SecurityDelegatingHttpContext(bc, httpContext);
+ }
+
+ /**
+ * This listens for service removal events and "un-exports" the service
+ * from the HttpService.
+ *
+ * @param sref the service reference to track
+ * @param alias the HTTP servlet context alias
+ */
+ private void registerUnexportHook(Long sid, String alias) {
+ LOG.debug("Registering service listener for service with ID {}", sid);
+
+ String previous = exportedAliases.put(sid, alias);
+ if (previous != null) {
+ LOG.warn("Overwriting service export for service with ID {}", sid);
+ }
+
+ try {
+ Filter f = bundleContext.createFilter("(" + org.osgi.framework.Constants.SERVICE_ID + "=" + sid + ")");
+ if (f != null) {
+ bundleContext.addServiceListener(new UnregisterListener(), f.toString());
+ } else {
+ LOG.warn("Service listener could not be started. The service will not be automatically unexported.");
+ }
+ } catch (InvalidSyntaxException e) {
+ LOG.warn("Service listener could not be started. The service will not be automatically unexported.", e);
+ }
+ }
+
+ public String getDefaultAddress(Class<?> type) {
+ return "/" + type.getName().replace('.', '/');
+ }
+
+ public String getAbsoluteAddress(String contextRoot, String relativeEndpointAddress) {
+ if (relativeEndpointAddress.startsWith("http")) {
+ return relativeEndpointAddress;
+ }
+ String effContextRoot = contextRoot == null ? cxfServletAlias : contextRoot;
+ return this.httpBase + effContextRoot + relativeEndpointAddress;
+ }
+
+ public void close() {
+ tracker.close();
+ }
+
+ private final class UnregisterListener implements ServiceListener {
+
+ public void serviceChanged(ServiceEvent event) {
+ if (!(event.getType() == ServiceEvent.UNREGISTERING)) {
+ return;
+ }
+ final ServiceReference<?> sref = event.getServiceReference();
+ final Long sid = (Long) sref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
+ final String alias = exportedAliases.remove(sid);
+ if (alias == null) {
+ LOG.error("Unable to unexport HTTP servlet for service class '{}',"
+ + " service-id {}: no servlet alias found",
+ sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS), sid);
+ return;
+ }
+ LOG.debug("Unexporting HTTP servlet for alias '{}'", alias);
+ try {
+ HttpService http = getHttpService();
+ http.unregister(alias);
+ } catch (Exception e) {
+ LOG.warn("An exception occurred while unregistering service for HTTP servlet alias '{}'", alias, e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/LocalHostUtil.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/LocalHostUtil.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/LocalHostUtil.java
new file mode 100644
index 0000000..f2fefe9
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/LocalHostUtil.java
@@ -0,0 +1,92 @@
+/**
+ * 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.dosgi.dsw.httpservice;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * Utility methods to get the local address even on a linux host.
+ */
+final class LocalHostUtil {
+
+ private LocalHostUtil() {
+ // Util Class
+ }
+
+ /**
+ * Returns an InetAddress representing the address of the localhost. Every
+ * attempt is made to find an address for this host that is not the loopback
+ * address. If no other address can be found, the loopback will be returned.
+ *
+ * @return InetAddress the address of localhost
+ * @throws UnknownHostException if there is a problem determining the address
+ */
+ public static InetAddress getLocalHost() throws UnknownHostException {
+ InetAddress localHost = InetAddress.getLocalHost();
+ if (!localHost.isLoopbackAddress()) {
+ return localHost;
+ }
+ InetAddress[] addrs = getAllLocalUsingNetworkInterface();
+ for (InetAddress addr : addrs) {
+ if (!addr.isLoopbackAddress() && !addr.getHostAddress().contains(":")) {
+ return addr;
+ }
+ }
+ return localHost;
+ }
+
+ /**
+ * Utility method that delegates to the methods of NetworkInterface to
+ * determine addresses for this machine.
+ *
+ * @return all addresses found from the NetworkInterfaces
+ * @throws UnknownHostException if there is a problem determining addresses
+ */
+ private static InetAddress[] getAllLocalUsingNetworkInterface() throws UnknownHostException {
+ try {
+ List<InetAddress> addresses = new ArrayList<InetAddress>();
+ Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
+ while (e.hasMoreElements()) {
+ NetworkInterface ni = e.nextElement();
+ for (Enumeration<InetAddress> e2 = ni.getInetAddresses(); e2.hasMoreElements();) {
+ addresses.add(e2.nextElement());
+ }
+ }
+ return addresses.toArray(new InetAddress[] {});
+ } catch (SocketException ex) {
+ throw new UnknownHostException("127.0.0.1");
+ }
+ }
+
+ public static String getLocalIp() {
+ String localIP;
+ try {
+ localIP = getLocalHost().getHostAddress();
+ } catch (Exception e) {
+ localIP = "localhost";
+ }
+ return localIP;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContext.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContext.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContext.java
new file mode 100644
index 0000000..042f2d5
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContext.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.dosgi.dsw.httpservice;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <p>
+ * An HttpContext that delegates to another HttpContext for all things other than security. This implementation handles
+ * security by delegating to a {@link FilterChain} based on the set of {@link Filter}s registered with a
+ * {@link #FILTER_PROP} property.
+ * </p>
+ * <p>
+ * If the {@link BundleContext} contains a {@link #FILTER_REQUIRED_PROP} property with value "true", requests will not
+ * be allowed until at least one {@link Filter} with a {@link #FILTER_PROP} property is registered.
+ * </p>
+ */
+class SecurityDelegatingHttpContext implements HttpContext {
+
+ public static final String FILTER_PROP = "org.apache.cxf.httpservice.filter";
+ public static final String FILTER_REQUIRED_PROP = "org.apache.cxf.httpservice.requirefilter";
+ private static final Logger LOG = LoggerFactory.getLogger(SecurityDelegatingHttpContext.class);
+ private static final String FILTER_FILTER = "(" + FILTER_PROP + "=*)";
+
+ BundleContext bundleContext;
+ HttpContext delegate;
+ boolean requireFilter;
+
+ SecurityDelegatingHttpContext(BundleContext bundleContext, HttpContext delegate) {
+ this.bundleContext = bundleContext;
+ this.delegate = delegate;
+ requireFilter = Boolean.TRUE.toString().equalsIgnoreCase(bundleContext.getProperty(FILTER_REQUIRED_PROP));
+ }
+
+ public String getMimeType(String name) {
+ return delegate.getMimeType(name);
+ }
+
+ public URL getResource(String name) {
+ return delegate.getResource(name);
+ }
+
+ @SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
+ public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ ServiceReference[] refs;
+ try {
+ refs = bundleContext.getServiceReferences(Filter.class.getName(), FILTER_FILTER);
+ } catch (InvalidSyntaxException e) {
+ LOG.warn(e.getMessage(), e);
+ return false;
+ }
+ if (refs == null || refs.length == 0) {
+ LOG.info("No filter registered.");
+ return !requireFilter;
+ }
+ Filter[] filters = new Filter[refs.length];
+ try {
+ for (int i = 0; i < refs.length; i++) {
+ filters[i] = (Filter)bundleContext.getService(refs[i]);
+ }
+ try {
+ new Chain(filters).doFilter(request, response);
+ return !response.isCommitted();
+ } catch (ServletException e) {
+ LOG.warn(e.getMessage(), e);
+ return false;
+ }
+ } finally {
+ for (int i = 0; i < refs.length; i++) {
+ if (filters[i] != null) {
+ bundleContext.ungetService(refs[i]);
+ }
+ }
+ }
+ }
+}
+
+/**
+ * A {@link FilterChain} composed of {@link Filter}s with the
+ */
+class Chain implements FilterChain {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Chain.class);
+
+ int current;
+ final Filter[] filters;
+
+ Chain(Filter[] filters) {
+ this.filters = filters;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
+ if (current < filters.length && !response.isCommitted()) {
+ Filter filter = filters[current++];
+ LOG.info("doFilter() on {}", filter);
+ filter.doFilter(request, response, this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Activator.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Activator.java
new file mode 100644
index 0000000..13ef30f
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Activator.java
@@ -0,0 +1,153 @@
+/**
+ * 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.dosgi.dsw.osgi;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.aries.rsa.spi.DistributionProvider;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.dosgi.dsw.handlers.CXFDistributionProvider;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.qos.DefaultIntentMapFactory;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
+import org.apache.cxf.dosgi.dsw.qos.IntentMap;
+import org.apache.cxf.dosgi.dsw.qos.IntentTracker;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+// registered as spring bean -> start / stop called accordingly
+public class Activator implements ManagedService, BundleActivator {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
+ private static final int DEFAULT_INTENT_TIMEOUT = 30000;
+ private static final String CONFIG_SERVICE_PID = "cxf-dsw";
+ private ServiceRegistration<?> rsaFactoryReg;
+ private ServiceRegistration<?> decoratorReg;
+ private IntentTracker intentTracker;
+ private HttpServiceManager httpServiceManager;
+ private BundleContext bc;
+ private BundleListener bundleListener;
+ private Dictionary<String, Object> curConfiguration;
+ private Bus bus;
+
+ public void start(BundleContext bundlecontext) throws Exception {
+ LOG.debug("RemoteServiceAdmin Implementation is starting up");
+ this.bc = bundlecontext;
+ // Disable the fast infoset as it's not compatible (yet) with OSGi
+ System.setProperty("org.apache.cxf.nofastinfoset", "true");
+ curConfiguration = getDefaultConfig();
+ init(curConfiguration);
+ registerManagedService(bc);
+ }
+
+ private Dictionary<String, Object> getDefaultConfig() {
+ return new Hashtable<String, Object>();
+ }
+
+ private synchronized void init(Dictionary<String, Object> config) {
+ bus = BusFactory.newInstance().createBus();
+
+ String httpBase = (String) config.get(org.apache.cxf.dosgi.dsw.osgi.Constants.HTTP_BASE);
+ String cxfServletAlias = (String) config.get(org.apache.cxf.dosgi.dsw.osgi.Constants.CXF_SERVLET_ALIAS);
+
+ IntentMap intentMap = new IntentMap(new DefaultIntentMapFactory().create());
+ intentTracker = new IntentTracker(bc, intentMap);
+ intentTracker.open();
+ IntentManager intentManager = new IntentManagerImpl(intentMap, DEFAULT_INTENT_TIMEOUT);
+ httpServiceManager = new HttpServiceManager(bc, httpBase, cxfServletAlias);
+ DistributionProvider cxfProvider
+ = new CXFDistributionProvider(bc, intentManager, httpServiceManager);
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ String[] supportedIntents = intentMap.keySet().toArray(new String[] {});
+ props.put(Constants.REMOTE_INTENTS_SUPPORTED, supportedIntents);
+ props.put(Constants.REMOTE_CONFIGS_SUPPORTED, cxfProvider.getSupportedTypes());
+ rsaFactoryReg = bc.registerService(DistributionProvider.class.getName(), cxfProvider, props);
+ }
+
+ private synchronized void uninit() {
+ if (decoratorReg != null) {
+ decoratorReg.unregister();
+ decoratorReg = null;
+ }
+ if (bundleListener != null) {
+ bc.removeBundleListener(bundleListener);
+ bundleListener = null;
+ }
+ if (rsaFactoryReg != null) {
+ // This also triggers the unimport and unexport of the remote services
+ rsaFactoryReg.unregister();
+ rsaFactoryReg = null;
+ }
+ if (httpServiceManager != null) {
+ httpServiceManager.close();
+ httpServiceManager = null;
+ }
+ if (intentTracker != null) {
+ intentTracker.close();
+ intentTracker = null;
+ }
+ }
+
+ private void registerManagedService(BundleContext bundlecontext) {
+ Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put(Constants.SERVICE_PID, CONFIG_SERVICE_PID);
+ // No need to store the registration. Will be unregistered in stop by framework
+ bundlecontext.registerService(ManagedService.class.getName(), this, props);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ LOG.debug("RemoteServiceAdmin Implementation is shutting down now");
+ uninit();
+ shutdownCXFBus();
+ }
+
+ /**
+ * Causes also the shutdown of the embedded HTTP server
+ */
+ private void shutdownCXFBus() {
+ if (bus != null) {
+ LOG.debug("Shutting down the CXF Bus");
+ bus.shutdown(true);
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public synchronized void updated(Dictionary config) throws ConfigurationException {
+ LOG.debug("RemoteServiceAdmin Implementation configuration is updated with {}", config);
+ // config is null if it doesn't exist, is being deleted or has not yet been loaded
+ // in which case we run with defaults (just like we do manually when bundle is first started)
+ Dictionary<String, Object> configMap = config == null ? getDefaultConfig() : config;
+ if (!configMap.equals(curConfiguration)) { // only if something actually changed
+ curConfiguration = configMap;
+ uninit();
+ init(configMap);
+ }
+ }
+
+}
[2/5] cxf-dosgi git commit: [DOSGI-242] Refactor provider, Cleanup
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java
new file mode 100644
index 0000000..678a495
--- /dev/null
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java
@@ -0,0 +1,424 @@
+/**
+ * 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.dosgi.dsw.handlers.pojo;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.aries.rsa.util.EndpointHelper;
+import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
+import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
+import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
+import org.apache.cxf.dosgi.dsw.qos.IntentMap;
+import org.apache.cxf.dosgi.dsw.util.ServerWrapper;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.easymock.IMocksControl;
+import org.junit.Assert;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+
+public class PojoConfigurationTypeHandlerTest extends TestCase {
+
+ public void testGetPojoAddressEndpointURI() {
+ IntentManager intentManager = new IntentManagerImpl(new IntentMap());
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
+ intentManager,
+ dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ String url = "http://somewhere:1234/blah";
+ sd.put(RemoteConstants.ENDPOINT_ID, url);
+ assertEquals(url, handler.getServerAddress(sd, String.class));
+ }
+
+ private HttpServiceManager dummyHttpServiceManager() {
+ return new HttpServiceManager(null, null, null, null);
+ }
+
+ public void testGetPojoAddressEndpointCxf() {
+ IntentManager intentManager = new IntentManagerImpl(new IntentMap());
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
+ intentManager,
+ dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ String url = "http://somewhere:29/boo";
+ sd.put("org.apache.cxf.ws.address", url);
+ assertEquals(url, handler.getServerAddress(sd, String.class));
+ }
+
+ public void testGetPojoAddressEndpointPojo() {
+ IntentManager intentManager = new IntentManagerImpl(new IntentMap());
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
+ intentManager,
+ dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ String url = "http://somewhere:32768/foo";
+ sd.put("osgi.remote.configuration.pojo.address", url);
+ assertEquals(url, handler.getServerAddress(sd, String.class));
+ }
+
+ public void testGetDefaultPojoAddress() {
+ IntentManager intentManager = new IntentManagerImpl(new IntentMap());
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
+ intentManager,
+ dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ assertEquals("/java/lang/String", handler.getServerAddress(sd, String.class));
+ }
+
+ // todo: add test for data bindings
+ public void testCreateProxy() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext bc1 = c.createMock(BundleContext.class);
+
+ BundleContext requestingContext = c.createMock(BundleContext.class);
+
+ final ClientProxyFactoryBean cpfb = c.createMock(ClientProxyFactoryBean.class);
+ ReflectionServiceFactoryBean sf = c.createMock(ReflectionServiceFactoryBean.class);
+ EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
+ IntentManager intentManager = new IntentManagerImpl(new IntentMap()) {
+ @Override
+ public String[] applyIntents(List<Feature> features,
+ AbstractEndpointFactory factory,
+ Map<String, Object> sd) {
+ return new String[0];
+ }
+ };
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc1,
+ intentManager,
+ dummyHttpServiceManager()) {
+ @Override
+ protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return cpfb;
+ }
+ };
+
+ Class<?>[] exportedInterfaces = new Class[]{Runnable.class};
+
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(RemoteConstants.ENDPOINT_ID, "http://google.de/");
+ EndpointHelper.addObjectClass(props, exportedInterfaces);
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[]{"my.config"});
+ EndpointDescription endpoint = new EndpointDescription(props);
+
+ cpfb.setAddress((String)EasyMock.eq(props.get(RemoteConstants.ENDPOINT_ID)));
+ EasyMock.expectLastCall().atLeastOnce();
+
+ cpfb.setServiceClass(EasyMock.eq(Runnable.class));
+ EasyMock.expectLastCall().atLeastOnce();
+
+ c.replay();
+ ClassLoader cl = null;
+ Object proxy = p.importEndpoint(cl, requestingContext, exportedInterfaces, endpoint);
+ assertNotNull(proxy);
+ assertTrue("Proxy is not of the requested type! ", proxy instanceof Runnable);
+ c.verify();
+ }
+
+ public void testCreateServerWithAddressProperty() throws Exception {
+ BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(dswContext);
+
+ String myService = "Hi";
+ final ServerFactoryBean sfb = createMockServerFactoryBean();
+
+ IntentMap intentMap = new IntentMap();
+ IntentManager intentManager = new IntentManagerImpl(intentMap) {
+ @Override
+ public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory,
+ Map<String, Object> sd) {
+ return new String[]{};
+ }
+ };
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, intentManager,
+ dummyHttpServiceManager()) {
+ @Override
+ protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return sfb;
+ }
+ };
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bundleContext);
+
+ Class<?>[] exportedInterface = new Class[]{String.class};
+ Map<String, Object> props = new HashMap<String, Object>();
+ EndpointHelper.addObjectClass(props, exportedInterface);
+ props.put(Constants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
+
+ Endpoint exportResult = p.exportService(myService, bundleContext, props, exportedInterface);
+ Map<String, Object> edProps = exportResult.description().getProperties();
+
+ assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
+ assertEquals(1, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)).length);
+ assertEquals(Constants.WS_CONFIG_TYPE, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS))[0]);
+ assertEquals("http://alternate_host:80/myString", edProps.get(RemoteConstants.ENDPOINT_ID));
+ }
+
+ public void testAddressing() throws Exception {
+ runAddressingTest(new HashMap<String, Object>(), "http://localhost:9000/java/lang/Runnable");
+
+ Map<String, Object> p1 = new HashMap<String, Object>();
+ p1.put("org.apache.cxf.ws.address", "http://somewhere");
+ runAddressingTest(p1, "http://somewhere");
+
+ Map<String, Object> p2 = new HashMap<String, Object>();
+ p2.put("org.apache.cxf.rs.address", "https://somewhereelse");
+ runAddressingTest(p2, "https://somewhereelse");
+
+ Map<String, Object> p3 = new HashMap<String, Object>();
+ p3.put("org.apache.cxf.ws.port", 65535);
+ runAddressingTest(p3, "http://localhost:65535/java/lang/Runnable");
+
+ Map<String, Object> p4 = new HashMap<String, Object>();
+ p4.put("org.apache.cxf.ws.port", "8181");
+ runAddressingTest(p4, "http://localhost:8181/java/lang/Runnable");
+ }
+
+ private void runAddressingTest(Map<String, Object> properties, String expectedAddress) throws Exception {
+ Class<?>[] exportedInterface = new Class[]{Runnable.class};
+ EndpointHelper.addObjectClass(properties, exportedInterface);
+ BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+ String expectedUUID = UUID.randomUUID().toString();
+ EasyMock.expect(dswContext.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn(expectedUUID);
+ EasyMock.replay(dswContext);
+
+ IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
+ EasyMock.replay(intentManager);
+
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswContext,
+ intentManager,
+ dummyHttpServiceManager()) {
+ @Override
+ protected Endpoint createServerFromFactory(ServerFactoryBean factory,
+ EndpointDescription epd) {
+ return new ServerWrapper(epd, null);
+ }
+ };
+ Runnable myService = EasyMock.createMock(Runnable.class);
+ EasyMock.replay(myService);
+
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bundleContext);
+
+ Endpoint result = handler.exportService(myService, bundleContext, properties, exportedInterface);
+ Map<String, Object> props = result.description().getProperties();
+ assertEquals(expectedAddress, props.get("org.apache.cxf.ws.address"));
+ Assert.assertArrayEquals(new String[] {"org.apache.cxf.ws"},
+ (String[]) props.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
+ Assert.assertArrayEquals(new String[] {"java.lang.Runnable"},
+ (String[]) props.get(org.osgi.framework.Constants.OBJECTCLASS));
+ }
+
+ public void t2estCreateServerException() {
+ BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(dswContext);
+
+ IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
+ EasyMock.replay(intentManager);
+
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswContext,
+ intentManager,
+ dummyHttpServiceManager()) {
+ @Override
+ protected Endpoint createServerFromFactory(ServerFactoryBean factory,
+ EndpointDescription epd) {
+ throw new TestException();
+ }
+ };
+
+ Map<String, Object> props = new HashMap<String, Object>();
+
+ Runnable myService = EasyMock.createMock(Runnable.class);
+ EasyMock.replay(myService);
+ try {
+ handler.exportService(myService, null, props, new Class[]{Runnable.class});
+ fail("Expected TestException");
+ } catch (TestException e) {
+ // Expected
+ }
+ }
+
+ private ServerFactoryBean createMockServerFactoryBean() {
+ ReflectionServiceFactoryBean sf = EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
+ EasyMock.replay(sf);
+
+ final StringBuilder serverURI = new StringBuilder();
+
+ ServerFactoryBean sfb = EasyMock.createNiceMock(ServerFactoryBean.class);
+ Server server = createMockServer(sfb);
+
+ EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();
+ EasyMock.expect(sfb.create()).andReturn(server);
+ sfb.setAddress((String) EasyMock.anyObject());
+ EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ serverURI.setLength(0);
+ serverURI.append(EasyMock.getCurrentArguments()[0]);
+ return null;
+ }
+ });
+ EasyMock.expect(sfb.getAddress()).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return serverURI.toString();
+ }
+ });
+ EasyMock.replay(sfb);
+ return sfb;
+ }
+
+ private Server createMockServer(final ServerFactoryBean sfb) {
+ AttributedURIType addr = EasyMock.createMock(AttributedURIType.class);
+ EasyMock.expect(addr.getValue()).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return sfb.getAddress();
+ }
+ });
+ EasyMock.replay(addr);
+
+ EndpointReferenceType er = EasyMock.createMock(EndpointReferenceType.class);
+ EasyMock.expect(er.getAddress()).andReturn(addr);
+ EasyMock.replay(er);
+
+ Destination destination = EasyMock.createMock(Destination.class);
+ EasyMock.expect(destination.getAddress()).andReturn(er);
+ EasyMock.replay(destination);
+
+ Server server = EasyMock.createNiceMock(Server.class);
+ EasyMock.expect(server.getDestination()).andReturn(destination);
+ EasyMock.replay(server);
+ return server;
+ }
+
+ public void testCreateEndpointProps() {
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
+ EasyMock.replay(bc);
+
+ IntentManager intentManager = new IntentManagerImpl(new IntentMap());
+ PojoConfigurationTypeHandler pch = new PojoConfigurationTypeHandler(bc,
+ intentManager,
+ dummyHttpServiceManager());
+ Class<?>[] exportedInterfaces = new Class[] {String.class};
+ Map<String, Object> sd = new HashMap<String, Object>();
+ sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
+ EndpointHelper.addObjectClass(sd, exportedInterfaces);
+ EndpointDescription epd = pch.createEndpointDesc(sd, new String[] {"org.apache.cxf.ws"},
+ "http://localhost:12345", new String[] {"my_intent", "your_intent"});
+
+ assertEquals("http://localhost:12345", epd.getId());
+ assertEquals(Arrays.asList("java.lang.String"), epd.getInterfaces());
+ assertEquals(Arrays.asList("org.apache.cxf.ws"), epd.getConfigurationTypes());
+ assertEquals(Arrays.asList("my_intent", "your_intent"), epd.getIntents());
+ assertEquals(new Version("0.0.0"), epd.getPackageVersion("java.lang"));
+ }
+
+ public void t2estCreateJaxWsEndpointWithoutIntents() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext dswBC = c.createMock(BundleContext.class);
+
+ IntentManager intentManager = new DummyIntentManager();
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC,
+ intentManager,
+ dummyHttpServiceManager());
+
+ Map<String, Object> sd = new HashMap<String, Object>();
+ sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere");
+ BundleContext serviceBC = c.createMock(BundleContext.class);
+ Object myService = null;
+ c.replay();
+
+ ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(myService,
+ serviceBC,
+ sd,
+ new Class[]{MyJaxWsEchoService.class});
+ c.verify();
+
+ org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
+ QName bindingName = ep.getEndpointInfo().getBinding().getName();
+ Assert.assertEquals(JaxWsEndpointImpl.class, ep.getClass());
+ Assert.assertEquals(new QName("http://jaxws.handlers.dsw.dosgi.cxf.apache.org/",
+ "MyJaxWsEchoServiceServiceSoapBinding"),
+ bindingName);
+ }
+
+ public void t2estCreateSimpleEndpointWithoutIntents() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext dswBC = c.createMock(BundleContext.class);
+
+ IntentManager intentManager = new DummyIntentManager();
+ PojoConfigurationTypeHandler handler
+ = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere_else");
+ BundleContext serviceBC = c.createMock(BundleContext.class);
+ c.replay();
+ ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(null, serviceBC, sd,
+ new Class[]{MySimpleEchoService.class});
+ c.verify();
+
+ org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
+ QName bindingName = ep.getEndpointInfo().getBinding().getName();
+ Assert.assertEquals(EndpointImpl.class, ep.getClass());
+ Assert.assertEquals(new QName("http://simple.handlers.dsw.dosgi.cxf.apache.org/",
+ "MySimpleEchoServiceSoapBinding"),
+ bindingName);
+ }
+
+ public static class DummyIntentManager implements IntentManager {
+
+ @Override
+ public String[] applyIntents(List<Feature> features,
+ AbstractEndpointFactory factory,
+ Map<String, Object> props) {
+ return new String[]{};
+ }
+
+ @Override
+ public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class TestException extends RuntimeException {
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java
new file mode 100644
index 0000000..72e578b
--- /dev/null
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java
@@ -0,0 +1,195 @@
+/**
+ * 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.dosgi.dsw.handlers.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
+import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
+import org.apache.cxf.jaxrs.provider.aegis.AegisElementProvider;
+import org.easymock.EasyMock;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+
+public class JaxRSUtilsTest extends TestCase {
+
+ private void addRequiredProps(Map<String, Object> props) {
+ props.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myGreatConfiguration");
+ props.put(org.osgi.framework.Constants.OBJECTCLASS, new String[] {"my.class"});
+ }
+
+ public void testNoGlobalProviders() {
+ Map<String, Object> props = new HashMap<String, Object>();
+ addRequiredProps(props);
+ props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
+
+ assertEquals(0, JaxRSUtils.getProviders(null, props).size());
+ }
+
+ public void testAegisProvider() {
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.RS_DATABINDING_PROP_KEY, "aegis");
+ props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
+
+ addRequiredProps(props);
+
+ List<Object> providers = JaxRSUtils.getProviders(null, props);
+ assertEquals(1, providers.size());
+ assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void testServiceProviders() {
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.RS_PROVIDER_PROP_KEY, new Object[] {
+ new AegisElementProvider()
+ });
+ props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
+ addRequiredProps(props);
+
+ List<Object> providers = JaxRSUtils.getProviders(null, props);
+ assertEquals(1, providers.size());
+ assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
+ }
+
+ public void testServiceProviderProperty() throws Exception {
+ BundleContext bc = EasyMock.createMock(BundleContext.class);
+ Bundle bundle = EasyMock.createMock(Bundle.class);
+ bc.getBundle();
+ EasyMock.expectLastCall().andReturn(bundle).times(2);
+ bundle.loadClass(AegisElementProvider.class.getName());
+ EasyMock.expectLastCall().andReturn(AegisElementProvider.class);
+ bundle.loadClass(JAXBElementProvider.class.getName());
+ EasyMock.expectLastCall().andReturn(JAXBElementProvider.class);
+ EasyMock.replay(bc, bundle);
+
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.RS_PROVIDER_PROP_KEY,
+ "\r\n " + AegisElementProvider.class.getName() + " , \r\n"
+ + JAXBElementProvider.class.getName() + "\r\n");
+
+ props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
+ addRequiredProps(props);
+
+ List<Object> providers = JaxRSUtils.getProviders(bc, props);
+ assertEquals(2, providers.size());
+ assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
+ assertEquals(JAXBElementProvider.class.getName(), providers.get(1).getClass().getName());
+ }
+
+ public void testServiceProviderStrings() throws Exception {
+ BundleContext bc = EasyMock.createMock(BundleContext.class);
+ Bundle bundle = EasyMock.createMock(Bundle.class);
+ bc.getBundle();
+ EasyMock.expectLastCall().andReturn(bundle).times(2);
+ bundle.loadClass(AegisElementProvider.class.getName());
+ EasyMock.expectLastCall().andReturn(AegisElementProvider.class);
+ bundle.loadClass(JAXBElementProvider.class.getName());
+ EasyMock.expectLastCall().andReturn(JAXBElementProvider.class);
+ EasyMock.replay(bc, bundle);
+
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.RS_PROVIDER_PROP_KEY, new String[] {
+ "\r\n " + AegisElementProvider.class.getName(),
+ JAXBElementProvider.class.getName() + "\r\n"
+ });
+
+ props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
+ addRequiredProps(props);
+
+ List<Object> providers = JaxRSUtils.getProviders(bc, props);
+ assertEquals(2, providers.size());
+ assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
+ assertEquals(JAXBElementProvider.class.getName(), providers.get(1).getClass().getName());
+ }
+
+ @SuppressWarnings({
+ "rawtypes", "unchecked"
+ })
+ public void testCustomGlobalProvider() throws Exception {
+ ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
+ EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
+ sref.getProperty(Constants.RS_PROVIDER_EXPECTED_PROP_KEY);
+ EasyMock.expectLastCall().andReturn(false);
+ bc.getService(sref);
+ AegisElementProvider<?> p = new AegisElementProvider();
+ EasyMock.expectLastCall().andReturn(p);
+ EasyMock.replay(bc, sref);
+ Map<String, Object> props = new HashMap<String, Object>();
+ addRequiredProps(props);
+
+ List<Object> providers = JaxRSUtils.getProviders(bc, props);
+ assertEquals(1, providers.size());
+ assertSame(p, providers.get(0));
+ }
+
+ @SuppressWarnings({
+ "rawtypes", "unchecked"
+ })
+ public void testNoCustomGlobalProvider() throws Exception {
+ ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
+ EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
+ sref.getProperty(Constants.RS_PROVIDER_PROP_KEY);
+ EasyMock.expectLastCall().andReturn(false);
+ bc.getService(sref);
+ AegisElementProvider<?> p = new AegisElementProvider();
+ EasyMock.expectLastCall().andReturn(p);
+ EasyMock.replay(bc);
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.RS_PROVIDER_EXPECTED_PROP_KEY, "true");
+ addRequiredProps(props);
+
+ List<Object> providers = JaxRSUtils.getProviders(bc, props);
+ assertEquals(0, providers.size());
+ }
+
+ @SuppressWarnings({
+ "rawtypes", "unchecked"
+ })
+ public void testCustomGlobalProviderExpected() throws Exception {
+ ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
+ EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
+ sref.getProperty(Constants.RS_PROVIDER_PROP_KEY);
+ EasyMock.expectLastCall().andReturn(true);
+ bc.getService(sref);
+ AegisElementProvider<?> p = new AegisElementProvider();
+ EasyMock.expectLastCall().andReturn(p);
+ EasyMock.replay(bc, sref);
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.RS_PROVIDER_EXPECTED_PROP_KEY, "true");
+ addRequiredProps(props);
+
+ List<Object> providers = JaxRSUtils.getProviders(bc, props);
+ assertEquals(1, providers.size());
+ assertSame(p, providers.get(0));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java
deleted file mode 100644
index fde48d2..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java
+++ /dev/null
@@ -1,341 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.hooks;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CxfFindListenerHookTest extends Assert {
-
- @Test
- public void testDUMMY() throws Exception {
- }
-
-// private IMocksControl control;
-//
-// @Before
-// public void setUp() {
-// control = EasyMock.createNiceControl();
-// }
-
- /* Todo this test doesn't apply at the moment since the ListenerHook doesn't
- * have a serviceReferencesRequested() API (yet).
- @Test
- public void testSyncListenerHook() throws Exception {
- Bundle bundle = control.createMock(Bundle.class);
- bundle.findEntries(EasyMock.eq("OSGI-INF/remote-service"),
- EasyMock.eq("*.xml"), EasyMock.anyBoolean());
- EasyMock.expectLastCall().andReturn(Collections.enumeration(
- Arrays.asList(getClass().getResource("/OSGI-INF/remote-service/remote-services.xml"))));
- Dictionary<String, String> bundleHeaders = new Hashtable<String, String>();
- bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME,
- "Test Bundle");
- bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION,
- "1.0.0");
- bundle.getHeaders();
- EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes();
- bundle.loadClass(TestService.class.getName());
- EasyMock.expectLastCall().andReturn(TestService.class).anyTimes();
- final BundleContext requestingContext = control.createMock(BundleContext.class);
- requestingContext.getBundle();
- EasyMock.expectLastCall().andReturn(bundle).anyTimes();
-
- BundleTestContext dswContext = new BundleTestContext(bundle);
- dswContext.addServiceReference(TestService.class.getName(),
- control.createMock(ServiceReference.class));
- control.replay();
-
- CxfListenerHook hook = new CxfListenerHook(dswContext, null);
-
- // TODO : if the next call ends up being executed in a thread of its own then
- // update the test accordingly, use Futures for ex
-
- hook.serviceReferencesRequested(requestingContext,
- TestService.class.getName(), null, true);
-
- List<ServiceReference> registeredRefs = dswContext.getRegisteredReferences();
- assertNotNull(registeredRefs);
- assertEquals(1, registeredRefs.size());
- } */
-
-// @Test
-// public void testTrackerPropertiesOnlyClassInFilterWithMatchingInterface() throws Exception {
-// String filter = "(objectClass=" + TestService.class.getName() + ")";
-// doTestTrackerPropertiesSet(filter,
-// "osgi.remote.discovery.interest.interfaces",
-// TestService.class.getName(),
-// asList(TestService.class.getName()),
-// Collections.EMPTY_SET);
-// }
-//
-// @Test
-// public void testTrackerPropertiesGenericFilterWithMatchingInterface() throws Exception {
-// String filter = "(&(objectClass=" + TestService.class.getName()
-// + ")(colour=blue))";
-// doTestTrackerPropertiesSet(filter,
-// "osgi.remote.discovery.interest.filters",
-// replacePredicate(filter),
-// asList(TestService.class.getName()),
-// Collections.EMPTY_SET);
-// }
-//
-// @Test
-// public void testTrackerPropertiesOnlyClassInFilterWithMatchingFilter() throws Exception {
-// String filter = "(objectClass=" + TestService.class.getName() + ")";
-// doTestTrackerPropertiesSet(filter,
-// "osgi.remote.discovery.interest.interfaces",
-// TestService.class.getName(),
-// Collections.EMPTY_SET,
-// asList(replacePredicate(filter)));
-// }
-//
-// @Test
-// public void testTrackerPropertiesGenericFilterWithMatchingFilter() throws Exception {
-// String filter = "(&(objectClass=" + TestService.class.getName()
-// + ")(colour=blue))";
-// doTestTrackerPropertiesSet(filter,
-// "osgi.remote.discovery.interest.filters",
-// replacePredicate(filter),
-// Collections.EMPTY_SET,
-// asList(replacePredicate(filter)));
-// }
-//
-// @Test
-// public void testTrackerPropertiesOnlyClassInFilterWithMatchingBoth() throws Exception {
-// String filter = "(objectClass=" + TestService.class.getName() + ")";
-// doTestTrackerPropertiesSet(filter,
-// "osgi.remote.discovery.interest.interfaces",
-// TestService.class.getName(),
-// asList(TestService.class.getName()),
-// asList(replacePredicate(filter)));
-// }
-//
-// @Test
-// public void testTrackerPropertiesGenericFilterWithMatchingBoth() throws Exception {
-// String filter = "(&(objectClass=" + TestService.class.getName()
-// + ")(colour=blue))";
-// doTestTrackerPropertiesSet(filter,
-// "osgi.remote.discovery.interest.filters",
-// replacePredicate(filter),
-// Collections.EMPTY_SET,
-// asList(replacePredicate(filter)));
-// }
-//
-// private void doTestTrackerPropertiesSet(final String filter,
-// String propKey,
-// String propValue,
-// Collection matchingInterfaces,
-// Collection matchingFilters) throws Exception {
-// Bundle bundle = control.createMock(Bundle.class);
-// Dictionary<String, String> bundleHeaders = new Hashtable<String, String>();
-// bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME,
-// "Test Bundle");
-// bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION,
-// "1.0.0");
-// bundle.getHeaders();
-// EasyMock.expectLastCall().andReturn(bundleHeaders).times(2);
-// final String serviceClass = TestService.class.getName();
-// bundle.loadClass(serviceClass);
-// EasyMock.expectLastCall().andReturn(TestService.class).times(2);
-// final BundleContext requestingContext = control.createMock(BundleContext.class);
-//
-// BundleTestContext dswContext = new BundleTestContext(bundle);
-// ServiceRegistration serviceRegistration = control.createMock(ServiceRegistration.class);
-// dswContext.addServiceRegistration(serviceClass, serviceRegistration);
-// serviceRegistration.unregister();
-// EasyMock.expectLastCall().times(1);
-// ServiceReference serviceReference = control.createMock(ServiceReference.class);
-// dswContext.addServiceReference(serviceClass, serviceReference);
-//
-// final String trackerClass = DiscoveredServiceTracker.class.getName();
-// ServiceRegistration trackerRegistration = control.createMock(ServiceRegistration.class);
-// dswContext.addServiceRegistration(trackerClass, trackerRegistration);
-// ServiceReference trackerReference = control.createMock(ServiceReference.class);
-// dswContext.addServiceReference(trackerClass, trackerReference);
-//
-// List property = asList(propValue);
-// Dictionary properties = new Hashtable();
-// properties.put(propKey, property);
-// trackerRegistration.setProperties(properties);
-// EasyMock.expectLastCall();
-//
-// if (matchingInterfaces.size() == 0 && matchingFilters.size() > 0) {
-// Iterator filters = matchingFilters.iterator();
-// while (filters.hasNext()) {
-// Filter f = control.createMock(Filter.class);
-// dswContext.addFilter((String)filters.next(), f);
-// f.match(EasyMock.isA(Dictionary.class));
-// EasyMock.expectLastCall().andReturn(true);
-// }
-// }
-//
-// control.replay();
-//
-// CxfFindListenerHook hook = new CxfFindListenerHook(dswContext, null);
-//
-// ListenerHook.ListenerInfo info = new ListenerHook.ListenerInfo() {
-// public BundleContext getBundleContext() {
-// return requestingContext;
-// }
-//
-// public String getFilter() {
-// return filter;
-// }
-//
-// public boolean isRemoved() {
-// return false;
-// }
-// };
-// hook.added(Collections.singleton(info));
-//
-// DiscoveredServiceTracker tracker = (DiscoveredServiceTracker)
-// dswContext.getService(trackerReference);
-// assertNotNull(tracker);
-//
-// Collection interfaces = asList(serviceClass);
-//
-// notifyAvailable(tracker, matchingInterfaces, matchingFilters, "1234");
-// notifyAvailable(tracker, matchingInterfaces, matchingFilters, "5678");
-// notifyAvailable(tracker, matchingInterfaces, matchingFilters, "1234");
-//
-// notifyUnAvailable(tracker, "1234");
-// notifyUnAvailable(tracker, "5678");
-//
-// notifyAvailable(tracker, matchingInterfaces, matchingFilters , "1234");
-//
-// control.verify();
-//
-// Map<String, ServiceReference> registeredRefs = dswContext.getRegisteredReferences();
-// assertNotNull(registeredRefs);
-// assertEquals(2, registeredRefs.size());
-// assertNotNull(registeredRefs.get(serviceClass));
-// assertSame(serviceReference, registeredRefs.get(serviceClass));
-//
-// Map<String, ServiceRegistration> registeredRegs = dswContext.getRegisteredRegistrations();
-// assertNotNull(registeredRegs);
-// assertEquals(2, registeredRegs.size());
-// assertNotNull(registeredRegs.get(trackerClass));
-// assertSame(trackerRegistration, registeredRegs.get(trackerClass));
-//
-// List<Object> registeredServices = dswContext.getRegisteredServices();
-// assertNotNull(registeredServices);
-// assertEquals(2, registeredServices.size());
-// }
-//
-// @Test
-// public void testConstructorAndGetters() {
-// BundleContext bc = control.createMock(BundleContext.class);
-// CxfRemoteServiceAdmin dp = control.createMock(CxfRemoteServiceAdmin.class);
-// control.replay();
-//
-// CxfFindListenerHook clh = new CxfFindListenerHook(bc, dp);
-// assertSame(bc, clh.getContext());
-// assertSame(dp, clh.getDistributionProvider());
-// }
-//
-// @Test
-// public void testFindHook() {
-// BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-//
-// final List<String> lookupCalls = new ArrayList<String>();
-// CxfFindListenerHook fh = new CxfFindListenerHook(bc, null) {
-// @Override
-// protected synchronized void lookupDiscoveryService(
-// String interfaceName, String filterValue) {
-// lookupCalls.add(interfaceName);
-// lookupCalls.add(filterValue);
-// }
-// };
-//
-// String clazz = "my.app.Class";
-// String filter = "&(A=B)(C=D)";
-// fh.find(null, clazz, filter, true, null);
-//
-// assertEquals(Arrays.asList(clazz, filter), lookupCalls);
-// }
-//
-// private void notifyAvailable(DiscoveredServiceTracker tracker,
-// Collection interfaces,
-// Collection filters,
-// String endpointId) {
-// Map<String, Object> props = new Hashtable<String, Object>();
-// props.put("osgi.remote.interfaces", "*");
-// props.put("osgi.remote.endpoint.id", endpointId);
-// tracker.serviceChanged(new Notification(AVAILABLE,
-// TestService.class.getName(),
-// interfaces,
-// filters,
-// props));
-// }
-//
-// private void notifyUnAvailable(DiscoveredServiceTracker tracker,
-// String endpointId) {
-// Map<String, Object> props = new Hashtable<String, Object>();
-// props.put("osgi.remote.endpoint.id", endpointId);
-// tracker.serviceChanged(new Notification(UNAVAILABLE,
-// TestService.class.getName(),
-// Collections.EMPTY_SET,
-// Collections.EMPTY_SET,
-// props));
-// }
-//
-// private List<String> asList(String s) {
-// List l = new ArrayList<String>();
-// l.add(s);
-// return l;
-// }
-//
-// private String replacePredicate(String filter) {
-// return filter.replace("objectClass", ServicePublication.SERVICE_INTERFACE_NAME);
-// }
-//
-// private class Notification implements DiscoveredServiceNotification {
-// private int type;
-// private ServiceEndpointDescription sed;
-// private Collection interfaces;
-// private Collection filters;
-//
-// Notification(int type,
-// String interfaceName,
-// Collection interfaces,
-// Collection filters,
-// Map<String, Object> props) {
-// this.type = type;
-// this.sed = new ServiceEndpointDescriptionImpl(interfaceName, props);
-// this.interfaces = interfaces;
-// this.filters = filters;
-// }
-//
-// public int getType() {
-// return type;
-// }
-//
-// public ServiceEndpointDescription getServiceEndpointDescription() {
-// return sed;
-// }
-//
-// public Collection getInterfaces() {
-// return interfaces;
-// }
-//
-// public Collection getFilters() {
-// return filters;
-// }
-// }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
deleted file mode 100644
index 40b40c5..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
+++ /dev/null
@@ -1,299 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.hooks;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CxfPublishHookTest extends Assert {
-
- @Test
- public void testDUMMY() throws Exception {
- }
-
- //
- // private IMocksControl control;
- //
- // @Before
- // public void setUp() {
- // control = EasyMock.createNiceControl();
- // }
- //
- // @Test
- // public void testPublishSingleInterface() throws Exception {
- // String[] serviceNames = new String[]{TestService.class.getName()};
- // String[] addresses = new String[]{"http://localhost:9000/hello"};
- // doTestPublishHook("remote-services.xml", serviceNames, addresses);
- // }
- //
- // @Test
- // public void testPublishSingleInterfaceAltFormat() throws Exception {
- // String[] serviceNames = new String[]{TestService.class.getName()};
- // String[] addresses = new String[]{"http://localhost:9000/hello"};
- // doTestPublishHook("alt-remote-services.xml", serviceNames, addresses);
- // }
- //
- // @Test
- // public void testPublishMultiInterface() throws Exception {
- // String[] serviceNames = new String[]{TestService.class.getName(),
- // AdditionalInterface.class.getName()};
- // String[] addresses = new String[]{"http://localhost:9001/hello",
- // "http://localhost:9002/hello"};
- // doTestPublishHook("multi-services.xml", serviceNames, addresses);
- // }
- //
- // @SuppressWarnings("unchecked")
- // private void doTestPublishHook(String remoteServices,
- // String[] serviceNames,
- // String[] addresses) throws Exception {
- //
- // Bundle bundle = control.createMock(Bundle.class);
- // bundle.findEntries(EasyMock.eq("OSGI-INF/remote-service"),
- // EasyMock.eq("*.xml"), EasyMock.anyBoolean());
- // EasyMock.expectLastCall().andReturn(Collections.enumeration(
- // Arrays.asList(getClass().getResource("/OSGI-INF/remote-service/" + remoteServices))));
- // Dictionary<String, String> bundleHeaders = new Hashtable<String, String>();
- // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME,
- // "Test Bundle");
- // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION,
- // "1.0.0");
- // bundle.getHeaders();
- // EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes();
- // BundleContext requestingContext = control.createMock(BundleContext.class);
- // bundle.getBundleContext();
- // EasyMock.expectLastCall().andReturn(requestingContext).anyTimes();
- //
- // TestService serviceObject = new TestServiceImpl();
- // Dictionary serviceProps = new Hashtable();
- //
- // ServiceReference sref = control.createMock(ServiceReference.class);
- // sref.getBundle();
- // EasyMock.expectLastCall().andReturn(bundle).anyTimes();
- // sref.getProperty(Constants.OBJECTCLASS);
- // EasyMock.expectLastCall().andReturn(serviceNames).anyTimes();
- // sref.getPropertyKeys();
- // EasyMock.expectLastCall().andReturn(new String[]{}).anyTimes();
- //
- // BundleTestContext dswContext = new BundleTestContext(bundle);
- //
- // ServiceRegistration[] serviceRegistrations =
- // new ServiceRegistration[serviceNames.length];
- //
- // for (int i = 0; i < serviceNames.length ; i++) {
- // serviceRegistrations[i] =
- // control.createMock(ServiceRegistration.class);
- // dswContext.addServiceRegistration(serviceNames[i],
- // serviceRegistrations[i]);
- // dswContext.addServiceReference(serviceNames[i], sref);
- // }
- // dswContext.registerService(serviceNames, serviceObject, serviceProps);
- //
- // Server server = control.createMock(Server.class);
- //
- // String publicationClass = ServicePublication.class.getName();
- // ServiceRegistration publicationRegistration =
- // control.createMock(ServiceRegistration.class);
- // publicationRegistration.unregister();
- // EasyMock.expectLastCall().times(serviceNames.length);
- // dswContext.addServiceRegistration(publicationClass, publicationRegistration);
- // ServiceReference publicationReference =
- // control.createMock(ServiceReference.class);
- // dswContext.addServiceReference(publicationClass, publicationReference);
- // control.replay();
- //
- // TestPublishHook hook = new TestPublishHook(dswContext,
- // serviceObject,
- // server);
- // hook.publishEndpoint(sref);
- // hook.verify();
- //
- // assertEquals(1, hook.getEndpoints().size());
- // List<EndpointInfo> list = hook.getEndpoints().get(sref);
- // assertNotNull(list);
- // assertEquals(serviceNames.length, list.size());
- // for (int i = 0; i < serviceNames.length; i++) {
- // assertNotNull(list.get(i));
- // ServiceEndpointDescription sd = list.get(i).getServiceDescription();
- // assertNotNull(sd);
- // assertNotNull(sd.getProvidedInterfaces());
- // assertEquals(1, sd.getProvidedInterfaces().size());
- // Collection names = sd.getProvidedInterfaces();
- // assertEquals(1, names.size());
- // assertEquals(serviceNames[i], names.toArray()[0]);
- // String excludeProp = "osgi.remote.interfaces";
- // assertNull(sd.getProperties().get(excludeProp));
- // String addrProp =
- // org.apache.cxf.dosgi.dsw.Constants.WS_ADDRESS_PROPERTY_OLD;
- // assertEquals(addresses[i], sd.getProperties().get(addrProp));
- // }
- //
- // Map<String, ServiceRegistration> registeredRegs =
- // dswContext.getRegisteredRegistrations();
- // assertNotNull(registeredRegs);
- // assertEquals(serviceNames.length + 1, registeredRegs.size());
- // assertNotNull(registeredRegs.get(publicationClass));
- // assertSame(publicationRegistration, registeredRegs.get(publicationClass));
- //
- // Map<String, List<Dictionary>> registeredProps =
- // dswContext.getRegisteredProperties();
- // assertNotNull(registeredProps);
- // assertEquals(serviceNames.length + 1, registeredProps.size());
- // assertNotNull(registeredProps.get(publicationClass));
- // List<Dictionary> propsList = registeredProps.get(publicationClass);
- // assertEquals(serviceNames.length, propsList.size());
- // for (Dictionary props : propsList) {
- // Collection interfaces =
- // (Collection)props.get(SERVICE_INTERFACE_NAME);
- // assertNotNull(interfaces);
- // assertTrue(interfaces.contains(TestService.class.getName())
- // || interfaces.contains(AdditionalInterface.class.getName()));
- // }
- //
- // hook.removeEndpoints();
- //
- // control.verify();
- // }
- //
- // @SuppressWarnings("unchecked")
- // @Test
- // public void testPublishMultipleTimes() {
- // Bundle bundle = control.createMock(Bundle.class);
- // bundle.findEntries(EasyMock.eq("OSGI-INF/remote-service"),
- // EasyMock.eq("*.xml"), EasyMock.anyBoolean());
- // EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- // public Object answer() throws Throwable {
- // return Collections.enumeration(Arrays.asList(
- // getClass().getResource("/OSGI-INF/remote-service/remote-services.xml")));
- // }
- // }).anyTimes();
- // Dictionary<String, String> bundleHeaders = new Hashtable<String, String>();
- // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME,
- // "org.apache.cxf.example.bundle");
- // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION,
- // "1.0.0");
- // bundle.getHeaders();
- // EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes();
- // BundleContext requestingContext = control.createMock(BundleContext.class);
- // bundle.getBundleContext();
- // EasyMock.expectLastCall().andReturn(requestingContext).anyTimes();
- //
- // TestService serviceObject = new TestServiceImpl();
- // Dictionary serviceProps = new Hashtable();
- //
- // ServiceReference sref = control.createMock(ServiceReference.class);
- // sref.getBundle();
- // EasyMock.expectLastCall().andReturn(bundle).anyTimes();
- // sref.getProperty(Constants.OBJECTCLASS);
- // String[] serviceNames = {TestService.class.getName()};
- // EasyMock.expectLastCall().andReturn(serviceNames).anyTimes();
- // sref.getPropertyKeys();
- // EasyMock.expectLastCall().andReturn(new String[]{}).anyTimes();
- //
- // BundleTestContext dswContext = new BundleTestContext(bundle);
- // ServiceRegistration[] serviceRegistrations =
- // new ServiceRegistration[serviceNames.length];
- // for (int i = 0; i < serviceNames.length ; i++) {
- // serviceRegistrations[i] =
- // control.createMock(ServiceRegistration.class);
- // dswContext.addServiceRegistration(serviceNames[i],
- // serviceRegistrations[i]);
- // dswContext.addServiceReference(serviceNames[i], sref);
- // }
- // dswContext.registerService(serviceNames, serviceObject, serviceProps);
- //
- // final Server server = control.createMock(Server.class);
- // control.replay();
- //
- // CxfPublishHook hook = new CxfPublishHook(dswContext, null) {
- // @Override
- // Server createServer(ServiceReference sref, ServiceEndpointDescription sd) {
- // return server;
- // }
- // };
- // assertNull("Precondition not met", hook.getEndpoints().get(sref));
- // hook.publishEndpoint(sref);
- // assertEquals(1, hook.getEndpoints().get(sref).size());
- //
- // hook.endpoints.put(sref, new ArrayList<EndpointInfo>());
- // assertEquals("Precondition failed", 0, hook.getEndpoints().get(sref).size());
- // hook.publishEndpoint(sref);
- // assertEquals(0, hook.getEndpoints().get(sref).size());
- //
- // control.verify();
- // }
- //
- // private static class TestPublishHook extends CxfPublishHook {
- //
- // private boolean called;
- // private TestService serviceObject;
- // private Server server;
- //
- // public TestPublishHook(BundleContext bc, TestService serviceObject,
- // Server s) {
- // super(bc, null);
- // this.serviceObject = serviceObject;
- // this.server = s;
- // }
- //
- // @Override
- // protected ConfigurationTypeHandler getHandler(ServiceEndpointDescription sd,
- // Map<String, Object> props) {
- // return new ConfigurationTypeHandler() {
- // public String getType() {
- // return "test";
- // }
- //
- // public Object createProxy(ServiceReference sr,
- // BundleContext dswContext, BundleContext callingContext,
- // Class<?> iClass, ServiceEndpointDescription sd) {
- // throw new UnsupportedOperationException();
- // }
- //
- // public Server createServer(ServiceReference sr,
- // BundleContext dswContext, BundleContext callingContext,
- // ServiceEndpointDescription sd, Class<?> iClass, Object serviceBean) {
- // Assert.assertSame(serviceBean, serviceObject);
- // TestPublishHook.this.setCalled();
- // Map props = sd.getProperties();
- // String address = (String)props.get(WS_ADDRESS_PROPERTY);
- // if (address != null) {
- // props.put(ENDPOINT_LOCATION, address);
- // }
- // return server;
- // }
- //
- // };
- // }
- //
- // public void setCalled() {
- // called = true;
- // }
- //
- // public void verify() {
- // Assert.assertTrue(called);
- // }
- // }
- //
- // public interface AdditionalInterface {
- // }
- //
- // private static class TestServiceImpl implements TestService, AdditionalInterface {
- //
- // }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
deleted file mode 100644
index c004702..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
+++ /dev/null
@@ -1,116 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.hooks;
-
-import junit.framework.TestCase;
-
-public class ServiceHookUtilsTest extends TestCase {
-
- public void testDUMMY() {
- assertTrue(true);
- }
-
-/*
- public void testCreateServer() {
- IMocksControl control = EasyMock.createNiceControl();
-
- Server srvr = control.createMock(Server.class);
- ServiceReference serviceReference = control.createMock(ServiceReference.class);
- BundleContext dswContext = control.createMock(BundleContext.class);
- BundleContext callingContext = control.createMock(BundleContext.class);
- ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl("java.lang.String");
- Object service = "hi";
-
- ConfigurationTypeHandler handler = control.createMock(ConfigurationTypeHandler.class);
- handler.createServer(serviceReference, dswContext, callingContext, sd, String.class, service);
- EasyMock.expectLastCall().andReturn(srvr);
- control.replay();
-
- assertSame(srvr,
- ServiceHookUtils.createServer(handler, serviceReference, dswContext, callingContext, sd, service));
- }
-
- public void testNoServerWhenNoInterfaceSpecified() {
- IMocksControl control = EasyMock.createNiceControl();
-
- Server srvr = control.createMock(Server.class);
- ServiceReference serviceReference = control.createMock(ServiceReference.class);
- BundleContext dswContext = control.createMock(BundleContext.class);
- BundleContext callingContext = control.createMock(BundleContext.class);
- ServiceEndpointDescription sd = mockServiceDescription(control, "Foo");
- Object service = "hi";
-
- ConfigurationTypeHandler handler = control.createMock(ConfigurationTypeHandler.class);
- handler.createServer(serviceReference, dswContext, callingContext, sd, String.class, service);
- EasyMock.expectLastCall().andReturn(srvr);
- control.replay();
-
- assertNull(ServiceHookUtils.createServer(handler, serviceReference, dswContext,
- callingContext, sd, service));
- }
-
- public void testPublish() throws Exception {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("foo", "bar");
- props.put(ServicePublication.ENDPOINT_LOCATION, "http:localhost/xyz");
- ServiceEndpointDescriptionImpl sed = new ServiceEndpointDescriptionImpl(String.class.getName(), props);
- assertEquals(new URI("http:localhost/xyz"), sed.getLocation());
-
- final Dictionary<String, Object> expectedProps = new Hashtable<String, Object>();
- expectedProps.put(ServicePublication.SERVICE_PROPERTIES, props);
- expectedProps.put(ServicePublication.SERVICE_INTERFACE_NAME, Collections.singleton(String.class.getName()));
- expectedProps.put(ServicePublication.ENDPOINT_LOCATION, new URI("http:localhost/xyz"));
-
- BundleContext bc = EasyMock.createMock(BundleContext.class);
- EasyMock.expect(bc.registerService(
- EasyMock.eq(ServicePublication.class.getName()),
- EasyMock.anyObject(),
- (Dictionary<?, ?>) EasyMock.anyObject()))
- .andAnswer(new IAnswer<ServiceRegistration>() {
- public ServiceRegistration answer() throws Throwable {
- assertTrue(EasyMock.getCurrentArguments()[1] instanceof ServicePublication);
- Dictionary<?, ?> actualProps =
- (Dictionary<?, ?>) EasyMock.getCurrentArguments()[2];
- UUID uuid = UUID.fromString(actualProps.get(ServicePublication.ENDPOINT_SERVICE_ID)
- .toString());
- expectedProps.put(ServicePublication.ENDPOINT_SERVICE_ID, uuid.toString());
- assertEquals(expectedProps, actualProps);
- return EasyMock.createMock(ServiceRegistration.class);
- }
- });
- EasyMock.replay(bc);
-
- ServiceHookUtils.publish(bc, null, sed);
- EasyMock.verify(bc);
- }
-
- private ServiceEndpointDescription mockServiceDescription(IMocksControl control,
- String... interfaceNames) {
- List<String> iList = new ArrayList<String>();
- for (String iName : interfaceNames) {
- iList.add(iName);
- }
- ServiceEndpointDescription sd = control.createMock(ServiceEndpointDescription.class);
- sd.getProvidedInterfaces();
- EasyMock.expectLastCall().andReturn(iList);
- return sd;
- }
-*/
-}
-
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java
deleted file mode 100644
index 07b5088..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java
+++ /dev/null
@@ -1,22 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.hooks;
-
-public interface TestService {
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManagerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManagerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManagerTest.java
new file mode 100644
index 0000000..593a06d
--- /dev/null
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/HttpServiceManagerTest.java
@@ -0,0 +1,125 @@
+/**
+ * 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.dosgi.dsw.httpservice;
+
+import java.util.Dictionary;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+import org.junit.Assert;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+
+public class HttpServiceManagerTest extends TestCase {
+
+ public void testGetAbsoluteAddress() {
+ IMocksControl c = EasyMock.createControl();
+ BundleContext bundleContext = c.createMock(BundleContext.class);
+ c.replay();
+ HttpServiceManager manager = new HttpServiceManager(bundleContext, null, null, null);
+ String localIp = LocalHostUtil.getLocalIp();
+
+ String address1 = manager.getAbsoluteAddress(null, "/myservice");
+ assertEquals("http://" + localIp + ":8181/cxf/myservice", address1);
+
+ String address2 = manager.getAbsoluteAddress("/mycontext", "/myservice");
+ assertEquals("http://" + localIp + ":8181/mycontext/myservice", address2);
+
+ c.verify();
+ }
+
+ public void testRegisterAndUnregisterServlet() throws Exception {
+ IMocksControl c = EasyMock.createControl();
+ BundleContext dswContext = c.createMock(BundleContext.class);
+ Filter filter = c.createMock(Filter.class);
+ expect(dswContext.createFilter(EasyMock.eq("(service.id=12345)"))).andReturn(filter).once();
+ Capture<ServiceListener> captured = EasyMock.newCapture();
+ dswContext.addServiceListener(EasyMock.capture(captured), EasyMock.<String>anyObject());
+ expectLastCall().atLeastOnce();
+ expect(dswContext.getProperty("org.apache.cxf.httpservice.requirefilter")).andReturn(null).atLeastOnce();
+ ServletConfig config = c.createMock(ServletConfig.class);
+ expect(config.getInitParameter(EasyMock.<String>anyObject())).andReturn(null).atLeastOnce();
+ ServletContext servletContext = c.createMock(ServletContext.class);
+ expect(config.getServletContext()).andReturn(servletContext);
+ final HttpService httpService = new DummyHttpService(config);
+ ServiceReference<?> sr = c.createMock(ServiceReference.class);
+ expect(sr.getProperty(EasyMock.eq("service.id"))).andReturn(12345L).atLeastOnce();
+ expect(servletContext.getResourceAsStream((String)EasyMock.anyObject())).andReturn(null).anyTimes();
+ c.replay();
+
+ HttpServiceManager h = new HttpServiceManager(dswContext, null, null, null) {
+ @Override
+ protected HttpService getHttpService() {
+ return httpService;
+ }
+ };
+ Bus bus = BusFactory.newInstance().createBus();
+ h.registerServlet(bus, "/myService", dswContext, 12345L);
+
+ ServiceEvent event = new ServiceEvent(ServiceEvent.UNREGISTERING, sr);
+ captured.getValue().serviceChanged(event);
+ c.verify();
+ }
+
+ static class DummyHttpService implements HttpService {
+
+ private ServletConfig config;
+
+ DummyHttpService(ServletConfig config) {
+ this.config = config;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context)
+ throws ServletException, NamespaceException {
+ Assert.assertEquals("/myService", alias);
+ servlet.init(config);
+ }
+
+ public void registerResources(String alias, String name, HttpContext context) throws NamespaceException {
+ throw new RuntimeException("This method should not be called");
+ }
+
+ public void unregister(String alias) {
+ }
+
+ public HttpContext createDefaultHttpContext() {
+ return EasyMock.createNiceMock(HttpContext.class);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContextTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContextTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContextTest.java
new file mode 100644
index 0000000..84718ad
--- /dev/null
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/httpservice/SecurityDelegatingHttpContextTest.java
@@ -0,0 +1,267 @@
+/**
+ * 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.dosgi.dsw.httpservice;
+
+import java.io.PrintWriter;
+import java.net.URL;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpContext;
+
+@SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
+public class SecurityDelegatingHttpContextTest extends TestCase {
+
+ protected HttpContext defaultHttpContext;
+ protected SecurityDelegatingHttpContext httpContext;
+ protected CommitResponseFilter commitFilter;
+ protected DoNothingFilter doNothingFilter;
+ protected AccessDeniedFilter accessDeniedFilter;
+ protected String mimeType;
+ protected URL url; // does not need to exist
+
+ public void setUp() throws Exception {
+ mimeType = "text/xml";
+ url = new URL("file:test.xml"); // does not need to exist
+
+ // Sample filters
+ commitFilter = new CommitResponseFilter();
+ doNothingFilter = new DoNothingFilter();
+ accessDeniedFilter = new AccessDeniedFilter();
+
+ // Mock up the default http context
+ defaultHttpContext = EasyMock.createNiceMock(HttpContext.class);
+ EasyMock.expect(defaultHttpContext.getMimeType((String)EasyMock.anyObject())).andReturn(mimeType);
+ EasyMock.expect(defaultHttpContext.getResource((String)EasyMock.anyObject())).andReturn(url);
+ EasyMock.replay(defaultHttpContext);
+ }
+
+ public void testFilterRequired() throws Exception {
+ // Mock up the service references
+ ServiceReference[] serviceReferences = new ServiceReference[] {};
+
+ // Mock up the bundle context
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.expect(bundleContext.getServiceReferences(Filter.class.getName(),
+ "(org.apache.cxf.httpservice.filter=true)"))
+ .andReturn(serviceReferences);
+ EasyMock.replay(bundleContext);
+
+ // Set up the secure http context
+ httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
+ httpContext.requireFilter = true;
+
+ // Ensure that the httpContext doesn't allow the request to be processed, since there are no registered servlet
+ // filters
+ HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
+ EasyMock.replay(request);
+ HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
+ EasyMock.replay(response);
+ boolean requestAllowed = httpContext.handleSecurity(request, response);
+ Assert.assertFalse(requestAllowed);
+
+ // Ensure that the httpContext returns true if there is no requirement for registered servlet filters
+ httpContext.requireFilter = false;
+ requestAllowed = httpContext.handleSecurity(request, response);
+ Assert.assertTrue(requestAllowed);
+ }
+
+ public void testSingleCommitFilter() throws Exception {
+ // Mock up the service references
+ ServiceReference filterReference = EasyMock.createNiceMock(ServiceReference.class);
+ EasyMock.replay(filterReference);
+ ServiceReference[] serviceReferences = new ServiceReference[] {
+ filterReference
+ };
+
+ // Mock up the bundle context
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.expect(bundleContext.getServiceReferences((String)EasyMock.anyObject(), (String)EasyMock.anyObject()))
+ .andReturn(serviceReferences);
+ EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(commitFilter);
+ EasyMock.replay(bundleContext);
+
+ // Set up the secure http context
+ httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
+
+ // Ensure that the httpContext returns false, since the filter has committed the response
+ HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
+ EasyMock.replay(request);
+ HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
+ EasyMock.expect(response.isCommitted()).andReturn(false); // the first call checks to see whether to invoke the
+ // filter
+ EasyMock.expect(response.isCommitted()).andReturn(true); // the second is called to determine the handleSecurity
+ // return value
+ EasyMock.expect(response.getWriter()).andReturn(new PrintWriter(System.out));
+ EasyMock.replay(response);
+ Assert.assertFalse(httpContext.handleSecurity(request, response));
+
+ // Ensure that the appropriate filters were called
+ Assert.assertTrue(commitFilter.called);
+ Assert.assertFalse(doNothingFilter.called);
+ Assert.assertFalse(accessDeniedFilter.called);
+ }
+
+ public void testFilterChain() throws Exception {
+ // Mock up the service references
+ ServiceReference filterReference = EasyMock.createNiceMock(ServiceReference.class);
+ EasyMock.replay(filterReference);
+ ServiceReference[] serviceReferences = new ServiceReference[] {
+ filterReference, filterReference
+ };
+
+ // Mock up the bundle context
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.expect(bundleContext.getServiceReferences((String)EasyMock.anyObject(), (String)EasyMock.anyObject()))
+ .andReturn(serviceReferences);
+ EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(doNothingFilter);
+ EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(commitFilter);
+ EasyMock.replay(bundleContext);
+
+ // Set up the secure http context
+ httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
+
+ // Ensure that the httpContext returns false, since the filter has committed the response
+ HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
+ EasyMock.replay(request);
+ HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
+ EasyMock.expect(response.isCommitted()).andReturn(false); // doNothingFilter should not commit the response
+ EasyMock.expect(response.getWriter()).andReturn(new PrintWriter(System.out));
+ EasyMock.expect(response.isCommitted()).andReturn(false);
+ EasyMock.expect(response.isCommitted()).andReturn(true); // the commit filter indicating that it committed the
+ // response
+ EasyMock.replay(response);
+ Assert.assertFalse(httpContext.handleSecurity(request, response));
+
+ // Ensure that the appropriate filters were called
+ Assert.assertTrue(doNothingFilter.called);
+ Assert.assertTrue(commitFilter.called);
+ Assert.assertFalse(accessDeniedFilter.called);
+ }
+
+ public void testAllowRequest() throws Exception {
+ // Mock up the service references
+ ServiceReference filterReference = EasyMock.createNiceMock(ServiceReference.class);
+ EasyMock.replay(filterReference);
+ ServiceReference[] serviceReferences = new ServiceReference[] {
+ filterReference
+ };
+
+ // Mock up the bundle context
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.expect(bundleContext.getServiceReferences((String)EasyMock.anyObject(), (String)EasyMock.anyObject()))
+ .andReturn(serviceReferences);
+ EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(doNothingFilter);
+ EasyMock.replay(bundleContext);
+
+ // Set up the secure http context
+ httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
+
+ // Ensure that the httpContext returns true, since the filter has not committed the response
+ HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
+ EasyMock.replay(request);
+ HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
+ EasyMock.expect(response.isCommitted()).andReturn(false);
+ EasyMock.replay(response);
+ Assert.assertTrue(httpContext.handleSecurity(request, response));
+
+ // Ensure that the appropriate filters were called
+ Assert.assertTrue(doNothingFilter.called);
+ Assert.assertFalse(commitFilter.called);
+ Assert.assertFalse(accessDeniedFilter.called);
+ }
+
+ public void testDelegation() throws Exception {
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bundleContext);
+
+ // Set up the secure http context
+ httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
+
+ // Ensure that it delegates non-security calls to the wrapped implementation (in this case, the mock)
+ Assert.assertEquals(mimeType, httpContext.getMimeType(""));
+ Assert.assertEquals(url, httpContext.getResource(""));
+ }
+}
+
+class CommitResponseFilter implements Filter {
+
+ boolean called;
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws java.io.IOException, javax.servlet.ServletException {
+ called = true;
+ response.getWriter().write("committing the response");
+ }
+}
+
+class DoNothingFilter implements Filter {
+
+ boolean called;
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws java.io.IOException, javax.servlet.ServletException {
+ called = true;
+ chain.doFilter(request, response);
+ }
+}
+
+class AccessDeniedFilter implements Filter {
+
+ boolean called;
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws java.io.IOException, javax.servlet.ServletException {
+ called = true;
+ ((HttpServletResponse)response).sendError(HttpServletResponse.SC_FORBIDDEN);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java
index b68cf61..380478c 100644
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java
@@ -18,7 +18,7 @@
*/
package org.apache.cxf.dosgi.dsw.qos;
-import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
import org.apache.cxf.feature.AbstractFeature;
import org.easymock.Capture;
import org.easymock.EasyMock;
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java
index f7fe844..ad04be0 100644
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java
@@ -25,7 +25,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
import org.junit.Assert;
import org.junit.Test;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
[3/5] cxf-dosgi git commit: [DOSGI-242] Refactor provider, Cleanup
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java
new file mode 100644
index 0000000..87c2c21
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java
@@ -0,0 +1,146 @@
+/**
+ * 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.dosgi.dsw.osgi;
+
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+
+public final class Constants {
+
+ // Constants from RFC 119, they should ultimately be picked up from an OSGi class.
+ @Deprecated
+ public static final String EXPORTED_INTERFACES = RemoteConstants.SERVICE_EXPORTED_INTERFACES;
+ @Deprecated
+ public static final String EXPORTED_INTERFACES_OLD = "osgi.remote.interfaces"; // for BW compatibility
+
+ @Deprecated
+ public static final String EXPORTED_CONFIGS = RemoteConstants.SERVICE_EXPORTED_CONFIGS;
+ @Deprecated
+ public static final String EXPORTED_CONFIGS_OLD = "osgi.remote.configuration.type"; // for BW compatibility
+
+ @Deprecated
+ public static final String EXPORTED_INTENTS = RemoteConstants.SERVICE_EXPORTED_INTENTS;
+ @Deprecated
+ public static final String EXPORTED_INTENTS_EXTRA = RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA;
+ @Deprecated
+ public static final String EXPORTED_INTENTS_OLD = "osgi.remote.requires.intents";
+
+ @Deprecated
+ public static final String IMPORTED = RemoteConstants.SERVICE_IMPORTED;
+ @Deprecated
+ public static final String IMPORTD_CONFIGS = RemoteConstants.SERVICE_IMPORTED_CONFIGS;
+
+ @Deprecated
+ public static final String INTENTS = RemoteConstants.SERVICE_INTENTS;
+
+ // WSDL
+ public static final String WSDL_CONFIG_TYPE = "wsdl";
+ public static final String WSDL_CONFIG_PREFIX = "osgi.remote.configuration" + "." + WSDL_CONFIG_TYPE;
+ public static final String WSDL_SERVICE_NAMESPACE = WSDL_CONFIG_PREFIX + ".service.ns";
+ public static final String WSDL_SERVICE_NAME = WSDL_CONFIG_PREFIX + ".service.name";
+ public static final String WSDL_PORT_NAME = WSDL_CONFIG_PREFIX + ".port.name";
+ public static final String WSDL_LOCATION = WSDL_CONFIG_PREFIX + ".location";
+ public static final String WSDL_HTTP_SERVICE_CONTEXT = WSDL_CONFIG_PREFIX + ".httpservice.context";
+ // Provider prefix
+ public static final String PROVIDER_PREFIX = "org.apache.cxf";
+
+ // WS
+ public static final String WS_CONFIG_TYPE = PROVIDER_PREFIX + ".ws";
+ public static final String WS_ADDRESS_PROPERTY = WS_CONFIG_TYPE + ".address";
+ public static final String WS_PORT_PROPERTY = WS_CONFIG_TYPE + ".port";
+ public static final String WS_HTTP_SERVICE_CONTEXT = WS_CONFIG_TYPE + ".httpservice.context";
+
+ public static final String WS_FRONTEND_PROP_KEY = WS_CONFIG_TYPE + ".frontend";
+ public static final String WS_FRONTEND_JAXWS = "jaxws";
+ public static final String WS_FRONTEND_SIMPLE = "simple";
+
+ public static final String WS_IN_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.interceptors";
+ public static final String WS_OUT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.interceptors";
+ public static final String WS_OUT_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.fault.interceptors";
+ public static final String WS_IN_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.fault.interceptors";
+ public static final String WS_CONTEXT_PROPS_PROP_KEY = WS_CONFIG_TYPE + ".context.properties";
+ public static final String WS_FEATURES_PROP_KEY = WS_CONFIG_TYPE + ".features";
+
+ public static final String WS_DATABINDING_PROP_KEY = WS_CONFIG_TYPE + ".databinding";
+ public static final String WS_DATABINDING_BEAN_PROP_KEY = WS_DATABINDING_PROP_KEY + ".bean";
+ public static final String WS_DATA_BINDING_JAXB = "jaxb";
+ public static final String WS_DATA_BINDING_AEGIS = "aegis";
+
+ public static final String WS_WSDL_SERVICE_NAMESPACE = WS_CONFIG_TYPE + ".service.ns";
+ public static final String WS_WSDL_SERVICE_NAME = WS_CONFIG_TYPE + ".service.name";
+ public static final String WS_WSDL_PORT_NAME = WS_CONFIG_TYPE + ".port.name";
+ public static final String WS_WSDL_LOCATION = WS_CONFIG_TYPE + ".wsdl.location";
+ // Rest
+ public static final String RS_CONFIG_TYPE = PROVIDER_PREFIX + ".rs";
+ public static final String RS_ADDRESS_PROPERTY = RS_CONFIG_TYPE + ".address";
+ public static final String RS_HTTP_SERVICE_CONTEXT = RS_CONFIG_TYPE + ".httpservice.context";
+ public static final String RS_DATABINDING_PROP_KEY = RS_CONFIG_TYPE + ".databinding";
+ public static final String RS_IN_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".in.interceptors";
+ public static final String RS_OUT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".out.interceptors";
+ public static final String RS_IN_FAULT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".in.fault.interceptors";
+ public static final String RS_OUT_FAULT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".out.fault.interceptors";
+ public static final String RS_CONTEXT_PROPS_PROP_KEY = RS_CONFIG_TYPE + ".context.properties";
+ public static final String RS_FEATURES_PROP_KEY = RS_CONFIG_TYPE + ".features";
+ public static final String RS_PROVIDER_PROP_KEY = RS_CONFIG_TYPE + ".provider";
+ public static final String RS_PROVIDER_EXPECTED_PROP_KEY = RS_PROVIDER_PROP_KEY + ".expected";
+ public static final String RS_PROVIDER_GLOBAL_PROP_KEY = RS_PROVIDER_PROP_KEY + ".globalquery";
+ public static final String RS_WADL_LOCATION = RS_CONFIG_TYPE + ".wadl.location";
+ // POJO (old value for WS)
+ public static final String WS_CONFIG_TYPE_OLD = "pojo";
+ public static final String WS_CONFIG_OLD_PREFIX = "osgi.remote.configuration." + WS_CONFIG_TYPE_OLD;
+ public static final String WS_ADDRESS_PROPERTY_OLD = WS_CONFIG_OLD_PREFIX + ".address";
+ public static final String WS_HTTP_SERVICE_CONTEXT_OLD = WS_CONFIG_OLD_PREFIX + ".httpservice.context";
+
+ // Common Configuration Properties
+ public static final String CHECK_BUNDLE = "check.bundle";
+
+ // The following constants are not evaluated anymore
+ @Deprecated
+ public static final String DEFAULT_PORT_CONFIG = "default.port";
+ @Deprecated
+ public static final String DEFAULT_HOST_CONFIG = "default.host";
+ @Deprecated
+ public static final String DEFAULT_PORT_VALUE = "9000";
+ @Deprecated
+ public static final String DEFAULT_HOST_VALUE = "localhost";
+ @Deprecated
+ public static final String USE_MASTER_MAP = "use.master.map";
+
+ // DSW Identification - TODO do we really need this one?
+ public static final String DSW_CLIENT_ID = PROVIDER_PREFIX + ".remote.dsw.client";
+
+ public static final String INTENT_NAME_PROP = "org.apache.cxf.dosgi.IntentName";
+
+ /**
+ * Prefix to create an absolute URL from a relative URL.
+ * See HttpServiceManager.getAbsoluteAddress
+ *
+ * Defaults to: http://<host name>:8181
+ */
+ public static final String HTTP_BASE = "httpBase";
+
+ /**
+ * Name of the cxf servlet alias
+ */
+ public static final String CXF_SERVLET_ALIAS = "cxfServletAlias";
+ public static final String DEFAULT_CXF_SERVLET_ALIAS = "/cxf";
+
+ private Constants() {
+ // never constructed
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java
index e1ceaaa..bdbe7c5 100644
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentTracker.java
@@ -18,7 +18,7 @@
*/
package org.apache.cxf.dosgi.dsw.qos;
-import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
index 31b1e42..5ee288c 100644
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
@@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ClassUtils.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ClassUtils.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ClassUtils.java
new file mode 100644
index 0000000..cd1a323
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ClassUtils.java
@@ -0,0 +1,86 @@
+/**
+ * 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.dosgi.dsw.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class ClassUtils {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ClassUtils.class);
+
+ private ClassUtils() {
+ }
+
+ public static List<Object> loadProviderClasses(BundleContext callingContext,
+ Map<String, Object> sd, String propName) {
+ Object serviceProviders = sd.get(propName);
+ if (serviceProviders != null) {
+ if (serviceProviders.getClass().isArray()) {
+ if (serviceProviders.getClass().getComponentType() == String.class) {
+ return loadProviders(callingContext, (String[])serviceProviders);
+ } else {
+ return Arrays.asList((Object[])serviceProviders);
+ }
+ } else if (serviceProviders.getClass() == String.class) {
+ String[] classNames = serviceProviders.toString().split(",");
+ return loadProviders(callingContext, classNames);
+ } else if (serviceProviders instanceof List) {
+ List<Object> list = CastUtils.cast((List<?>)serviceProviders);
+ if (!list.isEmpty()) {
+ List<Object> providers;
+ if (list.get(0).getClass() == String.class) {
+ providers = loadProviders(callingContext, list.toArray(new String[]{}));
+ } else {
+ providers = list;
+ }
+ return providers;
+ }
+ } else {
+ return Arrays.asList(serviceProviders);
+ }
+ }
+ return Collections.emptyList();
+
+ }
+
+ private static List<Object> loadProviders(BundleContext callingContext, String[] classNames) {
+ List<Object> providers = new ArrayList<Object>();
+ for (String className : classNames) {
+ try {
+ String realName = className.trim();
+ if (!realName.isEmpty()) {
+ Class<?> pClass = callingContext.getBundle().loadClass(realName);
+ providers.add(pClass.newInstance());
+ }
+ } catch (Exception ex) {
+ LOG.warn("Provider " + className.trim() + " can not be loaded or created " + ex.getMessage(), ex);
+ }
+ }
+ return providers;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java
index 9acd0f0..be1cba0 100644
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java
@@ -23,16 +23,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@SuppressWarnings("deprecation")
public final class OsgiUtils {
public static final Logger LOG = LoggerFactory.getLogger(OsgiUtils.class);
@@ -81,52 +75,4 @@ public final class OsgiUtils {
return null;
}
- /**
- * Tries to retrieve the version of iClass via the PackageAdmin.
- *
- * @param iClass tThe interface for which the version should be found
- * @param bc any valid BundleContext
- * @return the version of the interface or "0.0.0" if no version information could be found or an error
- * occurred during the retrieval
- */
- public static String getVersion(Class<?> iClass, BundleContext bc) {
- ServiceReference<PackageAdmin> paRef = bc.getServiceReference(PackageAdmin.class);
- if (paRef != null) {
- PackageAdmin pa = bc.getService(paRef);
- try {
- Bundle b = pa.getBundle(iClass);
- if (b == null) {
- LOG.info("Unable to find interface version for interface " + iClass.getName()
- + ". Falling back to 0.0.0");
- return "0.0.0";
- }
- LOG.debug("Interface source bundle: {}", b.getSymbolicName());
-
- ExportedPackage[] ep = pa.getExportedPackages(b);
- LOG.debug("Exported Packages of the source bundle: {}", (Object)ep);
-
- String pack = iClass.getPackage().getName();
- LOG.debug("Looking for Package: {}", pack);
- if (ep != null) {
- for (ExportedPackage p : ep) {
- if (p != null
- && pack.equals(p.getName())) {
- LOG.debug("found package -> Version: {}", p.getVersion());
- return p.getVersion().toString();
- }
- }
- }
- } finally {
- if (pa != null) {
- bc.ungetService(paRef);
- }
- }
- } else {
- LOG.error("Was unable to obtain the package admin service -> can't resolve interface versions");
- }
-
- LOG.info("Unable to find interface version for interface " + iClass.getName()
- + ". Falling back to 0.0.0");
- return "0.0.0";
- }
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ServerWrapper.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ServerWrapper.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ServerWrapper.java
new file mode 100644
index 0000000..d04db75
--- /dev/null
+++ b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/ServerWrapper.java
@@ -0,0 +1,49 @@
+/**
+ * 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.dosgi.dsw.util;
+
+import java.io.IOException;
+
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.cxf.endpoint.Server;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+
+public class ServerWrapper implements Endpoint {
+ private EndpointDescription desc;
+ private Server server;
+
+ public ServerWrapper(EndpointDescription desc, Server server) {
+ this.desc = desc;
+ this.server = server;
+ }
+
+ public Server getServer() {
+ return this.server;
+ }
+
+ @Override
+ public void close() throws IOException {
+ this.server.destroy();
+ }
+
+ @Override
+ public EndpointDescription description() {
+ return this.desc;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
index d9bc98d..ac3ae51 100644
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
@@ -24,6 +24,7 @@ import java.util.Hashtable;
import junit.framework.TestCase;
import org.apache.aries.rsa.spi.DistributionProvider;
+import org.apache.cxf.dosgi.dsw.osgi.Activator;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.osgi.framework.Bundle;
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
index dcf1f2d..6215f10 100644
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
@@ -23,7 +23,11 @@ import java.util.List;
import java.util.Map;
import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.handlers.pojo.PojoConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.handlers.pojo.WsdlConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.handlers.rest.JaxRSPojoConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.dsw.osgi.Constants;
import org.apache.cxf.dosgi.dsw.qos.DefaultIntentMapFactory;
import org.apache.cxf.dosgi.dsw.qos.IntentManager;
import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtilsTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtilsTest.java
index a0774be..a38fea7 100644
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtilsTest.java
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClassUtilsTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.cxf.dosgi.dsw.handlers;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@@ -28,6 +26,7 @@ import java.util.Map;
import junit.framework.TestCase;
+import org.apache.cxf.dosgi.dsw.util.ClassUtils;
import org.apache.cxf.dosgi.dsw.util.Provider;
import org.easymock.EasyMock;
import org.osgi.framework.Bundle;
@@ -35,23 +34,6 @@ import org.osgi.framework.BundleContext;
public class ClassUtilsTest extends TestCase {
- public void testGetInterfaceClass() {
- assertEquals(String.class,
- ClassUtils.getInterfaceClass("Hello", "java.lang.String"));
- assertNull(ClassUtils.getInterfaceClass("Hello", "java.lang.Integer"));
- assertEquals(List.class, ClassUtils.getInterfaceClass(
- new ArrayList<String>(), "java.util.List"));
- assertEquals(Collection.class, ClassUtils.getInterfaceClass(
- new ArrayList<String>(), "java.util.Collection"));
- }
-
- public void testGetInterfaceClassFromSubclass() {
- assertEquals(Map.class, ClassUtils.getInterfaceClass(
- new MySubclassFour(), "java.util.Map"));
- assertNull(ClassUtils.getInterfaceClass(new MySubclassFour(),
- "java.util.UnknownType"));
- }
-
public void testLoadProvidersAsString() throws Exception {
BundleContext bc = mockBundleContext();
Map<String, Object> sd = Collections.<String, Object>singletonMap("providers", Provider.class.getName());
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
deleted file mode 100644
index 10fba12..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
+++ /dev/null
@@ -1,125 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.util.Dictionary;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-import junit.framework.TestCase;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.easymock.Capture;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.junit.Assert;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpContext;
-import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
-
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-
-public class HttpServiceManagerTest extends TestCase {
-
- public void testGetAbsoluteAddress() {
- IMocksControl c = EasyMock.createControl();
- BundleContext bundleContext = c.createMock(BundleContext.class);
- c.replay();
- HttpServiceManager manager = new HttpServiceManager(bundleContext, null, null, null);
- String localIp = LocalHostUtil.getLocalIp();
-
- String address1 = manager.getAbsoluteAddress(null, "/myservice");
- assertEquals("http://" + localIp + ":8181/cxf/myservice", address1);
-
- String address2 = manager.getAbsoluteAddress("/mycontext", "/myservice");
- assertEquals("http://" + localIp + ":8181/mycontext/myservice", address2);
-
- c.verify();
- }
-
- public void testRegisterAndUnregisterServlet() throws Exception {
- IMocksControl c = EasyMock.createControl();
- BundleContext dswContext = c.createMock(BundleContext.class);
- Filter filter = c.createMock(Filter.class);
- expect(dswContext.createFilter(EasyMock.eq("(service.id=12345)"))).andReturn(filter).once();
- Capture<ServiceListener> captured = EasyMock.newCapture();
- dswContext.addServiceListener(EasyMock.capture(captured), EasyMock.<String>anyObject());
- expectLastCall().atLeastOnce();
- expect(dswContext.getProperty("org.apache.cxf.httpservice.requirefilter")).andReturn(null).atLeastOnce();
- ServletConfig config = c.createMock(ServletConfig.class);
- expect(config.getInitParameter(EasyMock.<String>anyObject())).andReturn(null).atLeastOnce();
- ServletContext servletContext = c.createMock(ServletContext.class);
- expect(config.getServletContext()).andReturn(servletContext);
- final HttpService httpService = new DummyHttpService(config);
- ServiceReference<?> sr = c.createMock(ServiceReference.class);
- expect(sr.getProperty(EasyMock.eq("service.id"))).andReturn(12345L).atLeastOnce();
- expect(servletContext.getResourceAsStream((String)EasyMock.anyObject())).andReturn(null).anyTimes();
- c.replay();
-
- HttpServiceManager h = new HttpServiceManager(dswContext, null, null, null) {
- @Override
- protected HttpService getHttpService() {
- return httpService;
- }
- };
- Bus bus = BusFactory.newInstance().createBus();
- h.registerServlet(bus, "/myService", dswContext, 12345L);
-
- ServiceEvent event = new ServiceEvent(ServiceEvent.UNREGISTERING, sr);
- captured.getValue().serviceChanged(event);
- c.verify();
- }
-
- static class DummyHttpService implements HttpService {
-
- private ServletConfig config;
-
- DummyHttpService(ServletConfig config) {
- this.config = config;
- }
-
- @SuppressWarnings("rawtypes")
- public void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context)
- throws ServletException, NamespaceException {
- Assert.assertEquals("/myService", alias);
- servlet.init(config);
- }
-
- public void registerResources(String alias, String name, HttpContext context) throws NamespaceException {
- throw new RuntimeException("This method should not be called");
- }
-
- public void unregister(String alias) {
- }
-
- public HttpContext createDefaultHttpContext() {
- return EasyMock.createNiceMock(HttpContext.class);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtilsTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtilsTest.java
deleted file mode 100644
index 6c8e35a..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtilsTest.java
+++ /dev/null
@@ -1,195 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
-import org.apache.cxf.jaxrs.provider.aegis.AegisElementProvider;
-import org.easymock.EasyMock;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public class JaxRSUtilsTest extends TestCase {
-
- private void addRequiredProps(Map<String, Object> props) {
- props.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
- props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myGreatConfiguration");
- props.put(org.osgi.framework.Constants.OBJECTCLASS, new String[] {"my.class"});
- }
-
- public void testNoGlobalProviders() {
- Map<String, Object> props = new HashMap<String, Object>();
- addRequiredProps(props);
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
-
- assertEquals(0, JaxRSUtils.getProviders(null, props).size());
- }
-
- public void testAegisProvider() {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_DATABINDING_PROP_KEY, "aegis");
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
-
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(null, props);
- assertEquals(1, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- }
-
- @SuppressWarnings("rawtypes")
- public void testServiceProviders() {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_PROP_KEY, new Object[] {
- new AegisElementProvider()
- });
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(null, props);
- assertEquals(1, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- }
-
- public void testServiceProviderProperty() throws Exception {
- BundleContext bc = EasyMock.createMock(BundleContext.class);
- Bundle bundle = EasyMock.createMock(Bundle.class);
- bc.getBundle();
- EasyMock.expectLastCall().andReturn(bundle).times(2);
- bundle.loadClass(AegisElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(AegisElementProvider.class);
- bundle.loadClass(JAXBElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(JAXBElementProvider.class);
- EasyMock.replay(bc, bundle);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_PROP_KEY,
- "\r\n " + AegisElementProvider.class.getName() + " , \r\n"
- + JAXBElementProvider.class.getName() + "\r\n");
-
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(2, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- assertEquals(JAXBElementProvider.class.getName(), providers.get(1).getClass().getName());
- }
-
- public void testServiceProviderStrings() throws Exception {
- BundleContext bc = EasyMock.createMock(BundleContext.class);
- Bundle bundle = EasyMock.createMock(Bundle.class);
- bc.getBundle();
- EasyMock.expectLastCall().andReturn(bundle).times(2);
- bundle.loadClass(AegisElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(AegisElementProvider.class);
- bundle.loadClass(JAXBElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(JAXBElementProvider.class);
- EasyMock.replay(bc, bundle);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_PROP_KEY, new String[] {
- "\r\n " + AegisElementProvider.class.getName(),
- JAXBElementProvider.class.getName() + "\r\n"
- });
-
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(2, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- assertEquals(JAXBElementProvider.class.getName(), providers.get(1).getClass().getName());
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- public void testCustomGlobalProvider() throws Exception {
- ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
- EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
- sref.getProperty(Constants.RS_PROVIDER_EXPECTED_PROP_KEY);
- EasyMock.expectLastCall().andReturn(false);
- bc.getService(sref);
- AegisElementProvider<?> p = new AegisElementProvider();
- EasyMock.expectLastCall().andReturn(p);
- EasyMock.replay(bc, sref);
- Map<String, Object> props = new HashMap<String, Object>();
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(1, providers.size());
- assertSame(p, providers.get(0));
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- public void testNoCustomGlobalProvider() throws Exception {
- ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
- EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
- sref.getProperty(Constants.RS_PROVIDER_PROP_KEY);
- EasyMock.expectLastCall().andReturn(false);
- bc.getService(sref);
- AegisElementProvider<?> p = new AegisElementProvider();
- EasyMock.expectLastCall().andReturn(p);
- EasyMock.replay(bc);
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_EXPECTED_PROP_KEY, "true");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(0, providers.size());
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- public void testCustomGlobalProviderExpected() throws Exception {
- ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
- EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
- sref.getProperty(Constants.RS_PROVIDER_PROP_KEY);
- EasyMock.expectLastCall().andReturn(true);
- bc.getService(sref);
- AegisElementProvider<?> p = new AegisElementProvider();
- EasyMock.expectLastCall().andReturn(p);
- EasyMock.replay(bc, sref);
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_EXPECTED_PROP_KEY, "true");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(1, providers.size());
- assertSame(p, providers.get(0));
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
deleted file mode 100644
index b6b05ea..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
+++ /dev/null
@@ -1,422 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.TestCase;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.aries.rsa.util.EndpointHelper;
-import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
-import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
-import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
-import org.apache.cxf.dosgi.dsw.qos.IntentMap;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.endpoint.EndpointImpl;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
-import org.apache.cxf.transport.Destination;
-import org.apache.cxf.ws.addressing.AttributedURIType;
-import org.apache.cxf.ws.addressing.EndpointReferenceType;
-import org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.easymock.IMocksControl;
-import org.junit.Assert;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Version;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public class PojoConfigurationTypeHandlerTest extends TestCase {
-
- public void testGetPojoAddressEndpointURI() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- String url = "http://somewhere:1234/blah";
- sd.put(RemoteConstants.ENDPOINT_ID, url);
- assertEquals(url, handler.getServerAddress(sd, String.class));
- }
-
- private HttpServiceManager dummyHttpServiceManager() {
- return new HttpServiceManager(null, null, null, null);
- }
-
- public void testGetPojoAddressEndpointCxf() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- String url = "http://somewhere:29/boo";
- sd.put("org.apache.cxf.ws.address", url);
- assertEquals(url, handler.getServerAddress(sd, String.class));
- }
-
- public void testGetPojoAddressEndpointPojo() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- String url = "http://somewhere:32768/foo";
- sd.put("osgi.remote.configuration.pojo.address", url);
- assertEquals(url, handler.getServerAddress(sd, String.class));
- }
-
- public void testGetDefaultPojoAddress() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- assertEquals("/java/lang/String", handler.getServerAddress(sd, String.class));
- }
-
- // todo: add test for data bindings
- public void testCreateProxy() {
- IMocksControl c = EasyMock.createNiceControl();
- BundleContext bc1 = c.createMock(BundleContext.class);
-
- BundleContext requestingContext = c.createMock(BundleContext.class);
-
- final ClientProxyFactoryBean cpfb = c.createMock(ClientProxyFactoryBean.class);
- ReflectionServiceFactoryBean sf = c.createMock(ReflectionServiceFactoryBean.class);
- EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
- IntentManager intentManager = new IntentManagerImpl(new IntentMap()) {
- @Override
- public String[] applyIntents(List<Feature> features,
- AbstractEndpointFactory factory,
- Map<String, Object> sd) {
- return new String[0];
- }
- };
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc1,
- intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return cpfb;
- }
- };
-
- Class<?>[] exportedInterfaces = new Class[]{Runnable.class};
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(RemoteConstants.ENDPOINT_ID, "http://google.de/");
- EndpointHelper.addObjectClass(props, exportedInterfaces);
- props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[]{"my.config"});
- EndpointDescription endpoint = new EndpointDescription(props);
-
- cpfb.setAddress((String)EasyMock.eq(props.get(RemoteConstants.ENDPOINT_ID)));
- EasyMock.expectLastCall().atLeastOnce();
-
- cpfb.setServiceClass(EasyMock.eq(Runnable.class));
- EasyMock.expectLastCall().atLeastOnce();
-
- c.replay();
- ClassLoader cl = null;
- Object proxy = p.importEndpoint(cl, requestingContext, exportedInterfaces, endpoint);
- assertNotNull(proxy);
- assertTrue("Proxy is not of the requested type! ", proxy instanceof Runnable);
- c.verify();
- }
-
- public void testCreateServerWithAddressProperty() throws Exception {
- BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(dswContext);
-
- String myService = "Hi";
- final ServerFactoryBean sfb = createMockServerFactoryBean();
-
- IntentMap intentMap = new IntentMap();
- IntentManager intentManager = new IntentManagerImpl(intentMap) {
- @Override
- public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory,
- Map<String, Object> sd) {
- return new String[]{};
- }
- };
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return sfb;
- }
- };
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(bundleContext);
-
- Class<?>[] exportedInterface = new Class[]{String.class};
- Map<String, Object> props = new HashMap<String, Object>();
- EndpointHelper.addObjectClass(props, exportedInterface);
- props.put(Constants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
-
- Endpoint exportResult = p.exportService(myService, bundleContext, props, exportedInterface);
- Map<String, Object> edProps = exportResult.description().getProperties();
-
- assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
- assertEquals(1, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)).length);
- assertEquals(Constants.WS_CONFIG_TYPE, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS))[0]);
- assertEquals("http://alternate_host:80/myString", edProps.get(RemoteConstants.ENDPOINT_ID));
- }
-
- public void testAddressing() throws Exception {
- runAddressingTest(new HashMap<String, Object>(), "http://localhost:9000/java/lang/Runnable");
-
- Map<String, Object> p1 = new HashMap<String, Object>();
- p1.put("org.apache.cxf.ws.address", "http://somewhere");
- runAddressingTest(p1, "http://somewhere");
-
- Map<String, Object> p2 = new HashMap<String, Object>();
- p2.put("org.apache.cxf.rs.address", "https://somewhereelse");
- runAddressingTest(p2, "https://somewhereelse");
-
- Map<String, Object> p3 = new HashMap<String, Object>();
- p3.put("org.apache.cxf.ws.port", 65535);
- runAddressingTest(p3, "http://localhost:65535/java/lang/Runnable");
-
- Map<String, Object> p4 = new HashMap<String, Object>();
- p4.put("org.apache.cxf.ws.port", "8181");
- runAddressingTest(p4, "http://localhost:8181/java/lang/Runnable");
- }
-
- private void runAddressingTest(Map<String, Object> properties, String expectedAddress) throws Exception {
- Class<?>[] exportedInterface = new Class[]{Runnable.class};
- EndpointHelper.addObjectClass(properties, exportedInterface);
- BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
- String expectedUUID = UUID.randomUUID().toString();
- EasyMock.expect(dswContext.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn(expectedUUID);
- EasyMock.replay(dswContext);
-
- IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
- EasyMock.replay(intentManager);
-
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswContext,
- intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected Endpoint createServerFromFactory(ServerFactoryBean factory,
- EndpointDescription epd) {
- return new ServerWrapper(epd, null);
- }
- };
- Runnable myService = EasyMock.createMock(Runnable.class);
- EasyMock.replay(myService);
-
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(bundleContext);
-
- Endpoint result = handler.exportService(myService, bundleContext, properties, exportedInterface);
- Map<String, Object> props = result.description().getProperties();
- assertEquals(expectedAddress, props.get("org.apache.cxf.ws.address"));
- Assert.assertArrayEquals(new String[] {"org.apache.cxf.ws"},
- (String[]) props.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
- Assert.assertArrayEquals(new String[] {"java.lang.Runnable"},
- (String[]) props.get(org.osgi.framework.Constants.OBJECTCLASS));
- }
-
- public void t2estCreateServerException() {
- BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(dswContext);
-
- IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
- EasyMock.replay(intentManager);
-
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswContext,
- intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected Endpoint createServerFromFactory(ServerFactoryBean factory,
- EndpointDescription epd) {
- throw new TestException();
- }
- };
-
- Map<String, Object> props = new HashMap<String, Object>();
-
- Runnable myService = EasyMock.createMock(Runnable.class);
- EasyMock.replay(myService);
- try {
- handler.exportService(myService, null, props, new Class[]{Runnable.class});
- fail("Expected TestException");
- } catch (TestException e) {
- // Expected
- }
- }
-
- private ServerFactoryBean createMockServerFactoryBean() {
- ReflectionServiceFactoryBean sf = EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
- EasyMock.replay(sf);
-
- final StringBuilder serverURI = new StringBuilder();
-
- ServerFactoryBean sfb = EasyMock.createNiceMock(ServerFactoryBean.class);
- Server server = createMockServer(sfb);
-
- EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();
- EasyMock.expect(sfb.create()).andReturn(server);
- sfb.setAddress((String) EasyMock.anyObject());
- EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- public Object answer() throws Throwable {
- serverURI.setLength(0);
- serverURI.append(EasyMock.getCurrentArguments()[0]);
- return null;
- }
- });
- EasyMock.expect(sfb.getAddress()).andAnswer(new IAnswer<String>() {
- public String answer() throws Throwable {
- return serverURI.toString();
- }
- });
- EasyMock.replay(sfb);
- return sfb;
- }
-
- private Server createMockServer(final ServerFactoryBean sfb) {
- AttributedURIType addr = EasyMock.createMock(AttributedURIType.class);
- EasyMock.expect(addr.getValue()).andAnswer(new IAnswer<String>() {
- public String answer() throws Throwable {
- return sfb.getAddress();
- }
- });
- EasyMock.replay(addr);
-
- EndpointReferenceType er = EasyMock.createMock(EndpointReferenceType.class);
- EasyMock.expect(er.getAddress()).andReturn(addr);
- EasyMock.replay(er);
-
- Destination destination = EasyMock.createMock(Destination.class);
- EasyMock.expect(destination.getAddress()).andReturn(er);
- EasyMock.replay(destination);
-
- Server server = EasyMock.createNiceMock(Server.class);
- EasyMock.expect(server.getDestination()).andReturn(destination);
- EasyMock.replay(server);
- return server;
- }
-
- public void testCreateEndpointProps() {
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
- EasyMock.replay(bc);
-
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler pch = new PojoConfigurationTypeHandler(bc,
- intentManager,
- dummyHttpServiceManager());
- Class<?>[] exportedInterfaces = new Class[] {String.class};
- Map<String, Object> sd = new HashMap<String, Object>();
- sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
- EndpointHelper.addObjectClass(sd, exportedInterfaces);
- EndpointDescription epd = pch.createEndpointDesc(sd, new String[] {"org.apache.cxf.ws"},
- "http://localhost:12345", new String[] {"my_intent", "your_intent"});
-
- assertEquals("http://localhost:12345", epd.getId());
- assertEquals(Arrays.asList("java.lang.String"), epd.getInterfaces());
- assertEquals(Arrays.asList("org.apache.cxf.ws"), epd.getConfigurationTypes());
- assertEquals(Arrays.asList("my_intent", "your_intent"), epd.getIntents());
- assertEquals(new Version("0.0.0"), epd.getPackageVersion("java.lang"));
- }
-
- public void t2estCreateJaxWsEndpointWithoutIntents() {
- IMocksControl c = EasyMock.createNiceControl();
- BundleContext dswBC = c.createMock(BundleContext.class);
-
- IntentManager intentManager = new DummyIntentManager();
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC,
- intentManager,
- dummyHttpServiceManager());
-
- Map<String, Object> sd = new HashMap<String, Object>();
- sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere");
- BundleContext serviceBC = c.createMock(BundleContext.class);
- Object myService = null;
- c.replay();
-
- ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(myService,
- serviceBC,
- sd,
- new Class[]{MyJaxWsEchoService.class});
- c.verify();
-
- org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
- QName bindingName = ep.getEndpointInfo().getBinding().getName();
- Assert.assertEquals(JaxWsEndpointImpl.class, ep.getClass());
- Assert.assertEquals(new QName("http://jaxws.handlers.dsw.dosgi.cxf.apache.org/",
- "MyJaxWsEchoServiceServiceSoapBinding"),
- bindingName);
- }
-
- public void t2estCreateSimpleEndpointWithoutIntents() {
- IMocksControl c = EasyMock.createNiceControl();
- BundleContext dswBC = c.createMock(BundleContext.class);
-
- IntentManager intentManager = new DummyIntentManager();
- PojoConfigurationTypeHandler handler
- = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere_else");
- BundleContext serviceBC = c.createMock(BundleContext.class);
- c.replay();
- ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(null, serviceBC, sd,
- new Class[]{MySimpleEchoService.class});
- c.verify();
-
- org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
- QName bindingName = ep.getEndpointInfo().getBinding().getName();
- Assert.assertEquals(EndpointImpl.class, ep.getClass());
- Assert.assertEquals(new QName("http://simple.handlers.dsw.dosgi.cxf.apache.org/",
- "MySimpleEchoServiceSoapBinding"),
- bindingName);
- }
-
- public static class DummyIntentManager implements IntentManager {
-
- @Override
- public String[] applyIntents(List<Feature> features,
- AbstractEndpointFactory factory,
- Map<String, Object> props) {
- return new String[]{};
- }
-
- @Override
- public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
- }
- }
-
- @SuppressWarnings("serial")
- public static class TestException extends RuntimeException {
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContextTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContextTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContextTest.java
deleted file mode 100644
index 58b5f58..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/SecurityDelegatingHttpContextTest.java
+++ /dev/null
@@ -1,267 +0,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.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import java.io.PrintWriter;
-import java.net.URL;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpContext;
-
-@SuppressWarnings({
- "unchecked", "rawtypes"
- })
-public class SecurityDelegatingHttpContextTest extends TestCase {
-
- protected HttpContext defaultHttpContext;
- protected SecurityDelegatingHttpContext httpContext;
- protected CommitResponseFilter commitFilter;
- protected DoNothingFilter doNothingFilter;
- protected AccessDeniedFilter accessDeniedFilter;
- protected String mimeType;
- protected URL url; // does not need to exist
-
- public void setUp() throws Exception {
- mimeType = "text/xml";
- url = new URL("file:test.xml"); // does not need to exist
-
- // Sample filters
- commitFilter = new CommitResponseFilter();
- doNothingFilter = new DoNothingFilter();
- accessDeniedFilter = new AccessDeniedFilter();
-
- // Mock up the default http context
- defaultHttpContext = EasyMock.createNiceMock(HttpContext.class);
- EasyMock.expect(defaultHttpContext.getMimeType((String)EasyMock.anyObject())).andReturn(mimeType);
- EasyMock.expect(defaultHttpContext.getResource((String)EasyMock.anyObject())).andReturn(url);
- EasyMock.replay(defaultHttpContext);
- }
-
- public void testFilterRequired() throws Exception {
- // Mock up the service references
- ServiceReference[] serviceReferences = new ServiceReference[] {};
-
- // Mock up the bundle context
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.expect(bundleContext.getServiceReferences(Filter.class.getName(),
- "(org.apache.cxf.httpservice.filter=true)"))
- .andReturn(serviceReferences);
- EasyMock.replay(bundleContext);
-
- // Set up the secure http context
- httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
- httpContext.requireFilter = true;
-
- // Ensure that the httpContext doesn't allow the request to be processed, since there are no registered servlet
- // filters
- HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
- EasyMock.replay(request);
- HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
- EasyMock.replay(response);
- boolean requestAllowed = httpContext.handleSecurity(request, response);
- Assert.assertFalse(requestAllowed);
-
- // Ensure that the httpContext returns true if there is no requirement for registered servlet filters
- httpContext.requireFilter = false;
- requestAllowed = httpContext.handleSecurity(request, response);
- Assert.assertTrue(requestAllowed);
- }
-
- public void testSingleCommitFilter() throws Exception {
- // Mock up the service references
- ServiceReference filterReference = EasyMock.createNiceMock(ServiceReference.class);
- EasyMock.replay(filterReference);
- ServiceReference[] serviceReferences = new ServiceReference[] {
- filterReference
- };
-
- // Mock up the bundle context
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.expect(bundleContext.getServiceReferences((String)EasyMock.anyObject(), (String)EasyMock.anyObject()))
- .andReturn(serviceReferences);
- EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(commitFilter);
- EasyMock.replay(bundleContext);
-
- // Set up the secure http context
- httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
-
- // Ensure that the httpContext returns false, since the filter has committed the response
- HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
- EasyMock.replay(request);
- HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
- EasyMock.expect(response.isCommitted()).andReturn(false); // the first call checks to see whether to invoke the
- // filter
- EasyMock.expect(response.isCommitted()).andReturn(true); // the second is called to determine the handleSecurity
- // return value
- EasyMock.expect(response.getWriter()).andReturn(new PrintWriter(System.out));
- EasyMock.replay(response);
- Assert.assertFalse(httpContext.handleSecurity(request, response));
-
- // Ensure that the appropriate filters were called
- Assert.assertTrue(commitFilter.called);
- Assert.assertFalse(doNothingFilter.called);
- Assert.assertFalse(accessDeniedFilter.called);
- }
-
- public void testFilterChain() throws Exception {
- // Mock up the service references
- ServiceReference filterReference = EasyMock.createNiceMock(ServiceReference.class);
- EasyMock.replay(filterReference);
- ServiceReference[] serviceReferences = new ServiceReference[] {
- filterReference, filterReference
- };
-
- // Mock up the bundle context
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.expect(bundleContext.getServiceReferences((String)EasyMock.anyObject(), (String)EasyMock.anyObject()))
- .andReturn(serviceReferences);
- EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(doNothingFilter);
- EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(commitFilter);
- EasyMock.replay(bundleContext);
-
- // Set up the secure http context
- httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
-
- // Ensure that the httpContext returns false, since the filter has committed the response
- HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
- EasyMock.replay(request);
- HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
- EasyMock.expect(response.isCommitted()).andReturn(false); // doNothingFilter should not commit the response
- EasyMock.expect(response.getWriter()).andReturn(new PrintWriter(System.out));
- EasyMock.expect(response.isCommitted()).andReturn(false);
- EasyMock.expect(response.isCommitted()).andReturn(true); // the commit filter indicating that it committed the
- // response
- EasyMock.replay(response);
- Assert.assertFalse(httpContext.handleSecurity(request, response));
-
- // Ensure that the appropriate filters were called
- Assert.assertTrue(doNothingFilter.called);
- Assert.assertTrue(commitFilter.called);
- Assert.assertFalse(accessDeniedFilter.called);
- }
-
- public void testAllowRequest() throws Exception {
- // Mock up the service references
- ServiceReference filterReference = EasyMock.createNiceMock(ServiceReference.class);
- EasyMock.replay(filterReference);
- ServiceReference[] serviceReferences = new ServiceReference[] {
- filterReference
- };
-
- // Mock up the bundle context
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.expect(bundleContext.getServiceReferences((String)EasyMock.anyObject(), (String)EasyMock.anyObject()))
- .andReturn(serviceReferences);
- EasyMock.expect(bundleContext.getService((ServiceReference)EasyMock.anyObject())).andReturn(doNothingFilter);
- EasyMock.replay(bundleContext);
-
- // Set up the secure http context
- httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
-
- // Ensure that the httpContext returns true, since the filter has not committed the response
- HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
- EasyMock.replay(request);
- HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
- EasyMock.expect(response.isCommitted()).andReturn(false);
- EasyMock.replay(response);
- Assert.assertTrue(httpContext.handleSecurity(request, response));
-
- // Ensure that the appropriate filters were called
- Assert.assertTrue(doNothingFilter.called);
- Assert.assertFalse(commitFilter.called);
- Assert.assertFalse(accessDeniedFilter.called);
- }
-
- public void testDelegation() throws Exception {
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(bundleContext);
-
- // Set up the secure http context
- httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
-
- // Ensure that it delegates non-security calls to the wrapped implementation (in this case, the mock)
- Assert.assertEquals(mimeType, httpContext.getMimeType(""));
- Assert.assertEquals(url, httpContext.getResource(""));
- }
-}
-
-class CommitResponseFilter implements Filter {
-
- boolean called;
-
- public void init(FilterConfig filterConfig) throws ServletException {
- }
-
- public void destroy() {
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws java.io.IOException, javax.servlet.ServletException {
- called = true;
- response.getWriter().write("committing the response");
- }
-}
-
-class DoNothingFilter implements Filter {
-
- boolean called;
-
- public void init(FilterConfig filterConfig) throws ServletException {
- }
-
- public void destroy() {
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws java.io.IOException, javax.servlet.ServletException {
- called = true;
- chain.doFilter(request, response);
- }
-}
-
-class AccessDeniedFilter implements Filter {
-
- boolean called;
-
- public void init(FilterConfig filterConfig) throws ServletException {
- }
-
- public void destroy() {
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws java.io.IOException, javax.servlet.ServletException {
- called = true;
- ((HttpServletResponse)response).sendError(HttpServletResponse.SC_FORBIDDEN);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/79bb9a43/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java
index 64beeac..3b909d6 100644
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java
+++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java
@@ -26,6 +26,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.cxf.dosgi.dsw.handlers.pojo.ServiceInvocationHandler;
+
import junit.framework.TestCase;
public class ServiceInvocationHandlerTest extends TestCase {