diff options
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse')
13 files changed, 95 insertions, 82 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java index 0b8e408b3..a89a7e77e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java @@ -297,7 +297,7 @@ public class EclipseStarter { registerFrameworkShutdownHandlers(); publishSplashScreen(endSplashHandler); - consoleMgr = ConsoleManager.startConsole(context); + consoleMgr = ConsoleManager.startConsole(context, equinoxConfig); Bundle[] startBundles = loadBasicBundles(); @@ -360,7 +360,7 @@ public class EclipseStarter { if (appLauncher == null) { boolean launchDefault = Boolean.valueOf(getProperty(PROP_APPLICATION_LAUNCHDEFAULT, "true")).booleanValue(); //$NON-NLS-1$ // create the ApplicationLauncher and register it as a service - appLauncher = new EclipseAppLauncher(context, Boolean.valueOf(getProperty(PROP_ALLOW_APPRELAUNCH)).booleanValue(), launchDefault, log); + appLauncher = new EclipseAppLauncher(context, Boolean.valueOf(getProperty(PROP_ALLOW_APPRELAUNCH)).booleanValue(), launchDefault, log, equinoxConfig); appLauncherRegistration = context.registerService(ApplicationLauncher.class.getName(), appLauncher, null); // must start the launcher AFTER service restration because this method // blocks and runs the application on the current thread. This method @@ -458,7 +458,7 @@ public class EclipseStarter { try { Dictionary<String, Object> monitorProps = new Hashtable<String, Object>(); monitorProps.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE)); - defaultMonitorRegistration = context.registerService(StartupMonitor.class.getName(), new DefaultStartupMonitor(endSplashHandler), monitorProps); + defaultMonitorRegistration = context.registerService(StartupMonitor.class.getName(), new DefaultStartupMonitor(endSplashHandler, equinoxConfig), monitorProps); } catch (IllegalStateException e) { //splash handler did not provide the necessary methods, ignore it } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java index 63abe9fe3..95e58a2e7 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java @@ -12,13 +12,14 @@ package org.eclipse.core.runtime.internal.adaptor; import java.lang.reflect.Method; import org.eclipse.core.runtime.adaptor.EclipseStarter; -import org.eclipse.osgi.framework.internal.core.FrameworkProperties; +import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.service.runnable.StartupMonitor; public class DefaultStartupMonitor implements StartupMonitor { - private Method updateMethod = null; - private Runnable splashHandler = null; + private final Method updateMethod; + private final Runnable splashHandler; + private final EquinoxConfiguration equinoxConfig; /** * Create a new startup monitor using the given splash handler. The splash handle must @@ -27,8 +28,9 @@ public class DefaultStartupMonitor implements StartupMonitor { * @param splashHandler * @throws IllegalStateException */ - public DefaultStartupMonitor(Runnable splashHandler) throws IllegalStateException { + public DefaultStartupMonitor(Runnable splashHandler, EquinoxConfiguration equinoxConfig) throws IllegalStateException { this.splashHandler = splashHandler; + this.equinoxConfig = equinoxConfig; try { updateMethod = splashHandler.getClass().getMethod("updateSplash", (Class[]) null); //$NON-NLS-1$ @@ -57,7 +59,7 @@ public class DefaultStartupMonitor implements StartupMonitor { public void applicationRunning() { if (EclipseStarter.debug) { - String timeString = FrameworkProperties.getProperty("eclipse.startTime"); //$NON-NLS-1$ + String timeString = equinoxConfig.getConfiguration("eclipse.startTime"); //$NON-NLS-1$ long time = timeString == null ? 0L : Long.parseLong(timeString); System.out.println("Application Started: " + (System.currentTimeMillis() - time)); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/EclipseAppLauncher.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/EclipseAppLauncher.java index 7bd75b156..d4dc9072f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/EclipseAppLauncher.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/EclipseAppLauncher.java @@ -14,9 +14,9 @@ package org.eclipse.core.runtime.internal.adaptor; import java.lang.reflect.Method; import java.util.Map; import org.eclipse.core.runtime.adaptor.EclipseStarter; -import org.eclipse.osgi.framework.internal.core.FrameworkProperties; import org.eclipse.osgi.framework.log.FrameworkLog; import org.eclipse.osgi.framework.log.FrameworkLogEntry; +import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.internal.framework.EquinoxContainer; import org.eclipse.osgi.internal.location.EclipseAdaptorMsg; import org.eclipse.osgi.service.runnable.*; @@ -31,12 +31,14 @@ public class EclipseAppLauncher implements ApplicationLauncher { private boolean relaunch = false; private boolean failOnNoDefault = false; private FrameworkLog log; + private final EquinoxConfiguration equinoxConfig; - public EclipseAppLauncher(BundleContext context, boolean relaunch, boolean failOnNoDefault, FrameworkLog log) { + public EclipseAppLauncher(BundleContext context, boolean relaunch, boolean failOnNoDefault, FrameworkLog log, EquinoxConfiguration equinoxConfig) { this.context = context; this.relaunch = relaunch; this.failOnNoDefault = failOnNoDefault; this.log = log; + this.equinoxConfig = equinoxConfig; findRunnableService(); } @@ -98,7 +100,7 @@ public class EclipseAppLauncher implements ApplicationLauncher { // this must happen after we have acquired an application (by acquiring waitForAppLock above). runningLock.acquire(); if (EclipseStarter.debug) { - String timeString = FrameworkProperties.getProperty("eclipse.startTime"); //$NON-NLS-1$ + String timeString = equinoxConfig.getConfiguration("eclipse.startTime"); //$NON-NLS-1$ long time = timeString == null ? 0L : Long.parseLong(timeString); System.out.println("Starting application: " + (System.currentTimeMillis() - time)); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java index 17d72d2d2..f832f7a72 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/internal/core/ConsoleManager.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osgi.framework.internal.core; +import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.osgi.framework.*; import org.osgi.service.packageadmin.PackageAdmin; @@ -20,35 +21,38 @@ public class ConsoleManager { public static final String PROP_CONSOLE_ENABLED = "osgi.console.enable.builtin"; //$NON-NLS-1$ private final BundleContext context; + private final EquinoxConfiguration equinoxConfig; private final String consoleBundle; private final String consolePort; - public ConsoleManager(BundleContext context, String consolePropValue) { + public ConsoleManager(BundleContext context, EquinoxConfiguration equinoxConfig) { + this.equinoxConfig = equinoxConfig; String port = null; + String consolePropValue = equinoxConfig.getConfiguration(PROP_CONSOLE); if (consolePropValue != null) { int index = consolePropValue.lastIndexOf(":"); //$NON-NLS-1$ port = consolePropValue.substring(index + 1); } this.consolePort = port != null ? port.trim() : port; - String enabled = FrameworkProperties.getProperty(PROP_CONSOLE_ENABLED, CONSOLE_BUNDLE); + String enabled = equinoxConfig.getConfiguration(PROP_CONSOLE_ENABLED, CONSOLE_BUNDLE); this.context = context; if (!"true".equals(enabled) || "none".equals(consolePort)) { //$NON-NLS-1$ //$NON-NLS-2$ this.consoleBundle = "false".equals(enabled) ? CONSOLE_BUNDLE : enabled; //$NON-NLS-1$ if (consolePort == null || consolePort.length() > 0) { // no -console was specified or it has specified none or a port for telnet; // need to make sure the gogo shell does not create an interactive console on standard in/out - FrameworkProperties.setProperty("gosh.args", "--nointeractive"); //$NON-NLS-1$//$NON-NLS-2$ + equinoxConfig.setProperty("gosh.args", "--nointeractive"); //$NON-NLS-1$//$NON-NLS-2$ } else { // Need to make sure we don't shutdown the framework if no console is around (bug 362412) - FrameworkProperties.setProperty("gosh.args", "--noshutdown"); //$NON-NLS-1$//$NON-NLS-2$ + equinoxConfig.setProperty("gosh.args", "--noshutdown"); //$NON-NLS-1$//$NON-NLS-2$ } return; } this.consoleBundle = "unknown"; //$NON-NLS-1$ } - public static ConsoleManager startConsole(BundleContext context) { - ConsoleManager consoleManager = new ConsoleManager(context, FrameworkProperties.getProperty(PROP_CONSOLE)); + public static ConsoleManager startConsole(BundleContext context, EquinoxConfiguration equinoxConfig) { + ConsoleManager consoleManager = new ConsoleManager(context, equinoxConfig); return consoleManager; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java index e41c9e066..f76b8fb09 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java @@ -91,6 +91,11 @@ public class EquinoxConfiguration implements EnvironmentInfo { public static final int BSN_VERSION_MULTIPLE = 2; public static final int BSN_VERSION_MANAGED = 3; + public final boolean throwErrorOnFailedStart; + + public final boolean CLASS_CERTIFICATE; + public final boolean PARALLEL_CAPABLE; + // JVM os.arch property name public static final String PROP_JVM_OS_ARCH = "os.arch"; //$NON-NLS-1$ // JVM os.name property name @@ -128,6 +133,7 @@ public class EquinoxConfiguration implements EnvironmentInfo { public static final String PROP_CONTEXT_BOOTDELEGATION = "osgi.context.bootdelegation"; //$NON-NLS-1$ public static final String PROP_COMPATIBILITY_BOOTDELEGATION = "osgi.compatibility.bootdelegation"; //$NON-NLS-1$ + public static final String PROP_COMPATIBILITY_ERROR_FAILED_START = "osgi.compatibility.errorOnFailedStart"; //$NON-NLS-1$ public static final String PROP_OSGI_OS = "osgi.os"; //$NON-NLS-1$ public static final String PROP_OSGI_WS = "osgi.ws"; //$NON-NLS-1$ @@ -155,6 +161,11 @@ public class EquinoxConfiguration implements EnvironmentInfo { public static final String PROP_BUNDLE_SETTCCL = "eclipse.bundle.setTCCL"; //$NON-NLS-1$ public static final String PROP_EQUINOX_SECURITY = "eclipse.security"; //$NON-NLS-1$ + public static final String PROP_FILE_LIMIT = "osgi.bundlefile.limit"; //$NON-NLS-1$ + + public final static String PROP_CLASS_CERTIFICATE_SUPPORT = "osgi.support.class.certificate"; //$NON-NLS-1$ + public final static String PROP_CLASS_LOADER_TYPE = "osgi.classloader.type"; //$NON-NLS-1$ + public final static String CLASS_LOADER_TYPE_PARALLEL = "parallel"; //$NON-NLS-1$ EquinoxConfiguration(Map<String, String> initialConfig, HookRegistry hookRegistry) { this.hookRegistry = hookRegistry; @@ -306,6 +317,11 @@ public class EquinoxConfiguration implements EnvironmentInfo { } BUNDLE_SET_TCCL = "true".equals(getConfiguration("eclipse.bundle.setTCCL", "true")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + throwErrorOnFailedStart = "true".equals(getConfiguration(PROP_COMPATIBILITY_ERROR_FAILED_START, "true")); //$NON-NLS-1$//$NON-NLS-2$ + + CLASS_CERTIFICATE = Boolean.valueOf(getConfiguration(PROP_CLASS_CERTIFICATE_SUPPORT, "true")).booleanValue(); //$NON-NLS-1$ + PARALLEL_CAPABLE = CLASS_LOADER_TYPE_PARALLEL.equals(getConfiguration(PROP_CLASS_LOADER_TYPE, CLASS_LOADER_TYPE_PARALLEL)); } public Map<String, String> asMap() { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java index 34d85ed7a..9458ef49b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java @@ -17,7 +17,6 @@ import org.eclipse.osgi.container.Module.StartOptions; import org.eclipse.osgi.container.Module.State; import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace; import org.eclipse.osgi.framework.adaptor.StatusException; -import org.eclipse.osgi.framework.internal.core.FrameworkProperties; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.internal.framework.EquinoxContainer; import org.eclipse.osgi.internal.hookregistry.ClassLoaderHook; @@ -27,7 +26,6 @@ import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; public class EclipseLazyStarter extends ClassLoaderHook { - private static final boolean throwErrorOnFailedStart = "true".equals(FrameworkProperties.getProperty("osgi.compatibility.errorOnFailedStart", "true")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ private static final EnumSet<State> alreadyActive = EnumSet.of(State.ACTIVE, State.STOPPING, State.UNINSTALLED); // holds the current activation trigger class and the ClasspathManagers that need to be activated private final ThreadLocal<List<Object>> activationStack = new ThreadLocal<List<Object>>(); @@ -91,7 +89,7 @@ public class EclipseLazyStarter extends ClassLoaderHook { return; for (int i = managers.length - 1; i >= 0; i--) { if (errors.get(managers[i]) != null) { - if (throwErrorOnFailedStart) + if (container.getConfiguration().throwErrorOnFailedStart) throw errors.get(managers[i]); continue; } @@ -119,7 +117,7 @@ public class EclipseLazyStarter extends ClassLoaderHook { String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CLASSLOADER_ACTIVATION, bundle.getSymbolicName(), Long.toString(bundle.getBundleId())); TerminatingClassNotFoundException error = new TerminatingClassNotFoundException(message, e); errors.put(managers[i], error); - if (throwErrorOnFailedStart) { + if (container.getConfiguration().throwErrorOnFailedStart) { container.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, message, e, null); throw error; } @@ -133,7 +131,7 @@ public class EclipseLazyStarter extends ClassLoaderHook { // Don't activate non-starting bundles if (State.RESOLVED.equals(module.getState())) { // handle the resolved case where a previous error occurred - if (throwErrorOnFailedStart) { + if (container.getConfiguration().throwErrorOnFailedStart) { TerminatingClassNotFoundException error = errors.get(manager); if (error != null) throw error; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java index af73ccc71..92c754af7 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java @@ -18,7 +18,6 @@ import java.net.URL; import java.security.*; import java.security.cert.Certificate; import java.util.*; -import org.eclipse.osgi.framework.internal.core.FrameworkProperties; import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.internal.loader.classpath.ClasspathEntry; import org.eclipse.osgi.internal.loader.classpath.ClasspathManager; @@ -36,34 +35,26 @@ public class ModuleClassLoader extends ClassLoader implements BundleReference { * A PermissionCollection for AllPermissions; shared across all ProtectionDomains when security is disabled */ protected static final PermissionCollection ALLPERMISSIONS; - private final static String CLASS_CERTIFICATE_SUPPORT = "osgi.support.class.certificate"; //$NON-NLS-1$ - private final static String CLASS_LOADER_TYPE = "osgi.classloader.type"; //$NON-NLS-1$ - private final static String CLASS_LOADER_TYPE_PARALLEL = "parallel"; //$NON-NLS-1$ - private static final boolean CLASS_CERTIFICATE; - private static final boolean PARALLEL_CAPABLE; + private static final boolean REGISTERED_AS_PARALLEL; @SuppressWarnings("unchecked") private static final Enumeration<URL> EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_LIST); static { - CLASS_CERTIFICATE = Boolean.valueOf(FrameworkProperties.getProperty(CLASS_CERTIFICATE_SUPPORT, "true")).booleanValue(); //$NON-NLS-1$ AllPermission allPerm = new AllPermission(); ALLPERMISSIONS = allPerm.newPermissionCollection(); if (ALLPERMISSIONS != null) ALLPERMISSIONS.add(allPerm); - boolean typeParallel = CLASS_LOADER_TYPE_PARALLEL.equals(FrameworkProperties.getProperty(CLASS_LOADER_TYPE, CLASS_LOADER_TYPE_PARALLEL)); - boolean parallelCapable = false; + boolean registeredAsParallel; try { - if (typeParallel) { - Method parallelCapableMetod = ClassLoader.class.getDeclaredMethod("registerAsParallelCapable", (Class[]) null); //$NON-NLS-1$ - parallelCapableMetod.setAccessible(true); - parallelCapable = ((Boolean) parallelCapableMetod.invoke(null, (Object[]) null)).booleanValue(); - } + Method parallelCapableMetod = ClassLoader.class.getDeclaredMethod("registerAsParallelCapable", (Class[]) null); //$NON-NLS-1$ + parallelCapableMetod.setAccessible(true); + registeredAsParallel = ((Boolean) parallelCapableMetod.invoke(null, (Object[]) null)).booleanValue(); } catch (Throwable e) { // must do everything to avoid failing in clinit - parallelCapable = false; + registeredAsParallel = false; } - PARALLEL_CAPABLE = parallelCapable; + REGISTERED_AS_PARALLEL = registeredAsParallel; } private final EquinoxConfiguration configuration; @@ -223,7 +214,7 @@ public class ModuleClassLoader extends ClassLoader implements BundleReference { * @return a ProtectionDomain which uses specified BundleFile and the permissions of the baseDomain */ @SuppressWarnings("deprecation") - public static ProtectionDomain createProtectionDomain(BundleFile bundlefile, ProtectionDomain baseDomain) { + public ProtectionDomain createProtectionDomain(BundleFile bundlefile, ProtectionDomain baseDomain) { // create a protection domain which knows about the codesource for this classpath entry (bug 89904) try { // use the permissions supplied by the domain passed in from the framework @@ -242,7 +233,7 @@ public class ModuleClassLoader extends ClassLoader implements BundleReference { wrapper = wrapper.getNext(); signedContent = wrapper == null ? null : (SignedContent) wrapper.getWrapped(); } - if (CLASS_CERTIFICATE && signedContent != null && signedContent.isSigned()) { + if (configuration.CLASS_CERTIFICATE && signedContent != null && signedContent.isSigned()) { SignerInfo[] signers = signedContent.getSignerInfos(); if (signers.length > 0) certs = signers[0].getCertificateChain(); @@ -263,7 +254,7 @@ public class ModuleClassLoader extends ClassLoader implements BundleReference { } public boolean isParallelCapable() { - return PARALLEL_CAPABLE; + return REGISTERED_AS_PARALLEL || configuration.PARALLEL_CAPABLE; } public List<URL> findEntries(String path, String filePattern, int options) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java index d30f3db1f..f75ec6544 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java @@ -628,7 +628,7 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { * Reads the PROP_LOG_SIZE_MAX and PROP_LOG_FILE_MAX properties. */ private void readLogProperties() { - String newMaxLogSize = secureAction.getProperty(PROP_LOG_SIZE_MAX); + String newMaxLogSize = environmentInfo.getConfiguration(PROP_LOG_SIZE_MAX); if (newMaxLogSize != null) { maxLogSize = Integer.parseInt(newMaxLogSize); if (maxLogSize != 0 && maxLogSize < LOG_SIZE_MIN) { @@ -638,7 +638,7 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { } } - String newMaxLogFiles = secureAction.getProperty(PROP_LOG_FILE_MAX); + String newMaxLogFiles = environmentInfo.getConfiguration(PROP_LOG_FILE_MAX); if (newMaxLogFiles != null) { maxLogFiles = Integer.parseInt(newMaxLogFiles); if (maxLogFiles < 1) { @@ -647,7 +647,7 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { } } - String newLogLevel = secureAction.getProperty(PROP_LOG_LEVEL); + String newLogLevel = environmentInfo.getConfiguration(PROP_LOG_LEVEL); if (newLogLevel != null) { if (newLogLevel.equals("ERROR")) //$NON-NLS-1$ logLevel = FrameworkLogEntry.ERROR; @@ -659,7 +659,7 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { logLevel = FrameworkLogEntry.OK; // OK (0) means log everything } - includeCommandLine = "true".equals(secureAction.getProperty(PROP_LOG_INCLUDE_COMMAND_LINE, "true")); //$NON-NLS-1$//$NON-NLS-2$ + includeCommandLine = "true".equals(environmentInfo.getConfiguration(PROP_LOG_INCLUDE_COMMAND_LINE, "true")); //$NON-NLS-1$//$NON-NLS-2$ } /** diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java index 3ea4552fe..9edcfdba3 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java @@ -19,6 +19,7 @@ import org.eclipse.osgi.framework.internal.core.Msg; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.framework.util.SecureAction; import org.eclipse.osgi.internal.framework.EquinoxContainer; +import org.eclipse.osgi.internal.location.EquinoxLocations; import org.eclipse.osgi.storage.url.BundleResourceHandler; import org.eclipse.osgi.util.NLS; import org.osgi.framework.BundleContext; @@ -140,7 +141,7 @@ public class URLStreamHandlerFactoryImpl extends MultiplexingFactory implements } else if (BundleResourceHandler.OSGI_RESOURCE_URL_PROTOCOL.equals(protocol)) { return new org.eclipse.osgi.storage.url.bundleresource.Handler(container.getStorage().getModuleContainer(), null); } else if (PROTOCOL_REFERENCE.equals(protocol)) { - return new org.eclipse.osgi.storage.url.reference.Handler(); + return new org.eclipse.osgi.storage.url.reference.Handler(container.getConfiguration().getConfiguration(EquinoxLocations.PROP_INSTALL_AREA)); } return null; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index 48054b3c0..7f4248752 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -70,10 +70,11 @@ public class Storage { private final Object saveMonitor = new Object(); private long lastSavedTimestamp = -1; private final LockSet<Long> idLocks = new LockSet<Long>(false); - private final MRUBundleFileList mruList = new MRUBundleFileList(); + private final MRUBundleFileList mruList; private final FrameworkExtensionInstaller extensionInstaller; public Storage(EquinoxContainer container) throws IOException, BundleException { + mruList = new MRUBundleFileList(getBundleFileLimit(container.getConfiguration())); equinoxContainer = container; extensionInstaller = new FrameworkExtensionInstaller(container.getConfiguration()); @@ -137,6 +138,18 @@ public class Storage { this.moduleContainer.setInitialModuleStates(); } + private int getBundleFileLimit(EquinoxConfiguration configuration) { + int propValue = 100; // enable to 100 open files by default + try { + String prop = configuration.getConfiguration(EquinoxConfiguration.PROP_FILE_LIMIT); + if (prop != null) + propValue = Integer.parseInt(prop); + } catch (NumberFormatException e) { + // use default of 100 + } + return propValue; + } + private void installExtensions() { Module systemModule = moduleContainer.getModule(0); ModuleRevision systemRevision = systemModule == null ? null : systemModule.getCurrentRevision(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java index 142372396..f3488fdcc 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/MRUBundleFileList.java @@ -23,21 +23,9 @@ import org.eclipse.osgi.framework.eventmgr.*; * @since 3.2 */ public class MRUBundleFileList implements EventDispatcher<Object, Object, BundleFile> { - private static final String PROP_FILE_LIMIT = "osgi.bundlefile.limit"; //$NON-NLS-1$ private static final int MIN = 10; - private static final int PROP_FILE_LIMIT_VALUE; private static final ThreadLocal<BundleFile> closingBundleFile = new ThreadLocal<BundleFile>(); - static { - int propValue = 100; // enable to 100 open files by default - try { - String prop = BundleFile.secureAction.getProperty(PROP_FILE_LIMIT); - if (prop != null) - propValue = Integer.parseInt(prop); - } catch (NumberFormatException e) { - //MRU will be disabled - } - PROP_FILE_LIMIT_VALUE = propValue; - } + // list of open bundle files final private BundleFile[] bundleFileList; // list of open bundle files use stamps @@ -53,10 +41,6 @@ public class MRUBundleFileList implements EventDispatcher<Object, Object, Bundle // used to work around bug 275166 private boolean firstDispatch = true; - public MRUBundleFileList() { - this(PROP_FILE_LIMIT_VALUE); - } - public MRUBundleFileList(int fileLimit) { // only enable the MRU if the initFileLimit is > MIN this.fileLimit = fileLimit; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/Handler.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/Handler.java index 8535953da..19d6ad890 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/Handler.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/Handler.java @@ -28,11 +28,23 @@ import java.net.*; */ public class Handler extends URLStreamHandler { + private final String installPath; + + public Handler(String installURL) { + super(); + if (installURL != null && installURL.startsWith("file:")) { //$NON-NLS-1$ + // this is the safest way to create a File object off a file: URL + this.installPath = installURL.substring(5); + } else { + this.installPath = null; + } + } + /** * @throws IOException */ protected URLConnection openConnection(URL url) throws IOException { - return new ReferenceURLConnection(url); + return new ReferenceURLConnection(url, installPath); } protected void parseURL(URL url, String str, int start, int end) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java index 374f42d47..a5fdd2168 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/url/reference/ReferenceURLConnection.java @@ -11,22 +11,23 @@ package org.eclipse.osgi.storage.url.reference; -import org.eclipse.osgi.framework.util.FilePath; - import java.io.*; import java.net.URL; import java.net.URLConnection; -import org.eclipse.osgi.framework.internal.core.FrameworkProperties; +import org.eclipse.osgi.framework.util.FilePath; +import org.eclipse.osgi.internal.framework.EquinoxConfiguration; /** * URLConnection for the reference protocol. */ public class ReferenceURLConnection extends URLConnection { - protected URL reference; + private final String installPath; + private URL reference; - protected ReferenceURLConnection(URL url) { + protected ReferenceURLConnection(URL url, String installPath) { super(url); + this.installPath = installPath; } @SuppressWarnings("deprecation") @@ -40,7 +41,6 @@ public class ReferenceURLConnection extends URLConnection { URL ref; if (!file.isAbsolute()) { - String installPath = getInstallPath(); if (installPath != null) file = makeAbsolute(installPath, file); } @@ -48,7 +48,7 @@ public class ReferenceURLConnection extends URLConnection { // Pre-check if file exists, if not, and it contains escape characters, // try decoding the absolute path generated by makeAbsolute if (!file.exists() && path.indexOf('%') >= 0) { - String decodePath = FrameworkProperties.decode(file.getAbsolutePath()); + String decodePath = EquinoxConfiguration.decode(file.getAbsolutePath()); File f = new File(decodePath); if (f.exists()) file = f; @@ -103,16 +103,6 @@ public class ReferenceURLConnection extends URLConnection { return new ReferenceInputStream(reference); } - private String getInstallPath() { - String installURL = FrameworkProperties.getProperty("osgi.install.area"); //$NON-NLS-1$ - if (installURL == null) - return null; - if (!installURL.startsWith("file:")) //$NON-NLS-1$ - return null; - // this is the safest way to create a File object off a file: URL - return installURL.substring(5); - } - private static File makeAbsolute(String base, File relative) { if (relative.isAbsolute()) return relative; |