Package org.rioproject.opstring

Examples of org.rioproject.opstring.ClassBundle


        Assert.assertNotNull(organization);
    }

    private ServiceElement makeServiceElement(String name) {
        ServiceElement elem = new ServiceElement();
        ClassBundle main = new ClassBundle("");
        elem.setComponentBundle(main);
        ServiceBeanConfig sbc = new ServiceBeanConfig();
        sbc.setName(name);
        elem.setServiceBeanConfig(sbc);
        return elem;
View Full Code Here


         */
        URL[] urls = ((URLClassLoader)loader).getURLs();
        if(urls.length==0)
            throw new RuntimeException("Unknown Export Codebase");

        ClassBundle exportBundle;
        String exportCodebase = urls[0].toExternalForm();
        if(!exportCodebase.startsWith("artifact:")) {
            if(exportCodebase.contains(".jar")) {
                int index = exportCodebase.lastIndexOf('/');
                if(index != -1)
                    exportCodebase = exportCodebase.substring(0, index+1);
            } else {
                throw new RuntimeException("Cannot determine export codebase from "+exportCodebase);
            }
            exportBundle = new ClassBundle("");
            exportBundle.setCodebase(exportCodebase);
            for (URL url : urls) {
                String jar = url.getFile();
                int index = jar.lastIndexOf('/');
                if (index != -1)
                    jar = jar.substring(1);
                exportBundle.addJAR(jar);
            }
        } else {
            exportBundle = new ClassBundle("");
            exportBundle.setArtifact(exportCodebase);
        }

        /* Default system threshold is the number of available processors.
         * Since the system threshold is the summation of all depletion oriented
         * resources, total utilization is =
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public static FaultDetectionHandler<ServiceID> getFaultDetectionHandler(final ClassBundle fdhBundle,
                                                                            final ClassLoader cl) throws Exception {
        Class fdhClass;
        ClassBundle theFdhBundle = getClassBundle(fdhBundle);
        if(cl==null)
            fdhClass = ClassBundleLoader.loadClass(theFdhBundle);
        else
            fdhClass = ClassBundleLoader.loadClass(cl, theFdhBundle);
        FaultDetectionHandler fdh = (FaultDetectionHandler)fdhClass.newInstance();
View Full Code Here

        return (fdh);
    }

    private static ClassBundle getClassBundle(ClassBundle cb) {
        if(cb==null)
            return new ClassBundle(AdminFaultDetectionHandler.class.getName());
        return cb;
    }
View Full Code Here

        final Thread currentThread = Thread.currentThread();
        final ClassLoader jsbCL = currentThread.getContextClassLoader();
        Created created;
        try {
            ClassBundle jsbBundle = context.getServiceElement().getComponentBundle();
            logger.trace("Loading class [{}], using ClassLoader: {}", jsbBundle.getClassName(), jsbCL.toString());
            Class<?> implClass = jsbCL.loadClass(jsbBundle.getClassName());
            if(useActivationConstructor(implClass) && !isServiceBean(implClass)) {
                Constructor constructor = implClass.getDeclaredConstructor(activationTypes);
                logger.trace("Obtained implementation constructor: {}", constructor);
                constructor.setAccessible(true);
                LifeCycle lifeCycle = (LifeCycle)context.getServiceBeanManager().getDiscardManager();
View Full Code Here

        int index = darrel.getIndexFromAnotherDummy();
        logger.info("The other dummy returned: {}", index);
    }

    ClassBundle makeClassBundle(String className, String codebase) {
        ClassBundle classBundle = new ClassBundle();
        classBundle.addJAR("test-classes/");
        classBundle.setClassName(className);
        classBundle.setCodebase(codebase);
        return classBundle;
    }
View Full Code Here

     *
     * @throws Exception If there are errors loading the bean
     */
    protected Object getBean(final ServiceBeanContext context) throws Exception {
        final Thread currentThread = Thread.currentThread();
        ClassBundle bundle = context.getServiceElement().getComponentBundle();
        ClassLoader beanCL = currentThread.getContextClassLoader();
        Class<?> beanClass = beanCL.loadClass(bundle.getClassName());
        logger.trace("Load service class: {}", beanClass);
        logger.trace("Activating as ServiceBean");
        Constructor constructor = beanClass.getConstructor((Class[])null);
        logger.trace("Obtained implementation constructor: {}", constructor);
        return(constructor.newInstance((Object[])null));
View Full Code Here

        codebaseBuilder.append(codebase);
        if (!codebase.endsWith("/")) {
            codebaseBuilder.append("/");
        }
        String codebaseToUse = codebaseBuilder.toString();
        ClassBundle bundle = elem.getComponentBundle();
        if (bundle.getCodebase() == null) {
            for(String jar : bundle.getJARNames())
                canServe(jar, codebaseToUse);
            bundle.setCodebase(codebaseToUse);
            logger.debug("Fixed ClassBundle {}", bundle);

        }

        ClassBundle[] exports = elem.getExportBundles();
View Full Code Here

* Test ClassBundleLoader
*/
public class ClassBundleLoaderTest {
    @Test
    public void testLoadClass() throws Exception {
        ClassBundle classBundle = new ClassBundle(JustForTesting.class.getName());
        classBundle.setCodebase(System.getProperty("user.dir")+File.separator+
                                "target"+File.separator+
                                "test-classes"+File.separator);
        Class testClass = ClassBundleLoader.loadClass(classBundle);
        Assert.assertNotNull(testClass);
    }
View Full Code Here

        return makeServiceElement(name, opStringName, 1);
    }

    public static ServiceElement makeServiceElement(String name, String opStringName, int planned) {
        ServiceElement elem = new ServiceElement();
        ClassBundle exports = new ClassBundle(Object.class.getName());
        elem.setExportBundles(exports);
        ClassBundle main = new ClassBundle("");
        elem.setComponentBundle(main);
        ServiceBeanConfig sbc = new ServiceBeanConfig();
        sbc.setName(name);
        sbc.setOperationalStringName(opStringName);
        elem.setServiceBeanConfig(sbc);
View Full Code Here

TOP

Related Classes of org.rioproject.opstring.ClassBundle

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.