Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Thoms2019-09-27 12:54:09 +0000
committerKarsten Thoms2019-10-02 08:50:37 +0000
commit97a4ce3c1961c36f59f1013296d5ad18d3be728c (patch)
treeb80d065517056cdcf6a3a23432d5850057133067
parent1e75ec162f392dcfe6eb9e3cfad6dfef6ea3d1c0 (diff)
downloadrt.equinox.p2-97a4ce3c1961c36f59f1013296d5ad18d3be728c.tar.gz
rt.equinox.p2-97a4ce3c1961c36f59f1013296d5ad18d3be728c.tar.xz
rt.equinox.p2-97a4ce3c1961c36f59f1013296d5ad18d3be728c.zip
The addition of the method breaks the contract with existing alternative implementations of IProvisioningAgent. By making the method a default method the contract can be fulfilled. This also makes the implementation in class ProvisioningAgent obsolete. Update version of bundle org.eclipse.equinox.p2.core for 4.14. Change-Id: I7263c80e89e38841ca95eca2f3ebc3c7ed9f659f Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IProvisioningAgent.java21
2 files changed, 12 insertions, 15 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 3d65f1b41..11889073e 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,12 +81,6 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust
}
}
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getService(Class<T> key) {
- return (T) getService(key.getName());
- }
-
private void checkRunning() {
if (stopped)
throw new IllegalStateException("Attempt to access stopped agent: " + this); //$NON-NLS-1$
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 3533278b9..694a40856 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
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Ericsson AB (Pascal Rapicault) - reading preferences from base in shared install
@@ -35,7 +35,7 @@ public interface IProvisioningAgent {
/**
* Service name constant for the agent service. Note that an agent obtained directly
* as a service typically represents the agent of the currently running system. To
- * obtain an agent for a different system the {@link IProvisioningAgentProvider}
+ * obtain an agent for a different system the {@link IProvisioningAgentProvider}
* service must be used.
*/
public static final String SERVICE_NAME = IProvisioningAgent.class.getName();
@@ -43,20 +43,20 @@ public interface IProvisioningAgent {
public static final String INSTALLER_AGENT = "org.eclipse.equinox.p2.installer.agent"; //$NON-NLS-1$
public static final String INSTALLER_PROFILEID = "org.eclipse.equinox.p2.installer.profile.id"; //$NON-NLS-1$
- /**
+ /**
* When running in "shared mode", this allows to retrieve from the IProvisioningAgent the agent representing what is in the shared location aka the base
* @since 2.3
*/
public static final String SHARED_BASE_AGENT = "org.eclipse.equinox.shared.base.agent"; //$NON-NLS-1$
- /**
- * When running in "shared mode", this allows to retrieve from the IProvisioningAgent identified by {@link #SHARED_BASE_AGENT} the current agent
+ /**
+ * When running in "shared mode", this allows to retrieve from the IProvisioningAgent identified by {@link #SHARED_BASE_AGENT} the current agent
* @since 2.3
*/
public static final String SHARED_CURRENT_AGENT = "org.eclipse.equinox.shared.current.agent"; //$NON-NLS-1$
/**
* Service property identifying whether an agent is the default agent.
- *
+ *
* <p>
* This property may be used by clients wishing to obtain or track the
* provisioning agent for the currently running system. When the value of
@@ -81,11 +81,14 @@ public interface IProvisioningAgent {
* @exception ClassCastException if the agent cannot be cast to the provided class
* @since 2.6
*/
- public <T> T getService(Class<T> key);
+ @SuppressWarnings("unchecked")
+ public default <T> T getService(Class<T> key) {
+ return (T) getService(key.getName());
+ }
/**
* Registers a service with this provisioning agent.
- *
+ *
* @param serviceName The name of the service to register
* @param service The service implementation
* @exception IllegalStateException if this agent has been stopped
@@ -108,7 +111,7 @@ public interface IProvisioningAgent {
* Unregisters a service that has previously been registered with this
* agent via {@link #registerService(String, Object)}. This method has
* no effect if no such service is registered with this agent.
- *
+ *
* @param serviceName The name of the service to unregister
* @param service The service implementation to unregister.
*/

Back to the top