微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。