Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwin Tratar2018-09-20 04:29:39 -0400
committerFred Bricon2018-09-20 22:54:54 -0400
commit9d607fe93389fca4925446d5134961ee0a269227 (patch)
tree635d3060084ba74b879459962167d7efc96e9d53
parent449bf606e78208daa0909cdd945917b30b4e8350 (diff)
downloadm2e-core-9d607fe93389fca4925446d5134961ee0a269227.tar.gz
m2e-core-9d607fe93389fca4925446d5134961ee0a269227.tar.xz
m2e-core-9d607fe93389fca4925446d5134961ee0a269227.zip
Add lookup(Class<T>) to IMaven API
The lookup() variant is preferred over the lookupComponent() as it is a better fit from the thrown Exception. Change-Id: Id3bebff08d075d6cfdad60d93841bb4594c2ab3a Signed-off-by: Erwin Tratar <erwin.tratar@gebit.de> Bug: 539248
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java10
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java2
2 files changed, 11 insertions, 1 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
index abfb2920..334c1d37 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
@@ -334,4 +334,14 @@ public interface IMaven {
* @since 1.4
*/
IMavenExecutionContext getExecutionContext();
+
+ /**
+ * Lookup a component from the embedded PlexusContainer.
+ * @param clazz the requested role
+ * @return The component instance requested.
+ * @throws CoreException if the requested component is not available
+ *
+ * @since 1.10
+ */
+ <T> T lookup(Class<T> clazz) throws CoreException;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
index 1d9b06db..a4221c7b 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
@@ -1265,7 +1265,7 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
}
}
- /*package*/<T> T lookup(Class<T> clazz) throws CoreException {
+ public <T> T lookup(Class<T> clazz) throws CoreException {
try {
return getPlexusContainer().lookup(clazz);
} catch(ComponentLookupException ex) {

Back to the top