diff options
author | Lars Vogel | 2018-12-05 09:24:13 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-01-16 20:01:37 +0000 |
commit | 4598d3ba75c455467a8c8729f7b2c766b2379b9c (patch) | |
tree | f2b8a4c19fd1fd5aa549ce8468e71a8332ad22b1 | |
parent | 244078186f2065a1458e2ce46deb8021d82a6b05 (diff) | |
download | rt.equinox.p2-4598d3ba75c455467a8c8729f7b2c766b2379b9c.tar.gz rt.equinox.p2-4598d3ba75c455467a8c8729f7b2c766b2379b9c.tar.xz rt.equinox.p2-4598d3ba75c455467a8c8729f7b2c766b2379b9c.zip |
Bug 542420 - Offer <T> T getService(Class<T> key) in IProvisioningAgent
Change-Id: Id1e32d7388ef8197acd4421831fbf6602227d370
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
2 files changed, 15 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java index 34d09fff9..5181955e0 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java @@ -81,6 +81,12 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust } } + @SuppressWarnings("unchecked") + @Override + public <T> T getService(Class<T> key) { + return (T) getService(key.getSimpleName()); + } + private void checkRunning() { if (stopped) throw new IllegalStateException("Attempt to access stopped agent: " + this); //$NON-NLS-1$ @@ -184,4 +190,5 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust toRemove.close(); } } + } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IProvisioningAgent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IProvisioningAgent.java index 958a62987..e5cfb1840 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IProvisioningAgent.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IProvisioningAgent.java @@ -75,6 +75,14 @@ public interface IProvisioningAgent { public Object getService(String serviceName); /** + * Returns the service with the given service name, or <code>null</code> + * if no such service is available in this agent. + * @exception IllegalStateException if this agent has been stopped + * @exception ClassCastException if the agent cannot be cast to the provided class + */ + public <T> T getService(Class<T> key); + + /** * Registers a service with this provisioning agent. * * @param serviceName The name of the service to register |