junit.framework.TestListener#org.osgi.util.tracker.BundleTracker源码实例Demo

下面列出了junit.framework.TestListener#org.osgi.util.tracker.BundleTracker 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public void start () throws ServletException, NamespaceException
{
    final BundleContext bundleContext = FrameworkUtil.getBundle ( DispatcherServletInitializer.class ).getBundleContext ();
    this.context = Dispatcher.createContext ( bundleContext );

    this.errorHandler = new ErrorHandlerTracker ();

    Dictionary<String, String> initparams = new Hashtable<> ();

    final MultipartConfigElement multipart = Servlets.createMultiPartConfiguration ( PROP_PREFIX_MP );
    final DispatcherServlet servlet = new DispatcherServlet ();
    servlet.setErrorHandler ( this.errorHandler );
    this.webContainer.registerServlet ( servlet, "dispatcher", new String[] { "/" }, initparams, 1, false, multipart, this.context );

    this.proxyFilter = new FilterTracker ( bundleContext );
    this.webContainer.registerFilter ( this.proxyFilter, new String[] { "/*" }, null, null, this.context );

    initparams = new Hashtable<> ();
    initparams.put ( "filter-mapping-dispatcher", "request" );
    this.webContainer.registerFilter ( new BundleFilter (), new String[] { "/bundle/*" }, null, initparams, this.context );

    this.jspTracker = new BundleTracker<> ( bundleContext, Bundle.INSTALLED | Bundle.ACTIVE, new JspBundleCustomizer ( this.webContainer, this.context ) );
    this.jspTracker.open ();
}
 
源代码2 项目: smarthome   文件: XmlDocumentBundleTracker.java
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public final synchronized void open() {
    final OpenState openState = withLock(lockOpenState.writeLock(), () -> {
        if (this.openState == OpenState.CREATED) {
            this.openState = OpenState.OPENED;
        }
        return this.openState;
    });
    if (openState != OpenState.OPENED) {
        logger.warn("Open XML document bundle tracker forbidden (state: {})", openState);
        return;
    }

    relevantBundlesTracker = new BundleTracker(context,
            Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE, null) {
        @Override
        public Object addingBundle(Bundle bundle, BundleEvent event) {
            return withLock(lockOpenState.readLock(),
                    () -> openState == OpenState.OPENED && isBundleRelevant(bundle) ? bundle : null);
        }
    };
    relevantBundlesTracker.open();

    super.open();
}
 
public ModelPackageBundleListener(BundleContext bundleContext,
                                  ModelAdapterFactory factory,
                                  AdapterImplementations adapterImplementations,
                                  BindingsValuesProvidersByContext bindingsValuesProvidersByContext,
                                  SlingModelsScriptEngineFactory scriptEngineFactory) {
    this.bundleContext = bundleContext;
    this.factory = factory;
    this.adapterImplementations = adapterImplementations;
    this.bindingsValuesProvidersByContext = bindingsValuesProvidersByContext;
    this.scriptEngineFactory = scriptEngineFactory;
    this.bundleTracker = new BundleTracker<>(bundleContext, Bundle.ACTIVE, this);
    this.bundleTracker.open();
}
 
源代码4 项目: openhab-core   文件: XmlDocumentBundleTracker.java
private Set<Bundle> getRelevantBundles() {
    BundleTracker<?> bundleTracker = relevantBundlesTracker;
    if (bundleTracker == null || bundleTracker.getBundles() == null) {
        return Collections.emptySet();
    }
    return (Set<Bundle>) Arrays.stream(bundleTracker.getBundles()).collect(Collectors.toSet());
}
 
源代码5 项目: openhab-core   文件: XmlDocumentBundleTracker.java
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public final synchronized void open() {
    final OpenState openState = withLock(lockOpenState.writeLock(), () -> {
        if (this.openState == OpenState.CREATED) {
            this.openState = OpenState.OPENED;
        }
        return this.openState;
    });
    if (openState != OpenState.OPENED) {
        logger.warn("Open XML document bundle tracker forbidden (state: {})", openState);
        return;
    }

    relevantBundlesTracker = new BundleTracker(context,
            Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE, null) {
        @Override
        public @Nullable Object addingBundle(@NonNullByDefault({}) Bundle bundle,
                @NonNullByDefault({}) BundleEvent event) {
            return withLock(lockOpenState.readLock(),
                    () -> openState == OpenState.OPENED && isBundleRelevant(bundle) ? bundle : null);
        }
    };
    relevantBundlesTracker.open();

    super.open();
}
 
