Package org.osgi.framework

Examples of org.osgi.framework.BundleReference


        // [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


        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

        BundleContext bundleContext = BundleContextAssociation.getBundleContext();

        if (bundleContext == null) {
            ClassLoader classLoader = OSGiTestEnricher.class.getClassLoader();
            if (classLoader instanceof BundleReference) {
                BundleReference bref = (BundleReference) classLoader;
                bundleContext = bref.getBundle().getBundleContext();
                bundleContext = bundleContext.getBundle(0).getBundleContext();
            }
        }
        return bundleContext;
    }
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

            @Override
            public byte[] runTestMethod(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(sysContext);
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

        ServiceReference<T> sref = context.getServiceReference(clazz);
        return context.getService(sref);
    }

    private <T> BundleContext getBundleContextFromClass(Class<T> clazz) {
        BundleReference bref = (BundleReference) clazz.getClassLoader();
        Bundle bundle = bref.getBundle();
        if (bundle.getState() != Bundle.ACTIVE) {
            try {
                bundle.start();
            } catch (BundleException ex)
            {
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

        // [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

        }
    }

    private BundleContext getBundleContext(Class<?> klass, long timeout) {
        try {
            BundleReference bundleRef = BundleReference.class.cast(klass.getClassLoader());
            Bundle bundle = bundleRef.getBundle();
            return getBundleContext(bundle, timeout);
        }
        catch (ClassCastException exc) {
            throw new TestContainerException("class " + klass.getName()
                + " is not loaded from an OSGi bundle");
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.