Author: davidb
Date: Sun Feb 19 00:39:05 2012
New Revision: 1290914
URL: http://svn.apache.org/viewvc?rev=1290914&view=rev
Log:
Changes towards passing the OSGi Remote Service Admin CT.
Modified:
cxf/dosgi/trunk/distribution/single-bundle/pom.xml
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
Modified: cxf/dosgi/trunk/distribution/single-bundle/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/pom.xml?rev=1290914&r1=1290913&r2=1290914&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/pom.xml (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/pom.xml Sun Feb 19 00:39:05 2012
@@ -332,6 +332,8 @@
javax.servlet.descriptor;resolution:=optional,
javax.servlet.*;version="[2.3.0,4.0)",
org.osgi.service.blueprint*;resolution:=optional,
+ org.osgi.service.event,
+ org.osgi.service.remoteserviceadmin,
org.osgi.*,
</Import-Package>
<Export-Package>
@@ -349,7 +351,9 @@
org.apache.cxf.dosgi.*;version="${project.version}",
org.apache.cxf.*;version="${cxf.version}",
org.jdom.*;version="1.1.0",
- org.osgi.service.remoteserviceadmin;version="1.0.0",
+ org.osgi.jmx.*,
+ org.osgi.service.*,
+ org.osgi.util.*,
!*
</_exportcontents>
<DynamicImport-Package>*</DynamicImport-Package>
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java?rev=1290914&r1=1290913&r2=1290914&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java
Sun Feb 19 00:39:05 2012
@@ -1,20 +1,20 @@
-/**
- * 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.service;
@@ -23,23 +23,44 @@ import org.osgi.service.remoteserviceadm
import org.osgi.service.remoteserviceadmin.ExportReference;
public class ExportReferenceImpl implements ExportReference {
+ private final ExportRegistrationImpl exportRegistration;
- private ExportRegistrationImpl exportRegistartion;
-
public ExportReferenceImpl(ExportRegistrationImpl exportRegistrationImpl) {
- exportRegistartion = exportRegistrationImpl;
+ exportRegistration = exportRegistrationImpl;
}
public EndpointDescription getExportedEndpoint() {
- return exportRegistartion.getEndpointDescription();
+ return exportRegistration.getEndpointDescription();
}
public ServiceReference getExportedService() {
- return exportRegistartion.getExportedService();
+ return exportRegistration.getExportedService();
}
protected EndpointDescription getExportedEndpointAlways() {
- return exportRegistartion.getEndpointDescriptionAlways();
+ return exportRegistration.getEndpointDescriptionAlways();
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * 1 + ((exportRegistration == null) ? 0 :
exportRegistration.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ExportReferenceImpl other = (ExportReferenceImpl) obj;
+ if (exportRegistration == null) {
+ if (other.exportRegistration != null)
+ return false;
+ } else if (!exportRegistration.equals(other.exportRegistration))
+ return false;
+ return true;
}
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java?rev=1290914&r1=1290913&r2=1290914&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
Sun Feb 19 00:39:05 2012
@@ -1,20 +1,20 @@
-/**
- * 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.service;
@@ -37,11 +37,11 @@ import org.osgi.util.tracker.ServiceTrac
-/// *************************** FIXME: some old methods might be in here ****
+/// *************************** FIXME: some old methods might be in here ****
public class ExportRegistrationImpl implements ExportRegistration {
private static final Logger LOG =
LogUtils.getL7dLogger(ExportRegistrationImpl.class);
-
+
private Server server;
private boolean closed = false;
private ServiceReference serviceReference = null;
@@ -52,12 +52,12 @@ public class ExportRegistrationImpl impl
private int instanceCount = 1;
private RemoteServiceAdminCore rsaCore;
-
+
private ExportReference exportReference;
-
+
private ServiceTracker serviceTracker;
-
- // provide a clone of the provided exp.Reg that is linked to this instance
+
+ // provide a clone of the provided exp.Reg that is linked to this instance
public ExportRegistrationImpl(ExportRegistrationImpl exportRegistration) {
parent = exportRegistration;
@@ -85,7 +85,7 @@ public class ExportRegistrationImpl impl
closed = true;
rsaCore.removeExportRegistration(this);
-
+
parent.instanceClosed();
if (server != null) {
server.stop();
@@ -100,9 +100,9 @@ public class ExportRegistrationImpl impl
// TODO close it and remove from management structure .... !
LOG.fine("really closing ExportRegistartion now! ");
-
-
-
+
+
+
if (server != null) {
// FIXME: is this done like this ?
server.stop();
@@ -110,17 +110,11 @@ public class ExportRegistrationImpl impl
}
}
- private void closeAll() {
- if(parent!=this){
- parent.closeAll();
- return;
- }
- // FIXME: close all clients !!!!
- close();
- }
-
public EndpointDescription getEndpointDescription() {
- return endpointDescription;
+ if (!closed)
+ return endpointDescription;
+ else
+ return null;
}
public Throwable getException() {
@@ -133,7 +127,7 @@ public class ExportRegistrationImpl impl
protected ServiceReference getServiceReference() {
return serviceReference;
}
-
+
public ServiceReference getExportedService() throws IllegalStateException {
if (!closed)
return serviceReference;
@@ -188,22 +182,22 @@ public class ExportRegistrationImpl impl
}
/**
- * Start the service tracker that monitors the osgi service that
+ * Start the service tracker that monitors the osgi service that
* is exported by this exportRegistration
* */
public void startServiceTracker(BundleContext bctx) {
-
+
// only the parent should do this
if(parent!=this){
parent.startServiceTracker(bctx);
return;
}
-
+
// do it only once
if(serviceTracker!=null){
return;
}
-
+
Filter f;
final Long sid =
(Long)serviceReference.getProperty(Constants.SERVICE_ID);
try {
@@ -214,17 +208,17 @@ public class ExportRegistrationImpl impl
return;
}
serviceTracker = new ServiceTracker(bctx, f, new
ServiceTrackerCustomizer() {
-
+
public void removedService(ServiceReference sr, Object s) {
LOG.info("Service ["+sid+"] has been unregistered: Removing
service export");
close();
}
-
+
public void modifiedService(ServiceReference sr, Object s) {
// FIXME:
LOG.warning("Service modifications after the service is
exported are currently not supported. The export is not modified!");
}
-
+
public Object addingService(ServiceReference sr) {
return sr;
}
@@ -239,5 +233,5 @@ public class ExportRegistrationImpl impl
public RemoteServiceAdminCore getRsaCore() {
return rsaCore;
}
-
+
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=1290914&r1=1290913&r2=1290914&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
Sun Feb 19 00:39:05 2012
@@ -1,20 +1,20 @@
-/**
- * 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.service;
@@ -42,6 +42,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ExportReference;
import org.osgi.service.remoteserviceadmin.ImportReference;
import org.osgi.service.remoteserviceadmin.ImportRegistration;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
@@ -71,7 +72,7 @@ public class RemoteServiceAdminCore impl
supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE);
supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE_OLD);
}
-
+
protected final static String DEFAULT_CONFIGURATION =
Constants.WS_CONFIG_TYPE;
public RemoteServiceAdminCore(BundleContext bc) {
@@ -114,8 +115,8 @@ public class RemoteServiceAdminCore impl
return Collections.EMPTY_LIST;
}
-
-
+
+
Properties serviceProperties = new Properties();
{// gather properties from sRef
@@ -217,10 +218,6 @@ public class RemoteServiceAdminCore impl
}
- // enlist initial export Registrations in global list of
exprtRegistrations
- exportedServices
- .put(serviceReference, new
ArrayList<ExportRegistrationImpl>(exportRegs.values()));
-
// FIXME: move out of synchronized ... -> blocks until publication
is finished
for (String iface : interfaces) {
LOG.info("creating server for interface " + iface);
@@ -246,7 +243,7 @@ public class RemoteServiceAdminCore impl
handler.createServer(exportRegistration, bctx,
callingContext, serviceProperties,
interfaceClass, serviceObject);
-
+
if(exportRegistration.getException()==null){
LOG.info("created server for interface " + iface);
@@ -255,13 +252,15 @@ public class RemoteServiceAdminCore impl
LOG.warning("server creation for interface " + iface +
" failed!");
// Fire event happens at the end
}
-
+
}
}
- List<ExportRegistrationImpl> lExpReg = new
ArrayList<ExportRegistrationImpl>(exportRegs.values());
+ // enlist initial export Registrations in global list of
exportRegistrations
+ exportedServices.put(serviceReference, new
ArrayList<ExportRegistrationImpl>(exportRegs.values()));
+ List<ExportRegistrationImpl> lExpReg = new
ArrayList<ExportRegistrationImpl>(exportRegs.values());
eventProducer.publishNotifcation(lExpReg);
return lExpReg;
@@ -299,9 +298,11 @@ public class RemoteServiceAdminCore impl
public Collection getExportedServices() {
synchronized (exportedServices) {
- List<ExportRegistrationImpl> ers = new
ArrayList<ExportRegistrationImpl>();
+ List<ExportReference> ers = new ArrayList<ExportReference>();
for (Collection<ExportRegistrationImpl> exportRegistrations :
exportedServices.values()) {
- ers.addAll(exportRegistrations);
+ for (ExportRegistrationImpl er : exportRegistrations) {
+ ers.add(new ExportReferenceImpl(er));
+ }
}
return Collections.unmodifiableCollection(ers);
}
@@ -338,8 +339,8 @@ public class RemoteServiceAdminCore impl
/**
* Importing form here ....
*/
- public ImportRegistration importService(EndpointDescription endpoint) {
-
+ public ImportRegistration importService(EndpointDescription endpoint) {
+
LOG.info("importService() Endpoint: " + endpoint.getProperties());
synchronized (importedServices) {
@@ -500,5 +501,4 @@ public class RemoteServiceAdminCore impl
eventProducer.notifyRemoval(iri);
}
}
-
}