diff options
4 files changed, 119 insertions, 36 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF index f8973fd7e..96e676715 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: FrameworkAdmin Service for Equinox Bundle-SymbolicName: org.eclipse.equinox.framework.equinox -Bundle-Version: 1.0.0 +Bundle-Version: 1.0.1 Bundle-Activator: org.eclipse.equinox.frameworkadmin.equinox.internal.Activator Bundle-Vendor: Eclipse.org Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxBundlesState.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxBundlesState.java index 4d4ad0bce..d03e7efd2 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxBundlesState.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxBundlesState.java @@ -140,13 +140,47 @@ public class EquinoxBundlesState implements BundlesState { BundleContext context; Manipulator manipulator = null; + Properties properties = new Properties(); long maxId = -1; StateObjectFactory soFactory = null; State state = null; - EquinoxBundlesState(BundleContext context, EquinoxFwAdminImpl fwAdmin, Manipulator manipulator) { + /** + * This constructor will not take a framework persistent data into account. + * It will create State object based on the specified platformProperties. + * + * @param context + * @param fwAdmin + * @param manipulator + * @param platformProperties + */ + EquinoxBundlesState(BundleContext context, EquinoxFwAdminImpl fwAdmin, Manipulator manipulator, Properties platformProperties) { + super(); + this.context = context; + this.fwAdmin = fwAdmin; + // copy manipulator object for avoiding modifying the parameters of the manipulator. + this.manipulator = fwAdmin.getManipulator(); + this.manipulator.setConfigData(manipulator.getConfigData()); + this.manipulator.setLauncherData(manipulator.getLauncherData()); + LauncherData launcherData = manipulator.getLauncherData(); + ConfigData configData = manipulator.getConfigData(); + BundleInfo[] bInfos = configData.getBundles(); + this.composeCleanState(launcherData, configData, properties, bInfos); + } + + /** + * If useFwPersistentData flag equals false, + * this constructor will not take a framework persistent data into account. + * Otherwise, it will. + * + * @param context + * @param fwAdmin + * @param manipulator + * @param useFwPersistentData + */ + EquinoxBundlesState(BundleContext context, EquinoxFwAdminImpl fwAdmin, Manipulator manipulator, boolean useFwPersistentData) { super(); this.context = context; this.fwAdmin = fwAdmin; @@ -154,23 +188,42 @@ public class EquinoxBundlesState implements BundlesState { this.manipulator = fwAdmin.getManipulator(); this.manipulator.setConfigData(manipulator.getConfigData()); this.manipulator.setLauncherData(manipulator.getLauncherData()); - initialize(); + initialize(useFwPersistentData); } + // EquinoxBundlesState(BundleContext context, EquinoxFwAdminImpl fwAdmin, Manipulator manipulator) { + // this(context, fwAdmin, manipulator, true); + // // this.context = context; + // // this.fwAdmin = fwAdmin; + // // // copy manipulator object for avoiding modifying the parameters of the manipulator. + // // this.manipulator = fwAdmin.getManipulator(); + // // this.manipulator.setConfigData(manipulator.getConfigData()); + // // this.manipulator.setLauncherData(manipulator.getLauncherData()); + // // initialize(); + // } + private void composeCleanState(LauncherData launcherData, ConfigData configData, BundleInfo[] bInfos) { - composeExpectedState(bInfos, configData.getFwDependentProps(), null); + this.composeCleanState(launcherData, configData, configData.getFwDependentProps(), bInfos); + } + + private void composeCleanState(LauncherData launcherData, ConfigData configData, Properties properties, BundleInfo[] bInfos) { + composeExpectedState(bInfos, properties, null); resolve(true); if (getSystemBundle() == null) { + File fwJar = getFwJar(launcherData);; + if (fwJar == null) + throw new IllegalStateException("launcherData.getLauncherConfigFile() == null && fwJar is not set."); + BundleInfo[] newBInfos = new BundleInfo[bInfos.length + 1]; try { - newBInfos[0] = new BundleInfo(launcherData.getFwJar().toURL().toExternalForm(), 0, true); + newBInfos[0] = new BundleInfo(fwJar.toURL().toExternalForm(), 0, true); } catch (MalformedURLException e) { // Nothign to do because never happens. e.printStackTrace(); } System.arraycopy(bInfos, 0, newBInfos, 1, bInfos.length); configData.setBundles(newBInfos); - composeExpectedState(bInfos, configData.getFwDependentProps(), null); + composeExpectedState(bInfos, properties, null); resolve(true); } } @@ -183,8 +236,10 @@ public class EquinoxBundlesState implements BundlesState { if (fwPersistentDataLocation != null) { AlienStateReader alienStateReader = new AlienStateReader(fwPersistentDataLocation, null); state = alienStateReader.getState(); - if (state != null) + if (state != null) { cachedInstalledBundles = state.getBundles(); + getPlatformProperties(state); + } } if (state == null) { state = soFactory.createState(true); @@ -192,6 +247,7 @@ public class EquinoxBundlesState implements BundlesState { if (props == null) return false; this.setPlatformProperties(props); + getPlatformProperties(state); } // remove initial bundle which were installed but not listed in fwConfigFileBInfos. @@ -227,12 +283,26 @@ public class EquinoxBundlesState implements BundlesState { return true; } - public void composeRuntimeState() throws FrameworkAdminRuntimeException { - SimpleBundlesState.checkAvailability(fwAdmin); - PlatformAdmin platformAdmin = (PlatformAdmin) BundleHelper.getDefault().acquireService(PlatformAdmin.class.getName()); - State currentState = platformAdmin.getState(false); - state = this.soFactory.createState(currentState); - state.setPlatformProperties(currentState.getPlatformProperties()); + // public void composeRuntimeState() throws FrameworkAdminRuntimeException { + // SimpleBundlesState.checkAvailability(fwAdmin); + // PlatformAdmin platformAdmin = (PlatformAdmin) BundleHelper.getDefault().acquireService(PlatformAdmin.class.getName()); + // State currentState = platformAdmin.getState(false); + // state = this.soFactory.createState(currentState); + // state.setPlatformProperties(currentState.getPlatformProperties()); + // } + + private void getPlatformProperties(State state) { + Dictionary platformProperties = state.getPlatformProperties()[0]; + + properties.clear(); + if (platformProperties != null) { + for (Enumeration enumeration = platformProperties.elements(); enumeration.hasMoreElements();) { + String key = (String) enumeration.nextElement(); + Object value = platformProperties.get(key); + if (value != null) + properties.setProperty(key, (String) value); + } + } } public BundleInfo convert(BundleDescription toConvert) { @@ -331,23 +401,22 @@ public class EquinoxBundlesState implements BundlesState { return ret; } - private void initialize() { + private void initialize(boolean useFwPersistentData) { LauncherData launcherData = manipulator.getLauncherData(); ConfigData configData = manipulator.getConfigData(); - File fwJar = getFwJar(launcherData);; - // if (launcherData.getLauncherConfigFile() != null) { - // - // } - if (fwJar == null) - throw new IllegalStateException("launcherData.getLauncherConfigFile() == null && fwJar is not set."); + BundleInfo[] bInfos = configData.getBundles(); + + if (!useFwPersistentData) { + composeCleanState(launcherData, configData, bInfos); + return; + } EquinoxManipulatorImpl.checkConsistencyOfFwConfigLocAndFwPersistentDataLoc(launcherData); - BundleInfo[] bInfos = configData.getBundles(); if (launcherData.isClean()) { composeCleanState(launcherData, configData, bInfos); } else { if (manipulator.getLauncherData().getFwPersistentDataLocation() != null) { - // TODO default value should be set more precisely. + // TODO default value should be set more precisely. File installArea = null; String installAreaSt = configData.getFwDependentProp(EquinoxConstants.PROP_INSTALL); if (installAreaSt == null) { @@ -435,7 +504,7 @@ public class EquinoxBundlesState implements BundlesState { // "osgi.os", "osgi.ws", "osgi.nl", "osgi.arch", Constants.FRAMEWORK_SYSTEMPACKAGES, "osgi.resolverMode", // Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "osgi.resolveOptional" - private Properties setDefaultPlatformProperties() { + static Properties setDefaultPlatformProperties() { Properties platformProperties = new Properties(); // set default value @@ -478,8 +547,8 @@ public class EquinoxBundlesState implements BundlesState { private void setPlatformProperties(Dictionary props) { Properties platformProperties = setDefaultPlatformProperties(); - for (Enumeration enum = props.keys(); enum.hasMoreElements();) { - String key = (String) enum.nextElement(); + for (Enumeration enumeration = props.keys(); enumeration.hasMoreElements();) { + String key = (String) enumeration.nextElement(); for (int i = 0; i < PROPS.length; i++) { if (key.equals(PROPS[i])) { platformProperties.put(key, props.get(key)); @@ -526,8 +595,8 @@ public class EquinoxBundlesState implements BundlesState { sb.append("PlatformProperties:\n"); Dictionary[] dics = state.getPlatformProperties(); for (int i = 0; i < dics.length; i++) { - for (Enumeration enum = dics[i].keys(); enum.hasMoreElements();) { - String key = (String) enum.nextElement(); + for (Enumeration enumeration = dics[i].keys(); enumeration.hasMoreElements();) { + String key = (String) enumeration.nextElement(); String value = (String) dics[i].get(key); sb.append(" (" + key + "," + value + ")\n"); } @@ -566,4 +635,8 @@ public class EquinoxBundlesState implements BundlesState { } + Properties getProperties() { + return properties; + } + } diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxFwConfigFileParser.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxFwConfigFileParser.java index a1ff1d44a..810604f3a 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxFwConfigFileParser.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxFwConfigFileParser.java @@ -144,8 +144,8 @@ class EquinoxFwConfigFileParser { is = null; } - for (Enumeration enum = props.keys(); enum.hasMoreElements();) { - String key = (String) enum.nextElement(); + for (Enumeration enumeration = props.keys(); enumeration.hasMoreElements();) { + String key = (String) enumeration.nextElement(); String value = props.getProperty(key); if (key.equals(EquinoxConstants.PROP_BUNDLES_STARTLEVEL)) configData.setInitialBundleStartLevel(Integer.parseInt(value)); diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxManipulatorImpl.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxManipulatorImpl.java index 22c6a66d7..79b1835e7 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxManipulatorImpl.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/frameworkadmin/equinox/internal/EquinoxManipulatorImpl.java @@ -12,6 +12,7 @@ package org.eclipse.equinox.frameworkadmin.equinox.internal; import java.io.File; import java.io.IOException; +import java.util.Properties; import org.eclipse.equinox.configurator.ConfiguratorManipulator; import org.eclipse.equinox.frameworkadmin.*; @@ -21,7 +22,6 @@ import org.osgi.framework.*; import org.osgi.service.log.LogService; import org.osgi.util.tracker.ServiceTracker; - public class EquinoxManipulatorImpl implements Manipulator { private static final String SYSTEMBUNDLE_SYMBOLICNAME = "org.eclipse.osg"; public static final String FW_NAME = "Equinox"; @@ -92,7 +92,7 @@ public class EquinoxManipulatorImpl implements Manipulator { LauncherData launcherData = new LauncherData(EquinoxConstants.FW_NAME, EquinoxConstants.FW_VERSION, EquinoxConstants.LAUNCHER_NAME, EquinoxConstants.LAUNCHER_VERSION); BundleContext context = null; - BundlesState bundleState = null; + Properties properties = new Properties(); ServiceTracker cmTracker; int trackingCount = -1; @@ -109,10 +109,13 @@ public class EquinoxManipulatorImpl implements Manipulator { } public BundlesState getBundlesState() throws FrameworkAdminRuntimeException { - if (EquinoxBundlesState.checkFullySupported()) - return new EquinoxBundlesState(context, fwAdmin, this); - return new SimpleBundlesState(context, fwAdmin, this, SYSTEMBUNDLE_SYMBOLICNAME); + if (!EquinoxBundlesState.checkFullySupported()) + return new SimpleBundlesState(context, fwAdmin, this, SYSTEMBUNDLE_SYMBOLICNAME); + if (properties.isEmpty()) + return new EquinoxBundlesState(context, fwAdmin, this, false); + // XXX checking if fwDependent or fwIndependent properties are updated after the properties was created might be required for better implementation. + return new EquinoxBundlesState(context, fwAdmin, this, properties); } public ConfigData getConfigData() throws FrameworkAdminRuntimeException { @@ -171,8 +174,15 @@ public class EquinoxManipulatorImpl implements Manipulator { if (fwConfigFile.exists()) parser.readFwConfig(configData, fwConfigFile); - BundlesState bundleState = this.getBundlesState(); - BundleInfo[] newBundleInfos = bundleState.getExpectedState(); + BundlesState bundlesState = null; + if (EquinoxBundlesState.checkFullySupported()) { + bundlesState = new EquinoxBundlesState(context, fwAdmin, this, true); + properties = ((EquinoxBundlesState) bundlesState).getProperties(); + } else { + bundlesState = new SimpleBundlesState(context, fwAdmin, this, SYSTEMBUNDLE_SYMBOLICNAME); + properties.clear(); + } + BundleInfo[] newBundleInfos = bundlesState.getExpectedState(); configData.setBundles(newBundleInfos); if (!useConfigurator) return; |