protected void startup() { String location = PropertyManager.getProperty(PROFILE_LOCATION); if (location != null) try { dataLocation = new URI(location); } catch (URISyntaxException e) { // do nothing. will deal with it below } if (dataLocation == null) { LogUtility.logError("Invalid profile location URI - " + location); return; } try { agent = agentProvider.createAgent(dataLocation); } catch (ProvisionException e) { LogUtility.logError("Unable to initialize p2 agent", e); return; } registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME); engine = (IEngine) agent.getService(IEngine.SERVICE_NAME); String spec = PropertyManager.getProperty(REPO_LOCATIONS); if (spec != null) addRepositories(spec); }
protected void initProvisioningAgent() throws RuntimeException { try { // Inject references BundleContext bundleContext = FrameworkUtil.getBundle(UpdateManager.class).getBundleContext(); IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(bundleContext); ContextInjectionFactory.inject(this, serviceContext); // get p2 agent for current system(Eclipse instance in this // case) // the location for the currently running system is null (see // docs) p2Agent = agentProvider.createAgent(null); session = new ProvisioningSession(p2Agent); artifactRepoManager = (IArtifactRepositoryManager) p2Agent.getService(IArtifactRepositoryManager.class.getName()); metadataRepoManager = (IMetadataRepositoryManager) p2Agent.getService(IMetadataRepositoryManager.class.getName()); } catch (Exception e) { throw new RuntimeException(Messages.UpdateManager_14, e); } }