public void addHooks(HookRegistry hookRegistry) { container = hookRegistry.getContainer(); hookRegistry.addActivatorHookFactory(this); String[] support = ManifestElement.getArrayFromList(hookRegistry.getConfiguration().getConfiguration(SIGNED_CONTENT_SUPPORT, hookRegistry.getConfiguration().getConfiguration(SIGNED_BUNDLE_SUPPORT)), ","); //$NON-NLS-1$ for (int i = 0; i < support.length; i++) { if (SUPPORT_CERTIFICATE.equals(support[i])) supportSignedBundles |= VERIFY_CERTIFICATE; else if (SUPPORT_TRUST.equals(support[i])) supportSignedBundles |= VERIFY_CERTIFICATE | VERIFY_TRUST; else if (SUPPORT_RUNTIME.equals(support[i])) supportSignedBundles |= VERIFY_CERTIFICATE | VERIFY_RUNTIME; else if (SUPPORT_TRUE.equals(support[i]) || SUPPORT_ALL.equals(support[i])) supportSignedBundles |= VERIFY_ALL; } trustEngineNameProp = hookRegistry.getConfiguration().getConfiguration(SignedContentConstants.TRUST_ENGINE); if ((supportSignedBundles & VERIFY_CERTIFICATE) != 0) { hookRegistry.addStorageHookFactory(new SignedStorageHook()); hookRegistry.addBundleFileWrapperFactoryHook(this); } }
/** * Adds a storage hook to this hook registry. * @param storageHookFactory a storage hook object. */ public void addStorageHookFactory(StorageHookFactory<?, ?, ?> storageHookFactory) { add(storageHookFactory, storageHookFactories); }
void registerHooks(HookRegistry hookRegistry) { // only register if sharing is enabled if (!Shared.isSharingEnabled()) { return; } hookRegistry.addClassLoaderHook(this); hookRegistry.addBundleFileWrapperFactoryHook(this); } }
/** * Initializes the hook configurators. The following steps are used to initialize the hook configurators. <p> * 1. Get a list of hook configurators from all hook configurators properties files on the classpath, * add this list to the overall list of hook configurators, remove duplicates. <p> * 2. Get a list of hook configurators from the ("osgi.hook.configurators.include") system property * and add this list to the overall list of hook configurators, remove duplicates. <p> * 3. Get a list of hook configurators from the ("osgi.hook.configurators.exclude") system property * and remove this list from the overall list of hook configurators. <p> * 4. Load each hook configurator class, create a new instance, then call the {@link HookConfigurator#addHooks(HookRegistry)} method <p> * 5. Set this HookRegistry object to read only to prevent any other hooks from being added. <p> */ public void initialize() { List<String> configurators = new ArrayList<String>(5); List<FrameworkLogEntry> errors = new ArrayList<FrameworkLogEntry>(0); // optimistic that no errors will occur mergeFileHookConfigurators(configurators, errors); mergePropertyHookConfigurators(configurators); synchronized (this) { addClassLoaderHook(new DevClassLoadingHook(container.getConfiguration())); addClassLoaderHook(new EclipseLazyStarter(container)); addClassLoaderHook(new WeavingHookConfigurator(container)); configurators.add(SignedBundleHook.class.getName()); loadConfigurators(configurators, errors); // set to read-only initialized = true; } for (FrameworkLogEntry error : errors) { container.getLogServices().getFrameworkLog().log(error); } }
private static ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration) { // allow hooks to determine the parent class loader for (ClassLoaderHook hook : configuration.getHookRegistry().getClassLoaderHooks()) { ClassLoader parent = hook.getModuleClassLoaderParent(configuration); if (parent != null) { // first one to return non-null wins. return parent; } } // DEFAULT behavior: // check property for specified parent // check the osgi defined property first String type = configuration.getConfiguration(Constants.FRAMEWORK_BUNDLE_PARENT); if (type == null) { type = configuration.getConfiguration(EquinoxConfiguration.PROP_PARENT_CLASSLOADER, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT); } if (Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK.equalsIgnoreCase(type) || EquinoxConfiguration.PARENT_CLASSLOADER_FWK.equalsIgnoreCase(type)) { ClassLoader cl = EquinoxContainer.class.getClassLoader(); return cl == null ? BOOT_CLASSLOADER : cl; } if (Constants.FRAMEWORK_BUNDLE_PARENT_APP.equalsIgnoreCase(type)) return ClassLoader.getSystemClassLoader(); if (Constants.FRAMEWORK_BUNDLE_PARENT_EXT.equalsIgnoreCase(type)) { ClassLoader appCL = ClassLoader.getSystemClassLoader(); if (appCL != null) return appCL.getParent(); } return BOOT_CLASSLOADER; }
public void startExtensionActivators(BundleContext context) { // First start the hook registry activators // TODO not sure we really need these anymore HookRegistry hookRegistry = configuration.getHookRegistry(); List<ActivatorHookFactory> activatorHookFactories = hookRegistry.getActivatorHookFactories(); for (ActivatorHookFactory activatorFactory : activatorHookFactories) { BundleActivator activator = activatorFactory.createActivator(); try { startActivator(activator, context, null); } catch (Exception e) { configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, null, e); } } // start the extension bundle activators. In Equinox we let // framework extensions define Bundle-Activator headers. ModuleWiring systemWiring = (ModuleWiring) context.getBundle().adapt(BundleWiring.class); if (systemWiring != null) { List<ModuleWire> extensionWires = systemWiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE); for (ModuleWire extensionWire : extensionWires) { ModuleRevision extensionRevision = extensionWire.getRequirer(); startExtensionActivator(extensionRevision, context); } } }
public EquinoxContainer(Map<String, ?> configuration) { this.equinoxConfig = new EquinoxConfiguration(configuration, new HookRegistry(this)); this.logServices = new EquinoxLogServices(this.equinoxConfig); this.equinoxConfig.logMessages(this.logServices); this.equinoxConfig.getHookRegistry().initialize(); try { this.storage = Storage.createStorage(this); for (ClassLoaderHook hook : equinoxConfig.getHookRegistry().getClassLoaderHooks()) { supportRecursion &= hook.isProcessClassRecursionSupported();
public EquinoxContainer(Map<String, ?> configuration) { this.equinoxConfig = new EquinoxConfiguration(configuration, new HookRegistry(this)); this.logServices = new EquinoxLogServices(this.equinoxConfig); this.equinoxConfig.getHookRegistry().initialize(); try { this.storage = Storage.createStorage(this);
public BundleFile wrapBundleFile(BundleFile bundleFile, Generation generation, boolean isBase) { // try creating a wrapper bundlefile out of it. List<BundleFileWrapperFactoryHook> wrapperFactories = getConfiguration().getHookRegistry().getBundleFileWrapperFactoryHooks(); BundleFileWrapperChain wrapped = wrapperFactories.isEmpty() ? null : new BundleFileWrapperChain(bundleFile, null); for (BundleFileWrapperFactoryHook wrapperFactory : wrapperFactories) { BundleFileWrapper wrapperBundle = wrapperFactory.wrapBundleFile(bundleFile, generation, isBase); if (wrapperBundle != null && wrapperBundle != bundleFile) bundleFile = wrapped = new BundleFileWrapperChain(wrapperBundle, wrapped); } return bundleFile; }
public void addHooks(HookRegistry hookRegistry) { boolean disableCDS = Boolean.valueOf(hookRegistry.getConfiguration().getProperty(DISABLE_CDS)); if (disableCDS) { return; } // check for the external com.ibm.cds system.bundle fragment try { Class.forName(OLD_CDS_CONFIGURATOR); // the old com.ibm.cds fragment is installed; disable build-in one return; } catch (ClassNotFoundException e) { // expected } try { Class.forName(J9_SHARED_CLASS_HELPER_CLASS); } catch (ClassNotFoundException e) { boolean reportErrors = Boolean.valueOf(hookRegistry.getConfiguration().getProperty(REPORT_ERRORS)); // not running on J9 if (reportErrors) { EquinoxContainer container = hookRegistry.getContainer(); EquinoxLogServices logServices = container.getLogServices(); logServices.log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, "The J9 Class Sharing Adaptor will not work in this configuration. You are not running on a J9 Java VM.", null); //$NON-NLS-1$ } return; } new CDSHookImpls().registerHooks(hookRegistry); }
@Override public void addHooks(HookRegistry hookRegistry) { hookRegistry.addActivatorHookFactory(this); }
/** * Initializes the hook configurators. The following steps are used to initialize the hook configurators. <p> * 1. Get a list of hook configurators from all hook configurators properties files on the classpath, * add this list to the overall list of hook configurators, remove duplicates. <p> * 2. Get a list of hook configurators from the ("osgi.hook.configurators.include") system property * and add this list to the overall list of hook configurators, remove duplicates. <p> * 3. Get a list of hook configurators from the ("osgi.hook.configurators.exclude") system property * and remove this list from the overall list of hook configurators. <p> * 4. Load each hook configurator class, create a new instance, then call the {@link HookConfigurator#addHooks(HookRegistry)} method <p> * 5. Set this HookRegistry object to read only to prevent any other hooks from being added. <p> */ public void initialize() { List<String> configurators = new ArrayList<String>(5); List<FrameworkLogEntry> errors = new ArrayList<FrameworkLogEntry>(0); // optimistic that no errors will occur mergeFileHookConfigurators(configurators, errors); mergePropertyHookConfigurators(configurators); synchronized (this) { addClassLoaderHook(new DevClassLoadingHook(container.getConfiguration())); addClassLoaderHook(new EclipseLazyStarter(container)); addClassLoaderHook(new WeavingHookConfigurator(container)); configurators.add(SignedBundleHook.class.getName()); loadConfigurators(configurators, errors); // set to read-only initialized = true; } for (FrameworkLogEntry error : errors) { container.getLogServices().getFrameworkLog().log(error); } }
private static ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration) { // allow hooks to determine the parent class loader for (ClassLoaderHook hook : configuration.getHookRegistry().getClassLoaderHooks()) { ClassLoader parent = hook.getModuleClassLoaderParent(configuration); if (parent != null) { // first one to return non-null wins. return parent; } } // DEFAULT behavior: // check property for specified parent // check the osgi defined property first String type = configuration.getConfiguration(Constants.FRAMEWORK_BUNDLE_PARENT); if (type == null) { type = configuration.getConfiguration(EquinoxConfiguration.PROP_PARENT_CLASSLOADER, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT); } if (Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK.equalsIgnoreCase(type) || EquinoxConfiguration.PARENT_CLASSLOADER_FWK.equalsIgnoreCase(type)) { ClassLoader cl = EquinoxContainer.class.getClassLoader(); return cl == null ? BOOT_CLASSLOADER : cl; } if (Constants.FRAMEWORK_BUNDLE_PARENT_APP.equalsIgnoreCase(type)) return ClassLoader.getSystemClassLoader(); if (Constants.FRAMEWORK_BUNDLE_PARENT_EXT.equalsIgnoreCase(type)) { ClassLoader appCL = ClassLoader.getSystemClassLoader(); if (appCL != null) return appCL.getParent(); } return BOOT_CLASSLOADER; }
public void startExtensionActivators(BundleContext context) { // First start the hook registry activators // TODO not sure we really need these anymore HookRegistry hookRegistry = configuration.getHookRegistry(); List<ActivatorHookFactory> activatorHookFactories = hookRegistry.getActivatorHookFactories(); for (ActivatorHookFactory activatorFactory : activatorHookFactories) { BundleActivator activator = activatorFactory.createActivator(); try { startActivator(activator, context, null); } catch (Exception e) { configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, null, e); } } // start the extension bundle activators. In Equinox we let // framework extensions define Bundle-Activator headers. ModuleWiring systemWiring = (ModuleWiring) context.getBundle().adapt(BundleWiring.class); if (systemWiring != null) { List<ModuleWire> extensionWires = systemWiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE); for (ModuleWire extensionWire : extensionWires) { ModuleRevision extensionRevision = extensionWire.getRequirer(); startExtensionActivator(extensionRevision, context); } } }
public EquinoxContainer(Map<String, ?> configuration) { this.equinoxConfig = new EquinoxConfiguration(configuration, new HookRegistry(this)); this.logServices = new EquinoxLogServices(this.equinoxConfig); this.equinoxConfig.logMessages(this.logServices); this.equinoxConfig.getHookRegistry().initialize(); try { this.storage = Storage.createStorage(this); for (ClassLoaderHook hook : equinoxConfig.getHookRegistry().getClassLoaderHooks()) { supportRecursion &= hook.isProcessClassRecursionSupported();
public EquinoxContainer(Map<String, ?> configuration) { this.equinoxConfig = new EquinoxConfiguration(configuration, new HookRegistry(this)); this.logServices = new EquinoxLogServices(this.equinoxConfig); this.equinoxConfig.getHookRegistry().initialize(); try { this.storage = Storage.createStorage(this);
public BundleFile wrapBundleFile(BundleFile bundleFile, Generation generation, boolean isBase) { // try creating a wrapper bundlefile out of it. List<BundleFileWrapperFactoryHook> wrapperFactories = getConfiguration().getHookRegistry().getBundleFileWrapperFactoryHooks(); BundleFileWrapperChain wrapped = wrapperFactories.isEmpty() ? null : new BundleFileWrapperChain(bundleFile, null); for (BundleFileWrapperFactoryHook wrapperFactory : wrapperFactories) { BundleFileWrapper wrapperBundle = wrapperFactory.wrapBundleFile(bundleFile, generation, isBase); if (wrapperBundle != null && wrapperBundle != bundleFile) bundleFile = wrapped = new BundleFileWrapperChain(wrapperBundle, wrapped); } return bundleFile; }
public void addHooks(HookRegistry hookRegistry) { container = hookRegistry.getContainer(); hookRegistry.addActivatorHookFactory(this); String[] support = ManifestElement.getArrayFromList(hookRegistry.getConfiguration().getConfiguration(SIGNED_CONTENT_SUPPORT, hookRegistry.getConfiguration().getConfiguration(SIGNED_BUNDLE_SUPPORT)), ","); //$NON-NLS-1$ for (int i = 0; i < support.length; i++) { if (SUPPORT_CERTIFICATE.equals(support[i])) supportSignedBundles |= VERIFY_CERTIFICATE; else if (SUPPORT_TRUST.equals(support[i])) supportSignedBundles |= VERIFY_CERTIFICATE | VERIFY_TRUST; else if (SUPPORT_RUNTIME.equals(support[i])) supportSignedBundles |= VERIFY_CERTIFICATE | VERIFY_RUNTIME; else if (SUPPORT_TRUE.equals(support[i]) || SUPPORT_ALL.equals(support[i])) supportSignedBundles |= VERIFY_ALL; } trustEngineNameProp = hookRegistry.getConfiguration().getConfiguration(SignedContentConstants.TRUST_ENGINE); if ((supportSignedBundles & VERIFY_CERTIFICATE) != 0) { hookRegistry.addStorageHookFactory(new SignedStorageHook()); hookRegistry.addBundleFileWrapperFactoryHook(this); } }
/** * Initializes the hook configurators. The following steps are used to initialize the hook configurators. <p> * 1. Get a list of hook configurators from all hook configurators properties files on the classpath, * add this list to the overall list of hook configurators, remove duplicates. <p> * 2. Get a list of hook configurators from the ("osgi.hook.configurators.include") system property * and add this list to the overall list of hook configurators, remove duplicates. <p> * 3. Get a list of hook configurators from the ("osgi.hook.configurators.exclude") system property * and remove this list from the overall list of hook configurators. <p> * 4. Load each hook configurator class, create a new instance, then call the {@link HookConfigurator#addHooks(HookRegistry)} method <p> * 5. Set this HookRegistry object to read only to prevent any other hooks from being added. <p> */ public void initialize() { List<String> configurators = new ArrayList<String>(5); List<FrameworkLogEntry> errors = new ArrayList<FrameworkLogEntry>(0); // optimistic that no errors will occur mergeFileHookConfigurators(configurators, errors); mergePropertyHookConfigurators(configurators); synchronized (this) { addClassLoaderHook(new DevClassLoadingHook(container.getConfiguration())); addClassLoaderHook(new EclipseLazyStarter(container)); addClassLoaderHook(new WeavingHookConfigurator(container)); configurators.add(SignedBundleHook.class.getName()); loadConfigurators(configurators, errors); // set to read-only initialized = true; } for (FrameworkLogEntry error : errors) { container.getLogServices().getFrameworkLog().log(error); } }
private static ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration) { // allow hooks to determine the parent class loader for (ClassLoaderHook hook : configuration.getHookRegistry().getClassLoaderHooks()) { ClassLoader parent = hook.getModuleClassLoaderParent(configuration); if (parent != null) { // first one to return non-null wins. return parent; } } // DEFAULT behavior: // check property for specified parent // check the osgi defined property first String type = configuration.getConfiguration(Constants.FRAMEWORK_BUNDLE_PARENT); if (type == null) { type = configuration.getConfiguration(EquinoxConfiguration.PROP_PARENT_CLASSLOADER, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT); } if (Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK.equalsIgnoreCase(type) || EquinoxConfiguration.PARENT_CLASSLOADER_FWK.equalsIgnoreCase(type)) { ClassLoader cl = EquinoxContainer.class.getClassLoader(); return cl == null ? BOOT_CLASSLOADER : cl; } if (Constants.FRAMEWORK_BUNDLE_PARENT_APP.equalsIgnoreCase(type)) return ClassLoader.getSystemClassLoader(); if (Constants.FRAMEWORK_BUNDLE_PARENT_EXT.equalsIgnoreCase(type)) { ClassLoader appCL = ClassLoader.getSystemClassLoader(); if (appCL != null) return appCL.getParent(); } return BOOT_CLASSLOADER; }