You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by da...@apache.org on 2009/12/17 12:28:41 UTC
svn commit: r891650 [3/10] - in /cxf/dosgi/trunk: ./
discovery/distributed/cxf-discovery/
discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/
discovery/distributed/cxf-discovery/src/main/java/org/osgi/service/dis...
Modified: cxf/dosgi/trunk/distribution/single-bundle/src/main/resources/org/apache/cxf/dosgi/singlebundle/activators.list
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/main/resources/org/apache/cxf/dosgi/singlebundle/activators.list?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/main/resources/org/apache/cxf/dosgi/singlebundle/activators.list (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/main/resources/org/apache/cxf/dosgi/singlebundle/activators.list Thu Dec 17 11:28:30 2009
@@ -4,4 +4,5 @@
org.apache.cxf.dosgi.discovery.local.Activator
org.apache.cxf.dosgi.dsw.Activator
org.apache.cxf.dosgi.discovery.zookeeper.Activator
+org.apache.cxf.dosgi.topologymanager.Activator
org.springframework.osgi.extender.internal.activator.ContextLoaderListener
Modified: cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivatorTest.java Thu Dec 17 11:28:30 2009
@@ -47,6 +47,7 @@
"org.apache.cxf.dosgi.discovery.local.Activator",
"org.apache.cxf.dosgi.dsw.Activator",
"org.apache.cxf.dosgi.discovery.zookeeper.Activator",
+ "org.apache.cxf.dosgi.topologymanager.Activator",
"org.springframework.osgi.extender.internal.activator.ContextLoaderListener"};
AggregatedActivator aa = new AggregatedActivator();
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml Thu Dec 17 11:28:30 2009
@@ -37,12 +37,23 @@
<bundle.import.package>*</bundle.import.package>
<bundle.export.package>
org.apache.cxf.dosgi.*;version="${pom.version}",
- org.osgi.service.distribution;version="1.0";-split-package:=merge-first,
- org.osgi.service.discovery;version="1.0";-split-package:=merge-first
+ org.osgi.service.remoteserviceadmin;version="${remote.service.admin.interfaces.version}"
</bundle.export.package>
+ <!--
+ org.osgi.service.discovery;-split-package:=merge-first,
+ org.osgi.service.distribution;-split-package:=merge-first
+ -->
</properties>
<dependencies>
+
+ <dependency>
+ <groupId>org.apache.cxf.dosgi</groupId>
+ <artifactId>cxf-dosgi-remote-service-admin-interfaces</artifactId>
+ <version>${remote.service.admin.interfaces.version}</version>
+ <!-- <scope>provided</scope> Include the interfaces -->
+ </dependency>
+
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-minimal</artifactId>
@@ -86,16 +97,18 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
<configuration>
<instructions>
- <Bundle-Name>CXF Distributed Software Bundle</Bundle-Name>
+ <Bundle-Name>CXF dOSGi Remote Service Admin Implementation</Bundle-Name>
<Bundle-Description>This bundle contains the implementation required by the CXF Distributed Software Bundle</Bundle-Description>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
<Bundle-Activator>org.apache.cxf.dosgi.dsw.Activator</Bundle-Activator>
<Import-Package>${bundle.import.package}</Import-Package>
- <Export-Package>${bundle.export.package}</Export-Package>
+ <Export-Package>${bundle.export.package}</Export-Package>
<DynamicImport-Package>*</DynamicImport-Package>
+ <Private-Package>org.osgi.service.discovery,org.osgi.service.distribution</Private-Package>
</instructions>
</configuration>
</plugin>
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java Thu Dec 17 11:28:30 2009
@@ -1,107 +1,94 @@
/**
- * 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.
- */
+ * 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 java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import org.apache.cxf.dosgi.dsw.decorator.ServiceDecorator;
import org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorImpl;
-import org.apache.cxf.dosgi.dsw.hooks.CxfFindListenerHook;
-import org.apache.cxf.dosgi.dsw.hooks.CxfPublishHook;
import org.apache.cxf.dosgi.dsw.qos.IntentMap;
-import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
-import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
+import org.apache.cxf.dosgi.dsw.service.RemoteServiceadminFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.hooks.service.FindHook;
-import org.osgi.framework.hooks.service.ListenerHook;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
import org.osgi.service.distribution.DistributionProvider;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
-public class Activator implements BundleActivator, ServiceListener, ManagedService {
+public class Activator implements BundleActivator, ManagedService {
private static final String CONFIG_SERVICE_PID = "cxf-dsw";
- private BundleContext bc;
- private ExecutorService execService =
- new ThreadPoolExecutor(5, 10, 50, TimeUnit.SECONDS,
- new LinkedBlockingQueue<Runnable>());
-
- CxfDistributionProvider dpService;
- CxfFindListenerHook lHook;
- CxfPublishHook pHook;
- ServiceRegistration decoratorReg;
+ private BundleContext bc;
+
+
+ private RemoteServiceadminFactory dpService;
+ private ServiceRegistration decoratorReg;
+
public void start(BundleContext context) throws Exception {
// Disable the fast infoset as it's not compatible (yet) with OSGi
System.setProperty("org.apache.cxf.nofastinfoset", "true");
+
+ bc = context;
+ // should we have a seperate PID for a find and publish hook ?
+ //context.registerService(ManagedService.class.getName(), this, getDefaults());
+
+ dpService = registerRemoteServiceAdminService();
+
+
+ /**
+ * What is this decorator doing ?!?!?! Why as a service ?
+ */
+ decoratorReg = bc.registerService(ServiceDecorator.class.getName(), new ServiceDecoratorImpl(bc),
+ null);
- bc = context;
- // should we have a seperate PID for a find and publish hook ?
- context.registerService(ManagedService.class.getName(),
- this, getDefaults());
-
- decoratorReg = context.registerService(ServiceDecorator.class.getName(),
- new ServiceDecoratorImpl(context), null);
- dpService = registerDistributionProviderService();
-
- pHook = new CxfPublishHook(context, dpService);
- lHook = new CxfFindListenerHook(context, dpService);
- context.registerService(new String [] {FindHook.class.getName(), ListenerHook.class.getName()}, lHook, new Hashtable());
- context.addServiceListener(this);
- checkExistingServices();
+
}
- private CxfDistributionProvider registerDistributionProviderService() {
- DistributionProviderImpl dpService = new DistributionProviderImpl(bc);
+ private RemoteServiceadminFactory registerRemoteServiceAdminService() {
+ RemoteServiceadminFactory dpService = new RemoteServiceadminFactory(bc);
Hashtable<String, Object> props = new Hashtable<String, Object>();
-
+
+ // TODO .... RemoteAdminService.XXX
props.put(DistributionProvider.PRODUCT_NAME, getHeader("Bundle-Name"));
props.put(DistributionProvider.PRODUCT_VERSION, getHeader("Bundle-Version"));
props.put(DistributionProvider.VENDOR_NAME, getHeader("Bundle-Vendor"));
-
- String[] supportedIntents = getIntentMap().getIntents().keySet().toArray(new String [] {});
+
+ String[] supportedIntents = getIntentMap().getIntents().keySet().toArray(new String[] {});
String siString = OsgiUtils.formatIntents(supportedIntents);
props.put(DistributionProvider.SUPPORTED_INTENTS, siString);
props.put("remote.intents.supported", supportedIntents);
// TODO make this a little smarter
String[] supportedConfigs = {
- org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE,
- org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE_OLD,
- org.apache.cxf.dosgi.dsw.Constants.RS_CONFIG_TYPE};
+ org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE,
+ org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE_OLD,
+ org.apache.cxf.dosgi.dsw.Constants.RS_CONFIG_TYPE
+ };
props.put("remote.configs.supported", supportedConfigs);
-
- bc.registerService(DistributionProvider.class.getName(), dpService, props);
+
+ bc.registerService(RemoteServiceAdmin.class.getName(), dpService, props);
return dpService;
}
@@ -119,57 +106,25 @@
}
public void stop(BundleContext context) {
- dpService.shutdown();
- execService.shutdown();
- pHook.removeEndpoints();
+ // dpService.shutdown();
+
+
- decoratorReg.unregister();
+ decoratorReg.unregister();
+
// unregister other registered services (ManagedService + Hooks)
}
private Dictionary<String, String> getDefaults() {
Dictionary<String, String> defaults = new Hashtable<String, String>();
- defaults.put(Constants.SERVICE_PID, CONFIG_SERVICE_PID);
+ defaults.put(Constants.SERVICE_PID, CONFIG_SERVICE_PID);
return defaults;
}
-
- public void updated(Dictionary props) throws ConfigurationException {
- if (props != null
- && CONFIG_SERVICE_PID.equals(props.get(Constants.SERVICE_PID))) {
- pHook.updateProperties(props);
- lHook.updateProperties(props);
- }
- }
- private void checkExistingServices() throws InvalidSyntaxException {
- ServiceReference[] references = bc.getServiceReferences(null,
- "(|(" + org.apache.cxf.dosgi.dsw.Constants.EXPORTED_INTERFACES + "=*)" +
- "(" + org.apache.cxf.dosgi.dsw.Constants.EXPORTED_INTERFACES_OLD + "=*))");
-
- if (references != null) {
- for (ServiceReference sref : references) {
- pHook.publishEndpoint(sref);
- }
+ public void updated(Dictionary props) throws ConfigurationException {
+ if (props != null && CONFIG_SERVICE_PID.equals(props.get(Constants.SERVICE_PID))) {
+ // topManager.updated(props);
}
}
- public void serviceChanged(ServiceEvent event) {
-
- final ServiceReference sref = event.getServiceReference();
-
- if (event.getType() == ServiceEvent.REGISTERED) {
-
- execService.execute(new Runnable(){
- public void run() {
- pHook.publishEndpoint(sref);
- }
- });
-
- } else if (event.getType() == ServiceEvent.UNREGISTERING) {
- // this should be timely enough
- pHook.removeEndpoint(sref);
- }
-
- }
-
}
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java Thu Dec 17 11:28:30 2009
@@ -1,21 +1,21 @@
/**
- * 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.
- */
+ * 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.net.URL;
@@ -45,24 +45,25 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-
public final class OsgiUtils {
- private static final Logger LOG =
- Logger.getLogger(OsgiUtils.class.getName());
-
+ private static final Logger LOG = Logger.getLogger(OsgiUtils.class.getName());
+
private static final String REMOTE_SERVICES_HEADER_NAME = "Remote-Service";
- private static final String REMOTE_SERVICES_DIRECTORY =
- "OSGI-INF/remote-service";
- private static final String REMOTE_SERVICES_NS =
- "http://www.osgi.org/xmlns/sd/v1.0.0";
-
- static final String[] INTENT_MAP = {"/OSGI-INF/cxf/intents/intent-map.xml"};
-
+ private static final String REMOTE_SERVICES_DIRECTORY = "OSGI-INF/remote-service";
+ private static final String REMOTE_SERVICES_NS = "http://www.osgi.org/xmlns/sd/v1.0.0";
+
+ static final String[] INTENT_MAP = {
+ "/OSGI-INF/cxf/intents/intent-map.xml"
+ };
+
private static final String SERVICE_DESCRIPTION_ELEMENT = "service-description";
-
+
private static final String PROVIDE_INTERFACE_ELEMENT = "provide";
private static final String PROVIDE_INTERFACE_NAME_ATTRIBUTE = "interface";
@@ -73,42 +74,40 @@
private static final String INTERFACE_WILDCARD = "*";
private static final String INTERFACE_SEPARATOR = ":";
-
+
private OsgiUtils() {
}
-
- // Used by PublishHook
+ // Used by PublishHook
public static ServiceEndpointDescription getRemoteReference(ServiceReference sref, boolean matchAllNames) {
-
+
String[] names = (String[])sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
if (names == null || names.length == 0) {
return null;
}
-
+
Map<String, Object> userProperties = new HashMap<String, Object>();
for (String key : sref.getPropertyKeys()) {
userProperties.put(key, sref.getProperty(key));
}
- List<ServiceEndpointDescription> srefs = getRemoteReferences(sref.getBundle(),
- names,
- userProperties,
- matchAllNames);
+ List<ServiceEndpointDescription> srefs = getRemoteReferences(sref.getBundle(), names, userProperties,
+ matchAllNames);
setAdditionalProperties(sref, userProperties);
-
+
if (srefs.isEmpty()) {
return new ServiceEndpointDescriptionImpl(Arrays.asList(names), userProperties);
}
-
- return srefs.get(0);
+
+ return srefs.get(0);
}
-
+
@SuppressWarnings("unchecked")
- public static List<ServiceEndpointDescription> getRemoteReferences(
- Bundle b, String[] names, Map<String, Object> userProperties, boolean matchAllNames) {
-
+ public static List<ServiceEndpointDescription> getRemoteReferences(Bundle b, String[] names,
+ Map<String, Object> userProperties,
+ boolean matchAllNames) {
+
List<Element> references = getAllDescriptionElements(b);
-
+
List<ServiceEndpointDescription> srefs = new ArrayList<ServiceEndpointDescription>();
Namespace ns = Namespace.getNamespace(REMOTE_SERVICES_NS);
for (Element ref : references) {
@@ -117,39 +116,40 @@
continue;
}
- Map<String, Object> remoteProps = new HashMap<String, Object>(userProperties);
+ Map<String, Object> remoteProps = new HashMap<String, Object>(userProperties);
addProperties(remoteProps, ref.getChildren(PROPERTY_ELEMENT, ns));
- srefs.add(new ServiceEndpointDescriptionImpl(iNames, remoteProps));
+ srefs.add(new ServiceEndpointDescriptionImpl(iNames, remoteProps));
}
return srefs;
-
+
}
-
+
public static ServiceEndpointDescription[] flattenServiceDescription(ServiceEndpointDescription sd) {
ServiceEndpointDescription[] list = null;
int interfaceNameCount = sd.getProvidedInterfaces().size();
if (sd.getProvidedInterfaces() == null || interfaceNameCount <= 1) {
- list = new ServiceEndpointDescription[] {sd};
+ list = new ServiceEndpointDescription[] {
+ sd
+ };
} else {
- String[] iNames = (String[])
- sd.getProvidedInterfaces().toArray(new String[interfaceNameCount]);
+ String[] iNames = (String[])sd.getProvidedInterfaces().toArray(new String[interfaceNameCount]);
list = new ServiceEndpointDescription[iNames.length];
for (int i = 0; i < iNames.length; i++) {
Map<String, Object> props = excludeProperty(sd.getProperties(),
- Constants.EXPORTED_INTERFACES, Constants.EXPORTED_INTERFACES_OLD,
- Constants.RS_PROVIDER_GLOBAL_PROP_KEY, Constants.RS_PROVIDER_EXPECTED_PROP_KEY,
- Constants.RS_PROVIDER_PROP_KEY);
-
+ Constants.EXPORTED_INTERFACES,
+ Constants.EXPORTED_INTERFACES_OLD,
+ Constants.RS_PROVIDER_GLOBAL_PROP_KEY,
+ Constants.RS_PROVIDER_EXPECTED_PROP_KEY,
+ Constants.RS_PROVIDER_PROP_KEY);
+
String keys[] = props.keySet().toArray(new String[props.size()]);
for (int j = 0; j < keys.length; j++) {
int sep = keys[j].indexOf(INTERFACE_SEPARATOR);
if (sep > -1) {
String value = (String)props.remove(keys[j]);
String root = keys[j].substring(0, sep);
- String iface =
- sep + INTERFACE_SEPARATOR.length() < keys[j].length()
- ? keys[j].substring(sep + INTERFACE_SEPARATOR.length())
- : "";
+ String iface = sep + INTERFACE_SEPARATOR.length() < keys[j].length() ? keys[j]
+ .substring(sep + INTERFACE_SEPARATOR.length()) : "";
if (iNames[i].equals(iface)) {
props.put(root, value);
}
@@ -161,10 +161,9 @@
return list;
}
- private static Map<String, Object> excludeProperty(Map properties,
- String ... excludes) {
+ private static Map<String, Object> excludeProperty(Map properties, String... excludes) {
Collection<String> exList = Arrays.asList(excludes);
-
+
Map<String, Object> pruned = new HashMap<String, Object>();
for (Object key : properties.keySet()) {
if (exList.contains(key)) {
@@ -175,20 +174,20 @@
}
return pruned;
}
-
+
@SuppressWarnings("unchecked")
public static List<Element> getAllDescriptionElements(Bundle b) {
Object directory = null;
-
+
Dictionary headers = b.getHeaders();
if (headers != null) {
directory = headers.get(REMOTE_SERVICES_HEADER_NAME);
}
-
+
if (directory == null) {
directory = REMOTE_SERVICES_DIRECTORY;
}
-
+
Enumeration urls = b.findEntries(directory.toString(), "*.xml", false);
if (urls == null) {
return Collections.emptyList();
@@ -196,41 +195,40 @@
List<Element> elements = new ArrayList<Element>();
while (urls.hasMoreElements()) {
- URL resourceURL = (URL) urls.nextElement();
+ URL resourceURL = (URL)urls.nextElement();
try {
Document d = new SAXBuilder().build(resourceURL.openStream());
Namespace ns = Namespace.getNamespace(REMOTE_SERVICES_NS);
elements.addAll(d.getRootElement().getChildren(SERVICE_DESCRIPTION_ELEMENT, ns));
} catch (Exception ex) {
LOG.log(Level.WARNING, "Problem parsing: " + resourceURL, ex);
- }
+ }
}
- return elements;
+ return elements;
}
-
- private static void setAdditionalProperties(ServiceReference sref, Map<String, Object> props) {
+
+ private static void setAdditionalProperties(ServiceReference sref, Map<String, Object> props) {
BundleContext bc = sref.getBundle().getBundleContext();
- ServiceReference [] refs;
- try {
- refs = bc.getServiceReferences(ServiceDecorator.class.getName(), null);
- } catch (InvalidSyntaxException e) {
- // should never happen, filter is null
- return;
- }
+ ServiceReference[] refs;
+ try {
+ refs = bc.getServiceReferences(ServiceDecorator.class.getName(), null);
+ } catch (InvalidSyntaxException e) {
+ // should never happen, filter is null
+ return;
+ }
if (refs == null) {
return;
}
-
+
for (ServiceReference ref : refs) {
Object svc = bc.getService(ref);
if (svc instanceof ServiceDecorator) {
- ((ServiceDecorator) svc).decorate(sref, props);
- }
+ ((ServiceDecorator)svc).decorate(sref, props);
+ }
}
}
-
- private static boolean serviceNamesMatch(
- String[] names, List<String> iNames, boolean matchAllNames) {
+
+ private static boolean serviceNamesMatch(String[] names, List<String> iNames, boolean matchAllNames) {
if (names == null || names.length == 0) {
return false;
}
@@ -250,78 +248,62 @@
return false;
}
}
-
+
/*
- // TODO : consider creating a new List rather than modifyiing the existing one
- public static void matchServiceDescriptions(List<ServiceEndpointDescription> sds,
- String interfaceName,
- Filter filter,
- boolean matchAll) {
-
- for (Iterator<ServiceEndpointDescription> it = sds.iterator(); it.hasNext();) {
- ServiceEndpointDescription sd = it.next();
-
- if (filter != null && !OsgiUtils.matchAgainstFilter(sd, interfaceName, filter, matchAll)) {
- it.remove();
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public static boolean matchAgainstFilter(ServiceEndpointDescription sd,
- String interfaceName, Filter filter, boolean matchAll) {
- Dictionary props = new Hashtable();
- for (Object key : sd.getPropertyKeys()) {
- if (matchAll || key.toString().startsWith(DistributionConstants.REMOTE)) {
- props.put(key, sd.getProperty(key.toString()));
- }
- }
- String[] interfaceNames = getProvidedInterfaces(sd, interfaceName);
- if (interfaceNames != null) {
- props.put(org.osgi.framework.Constants.OBJECTCLASS,
- interfaceNames);
- }
- return filter.match(props);
- } */
-
+ * // TODO : consider creating a new List rather than modifyiing the existing one public static void
+ * matchServiceDescriptions(List<ServiceEndpointDescription> sds, String interfaceName, Filter filter,
+ * boolean matchAll) { for (Iterator<ServiceEndpointDescription> it = sds.iterator(); it.hasNext();) {
+ * ServiceEndpointDescription sd = it.next(); if (filter != null && !OsgiUtils.matchAgainstFilter(sd,
+ * interfaceName, filter, matchAll)) { it.remove(); } } }
+ * @SuppressWarnings("unchecked") public static boolean matchAgainstFilter(ServiceEndpointDescription sd,
+ * String interfaceName, Filter filter, boolean matchAll) { Dictionary props = new Hashtable(); for
+ * (Object key : sd.getPropertyKeys()) { if (matchAll ||
+ * key.toString().startsWith(DistributionConstants.REMOTE)) { props.put(key,
+ * sd.getProperty(key.toString())); } } String[] interfaceNames = getProvidedInterfaces(sd,
+ * interfaceName); if (interfaceNames != null) { props.put(org.osgi.framework.Constants.OBJECTCLASS,
+ * interfaceNames); } return filter.match(props); }
+ */
+
public static String[] getProvidedInterfaces(ServiceEndpointDescription sd, String interfaceName) {
-
+
int interfaceNameCount = sd.getProvidedInterfaces().size();
- String[] interfaceNames = (String[])
- sd.getProvidedInterfaces().toArray(new String[interfaceNameCount]);
+ String[] interfaceNames = (String[])sd.getProvidedInterfaces()
+ .toArray(new String[interfaceNameCount]);
if (interfaceName == null) {
return interfaceNames;
}
-
+
for (String s : interfaceNames) {
if (s.equals(interfaceName)) {
- return new String[]{s};
+ return new String[] {
+ s
+ };
}
}
return null;
}
-
+
public static Filter createFilter(BundleContext bc, String filterValue) {
-
+
if (filterValue == null) {
return null;
}
-
+
try {
- return bc.createFilter(filterValue);
+ return bc.createFilter(filterValue);
} catch (InvalidSyntaxException ex) {
System.out.println("Invalid filter expression " + filterValue);
} catch (Exception ex) {
- System.out.println("Problem creating a Filter from " + filterValue);
+ System.out.println("Problem creating a Filter from " + filterValue);
}
return null;
}
-
+
public static String[] parseIntents(String intentsSequence) {
- return intentsSequence == null ? new String[]{} : intentsSequence.split(" ");
+ return intentsSequence == null ? new String[] {} : intentsSequence.split(" ");
}
-
- public static String formatIntents(String [] intents) {
+
+ public static String formatIntents(String[] intents) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String intent : intents) {
@@ -334,48 +316,45 @@
}
return sb.toString();
}
-
- private static Map<String, Object> getProperties(List<Element> elements) {
+
+ private static Map<String, Object> getProperties(List<Element> elements) {
Map<String, Object> props = new HashMap<String, Object>();
addProperties(props, elements);
return props;
}
-
- private static void addProperties(Map<String, Object> props, List<Element> elements) {
+
+ private static void addProperties(Map<String, Object> props, List<Element> elements) {
for (Element p : elements) {
String key = p.getAttributeValue(PROPERTY_NAME_ATTRIBUTE);
String value = p.getAttributeValue(PROPERTY_VALUE_ATTRIBUTE);
if (value == null) {
value = p.getTextTrim();
}
-
+
String iface = p.getAttributeValue(PROPERTY_INTERFACE_ATTRIBUTE);
if (key != null) {
- props.put(iface == null || iface.length() == 0
- ? key
- : key + INTERFACE_SEPARATOR + iface,
+ props.put(iface == null || iface.length() == 0 ? key : key + INTERFACE_SEPARATOR + iface,
value);
}
}
}
-
+
private static List<String> getProvidedInterfaces(List<Element> elements) {
-
+
List<String> names = new ArrayList<String>();
-
+
for (Element p : elements) {
String name = p.getAttributeValue(PROVIDE_INTERFACE_NAME_ATTRIBUTE);
if (name != null) {
names.add(name);
}
}
-
+
return names;
}
-
+
@SuppressWarnings("unchecked")
- public static <T> OsgiService<T> getOsgiService(
- BundleContext bc, Class<T> serviceClass) {
+ public static <T> OsgiService<T> getOsgiService(BundleContext bc, Class<T> serviceClass) {
try {
ServiceReference sr = bc.getServiceReference(serviceClass.getName());
if (sr != null) {
@@ -386,13 +365,13 @@
}
} catch (Exception ex) {
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Problem retrieving an OSGI service " + serviceClass.getName()
- + ", exception : " + ex.getMessage());
+ LOG.fine("Problem retrieving an OSGI service " + serviceClass.getName() + ", exception : "
+ + ex.getMessage());
}
}
return null;
}
-
+
public static IntentMap getIntentMap(BundleContext bundleContext) {
IntentMap im = readIntentMap(bundleContext);
if (im == null) {
@@ -401,9 +380,9 @@
im = new IntentMap();
im.setIntents(new HashMap<String, Object>());
}
- return im;
+ return im;
}
-
+
static IntentMap readIntentMap(BundleContext bundleContext) {
List<String> springIntentLocations = new ArrayList<String>();
for (String mapFile : INTENT_MAP) {
@@ -413,10 +392,10 @@
}
springIntentLocations.add("classpath:" + mapFile);
}
-
+
try {
- OsgiBundleXmlApplicationContext ctx =
- new OsgiBundleXmlApplicationContext(springIntentLocations.toArray(new String [] {}));
+ OsgiBundleXmlApplicationContext ctx = new OsgiBundleXmlApplicationContext(springIntentLocations
+ .toArray(new String[] {}));
ctx.setPublishContextAsService(false);
ctx.setBundleContext(bundleContext);
ctx.refresh();
@@ -429,18 +408,17 @@
return null;
}
}
-
- //Eg. "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))"
- public static Filter createFilterFromProperties(BundleContext bc,
- Dictionary properties) {
-
+
+ // Eg. "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))"
+ public static Filter createFilterFromProperties(BundleContext bc, Dictionary properties) {
+
if (properties == null || properties.isEmpty()) {
return null;
}
-
+
StringBuilder sb = new StringBuilder();
sb.append("(&");
- for (Enumeration keys = properties.keys();keys.hasMoreElements();) {
+ for (Enumeration keys = properties.keys(); keys.hasMoreElements();) {
String key = keys.nextElement().toString();
String value = properties.get(key).toString();
sb.append('(').append(key).append('=').append(value).append(')');
@@ -448,42 +426,56 @@
sb.append(')');
return createFilter(bc, sb.toString());
}
-
-
+
// TODO : move these property helpers into PropertyUtils ?
-
- public static boolean getBooleanProperty(ServiceEndpointDescription sd, String name) {
- Object value = sd.getProperty(name);
+
+ public static boolean getBooleanProperty(EndpointDescription sd, String name) {
+ Object value = sd.getProperties().get(name);
return toBoolean(value);
}
-
+
public static boolean toBoolean(Object value) {
- return value instanceof Boolean && ((Boolean)value).booleanValue()
- || value instanceof String && Boolean.parseBoolean((String)value);
+ return value instanceof Boolean && ((Boolean)value).booleanValue() || value instanceof String
+ && Boolean.parseBoolean((String)value);
}
-
+
@SuppressWarnings("unchecked")
public static Collection<String> getMultiValueProperty(Object property) {
if (property == null) {
return null;
}
-
+
if (property instanceof Collection) {
- return (Collection<String>) property;
- } else if (property instanceof String []) {
- return Arrays.asList((String []) property);
+ return (Collection<String>)property;
+ } else if (property instanceof String[]) {
+ return Arrays.asList((String[])property);
} else {
return Collections.singleton(property.toString());
}
}
- public static String getProperty(ServiceEndpointDescription sd, String name) {
- return getProperty(sd, name, String.class, null);
+ public static String getProperty(EndpointDescription sd, String name) {
+ Object o = sd.getProperties().get(name);
+
+ if (o != null && o instanceof String) {
+ return (String)o;
+ }
+
+ return null;
+
}
-
+
+ public static String getProperty(Map dict, String name) {
+ Object o = dict.get(name);
+
+ if (o != null && o instanceof String) {
+ return (String)o;
+ }
+ return null;
+ }
+
@SuppressWarnings("unchecked")
- public static <T> T getProperty(ServiceEndpointDescription sd, String name, Class<T> type,
- T defaultValue) {
+ public static <T> T getProperty(ServiceEndpointDescription sd, String name, Class<T> type, T defaultValue) {
Object o = sd.getProperty(name);
if (o == null) {
return defaultValue;
@@ -491,30 +483,24 @@
return type.isAssignableFrom(o.getClass()) ? (T)o : null;
}
- public static String[] getPublishableInterfaces(ServiceEndpointDescription sd,
- ServiceReference sref) {
- Collection<String> publishProperty =
- getMultiValueProperty(sd.getProperty(Constants.EXPORTED_INTERFACES));
+ public static String[] getPublishableInterfaces(ServiceEndpointDescription sd, ServiceReference sref) {
+ Collection<String> publishProperty = getMultiValueProperty(sd
+ .getProperty(Constants.EXPORTED_INTERFACES));
if (publishProperty == null) {
publishProperty = getMultiValueProperty(sd.getProperty(Constants.EXPORTED_INTERFACES_OLD));
}
-
- String[] actualInterfaces =
- (String[])sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
- String[] publishableInterfaces = null;
+ String[] actualInterfaces = (String[])sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
+ String[] publishableInterfaces = null;
- if (actualInterfaces != null
- && actualInterfaces.length > 0
- && publishProperty != null) {
+ if (actualInterfaces != null && actualInterfaces.length > 0 && publishProperty != null) {
- if (publishProperty.size() == 1
- && INTERFACE_WILDCARD.equals(publishProperty.iterator().next())) {
+ if (publishProperty.size() == 1 && INTERFACE_WILDCARD.equals(publishProperty.iterator().next())) {
// wildcard indicates all interfaces should be published
//
publishableInterfaces = actualInterfaces;
} else {
- String [] requestedInterfaces;
+ String[] requestedInterfaces;
if (publishProperty.size() == 0) {
requestedInterfaces = null;
} else if (publishProperty.size() == 1) {
@@ -524,22 +510,19 @@
}
ArrayList<String> publishableList = new ArrayList<String>();
- for (int i = 0; requestedInterfaces != null
- && i < requestedInterfaces.length; i++) {
+ for (int i = 0; requestedInterfaces != null && i < requestedInterfaces.length; i++) {
if (contains(actualInterfaces, requestedInterfaces[i])) {
publishableList.add(requestedInterfaces[i]);
} else {
// simply ignore non-exposed interfaces
//
- LOG.warning("ignoring publish interface, "
- + requestedInterfaces[i]
+ LOG.warning("ignoring publish interface, " + requestedInterfaces[i]
+ ", not exposed by service");
}
}
if (publishableList.size() > 0) {
- publishableInterfaces =
- publishableList.toArray(new String[publishableList.size()]);
+ publishableInterfaces = publishableList.toArray(new String[publishableList.size()]);
}
}
}
@@ -563,4 +546,49 @@
}
return found;
}
+
+ /**
+ * Tries to retrive the version of iClass via the PackageAdmin
+ *
+ * @param iClass - The 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
+ * occured duriung the retrival
+ */
+ public static String getVersion(Class<?> iClass, BundleContext bc) {
+
+ ServiceReference paRef = bc.getServiceReference(PackageAdmin.class.getName());
+ if (paRef != null) {
+ PackageAdmin pa = (PackageAdmin)bc.getService(paRef);
+
+ 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.finest("Interface source bundle: " + b.getSymbolicName());
+
+ ExportedPackage[] ep = pa.getExportedPackages(b);
+ LOG.finest("Exported Packages of the source bundle: " + ep);
+
+ String pack = iClass.getPackage().getName();
+ LOG.finest("Looking for Package: " + pack);
+
+ for (ExportedPackage p : ep) {
+ // LOG.severe("comparing package: " + p.getName() + " " + p.getVersion());
+ if (pack.equals(p.getName())) {
+ LOG.fine("found package -> Version: " + p.getVersion());
+ return p.getVersion().toString();
+ }
+ }
+ } else {
+ LOG.severe("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";
+ }
+
}
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java Thu Dec 17 11:28:30 2009
@@ -23,19 +23,18 @@
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
import org.osgi.framework.BundleContext;
public abstract class AbstractConfigurationHandler implements ConfigurationTypeHandler {
- private final CxfDistributionProvider distributionProvider;
+
final Map<String, Object> handlerProps;
protected BundleContext bundleContext;
protected AbstractConfigurationHandler(BundleContext dswBC,
- CxfDistributionProvider dp,
+
Map<String, Object> handlerProps) {
this.bundleContext = dswBC;
- this.distributionProvider = dp;
+
this.handlerProps = handlerProps;
}
@@ -61,13 +60,14 @@
return OsgiUtils.toBoolean(value);
}
- protected CxfDistributionProvider getDistributionProvider() {
- return distributionProvider;
- }
-
+
protected Object getProxy(Object serviceProxy, Class<?> iType) {
return Proxy.newProxyInstance(iType.getClassLoader(),
new Class[] {iType},
new ServiceInvocationHandler(serviceProxy, iType));
- }
+ }
+
+ protected BundleContext getBundleContext(){
+ return bundleContext;
+ }
}
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java Thu Dec 17 11:28:30 2009
@@ -18,8 +18,6 @@
*/
package org.apache.cxf.dosgi.dsw.handlers;
-import static org.osgi.service.discovery.ServicePublication.ENDPOINT_LOCATION;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -36,7 +34,6 @@
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.OsgiUtils;
import org.apache.cxf.dosgi.dsw.qos.IntentMap;
-import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
import org.apache.cxf.endpoint.AbstractEndpointFactory;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.AbstractFeature;
@@ -45,7 +42,8 @@
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.osgi.framework.BundleContext;
-import org.osgi.service.discovery.ServiceEndpointDescription;
+
+import static org.osgi.service.discovery.ServicePublication.ENDPOINT_LOCATION;
public abstract class AbstractPojoConfigurationTypeHandler extends AbstractConfigurationHandler {
private static final Logger LOG = Logger.getLogger(AbstractPojoConfigurationTypeHandler.class.getName());
@@ -55,9 +53,9 @@
private IntentMap masterMap;
public AbstractPojoConfigurationTypeHandler(BundleContext dswBC,
- CxfDistributionProvider dp,
+
Map<String, Object> handlerProps) {
- super(dswBC, dp, handlerProps);
+ super(dswBC, handlerProps);
}
// Isolated so that it can be substituted for testing
@@ -93,7 +91,7 @@
BundleContext callingContext,
List<AbstractFeature> features,
AbstractEndpointFactory factory,
- ServiceEndpointDescription sd) throws IntentUnsatifiedException {
+ Map sd) throws IntentUnsatifiedException {
String[] requestedIntents = getRequestedIntents(sd);
Set<String> appliedIntents = new HashSet<String>(Arrays.asList(requestedIntents));
@@ -190,7 +188,7 @@
return CONFIGURATION_TYPE;
}
- private static String[] getRequestedIntents(ServiceEndpointDescription sd) {
+ private static String[] getRequestedIntents(Map sd) {
Collection<String> intents = Arrays.asList(
OsgiUtils.parseIntents(OsgiUtils.getProperty(sd, Constants.EXPORTED_INTENTS)));
Collection<String> extraIntents = Arrays.asList(
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java Thu Dec 17 11:28:30 2009
@@ -1,88 +1,115 @@
/**
- * 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.
- */
+ * 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.logging.Level;
import java.util.logging.Logger;
+import org.apache.cxf.dosgi.dsw.service.ImportRegistrationImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
public class ClientServiceFactory implements ServiceFactory {
- private static final Logger LOG =
- Logger.getLogger(ClientServiceFactory.class.getName());
+ private static final Logger LOG = Logger.getLogger(ClientServiceFactory.class.getName());
private BundleContext dswContext;
- private Class<?> iClass;
- private ServiceEndpointDescription sd;
+ private Class<?> iClass;
+ private EndpointDescription sd;
private ConfigurationTypeHandler handler;
-
- public ClientServiceFactory(BundleContext dswContext, Class<?> iClass,
- ServiceEndpointDescription sd, ConfigurationTypeHandler handler) {
+
+ private ImportRegistrationImpl importRegistartion;
+
+ private boolean closeable = false;
+ private int serviceCounter = 0;
+
+ public ClientServiceFactory(BundleContext dswContext, Class<?> iClass, EndpointDescription sd,
+ ConfigurationTypeHandler handler, ImportRegistrationImpl ir) {
this.dswContext = dswContext;
this.iClass = iClass;
this.sd = sd;
this.handler = handler;
+ importRegistartion = ir;
}
-
- public Object getService(Bundle requestingBundle, ServiceRegistration sreg) {
- String interfaceName = sd.getProvidedInterfaces() != null && sd.getProvidedInterfaces().size() > 0
- ? (String)sd.getProvidedInterfaces().toArray()[0]
- : null;
+
+ public Object getService(Bundle requestingBundle, ServiceRegistration sreg) {
+ String interfaceName = sd.getInterfaces() != null && sd.getInterfaces().size() > 0 ? (String)sd
+ .getInterfaces().toArray()[0] : null;
+ LOG.info("************ getService() from serviceFactory for " + interfaceName);
+
try {
- return handler.createProxy(sreg.getReference(),
- dswContext,
- requestingBundle.getBundleContext(),
- iClass,
- sd);
+ Object proxy = handler.createProxy(sreg.getReference(), dswContext, requestingBundle
+ .getBundleContext(), iClass, sd);
+ synchronized (this) {
+ ++serviceCounter;
+ }
+ return proxy;
} catch (IntentUnsatifiedException iue) {
- LOG.info("Did not create proxy for " + interfaceName + " because intent " +
- iue.getIntent() + " could not be satisfied");
+ LOG.info("Did not create proxy for " + interfaceName + " because intent " + iue.getIntent()
+ + " could not be satisfied");
} catch (Exception ex) {
- LOG.log(Level.WARNING,
- "Problem creating a remote proxy for "
- + interfaceName + " from CXF FindHook: ",
- ex);
+ LOG.log(Level.WARNING, "Problem creating a remote proxy for " + interfaceName
+ + " from CXF FindHook: ", ex);
}
-
+
return null;
}
- public void ungetService(Bundle requestingBundle,
- ServiceRegistration sreg,
- Object serviceObject) {
-
+ public void ungetService(Bundle requestingBundle, ServiceRegistration sreg, Object serviceObject) {
+
StringBuilder sb = new StringBuilder();
sb.append("Releasing a client object");
- Object objectClass =
- sreg.getReference().getProperty(org.osgi.framework.Constants.OBJECTCLASS);
+ Object objectClass = sreg.getReference().getProperty(org.osgi.framework.Constants.OBJECTCLASS);
if (objectClass != null) {
sb.append(", interfaces : ");
- for (String s : (String[])objectClass) {
+ for (String s : (String[])objectClass) {
sb.append(" " + s);
}
}
LOG.info(sb.toString());
+
+ synchronized (this) {
+ --serviceCounter;
+ LOG.fine("Services still provided by this ServiceFactory: " + serviceCounter);
+
+ if (serviceCounter <= 0 && closeable)
+ remove();
+ }
+ }
+
+ private void remove() {
+ importRegistartion.closeAll();
+ }
+
+ public void setCloseable(boolean closeable) {
+ synchronized (this) {
+ this.closeable = closeable;
+ if (serviceCounter <= 0 && closeable)
+ remove();
+ }
+ }
+
+ public boolean isCloseable() {
+ return closeable;
}
}
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java Thu Dec 17 11:28:30 2009
@@ -1,111 +1,113 @@
/**
- * 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.
- */
+ * 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.Collection;
+import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
import org.osgi.framework.BundleContext;
-import org.osgi.service.discovery.ServiceEndpointDescription;
-import org.osgi.service.distribution.DistributionConstants;
public final class ConfigTypeHandlerFactory {
-
+
private static final Logger LOG = Logger.getLogger(ConfigTypeHandlerFactory.class.getName());
private static final ConfigTypeHandlerFactory FACTORY = new ConfigTypeHandlerFactory();
-
- private ConfigTypeHandlerFactory() {}
-
+
+ private ConfigTypeHandlerFactory() {
+ }
+
public static ConfigTypeHandlerFactory getInstance() {
return FACTORY;
}
-
- public ConfigurationTypeHandler getHandler(BundleContext dswBC, ServiceEndpointDescription sd,
- CxfDistributionProvider dp,
- Map<String, Object> handlerProperties) {
- Collection<String> types = OsgiUtils.getMultiValueProperty(sd.getProperty(Constants.EXPORTED_CONFIGS));
- if (types == null) {
- types = OsgiUtils.getMultiValueProperty(sd.getProperty(Constants.EXPORTED_CONFIGS_OLD));
- }
-
- if (types == null
- || types.contains(Constants.WS_CONFIG_TYPE)
- || types.contains(Constants.WS_CONFIG_TYPE_OLD)
- || types.contains(Constants.RS_CONFIG_TYPE)) {
- if (types == null) {
- LOG.info("Defaulting to pojo configuration type ");
- }
+ public ConfigurationTypeHandler getHandler(BundleContext dswBC, List<String> configurationTypes,
+ Map serviceProperties, Map<String, Object> props) {
- boolean jaxrs = isJaxrsRequested(types, sd);
-
- if (OsgiUtils.getProperty(sd, Constants.WS_HTTP_SERVICE_CONTEXT) != null
- || OsgiUtils.getProperty(sd, Constants.RS_HTTP_SERVICE_CONTEXT) != null
- || OsgiUtils.getProperty(sd, Constants.WS_HTTP_SERVICE_CONTEXT_OLD) != null) {
- return jaxrs ? new JaxRSHttpServiceConfigurationTypeHandler(dswBC, dp, handlerProperties)
- : new HttpServiceConfigurationTypeHandler(dswBC, dp, handlerProperties) ;
+ // Marc FIXME: write test case !!!
+
+ // EndpointDescription sd =null;
+
+ // Collection<String> types = configurationTypes;
+ // //OsgiUtils.getMultiValueProperty(sd.getProperties().get(Constants.EXPORTED_CONFIGS));
+ // if (types == null) {
+ // types = OsgiUtils.getMultiValueProperty(sd.getProperties().get(Constants.EXPORTED_CONFIGS_OLD));
+ // }
+
+ if (configurationTypes.contains(Constants.WS_CONFIG_TYPE)
+ || configurationTypes.contains(Constants.WS_CONFIG_TYPE_OLD) || configurationTypes.contains(Constants.RS_CONFIG_TYPE)) {
+
+// if (types == null) {
+// LOG.info("Defaulting to pojo configuration type ");
+// }
+
+ boolean jaxrs = isJaxrsRequested(configurationTypes, serviceProperties);
+
+ if (OsgiUtils.getProperty(serviceProperties, Constants.WS_HTTP_SERVICE_CONTEXT) != null
+ || OsgiUtils.getProperty(serviceProperties, Constants.RS_HTTP_SERVICE_CONTEXT) != null
+ || OsgiUtils.getProperty(serviceProperties, Constants.WS_HTTP_SERVICE_CONTEXT_OLD) != null) {
+ return jaxrs
+ ? new JaxRSHttpServiceConfigurationTypeHandler(dswBC, props)
+ : new HttpServiceConfigurationTypeHandler(dswBC, props);
} else {
- return jaxrs ? new JaxRSPojoConfigurationTypeHandler(dswBC, dp, handlerProperties)
- : new PojoConfigurationTypeHandler(dswBC, dp, handlerProperties);
+ return jaxrs
+ ? new JaxRSPojoConfigurationTypeHandler(dswBC, props)
+ : new PojoConfigurationTypeHandler(dswBC, props);
}
- } else if (types.contains(Constants.WSDL_CONFIG_TYPE)) {
- return new WsdlConfigurationTypeHandler(dswBC, dp, handlerProperties);
+ } else if (configurationTypes.contains(Constants.WSDL_CONFIG_TYPE)) {
+ return new WsdlConfigurationTypeHandler(dswBC, props);
}
-
- LOG.info("None of the configuration types in " + types + " is supported.");
-
+
+ LOG.info("None of the configuration types in " + configurationTypes + " is supported.");
+
return null;
}
-
- private boolean isJaxrsRequested(Collection<String> types, ServiceEndpointDescription sd) {
-
- if (types == null) {
- return false;
- }
-
- if (types.contains(Constants.RS_CONFIG_TYPE)) {
- String intentsProperty = OsgiUtils.getProperty(sd,
- Constants.EXPORTED_INTENTS);
+
+ private boolean isJaxrsRequested(Collection<String> types, Map serviceProperties) {
+
+ if (types == null) {
+ return false;
+ }
+
+ if (types.contains(Constants.RS_CONFIG_TYPE)) {
+ String intentsProperty = OsgiUtils.getProperty(serviceProperties, Constants.EXPORTED_INTENTS);
boolean hasHttpIntent = false, hasSoapIntent = false;
if (intentsProperty != null) {
- String[] intents = OsgiUtils.parseIntents(intentsProperty);
- for (int i = 0; i < intents.length; i++) {
- if (intents[i].indexOf("SOAP") > -1) {
- hasSoapIntent = true;
- break;
+ String[] intents = OsgiUtils.parseIntents(intentsProperty);
+ for (int i = 0; i < intents.length; i++) {
+ if (intents[i].indexOf("SOAP") > -1) {
+ hasSoapIntent = true;
+ break;
+ }
+ if ("HTTP".equals(intents[i])) {
+ hasHttpIntent = true;
+ }
}
- if("HTTP".equals(intents[i])) {
- hasHttpIntent = true;
- }
- }
}
- if (intentsProperty != null && hasHttpIntent && !hasSoapIntent
- || intentsProperty == null) {
+ if (intentsProperty != null && hasHttpIntent && !hasSoapIntent || intentsProperty == null) {
return true;
}
}
- return false;
+ return false;
}
-
+
}
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java Thu Dec 17 11:28:30 2009
@@ -18,23 +18,27 @@
*/
package org.apache.cxf.dosgi.dsw.handlers;
+import java.util.Dictionary;
+import java.util.Map;
+
+import org.apache.cxf.dosgi.dsw.service.ExportRegistrationImpl;
import org.apache.cxf.endpoint.Server;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
public interface ConfigurationTypeHandler {
String getType();
- Server createServer(ServiceReference serviceReference,
+ void createServer(ExportRegistrationImpl serviceReference,
BundleContext dswContext,
BundleContext callingContext,
- ServiceEndpointDescription sd,
+ Map sd,
Class<?> iClass,
Object serviceBean);
Object createProxy(ServiceReference serviceReference,
BundleContext dswContext,
BundleContext callingContext,
- Class<?> iClass, ServiceEndpointDescription sd);
+ Class<?> iClass, EndpointDescription sd);
}
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java Thu Dec 17 11:28:30 2009
@@ -20,6 +20,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
@@ -31,7 +32,7 @@
import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
+import org.apache.cxf.dosgi.dsw.service.ExportRegistrationImpl;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.endpoint.ServerLifeCycleListener;
import org.apache.cxf.endpoint.ServerLifeCycleManager;
@@ -41,8 +42,8 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceException;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.discovery.ServiceEndpointDescription;
import org.osgi.service.http.HttpService;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.util.tracker.ServiceTracker;
public class HttpServiceConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
@@ -51,9 +52,9 @@
Set<ServiceReference> httpServiceReferences = new CopyOnWriteArraySet<ServiceReference>();
protected HttpServiceConfigurationTypeHandler(BundleContext dswBC,
- CxfDistributionProvider dp,
+
Map<String, Object> handlerProps) {
- super(dswBC, dp, handlerProps);
+ super(dswBC, handlerProps);
ServiceTracker st = new ServiceTracker(dswBC, HttpService.class.getName(), null) {
@Override
@@ -73,65 +74,66 @@
public Object createProxy(ServiceReference serviceReference,
BundleContext dswContext, BundleContext callingContext,
- Class<?> iClass, ServiceEndpointDescription sd) {
+ Class<?> iClass, EndpointDescription sd) {
// This handler doesn't make sense on the client side
return null;
}
- public Server createServer(ServiceReference serviceReference,
+ public void createServer(ExportRegistrationImpl exportRegistration,
BundleContext dswContext,
BundleContext callingContext,
- ServiceEndpointDescription sd,
+ Map sd,
Class<?> iClass,
Object serviceBean) {
- final String contextRoot = getServletContextRoot(sd, iClass);
- if (contextRoot == null) {
- LOG.warning("Remote address is unavailable");
- return null;
- }
-
- CXFNonSpringServlet cxf = new CXFNonSpringServlet();
- HttpService httpService = getHttpService();
- try {
- httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(), null);
- LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
- } catch (Exception e) {
- throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet", e);
- }
- Bus bus = cxf.getBus();
- DataBinding databinding;
- String dataBindingImpl = (String) serviceReference.getProperty(Constants.WS_DATABINDING_PROP_KEY);
- if("jaxb".equals(dataBindingImpl)) {
- databinding = new JAXBDataBinding();
- } else {
- databinding = new AegisDatabinding();
- }
- String frontEndImpl = (String) serviceReference.getProperty(Constants.WS_FRONTEND_PROP_KEY);
- ServerFactoryBean factory = createServerFactoryBean(frontEndImpl);
- String address = constructAddress(dswContext, contextRoot);
- factory.setBus(bus);
- factory.setServiceClass(iClass);
- factory.setAddress("/");
- factory.getServiceFactory().setDataBinding(databinding);
- factory.setServiceBean(serviceBean);
-
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- String [] intents =
- applyIntents(dswContext, callingContext, factory.getFeatures(), factory, sd);
-
- Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
- Server server = factory.create();
- registerStopHook(bus, httpService, server, contextRoot, Constants.WS_HTTP_SERVICE_CONTEXT);
- getDistributionProvider().addExposedService(serviceReference, registerPublication(server, intents, address));
- addAddressProperty(sd.getProperties(), address);
- return server;
- } catch (IntentUnsatifiedException iue) {
- getDistributionProvider().intentsUnsatisfied(serviceReference);
- throw iue;
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
+// final String contextRoot = getServletContextRoot(sd, iClass);
+// if (contextRoot == null) {
+// LOG.warning("Remote address is unavailable");
+// return null;
+// }
+//
+// CXFNonSpringServlet cxf = new CXFNonSpringServlet();
+// HttpService httpService = getHttpService();
+// try {
+// httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(), null);
+// LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
+// } catch (Exception e) {
+// throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet", e);
+// }
+// Bus bus = cxf.getBus();
+// DataBinding databinding;
+// String dataBindingImpl = (String) serviceReference.getProperty(Constants.WS_DATABINDING_PROP_KEY);
+// if("jaxb".equals(dataBindingImpl)) {
+// databinding = new JAXBDataBinding();
+// } else {
+// databinding = new AegisDatabinding();
+// }
+// String frontEndImpl = (String) serviceReference.getProperty(Constants.WS_FRONTEND_PROP_KEY);
+// ServerFactoryBean factory = createServerFactoryBean(frontEndImpl);
+// String address = constructAddress(dswContext, contextRoot);
+// factory.setBus(bus);
+// factory.setServiceClass(iClass);
+// factory.setAddress("/");
+// factory.getServiceFactory().setDataBinding(databinding);
+// factory.setServiceBean(serviceBean);
+//
+// ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+// try {
+// String [] intents =
+// applyIntents(dswContext, callingContext, factory.getFeatures(), factory, sd);
+//
+// Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
+// Server server = factory.create();
+// registerStopHook(bus, httpService, server, contextRoot, Constants.WS_HTTP_SERVICE_CONTEXT);
+// //MARC: FIXME !!!! getDistributionProvider().addExposedService(serviceReference, registerPublication(server, intents, address));
+// addAddressProperty(sd.getProperties(), address);
+// return server;
+// } catch (IntentUnsatifiedException iue) {
+// //MARC: FIXME !!!! getDistributionProvider().intentsUnsatisfied(serviceReference);
+// throw iue;
+// } finally {
+// Thread.currentThread().setContextClassLoader(oldClassLoader);
+// }
+ throw new RuntimeException("Marc: Implement me !!!!");
}
protected Map<String, String> registerPublication(Server server, String[] intents, String address) {
@@ -173,7 +175,7 @@
throw new ServiceException("CXF DOSGi: No HTTP Service could be found to publish CXF endpoint in.");
}
- protected String getServletContextRoot(ServiceEndpointDescription sd, Class<?> iClass) {
+ protected String getServletContextRoot(EndpointDescription sd, Class<?> iClass) {
String context = OsgiUtils.getProperty(sd, Constants.WS_HTTP_SERVICE_CONTEXT);
if (context == null) {
context = OsgiUtils.getProperty(sd, Constants.WS_HTTP_SERVICE_CONTEXT_OLD);
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSHttpServiceConfigurationTypeHandler.java Thu Dec 17 11:28:30 2009
@@ -28,7 +28,6 @@
import org.apache.cxf.Bus;
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
@@ -37,8 +36,8 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceException;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.discovery.ServiceEndpointDescription;
import org.osgi.service.http.HttpService;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
public class JaxRSHttpServiceConfigurationTypeHandler extends HttpServiceConfigurationTypeHandler {
private static final Logger LOG = Logger.getLogger(JaxRSHttpServiceConfigurationTypeHandler.class.getName());
@@ -46,15 +45,15 @@
Set<ServiceReference> httpServiceReferences = new CopyOnWriteArraySet<ServiceReference>();
protected JaxRSHttpServiceConfigurationTypeHandler(BundleContext dswBC,
- CxfDistributionProvider dp,
+
Map<String, Object> handlerProps) {
- super(dswBC, dp, handlerProps);
+ super(dswBC, handlerProps);
}
public Server createServer(ServiceReference serviceReference,
BundleContext dswContext,
BundleContext callingContext,
- ServiceEndpointDescription sd,
+ EndpointDescription sd,
Class<?> iClass,
Object serviceBean) {
String contextRoot = getServletContextRoot(sd, iClass);
@@ -99,11 +98,11 @@
Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
Server server = factory.create();
registerStopHook(bus, httpService, server, contextRoot, Constants.RS_HTTP_SERVICE_CONTEXT);
- getDistributionProvider().addExposedService(serviceReference, registerPublication(server, intents, address));
+ //MARC: FIXME !!!! getDistributionProvider().addExposedService(serviceReference, registerPublication(server, intents, address));
addAddressProperty(sd.getProperties(), address);
return server;
} catch (IntentUnsatifiedException iue) {
- getDistributionProvider().intentsUnsatisfied(serviceReference);
+ //MARC: FIXME !!!! getDistributionProvider().intentsUnsatisfied(serviceReference);
throw iue;
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
@@ -111,7 +110,7 @@
}
@Override
- protected String getServletContextRoot(ServiceEndpointDescription sd, Class<?> iClass) {
+ protected String getServletContextRoot(EndpointDescription sd, Class<?> iClass) {
String context = OsgiUtils.getProperty(sd, Constants.RS_HTTP_SERVICE_CONTEXT);
if (context == null) {
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java Thu Dec 17 11:28:30 2009
@@ -27,7 +27,6 @@
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
@@ -35,7 +34,7 @@
import org.apache.cxf.jaxrs.model.UserResource;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
public class JaxRSPojoConfigurationTypeHandler extends PojoConfigurationTypeHandler {
private static final Logger LOG = Logger.getLogger(JaxRSPojoConfigurationTypeHandler.class.getName());
@@ -43,14 +42,14 @@
Set<ServiceReference> httpServiceReferences = new CopyOnWriteArraySet<ServiceReference>();
protected JaxRSPojoConfigurationTypeHandler(BundleContext dswBC,
- CxfDistributionProvider dp,
+
Map<String, Object> handlerProps) {
- super(dswBC, dp, handlerProps);
+ super(dswBC, handlerProps);
}
public Object createProxy(ServiceReference serviceReference,
BundleContext dswContext, BundleContext callingContext,
- Class<?> iClass, ServiceEndpointDescription sd) {
+ Class<?> iClass, EndpointDescription sd) {
String address = getPojoAddress(sd, iClass);
if (address == null) {
@@ -58,7 +57,7 @@
return null;
}
- LOG.info("Creating a " + sd.getProvidedInterfaces().toArray()[0]
+ LOG.info("Creating a " + sd.getInterfaces().toArray()[0]
+ " client, endpoint address is " + address);
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
@@ -78,7 +77,7 @@
}
Thread.currentThread().setContextClassLoader(JAXRSClientFactoryBean.class.getClassLoader());
Object proxy = getProxy(bean.create(), iClass);
- getDistributionProvider().addRemoteService(serviceReference);
+ //MARC: FIXME !!!! getDistributionProvider().addRemoteService(serviceReference);
return proxy;
} catch (Exception e) {
LOG.log(Level.WARNING, "proxy creation failed", e);
@@ -92,7 +91,7 @@
public Server createServer(ServiceReference serviceReference,
BundleContext dswContext,
BundleContext callingContext,
- ServiceEndpointDescription sd,
+ EndpointDescription sd,
Class<?> iClass,
Object serviceBean) {
String address = getPojoAddress(sd, iClass);
@@ -101,7 +100,7 @@
return null;
}
- LOG.info("Creating a " + sd.getProvidedInterfaces().toArray()[0]
+ LOG.info("Creating a " + sd.getInterfaces().toArray()[0]
+ " endpoint from CXF PublishHook, address is " + address);
JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
@@ -127,18 +126,18 @@
Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
Server server = factory.create();
- getDistributionProvider().addExposedService(serviceReference, registerPublication(server, intents));
+ //MARC: FIXME !!!! getDistributionProvider().addExposedService(serviceReference, registerPublication(server, intents));
addAddressProperty(sd.getProperties(), address);
return server;
} catch (IntentUnsatifiedException iue) {
- getDistributionProvider().intentsUnsatisfied(serviceReference);
+ //MARC: FIXME !!!! getDistributionProvider().intentsUnsatisfied(serviceReference);
throw iue;
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}
- protected String getPojoAddress(ServiceEndpointDescription sd, Class<?> iClass) {
+ protected String getPojoAddress(EndpointDescription sd, Class<?> iClass) {
String address = OsgiUtils.getProperty(sd, Constants.RS_ADDRESS_PROPERTY);
if (address == null) {
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java?rev=891650&r1=891649&r2=891650&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSUtils.java Thu Dec 17 11:28:30 2009
@@ -33,7 +33,7 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
public class JaxRSUtils {
@@ -53,14 +53,14 @@
public static List<Object> getProviders(BundleContext callingContext,
BundleContext dswBC,
- ServiceEndpointDescription sd) {
+ EndpointDescription sd) {
List<Object> providers = new ArrayList<Object>();
- if ("aegis".equals(sd.getProperty(org.apache.cxf.dosgi.dsw.Constants.RS_DATABINDING_PROP_KEY))) {
+ if ("aegis".equals(sd.getProperties().get(org.apache.cxf.dosgi.dsw.Constants.RS_DATABINDING_PROP_KEY))) {
providers.add(new AegisElementProvider());
}
Object serviceProviders =
- sd.getProperty(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_PROP_KEY);
+ sd.getProperties().get(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_PROP_KEY);
if (serviceProviders != null) {
if (serviceProviders.getClass().isArray()) {
if (serviceProviders.getClass().getComponentType() == String.class) {
@@ -75,7 +75,7 @@
}
Object globalQueryProp =
- sd.getProperty(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_GLOBAL_PROP_KEY);
+ sd.getProperties().get(org.apache.cxf.dosgi.dsw.Constants.RS_PROVIDER_GLOBAL_PROP_KEY);
boolean globalQueryRequired = globalQueryProp == null || OsgiUtils.toBoolean(globalQueryProp);
if (!globalQueryRequired) {
return providers;