Package org.osgi.framework

Examples of org.osgi.framework.Bundle.loadClass()


    public Class findClass(String name) throws ClassNotFoundException {
        for (Map.Entry<Long, Bundle> entry : bundles.entrySet()) {
            try {
                Bundle bundle = entry.getValue();
                if (bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING) {
                    return bundle.loadClass(name);
                }
            } catch (ClassNotFoundException cnfe) {
                // try next
            }
        }
View Full Code Here


        supplyChainBundle.start();
        Bundle clientBundle = osgiRuntime.getBundleContext().installBundle(supplyChainClientURL.toString());
        clientBundle.start();
       
        String clientClassName = "supplychain.client.SupplyChainClient";
        Class<?> clientClass = clientBundle.loadClass(clientClassName);
        ServiceReference testServiceRef = clientBundle.getBundleContext().getServiceReference(clientClassName);
        Object testService = clientBundle.getBundleContext().getService(testServiceRef);
       
        Method m = clientClass.getMethod("runTest", String.class);
        m.invoke(testService, contributionJarName);
View Full Code Here

       
        tuscanyRuntime.start();
       
        testBundle.start();
       
        Class<?> testClass = testBundle.loadClass(this.getClass().getName());
        Method testMethod = testClass.getMethod("runAllTestsFromBundle", Bundle.class);
        Object testObject = testClass.newInstance();
        testMethod.invoke(testObject, testBundle);
       
        testBundle.stop();
View Full Code Here

    }

    public Class<?> loadClass(String className) throws ClassNotFoundException {
        Bundle bundle = getCurrentBundle();
        if (bundle != null) {
            Class cls = bundle.loadClass(className);
            if (LOG.isTraceEnabled())
                LOG.trace("Located class [#0] in bundle [#1]", className, bundle.getSymbolicName());
            return cls;
        }
View Full Code Here

            try {
                ComponentMetadata metadata = blueprintContainer.getComponentMetadata(id);
                Class cl = null;
                if (metadata instanceof BeanMetadata) {
                    BeanMetadata beanMetadata = (BeanMetadata)metadata;
                    cl = bundle.loadClass(beanMetadata.getClassName());
                } else if (metadata instanceof ReferenceMetadata) {
                    ReferenceMetadata referenceMetadata = (ReferenceMetadata)metadata;
                    cl = bundle.loadClass(referenceMetadata.getInterface());
                }
                if (cl != null && type.isAssignableFrom(cl)) {
View Full Code Here

                if (metadata instanceof BeanMetadata) {
                    BeanMetadata beanMetadata = (BeanMetadata)metadata;
                    cl = bundle.loadClass(beanMetadata.getClassName());
                } else if (metadata instanceof ReferenceMetadata) {
                    ReferenceMetadata referenceMetadata = (ReferenceMetadata)metadata;
                    cl = bundle.loadClass(referenceMetadata.getInterface());
                }
                if (cl != null && type.isAssignableFrom(cl)) {
                    Object o = blueprintContainer.getComponentInstance(metadata.getId());
                    objects.put(metadata.getId(), type.cast(o));
                }
View Full Code Here

            } catch (Throwable t) {
                // Check if the bundle can see the class
                try {
                    PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                    Bundle b = (Bundle) ptm.getObject();
                    if (b.loadClass(DataFormatResolver.class.getName()) != DataFormatResolver.class) {
                        throw new UnsupportedOperationException();
                    }
                    svc.setInterface(DataFormatResolver.class.getName());
                } catch (Throwable t2) {
                    throw new UnsupportedOperationException();
View Full Code Here

            } catch (Throwable t) {
                // Check if the bundle can see the class
                try {
                    PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                    Bundle b = (Bundle) ptm.getObject();
                    if (b.loadClass(LanguageResolver.class.getName()) != LanguageResolver.class) {
                        throw new UnsupportedOperationException();
                    }
                    svc.setInterface(LanguageResolver.class.getName());
                } catch (Throwable t2) {
                    throw new UnsupportedOperationException();
View Full Code Here

            } catch (Throwable t) {
                // Check if the bundle can see the class
                try {
                    PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                    Bundle b = (Bundle) ptm.getObject();
                    if (b.loadClass(ComponentResolver.class.getName()) != ComponentResolver.class) {
                        throw new UnsupportedOperationException();
                    }
                    svc.setInterface(ComponentResolver.class.getName());
                } catch (Throwable t2) {
                    throw new UnsupportedOperationException();
View Full Code Here

                        } catch (Throwable t) {
                            // Check if the bundle can see the class
                            try {
                                PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                                Bundle b = (Bundle) ptm.getObject();
                                if (b.loadClass(ComponentResolver.class.getName()) != ComponentResolver.class) {
                                    throw new UnsupportedOperationException();
                                }
                                svc.setInterface(ComponentResolver.class.getName());
                            } catch (Throwable t2) {
                                throw new UnsupportedOperationException();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.