You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/03/18 10:26:52 UTC
svn commit: r755523 -
/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java
Author: gnodet
Date: Wed Mar 18 09:26:51 2009
New Revision: 755523
URL: http://svn.apache.org/viewvc?rev=755523&view=rev
Log:
SMX4NMR-130: fix bug with the timer
Modified:
servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java
Modified: servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java
URL: http://svn.apache.org/viewvc/servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java?rev=755523&r1=755522&r2=755523&view=diff
==============================================================================
--- servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java (original)
+++ servicemix/components/shared-libraries/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/osgi/EndpointExporter.java Wed Mar 18 09:26:51 2009
@@ -51,7 +51,6 @@
private Collection<ServiceRegistration> endpointRegistrations;
private ServiceRegistration assemblyRegistration;
private Timer timer;
- private boolean scheduled;
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
@@ -127,7 +126,10 @@
}
}
- protected void checkAndRegisterSA(Endpoint ep) {
+ protected synchronized void checkAndRegisterSA(Endpoint ep) {
+ if (assemblyRegistration != null) {
+ return;
+ }
if (ep != null) {
deployed.add(ep);
}
@@ -141,25 +143,27 @@
}
}
if (!initialized) {
+ // Create the timer if not already done
if (timer == null) {
timer = new Timer();
LOG.info("All endpoints have been deployed but waiting for components initialization");
}
+ // Retry a bit later to allow some time for the components to be initialized
+ // by the JBI container
synchronized (this) {
- if (!scheduled) {
- timer.schedule(new TimerTask() {
- public void run() {
- checkAndRegisterSA(null);
- }
- }, 500);
- scheduled = true;
- }
+ timer.schedule(new TimerTask() {
+ public void run() {
+ checkAndRegisterSA(null);
+ }
+ }, 500);
}
} else {
+ // Everything is ok, cancel the timer ...
if (timer != null) {
timer.cancel();
timer = null;
}
+ // ... and register the SA in OSGi
LOG.info("All endpoints have been deployed and components initialized. Registering service assembly.");
assemblyRegistration = bundleContext.registerService(DeployedAssembly.class.getName(), this, new Properties());
}