Package org.osgi.framework

Examples of org.osgi.framework.BundleReference


        // If the class comes from bundle class loader, then return
        // associated bundle if it is from this framework instance.
        if (clazz.getClassLoader() instanceof BundleReference)
        {
            // Only return the bundle if it is from this framework.
            BundleReference br = (BundleReference) clazz.getClassLoader();
            return ((br.getBundle() instanceof BundleImpl)
                && (((BundleImpl) br.getBundle()).getFramework() == this))
                    ? br.getBundle() : null;
        }
        // Otherwise check if the class conceptually comes from the
        // system bundle. Ignore implicit boot delegation.
        if (!clazz.getName().startsWith("java."))
        {
View Full Code Here


        ServiceReference sref = context.getServiceReference(Echo.class.getName());
        return (Echo) context.getService(sref);
    }

    private BundleContext getBundleContextFromClass(Class<?> clazz) {
        BundleReference bref = (BundleReference) clazz.getClassLoader();
        Bundle bundle = bref.getBundle();
        if (bundle.getState() != Bundle.ACTIVE) {
            try {
                bundle.start();
            } catch (BundleException ex) {
                log.errorf(ex, "Cannot start bundle: %s", bundle);
View Full Code Here

    private void installManagedBundles() {
        try {

            // Obtaining BundleContext from ServletContext class which is loaded
            // by bundle class loader
            BundleReference ref = (BundleReference) servletContext.getClass()
                    .getClassLoader();
            bctx = ref.getBundle().getBundleContext();

            // installing managed bundles
            installBundles();

        } catch (Exception ex) {
View Full Code Here

            });           
           
            if (loader == null) return false;
           
            if (loader instanceof BundleReference) {
                BundleReference ref = (BundleReference) loader;
                return ref.getBundle().equals(container.getBundleContext().getBundle());               
            }
           
            return false;
        }
View Full Code Here

        // If the class comes from bundle class loader, then return
        // associated bundle if it is from this framework instance.
        if (clazz.getClassLoader() instanceof BundleReference)
        {
            // Only return the bundle if it is from this framework.
            BundleReference br = (BundleReference) clazz.getClassLoader();
            return ((br.getBundle() instanceof BundleImpl)
                && (((BundleImpl) br.getBundle()).getFramework() == this))
                    ? br.getBundle() : null;
        }
        // Otherwise check if the class conceptually comes from the
        // system bundle. Ignore implicit boot delegation.
        if (!clazz.getName().startsWith("java."))
        {
View Full Code Here

            ClassLoader loader = declaringClass.get().getClassLoader();
           
            if (loader == null) return false;
           
            if (loader instanceof BundleReference) {
                BundleReference ref = (BundleReference) loader;
                return ref.getBundle().equals(container.getBundleContext().getBundle());               
            }
           
            return false;
        }
View Full Code Here

        // [ARQ-459] Allow TestRunner to TestEnricher communication
        Bundle bundle = BundleAssociation.getBundle();
        if (bundle == null) {
            ClassLoader classLoader = testCase.getClass().getClassLoader();
            if (classLoader instanceof BundleReference) {
                BundleReference bref = (BundleReference) classLoader;
                bundle = bref.getBundle();
            }
        }
        return bundle;
    }
View Full Code Here

            ClassLoader loader = declaringClass.get().getClassLoader();
           
            if (loader == null) return false;
           
            if (loader instanceof BundleReference) {
                BundleReference ref = (BundleReference) loader;
                return ref.getBundle().equals(container.getBundleContext().getBundle());               
            }
           
            return false;
        }
View Full Code Here

            ClassLoader loader = declaringClass.get().getClassLoader();
           
            if (loader == null) return false;
           
            if (loader instanceof BundleReference) {
                BundleReference ref = (BundleReference) loader;
                return ref.getBundle().equals(container.getBundleContext().getBundle());               
            }
           
            return false;
        }
View Full Code Here

            @Override
            public TestResult runTestMethodRemote(String className, String methodName) {
                Bundle bundle = null;
                try {
                    Class<?> testClass = testClassLoader.loadTestClass(className);
                    BundleReference bundleRef = (BundleReference) testClass.getClassLoader();
                    bundle = bundleRef.getBundle();
                } catch (ClassNotFoundException e) {
                    // ignore
                }
                BundleAssociation.setBundle(bundle);
                BundleContextAssociation.setBundleContext(context);
View Full Code Here

TOP

Related Classes of org.osgi.framework.BundleReference

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.