Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/osgi
diff options
context:
space:
mode:
authorslewis2018-05-16 18:13:56 -0400
committerslewis2018-05-16 18:13:56 -0400
commitd9dca4c6ffcb32f80523b16ed900598c90d667ef (patch)
treeeb91380154eeee49facc3d58c47124bdb8d3ed17 /osgi
parent2a21185f2be654c769ab1b9908ca75280ad47cb2 (diff)
downloadorg.eclipse.ecf-d9dca4c6ffcb32f80523b16ed900598c90d667ef.tar.gz
org.eclipse.ecf-d9dca4c6ffcb32f80523b16ed900598c90d667ef.tar.xz
org.eclipse.ecf-d9dca4c6ffcb32f80523b16ed900598c90d667ef.zip
Final fix for bndtools-imposed start structure
Diffstat (limited to 'osgi')
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF2
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/pom.xml2
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java77
3 files changed, 55 insertions, 26 deletions
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
index bb5624e6a..94f26adf2 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %bundle.name
Bundle-SymbolicName: org.eclipse.ecf.osgi.services.remoteserviceadmin
Automatic-Module-Name: org.eclipse.ecf.osgi.services.remoteserviceadmin
-Bundle-Version: 4.6.600.qualifier
+Bundle-Version: 4.6.700.qualifier
Bundle-Activator: org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator
Bundle-Vendor: %bundle.provider
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/pom.xml b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/pom.xml
index dc0adf92a..8a39760af 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/pom.xml
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/pom.xml
@@ -10,6 +10,6 @@
</parent>
<groupId>org.eclipse.ecf</groupId>
<artifactId>org.eclipse.ecf.osgi.services.remoteserviceadmin</artifactId>
- <version>4.6.600-SNAPSHOT</version>
+ <version>4.6.700-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java
index 332bdc2d9..555f6f70d 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java
@@ -11,23 +11,31 @@ package org.eclipse.ecf.osgi.services.remoteserviceadmin;
import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractTopologyManager;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.BundleEvent;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceReference;
import org.osgi.service.remoteserviceadmin.EndpointEvent;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
/**
* @since 4.6
*/
public class TopologyManagerImpl extends AbstractTopologyManager implements EndpointEventListener {
+ public static final int STARTUP_WAIT_TIME = Integer.getInteger("org.eclipse.ecf.osgi.services.remoteserviceadmin.startupWaitTime", 20000); //$NON-NLS-1$
+
public TopologyManagerImpl(BundleContext context) {
super(context);
}
@@ -56,7 +64,7 @@ public class TopologyManagerImpl extends AbstractTopologyManager implements Endp
}
// EventListenerHook impl
- protected void handleEvent(ServiceEvent event, @SuppressWarnings("rawtypes") Map listeners) {
+ protected void handleEvent(ServiceEvent event, Map listeners) {
super.handleEvent(event, listeners);
}
@@ -131,21 +139,41 @@ public class TopologyManagerImpl extends AbstractTopologyManager implements Endp
handleECFEndpointModified((EndpointDescription) endpoint);
}
- protected void exportRegisteredServices(String exportRegisteredSvcsFilter) {
- try {
- final ServiceReference[] existingServiceRefs = getContext()
- .getAllServiceReferences(null, exportRegisteredSvcsFilter);
- // Now export as if the service was registering right now...i.e.
- // perform
- // export
- if (existingServiceRefs != null && existingServiceRefs.length > 0) {
- // After having collected all pre-registered services (with
- // marker prop) we are going to asynchronously remote them.
- // Registering potentially is a long-running operation (due to
- // discovery I/O...) and thus should no be carried out in the
- // OSGi FW thread. (https://bugs.eclipse.org/405027)
- new Thread(new Runnable() {
- public void run() {
+ protected void exportRegisteredServices(final String exportRegisteredSvcsFilter) {
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ final CountDownLatch latch = new CountDownLatch(1);
+ BundleTracker bt = new BundleTracker<Bundle>(getContext(),Bundle.INSTALLED | Bundle.RESOLVED |
+ Bundle.STARTING | Bundle.START_TRANSIENT | Bundle.ACTIVE , new BundleTrackerCustomizer() {
+
+ public Bundle addingBundle(Bundle bundle, BundleEvent event) {
+ if (bundle.getSymbolicName().equals(Activator.PLUGIN_ID))
+ return bundle;
+ return null;
+ }
+
+ public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
+ if (event.getType() == BundleEvent.STARTED)
+ latch.countDown();
+ }
+
+ public void removedBundle(Bundle bundle, BundleEvent event, Object object) {}
+ });
+ bt.open();
+ latch.await(STARTUP_WAIT_TIME, TimeUnit.MILLISECONDS);
+ final ServiceReference[] existingServiceRefs = getContext().getAllServiceReferences(null,
+ exportRegisteredSvcsFilter);
+ // Now export as if the service was registering right now...i.e.
+ // perform
+ // export
+ if (existingServiceRefs != null && existingServiceRefs.length > 0) {
+ // After having collected all pre-registered services (with
+ // marker prop) we are going to asynchronously remote them.
+ // Registering potentially is a long-running operation (due to
+ // discovery I/O...) and thus should no be carried out in the
+ // OSGi FW thread. (https://bugs.eclipse.org/405027)
+
for (int i = 0; i < existingServiceRefs.length; i++) {
// This method will check the service properties for
// remote service props. If previously registered as
@@ -155,14 +183,15 @@ public class TopologyManagerImpl extends AbstractTopologyManager implements Endp
handleServiceRegistering(existingServiceRefs[i]);
}
}
- }, "BasicTopologyManagerPreRegSrvExporter").start(); //$NON-NLS-1$
+ } catch (Exception e) {
+ logError("exportRegisteredServices", //$NON-NLS-1$
+ "Could not retrieve existing service references for exportRegisteredSvcsFilter=" //$NON-NLS-1$
+ + exportRegisteredSvcsFilter,
+ e);
+ }
+
}
- } catch (InvalidSyntaxException e) {
- logError("exportRegisteredServices", //$NON-NLS-1$
- "Could not retrieve existing service references for exportRegisteredSvcsFilter=" //$NON-NLS-1$
- + exportRegisteredSvcsFilter,
- e);
- }
+ }, "BasicTopologyManagerPreRegSrvExporter").start(); //$NON-NLS-1$
}
}

Back to the top