diff options
author | Susan Franklin | 2007-10-24 20:36:05 +0000 |
---|---|---|
committer | Susan Franklin | 2007-10-24 20:36:05 +0000 |
commit | aa4fc65e3f1a9bd75b9040ad8d78c4dc5e9f2847 (patch) | |
tree | 4248c1488421996ed6ea9a7bd7c5e1ee2b51e307 /bundles/org.eclipse.equinox.p2.updatechecker | |
parent | 6c71a8356d8e81e8c75f98b7bff115549d04c06d (diff) | |
download | rt.equinox.p2-aa4fc65e3f1a9bd75b9040ad8d78c4dc5e9f2847.tar.gz rt.equinox.p2-aa4fc65e3f1a9bd75b9040ad8d78c4dc5e9f2847.tar.xz rt.equinox.p2-aa4fc65e3f1a9bd75b9040ad8d78c4dc5e9f2847.zip |
lazy initialize prov dependencies
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.updatechecker')
2 files changed, 25 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/Activator.java b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/Activator.java index 380c22ced..4ffbcdc49 100644 --- a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/Activator.java +++ b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/Activator.java @@ -28,15 +28,15 @@ public class Activator implements BundleActivator { return context; } - public void start(BundleContext context) throws Exception { - this.context = context; + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; updateChecker = new UpdateChecker(); registrationChecker = context.registerService(UpdateChecker.class.getName(), updateChecker, null); } - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext bundleContext) throws Exception { registrationChecker.unregister(); updateChecker = null; } diff --git a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java index 675778a6d..73148e062 100644 --- a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java +++ b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/p2/updatechecker/UpdateChecker.java @@ -47,7 +47,7 @@ public class UpdateChecker { UpdateCheckThread(String profileId, long delay, long poll, IUpdateListener listener) { this.poll = poll; this.delay = delay; - this.profile = profileRegistry.getProfile(profileId); + this.profile = getProfileRegistry().getProfile(profileId); this.listener = listener; } @@ -82,14 +82,6 @@ public class UpdateChecker { } } - public UpdateChecker() { - profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.class.getName()); - planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.class.getName()); - if (planner == null || profileRegistry == null) { - throw new IllegalStateException("Provisioning system has not been initialized"); //$NON-NLS-1$ - } - } - public void addUpdateCheck(String profileId, long delay, long poll, IUpdateListener listener) { log("Adding update checker for " + profileId + " at " + getTimeStamp()); //$NON-NLS-1$ //$NON-NLS-2$ UpdateCheckThread thread = new UpdateCheckThread(profileId, delay, poll, listener); @@ -120,7 +112,7 @@ public class UpdateChecker { Iterator iter = profile.getInstallableUnits(); while (iter.hasNext()) { IInstallableUnit iu = (IInstallableUnit) iter.next(); - IInstallableUnit[] replacements = planner.updatesFor(iu); + IInstallableUnit[] replacements = getPlanner().updatesFor(iu); if (replacements.length > 0) iusWithUpdates.add(iu); } @@ -144,4 +136,24 @@ public class UpdateChecker { return df.format(d); } + IPlanner getPlanner() { + if (planner == null) { + planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.class.getName()); + if (planner == null) { + throw new IllegalStateException("Provisioning system has not been initialized"); //$NON-NLS-1$ + } + } + return planner; + } + + IProfileRegistry getProfileRegistry() { + if (profileRegistry == null) { + profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.class.getName()); + if (profileRegistry == null) { + throw new IllegalStateException("Provisioning system has not been initialized"); //$NON-NLS-1$ + } + } + return profileRegistry; + } + } |