Package org.apache.servicemix.jbi.deployer.descriptor

Examples of org.apache.servicemix.jbi.deployer.descriptor.ComponentDesc


    protected void registerDeployedComponent(ServiceReference reference, javax.jbi.component.Component component) {
        String name = (String) reference.getProperty(NAME);
        if (name != null && !components.containsKey(name)) {
            String type = (String) reference.getProperty(TYPE);
            Descriptor descriptor = new Descriptor();
            ComponentDesc componentDesc = new ComponentDesc();
            componentDesc.setIdentification(new Identification());
            componentDesc.getIdentification().setName(name);
            componentDesc.setType(type);
            descriptor.setComponent(componentDesc);

            try {
                wrappedComponents.put(name, true);
                ComponentInstaller installer = new ComponentInstaller(this, descriptor, null, autoStart);
View Full Code Here


            }
        }
    }

    private boolean hasBootstrap() {
        ComponentDesc descriptor = installationContext.getDescriptor();
        return descriptor.getBootstrapClassName() != null;
    }
View Full Code Here

        return descriptor.getBootstrapClassName() != null;
    }

    private Bootstrap createBootstrap() throws DeploymentException {
        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
        ComponentDesc descriptor = installationContext.getDescriptor();
        try {
            ClassLoader cl = createClassLoader(
                    getBundle(),
                    installationContext.getInstallRoot(),
                    descriptor.getBootstrapClassPath().getPathElements(),
                    descriptor.isBootstrapClassLoaderDelegationParentFirst(),
                    null);
            Thread.currentThread().setContextClassLoader(cl);
            Class bootstrapClass = cl.loadClass(descriptor.getBootstrapClassName());
            return (Bootstrap) bootstrapClass.newInstance();
        } catch (ClassNotFoundException e) {
            LOGGER.error("Class not found: " + descriptor.getBootstrapClassName(), e);
            throw new DeploymentException(e);
        } catch (InstantiationException e) {
            LOGGER.error("Could not instantiate : " + descriptor.getBootstrapClassName(), e);
            throw new DeploymentException(e);
        } catch (IllegalAccessException e) {
            LOGGER.error("Illegal access on: " + descriptor.getBootstrapClassName(), e);
            throw new DeploymentException(e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldCl);
        }
    }
View Full Code Here

            Thread.currentThread().setContextClassLoader(oldCl);
        }
    }

    private ObjectName initComponent() throws Exception {
        ComponentDesc componentDesc = installationContext.getDescriptor();
        List<SharedLibrary> libs = new ArrayList<SharedLibrary>();
        if (componentDesc.getSharedLibraries() != null) {
            for (SharedLibraryList sll : componentDesc.getSharedLibraries()) {
                SharedLibrary lib = deployer.getSharedLibrary(sll.getName());
                if (lib == null) {
                    // TODO: throw exception here ?
                } else {
                    libs.add(lib);
                }
            }
        }
        SharedLibrary[] aLibs = libs.toArray(new SharedLibrary[libs.size()]);

        if (innerComponent == null) {
            ClassLoader classLoader = createClassLoader(
                    getBundle(),
                    componentDesc.getIdentification().getName(),
                    (String[]) installationContext.getClassPathElements().toArray(new String[installationContext.getClassPathElements().size()]),
                    componentDesc.isComponentClassLoaderDelegationParentFirst(),
                    aLibs);
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(classLoader);
                Class clazz = classLoader.loadClass(componentDesc.getComponentClassName());
                innerComponent = (javax.jbi.component.Component) clazz.newInstance();
            } finally {
                Thread.currentThread().setContextClassLoader(oldCl);
            }
        }
View Full Code Here

    protected void maybeWrapComponent(ServiceReference reference, javax.jbi.component.Component component) {
        String name = (String) reference.getProperty(NAME);
        if (name != null && !components.containsKey(name)) {
            String type = (String) reference.getProperty(TYPE);
            Preferences prefs = preferencesService.getUserPreferences(name);
            ComponentDesc componentDesc = new ComponentDesc();
            componentDesc.setIdentification(new Identification());
            componentDesc.getIdentification().setName(name);
            componentDesc.setType(type);
            ComponentImpl wrapper = new ComponentImpl(componentDesc, component, prefs, autoStart, this);
            wrappedComponents.put(name, true);
            components.put(name, wrapper);
            Dictionary<String, String> props = new Hashtable<String, String>();
            props.put(NAME, name);
            props.put(TYPE, componentDesc.getType());
            registerService(reference.getBundle(), Component.class.getName(), wrapper, props);
            registerService(reference.getBundle(), ComponentWrapper.class.getName(), wrapper, props);
        }
    }
