You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2016/03/11 20:43:33 UTC
[34/50] [abbrv] aries-rsa git commit: Switch project setup to Aries
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/pom.xml
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/pom.xml b/dsw/cxf-dosgi-tcp/pom.xml
deleted file mode 100644
index 8e40ee1..0000000
--- a/dsw/cxf-dosgi-tcp/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.8-SNAPSHOT</version>
- <relativePath>../../parent/pom.xml</relativePath>
- </parent>
- <artifactId>cxf-dosgi-ri-tcp</artifactId>
- <packaging>bundle</packaging>
- <name>CXF dOSGi Remote Service Admin TCP provider</name>
- <description>Provider for Java Serialization over TCP</description>
-
- <properties>
- <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.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-provider-api</artifactId>
- <version>${project.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>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.apache.aries.rsa.provider.tcp.Activator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java
deleted file mode 100644
index 128c3d8..0000000
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java
+++ /dev/null
@@ -1,45 +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.aries.rsa.provider.tcp;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public class Activator implements BundleActivator {
-
- @Override
- public void start(BundleContext context) throws Exception {
- DistributionProvider provider = new TCPProvider();
- Dictionary<String, Object> props = new Hashtable<>();
- props.put(RemoteConstants.REMOTE_INTENTS_SUPPORTED, new String[]{});
- props.put(RemoteConstants.REMOTE_CONFIGS_SUPPORTED, provider.getSupportedTypes());
- context.registerService(DistributionProvider.class, provider, props);
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- // unregister happens automatically
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java
deleted file mode 100644
index ac60950..0000000
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java
+++ /dev/null
@@ -1,43 +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.aries.rsa.provider.tcp;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectStreamClass;
-
-public class LoaderObjectInputStream extends ObjectInputStream {
-
- private ClassLoader loader;
-
- public LoaderObjectInputStream(InputStream in, ClassLoader loader) throws IOException {
- super(in);
- this.loader = loader;
- }
-
- @Override
- protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
- try {
- return loader.loadClass(desc.getName());
- } catch (ClassNotFoundException e) {
- return super.resolveClass(desc);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
deleted file mode 100644
index 3f40bd8..0000000
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/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.aries.rsa.provider.tcp;
-
-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/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
deleted file mode 100644
index 07c5a05..0000000
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
+++ /dev/null
@@ -1,67 +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.aries.rsa.provider.tcp;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.net.URI;
-import java.util.Map;
-
-import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
-import org.apache.cxf.dosgi.dsw.api.Endpoint;
-import org.apache.cxf.dosgi.dsw.api.IntentUnsatisfiedException;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-@SuppressWarnings("rawtypes")
-public class TCPProvider implements DistributionProvider {
-
- private static final String TCP_CONFIG_TYPE = "aries.tcp";
-
- @Override
- public String[] getSupportedTypes() {
- return new String[] {TCP_CONFIG_TYPE};
- }
-
- @Override
- public Endpoint exportService(Object serviceO,
- BundleContext serviceContext,
- Map<String, Object> effectiveProperties,
- Class[] exportedInterfaces) {
- effectiveProperties.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, getSupportedTypes());
- return new TcpEndpoint(serviceO, effectiveProperties);
- }
-
- @Override
- public Object importEndpoint(ClassLoader cl,
- BundleContext consumerContext,
- Class[] interfaces,
- EndpointDescription endpoint)
- throws IntentUnsatisfiedException {
- try {
- URI address = new URI(endpoint.getId());
- InvocationHandler handler = new TcpInvocationHandler(cl, address.getHost(), address.getPort());
- return Proxy.newProxyInstance(cl, interfaces, handler);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java
deleted file mode 100644
index e70731d..0000000
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java
+++ /dev/null
@@ -1,118 +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.aries.rsa.provider.tcp;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TCPServer implements Closeable, Runnable {
- private Logger log = LoggerFactory.getLogger(TCPServer.class);
- private ServerSocket serverSocket;
- private Object service;
- private boolean running;
- private ExecutorService executor;
-
- public TCPServer(Object service, String localip, Integer port, int numThreads) {
- this.service = service;
- try {
- this.serverSocket = new ServerSocket(port);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- this.running = true;
- this.executor = Executors.newCachedThreadPool();
- for (int c = 0; c < numThreads; c++) {
- this.executor.execute(this);
- }
- }
-
- int getPort() {
- return this.serverSocket.getLocalPort();
- }
-
- public void run() {
- ClassLoader serviceCL = service.getClass().getClassLoader();
- while (running) {
- try (
- Socket socket = this.serverSocket.accept();
- ObjectInputStream ois = new LoaderObjectInputStream(socket.getInputStream(), serviceCL);
- ObjectOutputStream objectOutput = new ObjectOutputStream(socket.getOutputStream())
- ) {
- String methodName = (String)ois.readObject();
- Object[] args = (Object[])ois.readObject();
- Object result = invoke(methodName, args);
- objectOutput.writeObject(result);
- } catch (SocketException e) {
- running = false;
- } catch (Exception e) {
- log.warn("Error processing service call.", e);
- }
- }
- }
-
- private Object invoke(String methodName, Object[] args)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- Class<?>[] parameterTypesAr = getTypes(args);
- Method method = service.getClass().getMethod(methodName, parameterTypesAr);
- try {
- return method.invoke(service, args);
- } catch (Throwable e) {
- return e;
- }
- }
-
- private Class<?>[] getTypes(Object[] args) {
- List<Class<?>> parameterTypes = new ArrayList<>();
- if (args != null) {
- for (Object arg : args) {
- parameterTypes.add(arg.getClass());
- }
- }
- Class<?>[] parameterTypesAr = parameterTypes.toArray(new Class[]{});
- return parameterTypesAr;
- }
-
- @Override
- public void close() throws IOException {
- this.serverSocket.close();
- this.running = false;
- this.executor.shutdown();
- try {
- this.executor.awaitTermination(10, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- }
- this.executor.shutdownNow();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java
deleted file mode 100644
index 5bc9d7a..0000000
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java
+++ /dev/null
@@ -1,58 +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.aries.rsa.provider.tcp;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.cxf.dosgi.dsw.api.Endpoint;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public class TcpEndpoint implements Endpoint {
- private EndpointDescription epd;
- private TCPServer tcpServer;
-
- public TcpEndpoint(Object service, Map<String, Object> effectiveProperties) {
- Integer port = getInt(effectiveProperties, "port", 0);
- String localip = LocalHostUtil.getLocalIp();
- int numThreads = getInt(effectiveProperties, "numThreads", 10);
- tcpServer = new TCPServer(service, localip, port, numThreads);
- effectiveProperties.put(RemoteConstants.ENDPOINT_ID, "tcp://" + localip + ":" + tcpServer.getPort());
- effectiveProperties.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, "");
- this.epd = new EndpointDescription(effectiveProperties);
- }
-
-
- private Integer getInt(Map<String, Object> effectiveProperties, String key, int defaultValue) {
- String value = (String)effectiveProperties.get(key);
- return value != null ? Integer.parseInt(value) : defaultValue;
- }
-
- @Override
- public EndpointDescription description() {
- return this.epd;
- }
-
-
- @Override
- public void close() throws IOException {
- tcpServer.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
deleted file mode 100644
index cdbf8ec..0000000
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
+++ /dev/null
@@ -1,68 +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.aries.rsa.provider.tcp;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-public class TcpInvocationHandler implements InvocationHandler {
- private String host;
- private int port;
- private ClassLoader cl;
-
- public TcpInvocationHandler(ClassLoader cl, String host, int port)
- throws UnknownHostException, IOException {
- this.cl = cl;
- this.host = host;
- this.port = port;
-
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- try (
- Socket socket = new Socket(this.host, this.port);
- ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream())
- ) {
- out.writeObject(method.getName());
- out.writeObject(args);
- out.flush();
- return parseResult(socket);
- } catch (Exception e) {
- throw new RuntimeException("Error calling " + host + ":" + port + " method: " + method.getName(), e);
- }
- }
-
- private Object parseResult(Socket socket) throws IOException, ClassNotFoundException, Throwable {
- try (ObjectInputStream in = new LoaderObjectInputStream(socket.getInputStream(), cl)) {
- Object result = in.readObject();
- if (result instanceof Throwable) {
- throw (Throwable)result;
- } else {
- return result;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
deleted file mode 100644
index 583c5e1..0000000
--- a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
+++ /dev/null
@@ -1,107 +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.aries.rsa.provider.tcp;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.aries.rsa.provider.tcp.myservice.MyService;
-import org.apache.aries.rsa.provider.tcp.myservice.MyServiceImpl;
-import org.apache.cxf.dosgi.dsw.api.Endpoint;
-import org.apache.cxf.dosgi.dsw.api.EndpointHelper;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-
-public class TcpProviderTest {
-
- private static final int NUM_CALLS = 100;
- private MyService myServiceProxy;
- private Endpoint ep;
-
- @Before
- public void createServerAndProxy() {
- Class<?>[] exportedInterfaces = new Class[] {MyService.class};
- TCPProvider provider = new TCPProvider();
- Map<String, Object> props = new HashMap<String, Object>();
- EndpointHelper.addObjectClass(props, exportedInterfaces);
- MyService myService = new MyServiceImpl();
- BundleContext bc = EasyMock.mock(BundleContext.class);
- ep = provider.exportService(myService, bc, props, exportedInterfaces);
- myServiceProxy = (MyService)provider.importEndpoint(MyService.class.getClassLoader(),
- bc,
- exportedInterfaces,
- ep.description());
- }
-
- @Test
- public void testPerf() throws IOException, InterruptedException {
- runPerfTest(myServiceProxy);
- String msg = "test";
- String result = myServiceProxy.echo(msg);
- Assert.assertEquals(msg, result);
- }
-
- @Test
- public void testCall() throws IOException, InterruptedException {
- myServiceProxy.call("test");
- }
-
- @Test
- public void testCallOneway() throws IOException, InterruptedException {
- myServiceProxy.callOneWay("test");
- }
-
- @After
- public void close() throws IOException {
- ep.close();
- }
-
- private void runPerfTest(final MyService myServiceProxy2) throws InterruptedException {
- StringBuilder msg = new StringBuilder();
- for (int c = 0; c < 1000; c++) {
- msg.append("testing123");
- }
- final String msg2 = msg.toString();
- ExecutorService executor = Executors.newFixedThreadPool(10);
- Runnable task = new Runnable() {
-
- @Override
- public void run() {
- String result = myServiceProxy2.echo(msg2);
- Assert.assertEquals(msg2, result);
- }
- };
- long start = System.currentTimeMillis();
- for (int c = 0; c < NUM_CALLS; c++) {
- executor.execute(task);
- }
- executor.shutdown();
- executor.awaitTermination(100, TimeUnit.SECONDS);
- long tps = NUM_CALLS * 1000 / (System.currentTimeMillis() - start);
- System.out.println(tps + " tps");
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java
deleted file mode 100644
index e9d56bf..0000000
--- a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java
+++ /dev/null
@@ -1,30 +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.aries.rsa.provider.tcp.myservice;
-
-import javax.jws.Oneway;
-
-public interface MyService {
- String echo(String msg);
- void call(String msg);
-
- // Oneway not yet supported
- @Oneway
- void callOneWay(String msg);
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
deleted file mode 100644
index 5f469ed..0000000
--- a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
+++ /dev/null
@@ -1,36 +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.aries.rsa.provider.tcp.myservice;
-
-public class MyServiceImpl implements MyService {
-
- @Override
- public String echo(String msg) {
- return msg;
- }
-
- @Override
- public void call(String msg) {
- }
-
- @Override
- public void callOneWay(String msg) {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/pom.xml
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/pom.xml b/dsw/cxf-dsw/pom.xml
deleted file mode 100644
index 81a3720..0000000
--- a/dsw/cxf-dsw/pom.xml
+++ /dev/null
@@ -1,155 +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-dsw-cxf</artifactId>
- <packaging>bundle</packaging>
- <name>CXF dOSGi Distribution provider</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.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <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.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-provider-api</artifactId>
- <version>${project.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>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_${servlet.version}_spec</artifactId>
- <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>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jvnet.jaxb2.maven2</groupId>
- <artifactId>maven-jaxb2-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </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>
- <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>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/TestUtils*</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
deleted file mode 100644
index 743e8f2..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.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;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
-import org.apache.cxf.dosgi.dsw.decorator.ServiceDecorator;
-import org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorBundleListener;
-import org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorImpl;
-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);
- ServiceDecoratorImpl serviceDecorator = new ServiceDecoratorImpl();
- bundleListener = new ServiceDecoratorBundleListener(serviceDecorator);
- bc.addBundleListener(bundleListener);
- decoratorReg = bc.registerService(ServiceDecorator.class.getName(), serviceDecorator, null);
- }
-
- 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/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
deleted file mode 100644
index 218bec6..0000000
--- a/dsw/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/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
deleted file mode 100644
index 82753b1..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
+++ /dev/null
@@ -1,85 +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.decorator;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
-import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationsType;
-
-class DecorationParser {
- private JAXBContext jaxbContext;
- private Schema schema;
-
- DecorationParser() {
- try {
- jaxbContext = JAXBContext.newInstance(ServiceDecorationsType.class.getPackage().getName(),
- this.getClass().getClassLoader());
- SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- URL resource = getClass().getResource("/service-decoration.xsd");
- schema = schemaFactory.newSchema(resource);
- } catch (Exception e) {
- throw new RuntimeException("Error loading decorations schema", e);
- }
-
- }
-
- List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException {
- if (resourceURL == null || !decorationType(resourceURL)) {
- return new ArrayList<ServiceDecorationType>();
- }
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- unmarshaller.setSchema(schema);
- InputStream is = resourceURL.openStream();
- Source source = new StreamSource(is);
- JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class);
- ServiceDecorationsType decorations = jaxb.getValue();
- return decorations.getServiceDecoration();
- }
-
- private boolean decorationType(URL resourceURL) {
- try {
- InputStream is = resourceURL.openStream();
- XMLInputFactory factory = XMLInputFactory.newInstance();
- XMLStreamReader reader = factory.createXMLStreamReader(is);
- reader.next();
- String ns = reader.getNamespaceURI();
- reader.close();
- return ns.equals("http://cxf.apache.org/xmlns/service-decoration/1.0.0");
- } catch (Exception e) {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
deleted file mode 100644
index 894d01d..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRule.java
+++ /dev/null
@@ -1,96 +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.decorator;
-
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class InterfaceRule implements Rule {
-
- private static final Logger LOG = LoggerFactory.getLogger(InterfaceRule.class);
-
- private final Bundle bundle;
- private final Pattern matchPattern;
- private final Map<String, String> propMatches = new HashMap<String, String>();
- private final Map<String, Object> addProps = new HashMap<String, Object>();
-
- public InterfaceRule(Bundle b, String im) {
- bundle = b;
- matchPattern = Pattern.compile(im);
- }
-
- public synchronized void addPropMatch(String name, String value) {
- propMatches.put(name, value);
- }
-
- public synchronized void addProperty(String name, String value, String type) {
- Object obj = value;
-
- if (type != null && !String.class.getName().equals(type)) {
- try {
- Class<?> cls = getClass().getClassLoader().loadClass(type);
- Constructor<?> ctor = cls.getConstructor(new Class[] {String.class});
- obj = ctor.newInstance(value);
- } catch (Throwable th) {
- LOG.warn("Could not handle property '" + name
- + "' with value '" + value + "' of type: " + type, th);
- return;
- }
- }
-
- addProps.put(name, obj);
- }
-
- public synchronized void apply(ServiceReference<?> sref, Map<String, Object> target) {
- String[] objectClass = (String[]) sref.getProperty(Constants.OBJECTCLASS);
- boolean matches = false;
- for (String cls : objectClass) {
- Matcher m = matchPattern.matcher(cls);
- if (m.matches()) {
- for (Map.Entry<String, String> pm : propMatches.entrySet()) {
- Object value = sref.getProperty(pm.getKey());
- if (value == null || !Pattern.matches(pm.getValue(), value.toString())) {
- return;
- }
- }
- matches = true;
- break;
- }
- }
- if (!matches) {
- return;
- }
-
- LOG.info("Adding the following properties to " + sref + ": " + addProps);
- target.putAll(addProps);
- }
-
- public Bundle getBundle() {
- return bundle;
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
deleted file mode 100644
index adbd1cf..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/Rule.java
+++ /dev/null
@@ -1,41 +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.decorator;
-
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-
-public interface Rule {
-
- /**
- * When the ServiceReference passed in matches the rule's condition,
- * set the additional properties in the target.
- * @param sref The Service Reference to be checked.
- * @param target Any additional properties are to be set in this map.
- */
- void apply(ServiceReference<?> sref, Map<String, Object> target);
-
- /**
- * Returns the bundle that provided this rule.
- * @return The Bundle where the Rule was defined.
- */
- Bundle getBundle();
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
deleted file mode 100644
index 203bd1c..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecorator.java
+++ /dev/null
@@ -1,28 +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.decorator;
-
-import java.util.Map;
-
-import org.osgi.framework.ServiceReference;
-
-public interface ServiceDecorator {
-
- void decorate(ServiceReference<?> sref, Map<String, Object> properties);
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
deleted file mode 100644
index 79c2908..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorBundleListener.java
+++ /dev/null
@@ -1,48 +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.decorator;
-
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-
-public class ServiceDecoratorBundleListener implements BundleListener {
- /**
- *
- */
- private final ServiceDecoratorImpl serviceDecorator;
-
- /**
- * @param serviceDecorator
- */
- public ServiceDecoratorBundleListener(ServiceDecoratorImpl serviceDecorator) {
- this.serviceDecorator = serviceDecorator;
- }
-
- public void bundleChanged(BundleEvent be) {
- switch(be.getType()) {
- case BundleEvent.STARTED:
- this.serviceDecorator.addDecorations(be.getBundle());
- break;
- case BundleEvent.STOPPING:
- this.serviceDecorator.removeDecorations(be.getBundle());
- break;
- default:
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
deleted file mode 100644
index 20130c3..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
+++ /dev/null
@@ -1,97 +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.decorator;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.apache.cxf.xmlns.service_decoration._1_0.AddPropertyType;
-import org.apache.cxf.xmlns.service_decoration._1_0.MatchPropertyType;
-import org.apache.cxf.xmlns.service_decoration._1_0.MatchType;
-import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ServiceDecoratorImpl implements ServiceDecorator {
- private static final Logger LOG = LoggerFactory.getLogger(ServiceDecoratorImpl.class);
- final List<Rule> decorations = new CopyOnWriteArrayList<Rule>();
-
- private DecorationParser parser;
-
- public ServiceDecoratorImpl() {
- parser = new DecorationParser();
- }
-
- public void decorate(ServiceReference<?> sref, Map<String, Object> target) {
- for (Rule matcher : decorations) {
- matcher.apply(sref, target);
- }
- }
-
- void addDecorations(Bundle bundle) {
- for (ServiceDecorationType decoration : getDecorationElements(bundle)) {
- for (MatchType match : decoration.getMatch()) {
- decorations.add(getRule(bundle, match));
- }
- }
- }
-
- private Rule getRule(Bundle bundle, MatchType match) {
- InterfaceRule m = new InterfaceRule(bundle, match.getInterface());
- for (MatchPropertyType propMatch : match.getMatchProperty()) {
- m.addPropMatch(propMatch.getName(), propMatch.getValue());
- }
- for (AddPropertyType addProp : match.getAddProperty()) {
- m.addProperty(addProp.getName(), addProp.getValue(), addProp.getType());
- }
- return m;
- }
-
- List<ServiceDecorationType> getDecorationElements(Bundle bundle) {
- @SuppressWarnings("rawtypes")
- Enumeration entries = bundle.findEntries("OSGI-INF/remote-service", "*.xml", false);
- if (entries == null) {
- return Collections.emptyList();
- }
- List<ServiceDecorationType> elements = new ArrayList<ServiceDecorationType>();
- while (entries.hasMoreElements()) {
- try {
- elements.addAll(parser.getDecorations((URL)entries.nextElement()));
- } catch (Exception e) {
- LOG.warn("Error parsing remote-service descriptions in bundle" + bundle.getSymbolicName(), e);
- }
- }
- return elements;
- }
-
- void removeDecorations(Bundle bundle) {
- for (Rule r : decorations) {
- if (bundle.equals(r.getBundle())) {
- decorations.remove(r); // the iterator doesn't support 'remove'
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/d73a3a7f/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
deleted file mode 100644
index 9e1356c..0000000
--- a/dsw/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.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.api.DistributionProvider;
-import org.apache.cxf.dosgi.dsw.api.Endpoint;
-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);
- }
- }
-
-}