源代码6 项目: packagedrone   文件: TagLibTracker.java
public TagLibTracker ( final BundleContext context, String mappedPrefix )
{
    this.systemTlds.add ( "org.apache.taglibs.standard-impl" );

    if ( mappedPrefix == null )
    {
        mappedPrefix = "/WEB-INF/";
    }
    this.mappedPrefix = mappedPrefix;

    this.bundleTracker = new BundleTracker<> ( context, Bundle.RESOLVED | Bundle.ACTIVE, this.customizer );
    this.bundleTracker.open ();
}
 
源代码7 项目: packagedrone   文件: OsgiMessageInterpolator.java
public OsgiMessageInterpolator ( final BundleContext context )
{
    this.tracker = new BundleTracker<> ( context, Bundle.ACTIVE | Bundle.RESOLVED, new BundleTrackerCustomizer<Resolver> () {

        @Override
        public Resolver addingBundle ( final Bundle bundle, final BundleEvent event )
        {
            if ( bundle.getResource ( "META-INF/ValidationMessages.properties" ) != null )
            {
                return new Resolver ( bundle );
            }
            return null;
        }

        @Override
        public void modifiedBundle ( final Bundle bundle, final BundleEvent event, final Resolver resolver )
        {
        }

        @Override
        public void removedBundle ( final Bundle bundle, final BundleEvent event, final Resolver resolver )
        {
            resolver.dispose ();
        }
    } );
    this.tracker.open ();
}
 
源代码8 项目: tomee   文件: ServiceManagerExtender.java
@Override
public void init() throws Exception {
    if (started != null && started.equals(Boolean.TRUE)) {
        throw new IllegalStateException("ServiceManager is already initialized");
    }
    final DiscoveryRegistry registry = new DiscoveryRegistry();
    SystemInstance.get().setComponent(DiscoveryRegistry.class, registry);

    started = Boolean.FALSE;
    stopped = false;
    final ServerServiceTracker t = new ServerServiceTracker();
    tracker = new BundleTracker(bundleContext, Bundle.ACTIVE | Bundle.STOPPING, t);
    tracker.open();
}
 
源代码9 项目: wisdom   文件: WebJarController.java
/**
 * Creates the controller serving resources embedded in WebJars.
 *
 * @param context the bundle context
 * @param path    the path (relative to the configuration's base dir) in which exploded webjars are
 */
public WebJarController(@Context BundleContext context, @Property(value = "assets/libs",
        name = "path") String path) {
    directory = new File(configuration.getBaseDir(), path); //NOSONAR Injected field
    tracker = new BundleTracker<>(context, Bundle.ACTIVE, this);
    deployer = new WebJarDeployer(context, this);
}
 
源代码10 项目: activiti6-boot2   文件: Extender.java
public Extender(BundleContext context) {
  Extender.context = context;
  this.engineServiceTracker = new ServiceTracker(context, ProcessEngine.class.getName(), this);
  this.bundleTracker = new BundleTracker(context, Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE, this);
}
 
源代码11 项目: flowable-engine   文件: Extender.java
public Extender(BundleContext context) {
    Extender.context = context;
    this.engineServiceTracker = new ServiceTracker(context, ProcessEngine.class.getName(), this);
    this.bundleTracker = new BundleTracker(context, Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE, this);
}
 
@Activate
protected void activate(BundleContext bc) {
    bTracker = new BundleTracker<>(bc, ~Bundle.UNINSTALLED, this);
    bTracker.open();
}
 
源代码13 项目: packagedrone   文件: TagDirTracker.java
public TagDirTracker ( final BundleContext context )
{
    this.bundleTracker = new BundleTracker<> ( context, Bundle.RESOLVED | Bundle.ACTIVE, this.customizer );
    this.bundleTracker.open ();
}
 
源代码14 项目: packagedrone   文件: ResourceTracker.java
public ResourceTracker ( final BundleContext context )
{
    this.tracker = new BundleTracker<> ( context, Bundle.ACTIVE | Bundle.INSTALLED, this.customizer );
    this.tracker.open ();
}
 
@Activate
protected void activate(BundleContext bc) {
    bTracker = new BundleTracker<Bundle>(bc, ~Bundle.UNINSTALLED, this);
    bTracker.open();
}
 
源代码16 项目: wisdom   文件: BrowserWatchController.java
@Validate
public void listenServices() {
	tracker = new BundleTracker<BundleInfos>(context, Bundle.ACTIVE, this);
	tracker.open();
	context.addServiceListener(this);
}
 
源代码17 项目: wisdom   文件: TemplateTracker.java
@Validate
public void start() {
    LOGGER.debug("Starting Thymeleaf template tracker");
    tracker = new BundleTracker<>(context, Bundle.ACTIVE, this);
    tracker.open();
}
 
@Validate
public void start() {
    tracker = new BundleTracker<>(context, Bundle.ACTIVE, this);
    tracker.open();
}