Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2014-08-07 13:11:52 -0400
committerIgor Fedorenko2014-08-14 13:43:09 -0400
commit6003796511c0fdeb203346b3fbe15d6921d01c31 (patch)
treed84617699b5182215b0c62ee256e33d0c9c6a778 /org.eclipse.m2e.core
parent444f41b76e7ff321dd444743f30f8ae46ea2eb19 (diff)
downloadm2e-core-6003796511c0fdeb203346b3fbe15d6921d01c31.tar.gz
m2e-core-6003796511c0fdeb203346b3fbe15d6921d01c31.tar.xz
m2e-core-6003796511c0fdeb203346b3fbe15d6921d01c31.zip
fixed IMavenComponentBinder does not honour @Singleton
Change-Id: I7696c6a2a88cca97833b22257906676b2da77a52 Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseBuildContext.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java31
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseRepositoryListener.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/ExtensionModule.java11
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/EclipsePluginDependenciesResolver.java7
5 files changed, 28 insertions, 28 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseBuildContext.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseBuildContext.java
index 52cfc528..4d3b50c8 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseBuildContext.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseBuildContext.java
@@ -11,15 +11,11 @@
package org.eclipse.m2e.core.internal.embedder;
-import org.codehaus.plexus.component.annotations.Component;
-
-import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.ThreadBuildContext;
/**
* Incremental build context.
*/
-@Component(role = BuildContext.class)
public class EclipseBuildContext extends ThreadBuildContext {
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java
index e9eeb44f..8e556b64 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseClassRealmManagerDelegate.java
@@ -17,11 +17,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Properties;
+import javax.inject.Inject;
+
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.util.IOUtil;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
@@ -35,31 +34,33 @@ import org.apache.maven.classrealm.ClassRealmRequest;
*
* @author igor
*/
-@Component(role = ClassRealmManagerDelegate.class)
public class EclipseClassRealmManagerDelegate implements ClassRealmManagerDelegate {
public static final String ROLE_HINT = EclipseClassRealmManagerDelegate.class.getName();
- @Requirement
- private PlexusContainer plexus;
+ private static final String PLEXUSBUILDCONTEXT_PROPERTIES = "/org/sonatype/plexus/build/incremental/version.properties"; //$NON-NLS-1$
+
+ private final PlexusContainer plexus;
- private final ArtifactVersion currentBuildApiVersion;
+ private static final ArtifactVersion currentBuildApiVersion;
- public EclipseClassRealmManagerDelegate() {
+ static {
Properties props = new Properties();
- InputStream is = getClass().getResourceAsStream("/org/sonatype/plexus/build/incremental/version.properties"); //$NON-NLS-1$
- if(is != null) {
- try {
+ try (InputStream is = EclipseClassRealmManagerDelegate.class.getResourceAsStream(PLEXUSBUILDCONTEXT_PROPERTIES)) {
+ if(is != null) {
props.load(is);
- } catch(IOException e) {
- e.printStackTrace();
- } finally {
- IOUtil.close(is);
}
+ } catch(IOException e) {
+ // TODO log
}
currentBuildApiVersion = new DefaultArtifactVersion(props.getProperty("api.version", "0.0.5")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Inject
+ public EclipseClassRealmManagerDelegate(PlexusContainer plexus) {
+ this.plexus = plexus;
+ }
+
public void setupRealm(ClassRealm realm, ClassRealmRequest request) {
if(supportsBuildApi(request.getConstituents())) {
ClassRealm coreRealm = plexus.getContainerRealm();
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseRepositoryListener.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseRepositoryListener.java
index 90808233..7366a766 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseRepositoryListener.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/EclipseRepositoryListener.java
@@ -18,8 +18,6 @@ import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryListener;
import org.eclipse.aether.artifact.Artifact;
-import org.codehaus.plexus.component.annotations.Component;
-
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.embedder.ILocalRepositoryListener;
@@ -28,7 +26,6 @@ import org.eclipse.m2e.core.embedder.ILocalRepositoryListener;
/**
* Dispatches local repository events to registered ILocalRepositoryListener's
*/
-@Component(role = RepositoryListener.class, hint = EclipseRepositoryListener.ROLE_HINT)
public class EclipseRepositoryListener extends AbstractRepositoryListener implements RepositoryListener {
public static final String ROLE_HINT = "EclipseRepositoryListener";
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/ExtensionModule.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/ExtensionModule.java
index 57135561..2d0b2857 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/ExtensionModule.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/ExtensionModule.java
@@ -11,10 +11,13 @@
package org.eclipse.m2e.core.internal.embedder;
+import javax.inject.Singleton;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.AbstractModule;
+import com.google.inject.binder.ScopedBindingBuilder;
import com.google.inject.name.Names;
import org.eclipse.core.runtime.CoreException;
@@ -32,10 +35,14 @@ class ExtensionModule extends AbstractModule implements IMavenComponentContribut
private static final Logger log = LoggerFactory.getLogger(ExtensionModule.class);
public <T> void bind(Class<T> role, Class<? extends T> impl, String hint) {
+ ScopedBindingBuilder builder;
if(hint == null || hint.length() <= 0 || "default".equals(hint)) { //$NON-NLS-1$
- bind(role).to(impl);
+ builder = bind(role).to(impl);
} else {
- bind(role).annotatedWith(Names.named(hint)).to(impl);
+ builder = bind(role).annotatedWith(Names.named(hint)).to(impl);
+ }
+ if(impl.getAnnotation(Singleton.class) != null) {
+ builder.in(com.google.inject.Singleton.class);
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/EclipsePluginDependenciesResolver.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/EclipsePluginDependenciesResolver.java
index e1933f66..d54fa76a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/EclipsePluginDependenciesResolver.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/EclipsePluginDependenciesResolver.java
@@ -13,21 +13,20 @@ package org.eclipse.m2e.core.internal.project.registry;
import java.util.List;
+import javax.inject.Singleton;
+
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.graph.DependencyFilter;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.repository.RemoteRepository;
-import org.codehaus.plexus.component.annotations.Component;
-
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.PluginResolutionException;
import org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver;
-import org.apache.maven.plugin.internal.PluginDependenciesResolver;
-@Component(role = PluginDependenciesResolver.class)
+@Singleton
public class EclipsePluginDependenciesResolver extends DefaultPluginDependenciesResolver {
/*

Back to the top