View Full Code Here

            }
        }
    }

    private boolean hasBootstrap() {
        ComponentDesc descriptor = installationContext.getDescriptor();
        return descriptor.getBootstrapClassName() != null;
    }
View Full Code Here

        return descriptor.getBootstrapClassName() != null;
    }

    private Bootstrap createBootstrap() throws DeploymentException {
        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
        ComponentDesc descriptor = installationContext.getDescriptor();
        try {
            ClassLoader cl = createClassLoader(
                    getBundle(),
                    installationContext.getInstallRoot(),
                    descriptor.getBootstrapClassPath().getPathElements(),
                    descriptor.isBootstrapClassLoaderDelegationParentFirst(),
                    null);
            Thread.currentThread().setContextClassLoader(cl);
            Class bootstrapClass = cl.loadClass(descriptor.getBootstrapClassName());
            return (Bootstrap) bootstrapClass.newInstance();
        } catch (ClassNotFoundException e) {
            LOGGER.error("Class not found: " + descriptor.getBootstrapClassName(), e);
            throw new DeploymentException(e);
        } catch (InstantiationException e) {
            LOGGER.error("Could not instantiate : " + descriptor.getBootstrapClassName(), e);
            throw new DeploymentException(e);
        } catch (IllegalAccessException e) {
            LOGGER.error("Illegal access on: " + descriptor.getBootstrapClassName(), e);
            throw new DeploymentException(e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldCl);
        }
    }
View Full Code Here

            Thread.currentThread().setContextClassLoader(oldCl);
        }
    }

    private ObjectName initComponent() throws Exception {
        ComponentDesc componentDesc = installationContext.getDescriptor();
        List<SharedLibrary> libs = new ArrayList<SharedLibrary>();
        if (componentDesc.getSharedLibraries() != null) {
            for (SharedLibraryList sll : componentDesc.getSharedLibraries()) {
                SharedLibrary lib = deployer.getSharedLibrary(sll.getName());
                if (lib == null) {
                    // TODO: throw exception here ?
                } else {
                    libs.add(lib);
                }
            }
        }
        SharedLibrary[] aLibs = libs.toArray(new SharedLibrary[libs.size()]);

        if (innerComponent == null) {
            ClassLoader classLoader = createClassLoader(
                    getBundle(),
                    componentDesc.getIdentification().getName(),
                    (String[]) installationContext.getClassPathElements().toArray(new String[installationContext.getClassPathElements().size()]),
                    componentDesc.isComponentClassLoaderDelegationParentFirst(),
                    aLibs);
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(classLoader);
                Class clazz = classLoader.loadClass(componentDesc.getComponentClassName());
                innerComponent = (javax.jbi.component.Component) clazz.newInstance();
            } finally {
                Thread.currentThread().setContextClassLoader(oldCl);
            }
        }
View Full Code Here

    protected void registerDeployedComponent(ServiceReference reference, javax.jbi.component.Component component) {
        String name = (String) reference.getProperty(NAME);
        if (name != null && !components.containsKey(name)) {
            String type = (String) reference.getProperty(TYPE);
            Descriptor descriptor = new Descriptor();
            ComponentDesc componentDesc = new ComponentDesc();
            componentDesc.setIdentification(new Identification());
            componentDesc.getIdentification().setName(name);
            componentDesc.setType(type);
            descriptor.setComponent(componentDesc);

            try {
                wrappedComponents.put(name, true);
                ComponentInstaller installer = new ComponentInstaller(this, descriptor, null, autoStart);
View Full Code Here

    protected void maybeWrapComponent(ServiceReference reference, javax.jbi.component.Component component) {
        String name = (String) reference.getProperty(NAME);
        if (name != null && !components.containsKey(name)) {
            String type = (String) reference.getProperty(TYPE);
            Preferences prefs = preferencesService.getUserPreferences(name);
            ComponentDesc componentDesc = new ComponentDesc();
            componentDesc.setIdentification(new Identification());
            componentDesc.getIdentification().setName(name);
            componentDesc.setType(type);
            ComponentImpl wrapper = new ComponentImpl(componentDesc, component, prefs, autoStart, this);
            wrappedComponents.put(name, true);
            components.put(name, wrapper);
            Dictionary<String, String> props = new Hashtable<String, String>();
            props.put(NAME, name);
            props.put(TYPE, componentDesc.getType());
            registerService(reference.getBundle(), Component.class.getName(), wrapper, props);
            registerService(reference.getBundle(), ComponentWrapper.class.getName(), wrapper, props);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.jbi.deployer.descriptor.ComponentDesc

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.