diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java index 8cf88ba61..0ded00367 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java @@ -19,10 +19,13 @@ import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdminRuntimeException; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.Operand; +import org.eclipse.equinox.p2.engine.spi.Touchpoint; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; public class EclipseTouchpoint extends Touchpoint { @@ -33,36 +36,37 @@ public class EclipseTouchpoint extends Touchpoint { public static final String PARM_IU = "iu"; //$NON-NLS-1$ public static final String PARM_ARTIFACT = "artifact"; //$NON-NLS-1$ public static final String PARM_ARTIFACT_LOCATION = "artifact.location"; //$NON-NLS-1$ + private static final Object PARM_AGENT = "agent"; //$NON-NLS-1$ private static final String NATIVE_TOUCHPOINT_ID = "org.eclipse.equinox.p2.touchpoint.natives"; //$NON-NLS-1$ - private static List NATIVE_ACTIONS = Arrays.asList(new String[] {"mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$ + private static List<String> NATIVE_ACTIONS = Arrays.asList(new String[] {"mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$ private static final String VALIDATE_PROFILE = "org.eclipse.equinox.internal.p2.touchpoint.eclipse.validateProfile"; //$NON-NLS-1$ - private static Map manipulators = new WeakHashMap(); - private static Map wrappers = new WeakHashMap(); - private static Map sourceManipulators = new WeakHashMap(); - private static Map preparedIUs = new WeakHashMap(); + private static Map<IProfile, LazyManipulator> manipulators = new WeakHashMap<IProfile, LazyManipulator>(); + private static Map<IProfile, PlatformConfigurationWrapper> wrappers = new WeakHashMap<IProfile, PlatformConfigurationWrapper>(); + private static Map<IProfile, SourceManipulator> sourceManipulators = new WeakHashMap<IProfile, SourceManipulator>(); + private static Map<IProfile, Map<IInstallableUnit, IInstallableUnit>> preparedIUs = new WeakHashMap<IProfile, Map<IInstallableUnit, IInstallableUnit>>(); - private static synchronized LazyManipulator getManipulator(IProfile profile) { - LazyManipulator manipulator = (LazyManipulator) manipulators.get(profile); + private static synchronized LazyManipulator getManipulator(IProvisioningAgent agent, IProfile profile) { + LazyManipulator manipulator = manipulators.get(profile); if (manipulator == null) { - manipulator = new LazyManipulator(profile); + manipulator = new LazyManipulator(agent, profile); manipulators.put(profile, manipulator); } return manipulator; } private static synchronized void saveManipulator(IProfile profile) throws FrameworkAdminRuntimeException, IOException { - LazyManipulator manipulator = (LazyManipulator) manipulators.remove(profile); + LazyManipulator manipulator = manipulators.remove(profile); if (manipulator != null) manipulator.save(false); } - private static synchronized PlatformConfigurationWrapper getPlatformConfigurationWrapper(IProfile profile, LazyManipulator manipulator) { - PlatformConfigurationWrapper wrapper = (PlatformConfigurationWrapper) wrappers.get(profile); + private static synchronized PlatformConfigurationWrapper getPlatformConfigurationWrapper(IProvisioningAgent agent, IProfile profile, LazyManipulator manipulator) { + PlatformConfigurationWrapper wrapper = wrappers.get(profile); if (wrapper == null) { File configLocation = Util.getConfigurationFolder(profile); - URI poolURI = Util.getBundlePoolLocation(profile); + URI poolURI = Util.getBundlePoolLocation(agent, profile); wrapper = new PlatformConfigurationWrapper(configLocation, poolURI, manipulator); wrappers.put(profile, wrapper); } @@ -70,13 +74,13 @@ public class EclipseTouchpoint extends Touchpoint { } private static synchronized void savePlatformConfigurationWrapper(IProfile profile) throws ProvisionException { - PlatformConfigurationWrapper wrapper = (PlatformConfigurationWrapper) wrappers.remove(profile); + PlatformConfigurationWrapper wrapper = wrappers.remove(profile); if (wrapper != null) wrapper.save(); } private static synchronized SourceManipulator getSourceManipulator(IProfile profile) { - SourceManipulator sourceManipulator = (SourceManipulator) sourceManipulators.get(profile); + SourceManipulator sourceManipulator = sourceManipulators.get(profile); if (sourceManipulator == null) { sourceManipulator = new SourceManipulator(profile); sourceManipulators.put(profile, sourceManipulator); @@ -85,23 +89,23 @@ public class EclipseTouchpoint extends Touchpoint { } private static synchronized void saveSourceManipulator(IProfile profile) throws IOException { - SourceManipulator sourceManipulator = (SourceManipulator) sourceManipulators.remove(profile); + SourceManipulator sourceManipulator = sourceManipulators.remove(profile); if (sourceManipulator != null) sourceManipulator.save(); } private static synchronized IInstallableUnit getPreparedIU(IProfile profile, IInstallableUnit iu) { - Map preparedProfileIUs = (Map) preparedIUs.get(profile); + Map<IInstallableUnit, IInstallableUnit> preparedProfileIUs = preparedIUs.get(profile); if (preparedProfileIUs == null) return null; - return (IInstallableUnit) preparedProfileIUs.get(iu); + return preparedProfileIUs.get(iu); } private static synchronized void savePreparedIU(IProfile profile, IInstallableUnit iu) { - Map preparedProfileIUs = (Map) preparedIUs.get(profile); + Map<IInstallableUnit, IInstallableUnit> preparedProfileIUs = preparedIUs.get(profile); if (preparedProfileIUs == null) { - preparedProfileIUs = new HashMap(); + preparedProfileIUs = new HashMap<IInstallableUnit, IInstallableUnit>(); preparedIUs.put(profile, preparedProfileIUs); } preparedProfileIUs.put(iu, iu); @@ -165,19 +169,21 @@ public class EclipseTouchpoint extends Touchpoint { return touchpointQualifier + "." + actionId; //$NON-NLS-1$ } - public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) { - LazyManipulator manipulator = getManipulator(profile); + public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map<String, Object> touchpointParameters) { + IProvisioningAgent agent = (IProvisioningAgent) touchpointParameters.get(PARM_AGENT); + LazyManipulator manipulator = getManipulator(agent, profile); touchpointParameters.put(PARM_MANIPULATOR, manipulator); touchpointParameters.put(PARM_SOURCE_BUNDLES, getSourceManipulator(profile)); - touchpointParameters.put(PARM_PLATFORM_CONFIGURATION, getPlatformConfigurationWrapper(profile, manipulator)); + touchpointParameters.put(PARM_PLATFORM_CONFIGURATION, getPlatformConfigurationWrapper(agent, profile, manipulator)); return null; } - public IStatus initializeOperand(IProfile profile, Operand operand, Map parameters) { + public IStatus initializeOperand(IProfile profile, Operand operand, Map<String, Object> parameters) { IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU); IArtifactKey artifactKey = (IArtifactKey) parameters.get(PARM_ARTIFACT); + IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT); if (iu != null && Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue()) { - IInstallableUnit preparedIU = prepareIU(iu, artifactKey, profile); + IInstallableUnit preparedIU = prepareIU(agent, profile, iu, artifactKey); if (preparedIU == null) return Util.createError(NLS.bind(Messages.failed_prepareIU, iu)); @@ -185,19 +191,19 @@ public class EclipseTouchpoint extends Touchpoint { } if (!parameters.containsKey(PARM_ARTIFACT_LOCATION) && artifactKey != null) { - File fileLocation = Util.getArtifactFile(artifactKey, profile); + File fileLocation = Util.getArtifactFile(agent, artifactKey, profile); if (fileLocation != null && fileLocation.exists()) parameters.put(PARM_ARTIFACT_LOCATION, fileLocation.getAbsolutePath()); } return Status.OK_STATUS; } - public IInstallableUnit prepareIU(IInstallableUnit iu, IArtifactKey artifactKey, IProfile profile) { + public IInstallableUnit prepareIU(IProvisioningAgent agent, IProfile profile, IInstallableUnit iu, IArtifactKey artifactKey) { IInstallableUnit preparedIU = getPreparedIU(profile, iu); if (preparedIU != null) return preparedIU; - Class c = null; + Class<?> c = null; try { c = Class.forName("org.eclipse.equinox.p2.publisher.eclipse.BundlesAction"); //$NON-NLS-1$ if (c != null) @@ -211,7 +217,7 @@ public class EclipseTouchpoint extends Touchpoint { if (artifactKey == null) return iu; - File bundleFile = Util.getArtifactFile(artifactKey, profile); + File bundleFile = Util.getArtifactFile(agent, artifactKey, profile); if (bundleFile == null) { LogHelper.log(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey.toString()))); return null; @@ -234,7 +240,7 @@ public class EclipseTouchpoint extends Touchpoint { if (Boolean.FALSE.toString().equals(profile.getProperty(VALIDATE_PROFILE))) return Status.OK_STATUS; - Class c = null; + Class<?> c = null; try { c = Class.forName("org.eclipse.equinox.internal.provisional.p2.director.IPlanner"); //$NON-NLS-1$ } catch (ClassNotFoundException e) { |