Package org.apache.servicemix.jbi.container

Examples of org.apache.servicemix.jbi.container.ServiceAssemblyEnvironment


        // Initialize all assemblies
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                String assemblyName = files[i].getName();
                try {
                    ServiceAssemblyEnvironment env = environmentContext.getServiceAssemblyEnvironment(assemblyName);
                    Descriptor root = DescriptorFactory.buildDescriptor(env.getInstallDir());
                    if (root != null) {
                        ServiceAssembly sa = root.getServiceAssembly();
                        if (sa != null && sa.getIdentification() != null) {
                            registry.registerServiceAssembly(sa, env);
                        }
View Full Code Here


      container.deactivateComponent(component.getName());
    }
   
    public void register(ServiceAssembly assembly) throws Exception {
      File rootDir = new File(assembly.getRootDir());
      ServiceAssemblyEnvironment env = new ServiceAssemblyEnvironment();
      env.setRootDir(rootDir);
      env.setInstallDir(new File(rootDir, "install"));
      env.setSusDir(new File(rootDir, "sus"));
      env.setStateFile(new File(rootDir, "state.xml"));
      ServiceAssemblyLifeCycle salc = container.getRegistry().registerServiceAssembly(assembly.getDescriptor().getServiceAssembly(), env);
      if (env.getStateFile().isFile()) {
        salc.restore();
      } else {
        salc.start();
      }
    }
View Full Code Here

     * @return result/status of the deployment in xml format
     * @throws Exception  in xml format
     */
    protected String deployServiceAssembly(File tmpDir, ServiceAssembly sa) throws Exception {
        String assemblyName = sa.getIdentification().getName();
        ServiceAssemblyEnvironment env = environmentContext.getNewServiceAssemblyEnvironment(assemblyName);
        File saDirectory = env.getInstallDir();

        // move the assembly to a well-named holding area
        if (log.isDebugEnabled()) {
            log.debug("Moving " + tmpDir.getAbsolutePath() + " to " + saDirectory.getAbsolutePath());
        }
        saDirectory.getParentFile().mkdirs();
        if (!tmpDir.renameTo(saDirectory)) {
            throw ManagementSupport.failure("deploy", "Failed to rename " + tmpDir + " to " + saDirectory);
        }
        // Check all SUs requirements
        ServiceUnit[] sus = sa.getServiceUnits();
        if (sus != null) {
            for (int i = 0; i < sus.length; i++) {
                String suName = sus[i].getIdentification().getName();
                String artifact = sus[i].getTarget().getArtifactsZip();
                String componentName = sus[i].getTarget().getComponentName();
                File artifactFile = new File(saDirectory, artifact);
                if (!artifactFile.exists()) {
                    throw ManagementSupport.failure("deploy", "Artifact " + artifact + " not found for service unit " + suName);
                }
                ComponentMBeanImpl lcc = container.getComponent(componentName);
                if (lcc == null) {
                    throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " is not installed");
                }
                if (!lcc.isStarted()) {
                    throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " is not started");
                }
                if (lcc.getServiceUnitManager() == null) {
                    throw ManagementSupport.failure("deploy", "Target component " + componentName + " for service unit " + suName + " does not accept deployments");
                }
                // TODO: check duplicates here ?
                if (isDeployedServiceUnit(componentName, suName)) {
                    throw ManagementSupport.failure("deploy", "Service unit " + suName + " is already deployed on component " + componentName);
                }
            }
        }
        // Everything seems ok, so deploy all SUs
        int nbSuccess = 0;
        int nbFailures = 0;
        List componentResults = new ArrayList();
        List suKeys = new ArrayList();
        if (sus != null) {
            for (int i = 0; i < sus.length; i++) {
                File targetDir = null;
                String suName = sus[i].getIdentification().getName();
                String artifact = sus[i].getTarget().getArtifactsZip();
                String componentName = sus[i].getTarget().getComponentName();
                // TODO: skip duplicates
                // Unpack SU
                try {
                    File artifactFile = new File(saDirectory, artifact);
                    targetDir = env.getServiceUnitDirectory(componentName, suName);
                    if (log.isDebugEnabled()) {
                        log.debug("Unpack service unit archive " + artifactFile + " to " + targetDir);
                    }
                    FileUtil.unpackArchive(artifactFile, targetDir);
                } catch (IOException e) {
View Full Code Here

              // Initialize all assemblies
                for (int i = 0; i < files.length; i++) {
                    if (files[i].isDirectory()) {
                        String assemblyName = files[i].getName();
                        try {
                            ServiceAssemblyEnvironment env = environmentContext.getServiceAssemblyEnvironment(assemblyName);
                          Descriptor root = DescriptorFactory.buildDescriptor(env.getInstallDir());
                          if (root != null) {
                              ServiceAssembly sa = root.getServiceAssembly();
                              if (sa != null && sa.getIdentification() != null) {
                                  registry.registerServiceAssembly(sa, env);
                              }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.jbi.container.ServiceAssemblyEnvironment

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.