Package org.osgi.framework

Examples of org.osgi.framework.BundleActivator


        // CONCURRENCY NOTE:
        // This method is called indirectly from startBundle() (via _startBundle()),
        // which has the bundle lock, so there is no need to do any locking here.

        // Get the activator class from the header map.
        BundleActivator activator = null;
        Map headerMap = ((BundleRevisionImpl) impl.adapt(BundleRevision.class)).getHeaders();
        String className = (String) headerMap.get(Constants.BUNDLE_ACTIVATOR);
        // Try to instantiate activator class if present.
        if (className != null)
        {
View Full Code Here


        if (activatorClass != null)
        {
            try
            {
// TODO: SECURITY - Should this consider security?
                BundleActivator activator = (BundleActivator)
                    felix.getClass().getClassLoader().loadClass(
                        activatorClass.trim()).newInstance();

// TODO: EXTENSIONMANAGER - This is kind of hacky, can we improve it?
                felix.m_activatorList.add(activator);
View Full Code Here

            for (String s : getActivators()) {
                try {
                    Class<?> clazz = getClass().getClassLoader().loadClass(s);
                    Object o = clazz.newInstance();
                    if (o instanceof BundleActivator) {
                        BundleActivator ba = (BundleActivator) o;
                        activators.add(ba);
                        ba.start(ctx);
                    }
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
View Full Code Here

               
       
                felix = felixClass.newInstance();
                Method startMethod = felixClass.getMethod("start", propertyResolverClass, List.class);
                List<BundleActivator> activators = new ArrayList<BundleActivator>();
                BundleActivator activator = new FelixRuntime();
                activators.add(activator);
                startMethod.invoke(felix, mutableProps, activators);
       
                synchronized (activator) {
                    int retries = 0;
                    while (bundleContext == null && retries++ < 10) {
                        activator.wait(1000);
                    }
                }
            }
        }
       
View Full Code Here

            List<BundleActivator> activators = new ArrayList<BundleActivator>();

            try {
                Class<?> autoActivatorClass = cl.loadClass("org.apache.felix.main.AutoActivator");
                Constructor autoActivatorConstructor = autoActivatorClass.getConstructor(Map.class);
                BundleActivator autoActivator = (BundleActivator)autoActivatorConstructor.newInstance(props);
                activators.add(autoActivator);

            } catch (Throwable e) {
                // Pre-1.0.3 release of Felix did not require AutoActivator
            }
           

            felix = felixConstructor.newInstance(props, activators);
            ((Bundle)felix).start();
            bundleContext = ((Bundle)felix).getBundleContext();
           
           
        } catch (Exception e) {
           
            // This is the older Felix API which has been retained temporarily to avoid build break
            // TODO: Remove these once Felix 1.0.0 is released.
           
            Class<?> propertyResolverClass = cl.loadClass("org.apache.felix.framework.util.MutablePropertyResolver");
            Class<?> propertyResolverImplClass = cl.loadClass("org.apache.felix.framework.util.MutablePropertyResolverImpl");

            Constructor implConstructor = propertyResolverImplClass.getConstructor(Map.class);
            Object mutableProps = implConstructor.newInstance(props);
           
           
            try {
                Constructor felixConstructor = felixClass.getConstructor(propertyResolverClass, List.class);
                List<BundleActivator> activators = new ArrayList<BundleActivator>();
                felix = felixConstructor.newInstance(mutableProps, activators);
                ((Bundle)felix).start();
                bundleContext = ((Bundle)felix).getBundleContext();
            } catch (Exception e1) {
               
       
                felix = felixClass.newInstance();
                Method startMethod = felixClass.getMethod("start", propertyResolverClass, List.class);
                List<BundleActivator> activators = new ArrayList<BundleActivator>();
                BundleActivator activator = new FelixRuntime();
                activators.add(activator);
                startMethod.invoke(felix, mutableProps, activators);
       
                synchronized (activator) {
                    int retries = 0;
                    while (bundleContext == null && retries++ < 10) {
                        activator.wait(1000);
                    }
                }
            }
        }
       
View Full Code Here

        if (activatorClass != null)
        {
            try
            {
// TODO: SECURITY - Should this consider security?
                BundleActivator activator = (BundleActivator)
                    felix.getClass().getClassLoader().loadClass(
                        activatorClass.trim()).newInstance();

// TODO: EXTENSIONMANAGER - This is kind of hacky, can we improve it?
                felix.m_activatorList.add(activator);
View Full Code Here

        // CONCURRENCY NOTE:
        // This method is called indirectly from startBundle() (via _startBundle()),
        // which has the bundle lock, so there is no need to do any locking here.

        // Get the activator class from the header map.
        BundleActivator activator = null;
        Map headerMap = ((BundleRevisionImpl) impl.adapt(BundleRevision.class)).getHeaders();
        String className = (String) headerMap.get(Constants.BUNDLE_ACTIVATOR);
        // Try to instantiate activator class if present.
        if (className != null)
        {
View Full Code Here

            for (String s : getActivators()) {
                try {
                    Class<?> clazz = getClass().getClassLoader().loadClass(s);
                    Object o = clazz.newInstance();
                    if (o instanceof BundleActivator) {
                        BundleActivator ba = (BundleActivator) o;
                        activators.add(ba);
                        ba.start(ctx);
                    }
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
View Full Code Here

    private volatile ConfigurationAdmin m_config;
   
    @Override
    public void init(BundleContext context, DependencyManager manager) throws Exception {
        for (int i = 0; i < m_activators.length; i++) {
            BundleActivator a = m_activators[i];
            a.start(context);
        }
       
        manager.add(createComponent()
            .setImplementation(this)
            .add(createServiceDependency()
View Full Code Here

    }

    @Override
    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
        for (int i = 0; i < m_activators.length; i++) {
            BundleActivator a = m_activators[i];
            a.stop(context);
        }
    }
View Full Code Here

TOP

Related Classes of org.osgi.framework.BundleActivator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.