当前位置: 首页>>代码示例>>Java>>正文


Java BundleActivator类代码示例

本文整理汇总了Java中org.osgi.framework.BundleActivator的典型用法代码示例。如果您正苦于以下问题:Java BundleActivator类的具体用法?Java BundleActivator怎么用?Java BundleActivator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BundleActivator类属于org.osgi.framework包,在下文中一共展示了BundleActivator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadActivators

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
private Set<BundleActivator> loadActivators() {
	String serviceFile =
		_SERVICES + "/" + BundleActivator.class.getCanonicalName();

	Set<BundleActivator> activators = new LinkedHashSet<>();

	ClassLoader classLoader = getClass().getClassLoader();

	try {
		Enumeration<URL> enumeration = classLoader.getResources(
			serviceFile);

		while (enumeration.hasMoreElements()) {
			addBundleActivatorToActivatorsListFromURL(
				activators, enumeration.nextElement());
		}
	}
	catch (Exception e) {
		throw new RuntimeException("Could not load bundle activators", e);
	}

	return activators;
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:24,代码来源:ArquillianBundleActivator.java

示例2: bundleB

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
@Deployment(name = BUNDLE_B, testable = false, managed = false)
public static Archive<?> bundleB() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, BUNDLE_B);
    archive.addClasses(SimpleBundleActivator.class);
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleVersion("1.0.0");
            builder.addImportPackages(BundleActivator.class);
            builder.addBundleActivator(SimpleBundleActivator.class);
            return builder.openStream();
        }
    });
    return archive;
}
 
开发者ID:tdiesler,项目名称:gravia,代码行数:19,代码来源:BundleIntegrationTest.java

示例3: prepareFramework

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
private void prepareFramework() {
    fileInstall = new FileInstall();
    propertiesDictionary = new Hashtable<String, String>();
    StartupProperties startupProperties = CommunoteRuntime.getInstance()
            .getConfigurationManager().getStartupProperties();
    propertiesDictionary.put(DirectoryWatcher.DIR, startupProperties.getPluginDir()
            .getAbsolutePath());
    propertiesDictionary.put(DirectoryWatcher.NO_INITIAL_DELAY, Boolean.TRUE.toString());
    propertiesDictionary.put(DirectoryWatcher.START_NEW_BUNDLES, Boolean.TRUE.toString());
    propertiesDictionary.put(DirectoryWatcher.LOG_LEVEL, Integer.toString(4));
    Properties frameworkProperties = loadFrameworkProperties();
    List<BundleActivator> activatorList = new ArrayList<BundleActivator>();
    activatorList.add(fileInstall);
    frameworkProperties.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, activatorList);
    // TODO better add a setSystemBundlesLocation method
    String pathToWebInf = CommunoteRuntime.getInstance().getApplicationInformation()
            .getApplicationRealPath()
            + "WEB-INF" + File.separator;
    initSystemBundles(frameworkProperties, pathToWebInf + "plugins");
    frameworkProperties.put(Constants.FRAMEWORK_STORAGE, OSGiHelper.getBundleBasePath()
            .getAbsolutePath() + File.separator + "bundle-cache");
    try {
        framework = new Felix(frameworkProperties);
        framework.init();
        AutoProcessor.process(frameworkProperties, framework.getBundleContext());
        framework.getBundleContext().addBundleListener(this);
    } catch (BundleException e) {
        throw new BeanCreationException(
                "Starting OSGi framework failed because of a BundleException.", e);
    }
    LOG.info("OSGi Framework initialized.");
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:33,代码来源:OSGiManagement.java

