Package org.osgi.framework

Examples of org.osgi.framework.BundleActivator


            InputStream is = url.openStream();
            try {
                Manifest mf = new Manifest(is);
                className = mf.getMainAttributes().getValue(KARAF_ACTIVATOR);
                if (className != null) {
                    BundleActivator activator = (BundleActivator) classLoader.loadClass(className).newInstance();
                    activator.start(framework.getBundleContext());
                    karafActivators.add(activator);
                }
            } catch (Throwable e) {
                if (className != null) {
                    System.err.println("Error starting karaf activator " + className + ": " + e.getMessage());
View Full Code Here


     */
    @Override
    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
        // ACE-276 same logic as init()
        for (int i = 0; i < m_activators.length; i++) {
            BundleActivator a = m_activators[i];
            String packageName = a.getClass().getPackage().getName();
            if (!"disabled".equals(System.getProperty(packageName))) {
                a.stop(context);
            }
            else if (!m_quiet) {
                System.out.println("Not stopping activator " + packageName + ".");
            }
        }
View Full Code Here

        if (m_logToConsole) {
            new org.apache.ace.consolelogger.Activator().start(context);
        }

        for (int i = 0; i < m_activators.length; i++) {
            BundleActivator a = m_activators[i];
            // start the bundle unless there is a system property with the same package name as
            // the package that the bundle activator is part of that has the value 'disabled'
            // example use case: turn off the embedded scheduler
            String packageName = a.getClass().getPackage().getName();
            if (!"disabled".equals(System.getProperty(packageName))) {
                a.start(context);
            }
            else if (!m_quiet) {
                System.out.println("Not starting activator " + packageName + ".");
            }
        }
View Full Code Here

            InputStream is = url.openStream();
            try {
                Manifest mf = new Manifest(is);
                className = mf.getMainAttributes().getValue(KARAF_ACTIVATOR);
                if (className != null) {
                    BundleActivator activator = (BundleActivator) classLoader.loadClass(className).newInstance();
                    activator.start(framework.getBundleContext());
                    karafActivators.add(activator);
                }
            } catch (Throwable e) {
                if (className != null) {
                    System.err.println("Error starting karaf activator " + className + ": " + e.getMessage());
View Full Code Here

            Constructor felixConstructor = felixClass.getConstructor(Map.class, List.class);
            List<BundleActivator> activators = new ArrayList<BundleActivator>();

            Class<?> autoActivatorClass = cl.loadClass("org.apache.felix.main.AutoActivator");
            Constructor autoActivatorConstructor = autoActivatorClass.getConstructor(Map.class);
            BundleActivator autoActivator = (BundleActivator)autoActivatorConstructor.newInstance(props);           
            activators.add(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

                {
                    Class bundleActivatorClass = bundleGeneration.getClassLoader().loadClass(bundleActivatorClassName);

                    if (bundleActivatorClass == null) throw new BundleException("Bundle activator class " + bundleActivatorClassName + " not found");

                    final BundleActivator bundleActivator = (BundleActivator) bundleActivatorClass.newInstance();

                    bundleController.setBundleActivator(bundleActivator);

                    SecurityUtils.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
                    {
                        public Void run() throws Exception
                        {
                            bundleActivator.start(bundleController.getBundleContext());
                            return null;
                        }
                    },
                                                              framework.getAcc());
                }
View Full Code Here

        }
    }

    public void performDeactivation(final BundleController bundleController) throws Exception
    {
        final BundleActivator bundleActivator = bundleController.getBundleActivator();

        if (bundleActivator != null)
        {
            SecurityUtils.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
            {
                public Void run() throws Exception
                {
                    bundleActivator.stop(bundleController.getBundleContext());
                    return null;
                }
            },
                                                      framework.getAcc());
            bundleController.setBundleActivator(null);
View Full Code Here

        Constructor felixConstructor = felixClass.getConstructor(Map.class, List.class);
        List<BundleActivator> activators = new ArrayList<BundleActivator>();

        Class<?> autoActivatorClass = cl.loadClass("org.apache.felix.main.AutoActivator");
        Constructor autoActivatorConstructor = autoActivatorClass.getConstructor(Map.class);
        BundleActivator autoActivator = (BundleActivator)autoActivatorConstructor.newInstance(props);           
        activators.add(autoActivator);
        felix = (Bundle)felixConstructor.newInstance(props, activators);
        felix.start();
        bundleContext = felix.getBundleContext();
                  
View Full Code Here

            Constructor felixConstructor = felixClass.getConstructor(Map.class, List.class);
            List<BundleActivator> activators = new ArrayList<BundleActivator>();

            Class<?> autoActivatorClass = cl.loadClass("org.apache.felix.main.AutoActivator");
            Constructor autoActivatorConstructor = autoActivatorClass.getConstructor(Map.class);
            BundleActivator autoActivator = (BundleActivator)autoActivatorConstructor.newInstance(props);           
            activators.add(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

               
       
                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

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.