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

Activator.java 文件源码 项目:osgi-jpms-layer 阅读 41 收藏 0 点赞 0 评论 0
@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);
}
Activator.java 文件源码 项目:aries-jpa 阅读 45 收藏 0 点赞 0 评论 0
/**
 * 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);
}
PlatformActivator.java 文件源码 项目:motech 阅读 32 收藏 0 点赞 0 评论 0
private void registerOSGiHooks() {
    bundleContext.registerService(WeavingHook.class, new ValidationWeavingHook(), new Hashtable<>());
}
Activator.java 文件源码 项目:osgi.ee 阅读 25 收藏 0 点赞 0 评论 0
@Override
public void start(BundleContext context) {
    LoadingHook hook = new LoadingHook(context);
    context.registerService(WeavingHook.class, hook, null);
}
JPAManager.java 文件源码 项目:bundles 阅读 37 收藏 0 点赞 0 评论 0
@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();
}


问题


面经


文章

微信
公众号

扫码关注公众号