Package org.apache.servicemix.jbi.deployer.artifacts

Examples of org.apache.servicemix.jbi.deployer.artifacts.ComponentImpl


                sus = deploySUs();
            } else {
                sus = new ArrayList<ServiceUnitImpl>();
                for (ServiceUnitDesc sud : descriptor.getServiceAssembly().getServiceUnits()) {
                    String componentName = sud.getTarget().getComponentName();
                    ComponentImpl component = deployer.getComponent(componentName);
                    // Create service unit object
                    ServiceUnitImpl su = deployer.createServiceUnit(sud, null, component);
                    sus.add(su);
                }
            }
View Full Code Here


        // Quickly undeploy the SA if it has changed
        if (isModified && !isFirstInstall) {
            for (ServiceUnitDesc sud : descriptor.getServiceAssembly().getServiceUnits()) {
                File suRootDir = new File(saDir, sud.getIdentification().getName());
                String componentName = sud.getTarget().getComponentName();
                ComponentImpl component = deployer.getComponent(componentName);
                ServiceUnitImpl su = deployer.createServiceUnit(sud, suRootDir, component);
                try {
                    su.undeploy();
                } catch (Exception e) {
                    LOGGER.warn("Problem undeploying SU " + su.getName());
                }
            }
        }

        // Wipe out the SA dir
        if (isModified) {
            FileUtil.deleteFile(saDir);
            FileUtil.buildDirectory(saDir);
        }
        // Iterate each SU and deploy it
        List<ServiceUnitImpl> sus = new ArrayList<ServiceUnitImpl>();
        Exception failure = null;
        for (ServiceUnitDesc sud : descriptor.getServiceAssembly().getServiceUnits()) {
            // Create directory for this SU
            File suRootDir = new File(saDir, sud.getIdentification().getName());
            // Unpack it
            if (isModified) {
                String zip = sud.getTarget().getArtifactsZip();
                URL zipUrl = bundle.getResource(zip);
                FileUtil.unpackArchive(zipUrl, suRootDir);
            }
            // Find component
            String componentName = sud.getTarget().getComponentName();
            ComponentImpl component = deployer.getComponent(componentName);
            // Create service unit object
            ServiceUnitImpl su = deployer.createServiceUnit(sud, suRootDir, component);
            try {
                LOGGER.debug("Deploying SU " + su.getName());
                if (isModified) {
View Full Code Here

            throw new JBIException(e);
        }
    }

    public void stop(boolean force) throws Exception {
        ComponentImpl comp = deployer.getComponent(getName());
        if (comp == null && !force) {
            throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not installed.");
        }
        // Check component state is shutdown
        if (comp != null && !LifeCycleMBean.SHUTDOWN.equals(comp.getCurrentState())) {
            if (!force) {
                throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not shut down.");
            }
            if (LifeCycleMBean.STARTED.equals(comp.getCurrentState())) {
                comp.stop(false);
            }
            if (LifeCycleMBean.STOPPED.equals(comp.getCurrentState())) {
                comp.shutDown(false, force);
            }
        }
    }
View Full Code Here

    public void uninstall(boolean force) throws Exception {
        // Shutdown component
        stop(force);
        // Retrieve component
        ComponentImpl comp = deployer.getComponent(getName());
        if (comp == null && !force) {
            throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not installed.");
        }
        // TODO: if there is any SA deployed onto this component, undeploy the SA and put it in a pending state
        // Bootstrap stuff
View Full Code Here

    }

    public Component registerComponent(Bundle bundle, ComponentDesc componentDesc, javax.jbi.component.Component innerComponent, SharedLibrary[] sharedLibraries) throws Exception {
        String name = componentDesc.getIdentification().getName();
        Preferences prefs = preferencesService.getUserPreferences(name);
        ComponentImpl component = new ComponentImpl(bundle, componentDesc, innerComponent, prefs, autoStart, sharedLibraries);
        component.setListenerRegistry(listenerRegistry);
        // populate props from the component meta-data
        Dictionary<String, String> props = new Hashtable<String, String>();
        props.put(NAME, name);
        props.put(TYPE, componentDesc.getType());
        for (SharedLibrary lib : sharedLibraries) {
View Full Code Here

        }
    }

    public void lifeCycleChanged(LifeCycleEvent event) throws JBIException {
        if (event.getLifeCycleMBean() instanceof ComponentImpl) {
            ComponentImpl comp = (ComponentImpl) event.getLifeCycleMBean();
            switch (event.getType()) {
                case Stopping:
                    if (comp.getState() == AbstractLifecycleJbiArtifact.State.Started) {
                        // Stop deployed SAs
                        for (ServiceAssemblyImpl sa : comp.getServiceAssemblies()) {
                            if (sa.getState() == ServiceAssemblyImpl.State.Started) {
                                sa.stop(false);
                                pendingAssemblies.add(sa);
                            }
                        }
                    }
                    break;
                case ShuttingDown:
                    if (comp.getState() == AbstractLifecycleJbiArtifact.State.Stopped) {
                        // Shutdown deployed SAs
                        for (ServiceAssemblyImpl sa : comp.getServiceAssemblies()) {
                            if (sa.getState() == ServiceAssemblyImpl.State.Stopped) {
                                sa.shutDown(false, event.isForced());
                                pendingAssemblies.add(sa);
                            }
                        }
View Full Code Here

            throw new JBIException(e);
        }
    }

    public void stop(boolean force) throws Exception {
        ComponentImpl comp = deployer.getComponent(getName());
        if (comp == null && !force) {
            throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not installed.");
        }
        // Check component state is shutdown
        if (comp != null && !LifeCycleMBean.SHUTDOWN.equals(comp.getCurrentState())) {
            if (!force) {
                throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not shut down.");
            }
            if (LifeCycleMBean.STARTED.equals(comp.getCurrentState())) {
                comp.stop(false);
            }
            if (LifeCycleMBean.STOPPED.equals(comp.getCurrentState())) {
                comp.shutDown(false, force);
            }
        }
    }
View Full Code Here

    public void uninstall(boolean force) throws Exception {
        // Shutdown component
        stop(force);
        // Retrieve component
        ComponentImpl comp = deployer.getComponent(getName());
        if (comp == null && !force) {
            throw ManagementSupport.failure("uninstallComponent", "Component '" + getName() + "' is not installed.");
        }
        // TODO: if there is any SA deployed onto this component, undeploy the SA and put it in a pending state
        // Bootstrap stuff
View Full Code Here

        return sl;
    }

    public ComponentImpl registerComponent(Bundle bundle, ComponentDesc componentDesc, javax.jbi.component.Component innerComponent, SharedLibrary[] sharedLibraries) throws Exception {
        String name = componentDesc.getIdentification().getName();
        ComponentImpl component = new ComponentImpl(bundle, componentDesc, innerComponent, storage.getStorage(name), autoStart, sharedLibraries);
        component.setListenerRegistry(listenerRegistry);
        // populate props from the component meta-data
        Dictionary<String, String> props = new Hashtable<String, String>();
        props.put(NAME, name);
        props.put(TYPE, componentDesc.getType());
        for (SharedLibrary lib : sharedLibraries) {
View Full Code Here

        }
    }

    public void lifeCycleChanged(LifeCycleEvent event) throws JBIException {
        if (event.getLifeCycleMBean() instanceof ComponentImpl) {
            ComponentImpl comp = (ComponentImpl) event.getLifeCycleMBean();
            switch (event.getType()) {
                case Stopping:
                    if (comp.getState() == AbstractLifecycleJbiArtifact.State.Started) {
                        // Stop deployed SAs
                        for (ServiceAssemblyImpl sa : comp.getServiceAssemblies()) {
                            if (sa.getState() == ServiceAssemblyImpl.State.Started) {
                                sa.stop(false);
                                pendingAssemblies.add(sa);
                            }
                        }
                    }
                    break;
                case ShuttingDown:
                    if (comp.getState() == AbstractLifecycleJbiArtifact.State.Stopped) {
                        // Shutdown deployed SAs
                        for (ServiceAssemblyImpl sa : comp.getServiceAssemblies()) {
                            if (sa.getState() == ServiceAssemblyImpl.State.Stopped) {
                                sa.shutDown(false, event.isForced());
                                pendingAssemblies.add(sa);
                            }
                        }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.jbi.deployer.artifacts.ComponentImpl

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.