Author: davidb
Date: Mon Mar 5 13:13:29 2012
New Revision: 1297044
URL: http://svn.apache.org/viewvc?rev=1297044&view=rev
Log:
Further fixes to pass OSGi RemoteServiceAdmin TCK tests
Modified:
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
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
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=1297044&r1=1297043&r2=1297044&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
Mon Mar 5 13:13:29 2012
@@ -233,5 +233,4 @@ 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=1297044&r1=1297043&r2=1297044&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
Mon Mar 5 13:13:29 2012
@@ -24,9 +24,11 @@ import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.logging.Logger;
@@ -38,6 +40,7 @@ import org.apache.cxf.dosgi.dsw.handlers
import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
import org.apache.cxf.dosgi.dsw.qos.IntentMap;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -465,7 +468,6 @@ public class RemoteServiceAdminCore impl
* when the export Registration is closed
*/
protected void removeExportRegistration(ExportRegistrationImpl eri) {
-
synchronized (exportedServices) {
Collection<ExportRegistrationImpl> exRegs =
exportedServices.get(eri.getServiceReference());
if (exRegs != null && exRegs.contains(eri)) {
@@ -483,6 +485,26 @@ public class RemoteServiceAdminCore impl
}
+ // Remove all export registrations associated with the given bundle
+ protected void removeExportRegistrations(BundleContext exportingBundleCtx)
{
+ Bundle exportingBundle = exportingBundleCtx.getBundle();
+
+ // Work on a copy as the map gets modified as part of the behaviour by
underlying methods
+ HashMap<ServiceReference, Collection<ExportRegistrationImpl>>
exportCopy = new HashMap<ServiceReference,
Collection<ExportRegistrationImpl>>(exportedServices);
+
+ for (Iterator<Map.Entry<ServiceReference,
Collection<ExportRegistrationImpl>>> it = exportCopy.entrySet().iterator();
it.hasNext(); ) {
+ Entry<ServiceReference, Collection<ExportRegistrationImpl>> entry
= it.next();
+ Bundle regBundle = entry.getKey().getBundle();
+ if (exportingBundle.equals(regBundle)) {
+ // Again work on a copy, as the value gets modified by the
behaviour inside export.close()
+ for (ExportRegistrationImpl export : new
ArrayList<ExportRegistrationImpl>(entry.getValue())) {
+ // This will remove the registration from the real map of
exports
+ export.close();
+ }
+ }
+ }
+ }
+
protected void removeImportRegistration(ImportRegistrationImpl iri) {
synchronized (importedServices) {
LOG.finest("Removing importRegistration " + iri);
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java?rev=1297044&r1=1297043&r2=1297044&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
Mon Mar 5 13:13:29 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;
@@ -53,16 +53,16 @@ public class RemoteServiceAdminInstance
SecurityManager sm = System.getSecurityManager();
EndpointPermission epp = new EndpointPermission("*",
EndpointPermission.EXPORT);
-
-
+
+
if (sm != null) {
sm.checkPermission(epp);
}
-
-
+
+
final ServiceReference refFinal = ref;
final Map propertiesFinal = properties;
-
+
return AccessController.doPrivileged(new PrivilegedAction<List>() {
public List run() {
@@ -75,26 +75,26 @@ public class RemoteServiceAdminInstance
}
public Collection getExportedServices() {
-
+
SecurityManager sm = System.getSecurityManager();
EndpointPermission epp = new EndpointPermission("*",
EndpointPermission.READ);
if (sm != null) {
sm.checkPermission(epp);
}
-
+
if (closed)
return null;
return rsaCore.getExportedServices();
}
public Collection getImportedEndpoints() {
-
+
SecurityManager sm = System.getSecurityManager();
EndpointPermission epp = new EndpointPermission("*",
EndpointPermission.READ);
if (sm != null) {
sm.checkPermission(epp);
}
-
+
if (closed)
return null;
return rsaCore.getImportedEndpoints();
@@ -124,6 +124,7 @@ public class RemoteServiceAdminInstance
public void close() {
closed = true;
- }
+ rsaCore.removeExportRegistrations(bctx);
+ }
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java?rev=1297044&r1=1297043&r2=1297044&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
Mon Mar 5 13:13:29 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;
@@ -36,7 +36,7 @@ public class RemoteServiceadminFactory i
private List<RemoteServiceAdminInstance> rsaServiceInstances = new
ArrayList<RemoteServiceAdminInstance>();
private RemoteServiceAdminCore rsaCore;
-
+
public RemoteServiceadminFactory(BundleContext bc) {
bctx = bc;
rsaCore = new RemoteServiceAdminCore(bc);
@@ -45,7 +45,7 @@ public class RemoteServiceadminFactory i
public Object getService(Bundle b, ServiceRegistration sr) {
LOG.log(Level.FINEST, "new RemoteServiceAdmin ServiceInstance created
for Bundle {0}",
b.getSymbolicName());
- RemoteServiceAdminInstance rsai = new
RemoteServiceAdminInstance(bctx,rsaCore);
+ RemoteServiceAdminInstance rsai = new
RemoteServiceAdminInstance(b.getBundleContext(),rsaCore);
rsaServiceInstances.add(rsai);
return rsai;
}