示例4: testStartupExtension

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
@Test
public void testStartupExtension() {
  Extension extension = getEarlyStartup();

  IStartup startup = extension.createExecutableExtension( "class", IStartup.class );
  assertThat( startup ).isInstanceOf( DynamicWorkingSetStartup.class );
  assertThat( startup ).isNotInstanceOf( BundleActivator.class );
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:9,代码来源:DynamicWorkingSetStartupPDETest.java

示例5: testStartupExtension

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
@Test
public void testStartupExtension() {
  Extension extension = getEarlyStartup();

  IStartup startup = extension.createExecutableExtension( "class", IStartup.class );
  assertThat( startup ).isInstanceOf( LaunchExtrasStartup.class );
  assertThat( startup ).isNotInstanceOf( BundleActivator.class );
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:9,代码来源:LaunchExtrasStartupPDETest.java

示例6: startBundle

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
public synchronized void startBundle() throws BundleException {
    if (this.state == 1) {
        throw new IllegalStateException("Cannot start uninstalled bundle " + toString());
    } else if (this.state != 32) {
        if (this.state == 2) {
            resolveBundle(true);
        }
        this.state = 8;
        try {
            this.context.isValid = true;
            if (!(this.classloader.activatorClassName == null || StringUtils.isBlank(this.classloader.activatorClassName))) {
                Class loadClass = this.classloader.loadClass(this.classloader.activatorClassName);
                if (loadClass == null) {
                    throw new ClassNotFoundException(this.classloader.activatorClassName);
                }
                this.classloader.activator = (BundleActivator) loadClass.newInstance();
                this.classloader.activator.start(this.context);
            }
            this.state = 32;
            Framework.notifyBundleListeners(2, this);
            if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) {
                log.info("Framework: Bundle " + toString() + " started.");
            }
        } catch (Throwable th) {
            Throwable th2 = th;
            Framework.clearBundleTrace(this);
            this.state = 4;
            String str = "Error starting bundle " + toString();
            if (th2.getCause() != null) {
                th2 = th2.getCause();
            }
            BundleException bundleException = new BundleException(str, th2);
        }
    }
}
 
开发者ID:achellies,项目名称:AtlasForAndroid,代码行数:36,代码来源:BundleImpl.java

示例7: HostApplication

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
public HostApplication() throws IOException {
    // Create a configuration property map.
    Map<String, Object> config = new HashMap<String, Object>();
    // Create host activator;
    m_activator = new HostActivator();
    List<BundleActivator> list = new ArrayList<BundleActivator>();
    list.add(m_activator);
    config.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
    config.put(FelixConstants.FRAMEWORK_STORAGE, "target/felix");
    config.put(FelixConstants.LOG_LEVEL_PROP, "5");

    cleanUp("target/felix");

    try
    {
        // Now create an instance of the framework with
        // our configuration properties.
        m_felix = new Felix(config);
        // Now start Felix instance.
        m_felix.start();
    }
    catch (Exception ex)
    {
        System.err.println("Could not create framework: " + ex);
        ex.printStackTrace();
    }
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:28,代码来源:HostApplication.java

示例8: start

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
@Override
public void start(final BundleContext context) throws Exception {
	final TestClassLoader testClassLoader = new TestClassLoader() {

		@Override
		public Class<?> loadTestClass(String className)
			throws ClassNotFoundException {

			return context.getBundle().loadClass(className);
		}
	};

	// Execute all activators

	bundleActivators = loadActivators();

	for (BundleActivator bundleActivator : bundleActivators) {
		bundleActivator.start(context);
	}

	// Register the JMXTestRunner

	MBeanServer mbeanServer = findOrCreateMBeanServer();

	testRunner = new JMXTestRunner(testClassLoader) {
		@Override
		public byte[] runTestMethod(String className, String methodName) {
			BundleAssociation.setBundle(context.getBundle());
			BundleContextAssociation.setBundleContext(context);

			return super.runTestMethod(className, methodName);
		}
	};
	testRunner.registerMBean(mbeanServer);
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:36,代码来源:ArquillianBundleActivator.java

示例9: stop

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
@Override
public void stop(BundleContext context) throws Exception {

	// Execute all activators

	for (BundleActivator bundleActivator : bundleActivators) {
		bundleActivator.stop(context);
	}

	// Unregister the JMXTestRunner

	MBeanServer mbeanServer = findOrCreateMBeanServer();
	testRunner.unregisterMBean(mbeanServer);
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:15,代码来源:ArquillianBundleActivator.java

示例10: addBundleActivatorToActivatorsListFromStringLine

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
private void addBundleActivatorToActivatorsListFromStringLine(
	Set<BundleActivator> activators, String line) {

	ClassLoader classLoader = getClass().getClassLoader();

	if (line.startsWith("!")) {
		return;
	}

	try {
		Class<?> aClass = classLoader.loadClass(line);

		Class<? extends BundleActivator> bundleActivatorClass =
			aClass.asSubclass(BundleActivator.class);

		activators.add(bundleActivatorClass.newInstance());
	}
	catch (ClassNotFoundException cnfe) {
		throw new IllegalStateException(
			"Activator " + line + " class not found", cnfe);
	}
	catch (ClassCastException cce) {
		throw new IllegalStateException(
			"Activator " + line + " does not implement expected type " +
				BundleActivator.class.getCanonicalName(),
			cce);
	}
	catch (Exception e) {
		throw new IllegalStateException(
			"Activator " + line + " can't be created ", e);
	}
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:33,代码来源:ArquillianBundleActivator.java

示例11: addBundleActivatorToActivatorsListFromURL

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
private void addBundleActivatorToActivatorsListFromURL(
		Set<BundleActivator> activators, URL url)
	throws IOException {

	final InputStream is = url.openStream();

	BufferedReader reader = null;

	try {
		reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));

		String line = reader.readLine();

		while (null != line) {
			line = skipCommentAndTrim(line);

			addBundleActivatorToActivatorsListFromStringLine(
				activators, line);

			line = reader.readLine();
		}
	}
	finally {
		if (reader != null) {
			reader.close();
		}
	}
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:29,代码来源:ArquillianBundleActivator.java

示例12: ChainActivator

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
public ChainActivator() {
       final LoggingActivator logStatus = new LoggingActivator();
       final JavaBeansCacheActivator activateJavaBeansCache = new JavaBeansCacheActivator();
       final NamespaceHandlerActivator activateCustomNamespaceHandling = new NamespaceHandlerActivator();
       final NamespaceHandlerActivator activateBlueprintspecificNamespaceHandling = new BlueprintNamespaceHandlerActivator();
       final ExtenderConfiguration initializeExtenderConfiguration = new ExtenderConfiguration();
       final ListenerServiceActivator activateListeners = new ListenerServiceActivator(initializeExtenderConfiguration);
       final ContextLoaderListener listenForSpringDmBundles = new ContextLoaderListener(initializeExtenderConfiguration);
       final BlueprintLoaderListener listenForBlueprintBundles = new BlueprintLoaderListener(initializeExtenderConfiguration, activateListeners);

       if (OsgiPlatformDetector.isR42()) {
		if (BLUEPRINT_AVAILABLE) {
			log.info("Blueprint API detected; enabling Blueprint Container functionality");
			CHAIN = new BundleActivator[] {
                       logStatus,
                       activateJavaBeansCache,
                       activateCustomNamespaceHandling,
                       activateBlueprintspecificNamespaceHandling,
                       initializeExtenderConfiguration,
                       activateListeners,
                       listenForSpringDmBundles,
                       listenForBlueprintBundles
               };
		}
		else {
			log.warn("Blueprint API not found; disabling Blueprint Container functionality");
			CHAIN = new BundleActivator[] {
                       logStatus,
                       activateJavaBeansCache,
                       activateCustomNamespaceHandling,
                       initializeExtenderConfiguration,
                       activateListeners,
                       listenForSpringDmBundles
               };
		}
	} else {
		log.warn("Pre-4.2 OSGi platform detected; disabling Blueprint Container functionality");
           CHAIN = new BundleActivator[] {
                   logStatus,
                   activateJavaBeansCache,
                   activateCustomNamespaceHandling,
                   initializeExtenderConfiguration,
                   activateListeners,
                   listenForSpringDmBundles
           };
       }
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:48,代码来源:ChainActivator.java

示例13: createActivator

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
@Override
public BundleActivator createActivator() {
	return this;
}
 
开发者ID:tjwatson,项目名称:osgi-jpms-layer,代码行数:5,代码来源:EquinoxJPMSSupport.java

示例14: configHostActivator

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
protected void configHostActivator(Map<String, Object> config) {
    List<BundleActivator> activators = new ArrayList<BundleActivator>();
    activators.add(this.hostActivator);
    config.put(SYSTEMBUNDLE_ACTIVATORS_PROP, activators);
}
 
开发者ID:Indoqa,项目名称:osgi-embedded,代码行数:6,代码来源:EmbeddedOSGiContainer.java

示例15: createHostActivator

import org.osgi.framework.BundleActivator; //导入依赖的package包/类
private BundleActivator createHostActivator() {
    this.hostActivator = new HostActivator(
        this.containerConfiguration.areRemoteShellBundlesEnabled(), this.containerConfiguration.isSlf4jBridgeActivated());
    return this.hostActivator;
}
 
开发者ID:Indoqa,项目名称:osgi-embedded,代码行数:6,代码来源:EmbeddedOSGiContainer.java


注:本文中的org.osgi.framework.BundleActivator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。