Java 类org.osgi.framework.hooks.weaving.WeavingHook 实例源码

项目:osgi-jpms-layer    文件:Activator.java   
@Override
public void start(BundleContext context) {
    logErrors = Boolean.parseBoolean(context.getProperty("osgi.jpms.layer.log.errors"));
    // Check that the launcher created a layer for the framework
    Module systemModule = context.getClass().getModule();
    if (!Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(systemModule.getName())) {
        throw new IllegalStateException("The framework launcher has not setup the system.bundle module for the framework implementation: " + getClass().getModule());
    }
    logService = new ServiceTracker<>(context, LOG_SERVICE, null);
    logService.open();
    // Create the LayerFactory implementation and register it
    factory = new LayerFactoryImpl(this, context, systemModule);
    // The factory is a bundle listener to keep track of resolved bundles
    context.addBundleListener(factory);
    // The factory is also a WovenClassListener to intercept bundle class loaders before
    // they define any classes.  This is to ensure they are part of a layer before the
    // first class is defined.
    String[] serviceClasses = new String[] {LayerFactory.class.getName(), WovenClassListener.class.getName(), WeavingHook.class.getName()};
    factoryReg = context.registerService(serviceClasses, factory, null);
}
项目:aries-jpa    文件:Activator.java   
/**
 * ARIES-1019: Register with the highest possible service ranking to
 * avoid ClassNotFoundException caused by interfaces added by earlier
 * weaving hooks that are not yet visible to the bundle class loader.
 */
private void registerWeavingHook(BundleContext context, TransformerRegistry tr) {
    Dictionary<String, Object> props = new Hashtable<String, Object>(1); // NOSONAR
    props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
    context.registerService(WeavingHook.class.getName(), tr, props);
}
项目:motech    文件:PlatformActivator.java   
private void registerOSGiHooks() {
    bundleContext.registerService(WeavingHook.class, new ValidationWeavingHook(), new Hashtable<>());
}
项目:osgi.ee    文件:Activator.java   
@Override
public void start(BundleContext context) {
    LoadingHook hook = new LoadingHook(context);
    context.registerService(WeavingHook.class, hook, null);
}
项目:bundles    文件:JPAManager.java   
@Activate
void activate(BundleContext context, Map<String, Object> props) throws Exception {
    this.context = context;
    config = Converter.cnv(Config.class, props);

    //
    // The Transformers hook enables weaving in OSGi
    // Every persistence unit will register itself with
    // the transformers hook. Order is important, once
    // the bundle tracker is called, the transformers
    // will be registered so do not move this method lower.
    //

    transformersHook = new TransformersHook(getImports(persistenceProvider));
    context.registerService(WeavingHook.class, transformersHook, null);

    //
    // Track bundles with persistence units.
    //

    bundles = new BundleTracker<PersistentBundle>(context, Bundle.ACTIVE + Bundle.STARTING, null) {

        @Override
        public PersistentBundle addingBundle(Bundle bundle, BundleEvent event) {
            try {
                //
                // Parse any persistence units, returns null (not tracked)
                // when there is no PU
                //
                return parse(bundle);
            }
            catch (Exception e) {
                e.printStackTrace();
                log.bundleParseException(bundle, e);
                return null;
            }
        }

        @Override
        public void removedBundle(Bundle bundle, BundleEvent event, PersistentBundle put) {
            put.close();
        }
    };

    bundles.open();
}