Package org.mule.registry

Examples of org.mule.registry.RegistryException


    com.sun.java.xml.ns.jbi.ComponentDocument.Component.SharedLibrary[] libs = jbi.getComponent().getSharedLibraryArray();
    for (int i = 0; i < libs.length; i++) {
      String libName = libs[i].getDomNode().getFirstChild().getNodeValue();
      Library library = getRegistry().getLibrary(libName);
      if (library == null) {
        throw new RegistryException("Component requires a missing shared library: " + libName);
      }
      library.addComponent(this);
    }

        // Get class path elements
View Full Code Here


        }
        this.configuration = JbiDocument.Factory.parse(file).getJbi();
        validate();
      }
        } catch (Exception e) {
      throw new RegistryException(e);
    }
  }
View Full Code Here

   */
  protected void checkDescriptor() throws RegistryException {
    super.checkDescriptor();
    // Check that it is a service assembly
    if (!getDescriptor().isServiceAssembly()) {
      throw new RegistryException("service-assembly should be set");
    }
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.mule.jbi.registry.Assembly#deploy()
   */
  public synchronized String deploy() throws RegistryException {
    if (!getCurrentState().equals(UNKNOWN)) {
      throw new RegistryException("Illegal status: " + getCurrentState());
    }
    try {
      Jbi jbi = (Jbi)getDescriptor().getConfiguration();
      // Deploy service units
      ServiceUnit[] sua = jbi.getServiceAssembly().getServiceUnitArray();
      this.units = new ArrayList();
      for (int i = 0; i < sua.length; i++) {
        String suName = sua[i].getIdentification().getName();
        String artifactName = sua[i].getTarget().getArtifactsZip();
        String componentName = sua[i].getTarget().getComponentName();
        File artifact = new File(getInstallRoot(), artifactName);
        File installDir = new File(getInstallRoot(), componentName + File.separator + suName);
        // Check that artifact exists
        if (!artifact.isFile()) {
          throw new JBIException("Artifact file not found: " + sua[i].getTarget().getArtifactsZip());
        }
        // Check that component exists
        RegistryComponent component = getRegistry().getComponent(componentName);
        if (component == null) {
          throw new JBIException("Service assembly requires a missing component: " + componentName);
        }
        // Check component is fully installed
        if (!component.getCurrentState().equals(RUNNING)) {
          throw new JBIException("Component is not started: " + componentName);
        }
        // Check that we can deploy onto it
        ServiceUnitManager mgr = ((Component)component.getComponent()).getServiceUnitManager();
        if (mgr == null) {
          throw new JBIException("Component does not accept deployments: " + componentName);
        }
        // Check for duplicate SU
        Unit[] compUnits = component.getUnits();
        for (int j = 0; j < compUnits.length; j++) {
          if (compUnits[i].getName().equals(suName)) {
            throw new JBIException("Service unit already installed on component: " + suName);
          }
        }
        // Unzip artifact
        Utility.unzip(artifact, installDir);
        // Create Unit
        Unit unit = registry.createUnit(suName);
        unit.setAssembly(this);
        unit.setRegistryComponent(component);
        unit.setInstallRoot(installDir.getAbsolutePath());
        // Deploy this unit
        String result = unit.deploy();
        // TODO: analyse result
      }
      // Deploy connections
      if (jbi.getServiceAssembly().isSetConnections()) {
        Connections connections = jbi.getServiceAssembly().getConnections();
        Connection[] cns = connections.getConnectionArray();
        for (int i = 0; i < cns.length; i++) {
          QName  consItf = cns[i].getConsumer().getInterfaceName();
          QName  consSer = cns[i].getConsumer().getServiceName();
          String consEP  = cns[i].getConsumer().getEndpointName().getStringValue();
          QName  provSer = cns[i].getProvider().getServiceName();
          String provEP  = cns[i].getProvider().getEndpointName().getStringValue();
          // TODO: deploy connection info
        }
      }
      // Finish
      setCurrentState(SHUTDOWN);
      // TODO return info
      return null;
    } catch (Exception e) {
      // If we failed, undeploy
      undeploy();
      if (e instanceof RegistryException) {
        throw (RegistryException) e;
      } else {
        throw new RegistryException("Could not deploy assembly", e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.mule.registry.RegistryException

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.