Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oberlies2011-12-06 09:31:42 +0000
committerTobias Oberlies2011-12-06 10:33:12 +0000
commit713962c047eb048223d711c62bdb418931172890 (patch)
tree48ac4bdf89f57243cb38b91d9ac9b101a78ed98b
parent518333a7effd6c808641afa85d7db0566b322e81 (diff)
downloadorg.eclipse.tycho-713962c047eb048223d711c62bdb418931172890.tar.gz
org.eclipse.tycho-713962c047eb048223d711c62bdb418931172890.tar.xz
org.eclipse.tycho-713962c047eb048223d711c62bdb418931172890.zip
365699 Only allow registering services in EquinoxLifecycleListeners
- Until we have really good reasons to do this differently, we should only allow to register OSGi services on startup of the embedded Equinox runtime. This is encouraged by moving the registerService methods to EquinoxEmbedder/EmbeddedEquinox. - Renamed EquinoxEmbedder to EmbeddedEquinox to clarify that the interface represents an already running Equinox.
-rw-r--r--sisu-equinox/sisu-equinox-api/src/main/java/org/eclipse/sisu/equinox/EquinoxServiceFactory.java7
-rw-r--r--sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EmbeddedEquinox.java (renamed from sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxEmbedder.java)12
-rw-r--r--sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxLifecycleListener.java7
-rw-r--r--sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java6
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/FileLockServiceConfigurator.java6
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java4
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/P2ProxyConfigurator.java4
7 files changed, 28 insertions, 18 deletions
diff --git a/sisu-equinox/sisu-equinox-api/src/main/java/org/eclipse/sisu/equinox/EquinoxServiceFactory.java b/sisu-equinox/sisu-equinox-api/src/main/java/org/eclipse/sisu/equinox/EquinoxServiceFactory.java
index af26d0b26..8b51aac1f 100644
--- a/sisu-equinox/sisu-equinox-api/src/main/java/org/eclipse/sisu/equinox/EquinoxServiceFactory.java
+++ b/sisu-equinox/sisu-equinox-api/src/main/java/org/eclipse/sisu/equinox/EquinoxServiceFactory.java
@@ -10,10 +10,9 @@
*******************************************************************************/
package org.eclipse.sisu.equinox;
-import java.util.Dictionary;
/**
- * "Client" interface to access and register OSGi services in the Equinox framework.
+ * Interface to access OSGi services in an Equinox runtime.
*/
public interface EquinoxServiceFactory {
@@ -21,8 +20,4 @@ public interface EquinoxServiceFactory {
public <T> T getService(Class<T> clazz, String filter);
- public <T> void registerService(Class<T> clazz, T service);
-
- public <T> void registerService(Class<T> clazz, T service, Dictionary<String, ?> properties);
-
}
diff --git a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxEmbedder.java b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EmbeddedEquinox.java
index c7c25771c..22b3ddd15 100644
--- a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxEmbedder.java
+++ b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EmbeddedEquinox.java
@@ -10,10 +10,20 @@
*******************************************************************************/
package org.eclipse.sisu.equinox.embedder;
+import java.util.Dictionary;
+
import org.eclipse.sisu.equinox.EquinoxServiceFactory;
-public interface EquinoxEmbedder {
+/**
+ * Interface to configure an embedded Equinox runtime. Implement an {@link EquinoxLifecycleListener}
+ * component to be notified about instances of this type.
+ */
+public interface EmbeddedEquinox {
EquinoxServiceFactory getServiceFactory();
+ public <T> void registerService(Class<T> clazz, T service);
+
+ public <T> void registerService(Class<T> clazz, T service, Dictionary<String, ?> properties);
+
}
diff --git a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxLifecycleListener.java b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxLifecycleListener.java
index 7afcbcf2c..37e9b3a4d 100644
--- a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxLifecycleListener.java
+++ b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/EquinoxLifecycleListener.java
@@ -10,6 +10,11 @@
*******************************************************************************/
package org.eclipse.sisu.equinox.embedder;
+/**
+ * Listener interface for events of {@link EmbeddedEquinox} instances.
+ */
public abstract class EquinoxLifecycleListener {
- public abstract void afterFrameworkStarted(EquinoxEmbedder framework);
+
+ public abstract void afterFrameworkStarted(EmbeddedEquinox framework);
+
}
diff --git a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java
index b9262d8a1..6e79ae906 100644
--- a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java
+++ b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java
@@ -26,7 +26,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.core.runtime.adaptor.EclipseStarter;
import org.eclipse.sisu.equinox.EquinoxServiceFactory;
-import org.eclipse.sisu.equinox.embedder.EquinoxEmbedder;
+import org.eclipse.sisu.equinox.embedder.EmbeddedEquinox;
import org.eclipse.sisu.equinox.embedder.EquinoxLifecycleListener;
import org.eclipse.sisu.equinox.embedder.EquinoxRuntimeLocator;
import org.osgi.framework.Bundle;
@@ -36,7 +36,7 @@ import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
@Component(role = EquinoxServiceFactory.class)
-public class DefaultEquinoxEmbedder extends AbstractLogEnabled implements EquinoxServiceFactory, EquinoxEmbedder,
+public class DefaultEquinoxEmbedder extends AbstractLogEnabled implements EquinoxServiceFactory, EmbeddedEquinox,
Disposable {
@Requirement(role = EquinoxLifecycleListener.class)
private Map<String, EquinoxLifecycleListener> lifecycleListeners;
@@ -256,7 +256,7 @@ public class DefaultEquinoxEmbedder extends AbstractLogEnabled implements Equino
}
public <T> void registerService(Class<T> clazz, T service, Dictionary<String, ?> properties) {
- checkStarted();
+ // don't need to call checkStarted here because EmbeddedEquinox instances are already started
frameworkContext.registerService(clazz, service, properties);
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/FileLockServiceConfigurator.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/FileLockServiceConfigurator.java
index 392eba2aa..f1d7ef298 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/FileLockServiceConfigurator.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/FileLockServiceConfigurator.java
@@ -13,7 +13,7 @@ package org.eclipse.tycho.osgi.configuration;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
-import org.eclipse.sisu.equinox.embedder.EquinoxEmbedder;
+import org.eclipse.sisu.equinox.embedder.EmbeddedEquinox;
import org.eclipse.sisu.equinox.embedder.EquinoxLifecycleListener;
import org.eclipse.tycho.locking.facade.FileLockService;
@@ -28,8 +28,8 @@ public class FileLockServiceConfigurator extends EquinoxLifecycleListener {
* from OSGi too.
*/
@Override
- public void afterFrameworkStarted(EquinoxEmbedder framework) {
- framework.getServiceFactory().registerService(FileLockService.class, fileLockService);
+ public void afterFrameworkStarted(EmbeddedEquinox framework) {
+ framework.registerService(FileLockService.class, fileLockService);
}
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java
index 1a9926f2b..e2db68e2b 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java
@@ -17,7 +17,7 @@ import org.apache.maven.plugin.LegacySupport;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
-import org.eclipse.sisu.equinox.embedder.EquinoxEmbedder;
+import org.eclipse.sisu.equinox.embedder.EmbeddedEquinox;
import org.eclipse.sisu.equinox.embedder.EquinoxLifecycleListener;
import org.eclipse.tycho.core.facade.MavenContext;
import org.eclipse.tycho.core.facade.internal.MutableMavenContext;
@@ -33,7 +33,7 @@ public class MavenContextConfigurator extends EquinoxLifecycleListener {
private LegacySupport context;
@Override
- public void afterFrameworkStarted(EquinoxEmbedder framework) {
+ public void afterFrameworkStarted(EmbeddedEquinox framework) {
MutableMavenContext mavenContext = (MutableMavenContext) framework.getServiceFactory().getService(
MavenContext.class);
MavenSession session = context.getSession();
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/P2ProxyConfigurator.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/P2ProxyConfigurator.java
index 8d39e8fe9..f3a0a230c 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/P2ProxyConfigurator.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/P2ProxyConfigurator.java
@@ -19,7 +19,7 @@ import org.apache.maven.settings.Proxy;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
-import org.eclipse.sisu.equinox.embedder.EquinoxEmbedder;
+import org.eclipse.sisu.equinox.embedder.EmbeddedEquinox;
import org.eclipse.sisu.equinox.embedder.EquinoxLifecycleListener;
import org.eclipse.tycho.core.facade.ProxyServiceFacade;
@@ -32,7 +32,7 @@ public class P2ProxyConfigurator extends EquinoxLifecycleListener {
private LegacySupport context;
@Override
- public void afterFrameworkStarted(EquinoxEmbedder framework) {
+ public void afterFrameworkStarted(EmbeddedEquinox framework) {
MavenSession session = context.getSession();
final List<Proxy> activeProxies = new ArrayList<Proxy>();

Back to the top