diff options
author | John Arthorne | 2009-10-20 18:17:33 +0000 |
---|---|---|
committer | John Arthorne | 2009-10-20 18:17:33 +0000 |
commit | d80ba2d81fc220ab5862e72c05e93e403542efb1 (patch) | |
tree | 2d49008e3573a51df96b2e55304607dcff8fdf1d /bundles/org.eclipse.equinox.p2.engine | |
parent | 0f37c767a9e304c0b15c4eaa08f833bd5f454831 (diff) | |
download | rt.equinox.p2-d80ba2d81fc220ab5862e72c05e93e403542efb1.tar.gz rt.equinox.p2-d80ba2d81fc220ab5862e72c05e93e403542efb1.tar.xz rt.equinox.p2-d80ba2d81fc220ab5862e72c05e93e403542efb1.zip |
Bug 290207 - Support multiple p2 instances in a single VM
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine')
8 files changed, 77 insertions, 18 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF index 271a82898..ac818ce52 100644 --- a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF @@ -62,4 +62,4 @@ Require-Bundle: org.eclipse.equinox.common, org.eclipse.equinox.registry, org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.100", org.eclipse.core.jobs;bundle-version="[3.4.0,4.0.0)" -Service-Component: OSGI-INF/profileRegistry.xml +Service-Component: OSGI-INF/profileRegistry.xml, OSGI-INF/engine.xml diff --git a/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/engine.xml b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/engine.xml new file mode 100644 index 000000000..2f6630ca2 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/engine.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.engine"> + <implementation class="org.eclipse.equinox.internal.p2.engine.EngineComponent"/> + <service> + <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/> + </service> + <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.engine.IEngine"/> +</scr:component>
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml index 0e5ba9e67..4cb89bde7 100644 --- a/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml +++ b/bundles/org.eclipse.equinox.p2.engine/OSGI-INF/profileRegistry.xml @@ -1,4 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.engine.registry"> <implementation class="org.eclipse.equinox.internal.p2.engine.ProfileRegistryComponent"/> + <service> + <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/> + </service> + <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry"/> </scr:component>
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.engine/build.properties b/bundles/org.eclipse.equinox.p2.engine/build.properties index ce260dd3f..2be866258 100644 --- a/bundles/org.eclipse.equinox.p2.engine/build.properties +++ b/bundles/org.eclipse.equinox.p2.engine/build.properties @@ -1,11 +1,11 @@ output.. = bin/ bin.includes = META-INF/,\ + OSGI-INF/,\ .,\ plugin.xml,\ about.html,\ plugin.properties,\ .options,\ - OSGI-INF/profileRegistry.xml src.includes = about.html,\ schema/ source.. = src/ diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineComponent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineComponent.java new file mode 100644 index 000000000..6a8de3a60 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineComponent.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.p2.engine; + +import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; +import org.eclipse.equinox.internal.provisional.p2.engine.*; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; + +/** + * Component that provides a factory that can create and initialize + * {@link IEngine} instances. + */ +public class EngineComponent implements IAgentServiceFactory { + + /*(non-Javadoc) + * @see org.eclipse.equinox.p2.core.spi.IAgentServiceFactory#createService(org.eclipse.equinox.p2.core.IProvisioningAgent) + */ + public Object createService(IProvisioningAgent agent) { + IProvisioningEventBus bus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME); + Engine result = new Engine(bus); + result.setProfileRegistry((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME)); + return result; + } +} diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java index 0b6e6f728..1e05b8a91 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java @@ -24,7 +24,7 @@ public class ProfileRegistryComponent implements IAgentServiceFactory { public Object createService(IProvisioningAgent agent) { AgentLocation location = (AgentLocation) agent.getService(AgentLocation.SERVICE_NAME); SimpleProfileRegistry registry = new SimpleProfileRegistry(SimpleProfileRegistry.getDefaultRegistryDirectory(location)); - registry.setEventBus((IProvisioningEventBus) agent.getService(AgentLocation.SERVICE_NAME)); + registry.setEventBus((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)); return registry; } } diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java index dcec62074..0ff2d0f12 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/Engine.java @@ -13,7 +13,6 @@ package org.eclipse.equinox.internal.provisional.p2.engine; import java.io.File; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; @@ -23,14 +22,27 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEv public class Engine implements IEngine { private static final String ENGINE = "engine"; //$NON-NLS-1$ - private final IProvisioningEventBus eventBus; private ActionManager actionManager; + private final IProvisioningEventBus eventBus; + + private SimpleProfileRegistry profileRegistry; public Engine(IProvisioningEventBus eventBus) { this.eventBus = eventBus; this.actionManager = new ActionManager(); } + private void checkArguments(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) { + if (iprofile == null) + throw new IllegalArgumentException(Messages.null_profile); + + if (phaseSet == null) + throw new IllegalArgumentException(Messages.null_phaseset); + + if (operands == null) + throw new IllegalArgumentException(Messages.null_operands); + } + public IStatus perform(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) { checkArguments(iprofile, phaseSet, operands, context, monitor); @@ -40,8 +52,6 @@ public class Engine implements IEngine { if (monitor == null) monitor = new NullProgressMonitor(); - SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(EngineActivator.getContext(), IProfileRegistry.class.getName()); - Profile profile = profileRegistry.validate(iprofile); profileRegistry.lockProfile(profile); @@ -86,6 +96,17 @@ public class Engine implements IEngine { } } + public void setProfileRegistry(IProfileRegistry registry) { + //we can only work with our own registry implementation + if (registry instanceof SimpleProfileRegistry) + this.profileRegistry = (SimpleProfileRegistry) registry; + } + + public void unsetProfileRegistry(IProfileRegistry registry) { + if (this.profileRegistry == registry) + this.profileRegistry = null; + } + public IStatus validate(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) { checkArguments(iprofile, phaseSet, operands, context, monitor); @@ -97,15 +118,4 @@ public class Engine implements IEngine { return phaseSet.validate(actionManager, iprofile, operands, context, monitor); } - - private void checkArguments(IProfile iprofile, PhaseSet phaseSet, Operand[] operands, ProvisioningContext context, IProgressMonitor monitor) { - if (iprofile == null) - throw new IllegalArgumentException(Messages.null_profile); - - if (phaseSet == null) - throw new IllegalArgumentException(Messages.null_phaseset); - - if (operands == null) - throw new IllegalArgumentException(Messages.null_operands); - } } diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java index a3cfdbc4f..2b7cace00 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/provisional/p2/engine/IProfileRegistry.java @@ -19,6 +19,10 @@ import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; */ public interface IProfileRegistry { public static final String SELF = "_SELF_"; //$NON-NLS-1$ + /** + * Service name constant for the profile registry service. + */ + public static final String SERVICE_NAME = IProfileRegistry.class.getName(); /** * Return the profile in the registry that has the given id. If it does not exist, |