Package com.sun.java.xml.ns.jbi.JbiDocument

Examples of com.sun.java.xml.ns.jbi.JbiDocument.Jbi


      }
      File jbiFile = new File(unzip, JBI_DESCRIPTOR);
      if (!jbiFile.isFile()) {
        throw new JBIException("No jbi descriptor found");
      }
      Jbi jbi = JbiDocument.Factory.parse(jbiFile).getJbi();
      // Check version number
      if (jbi.getVersion().doubleValue() != 1.0) {
        throw new JBIException("version attribute should be '1.0'");
      }
      // Check that it is a component
      if (!jbi.isSetComponent()) {
        throw new JBIException("component should be set");
      }
      String name = jbi.getComponent().getIdentification().getName();
      // Check that an installer has not been create already
      if (this.installers.get(name) != null) {
        throw new JBIException("an installer has already been created");
      }
      // Check that component does not already exists
      if (context.getRegistry().getComponent(name) != null) {
        throw new JBIException("component already installed");
      }
      // Retrieve component type
      boolean engine = jbi.getComponent().getType() == com.sun.java.xml.ns.jbi.ComponentDocument.Component.Type.SERVICE_ENGINE;
      // Init directories
      File installDir;
      File workspaceDir;
      if (engine) {
        installDir = Directories.getEngineInstallDir(context.getWorkingDir(), name);
View Full Code Here


  }

  private String installSharedLibrary(File file, File dir) throws Exception {
    // Load jbi descriptor
    URL jbiUrl = new URL("jar", "", file.toURL().toString() + "!/" + JBI_DESCRIPTOR);
    Jbi jbi = JbiDocument.Factory.parse(jbiUrl).getJbi();
    // Check version number
    if (jbi.getVersion().doubleValue() != 1.0) {
      throw new JBIException("version attribute should be '1.0'");
    }
    // Check that it is a component
    if (!jbi.isSetSharedLibrary()) {
      throw new JBIException("shared-library should be set");
    }
    // Retrieve name
    String name = jbi.getSharedLibrary().getIdentification().getName();
    // Check that it is not already installed
    if (context.getRegistry().getLibrary(name) != null) {
      throw new JBIException("Shared library is already installed");
    }
    // Create library
View Full Code Here

  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();
View Full Code Here

      // Unzip file to temp dir
      File unzip = new File(dir, "unzip");
      IOUtils.unzip(archive, unzip);
      // Load jbi descriptor
      File jbiFile = new File(unzip, JBI_DESCRIPTOR);
      Jbi jbi = JbiDocument.Factory.parse(jbiFile).getJbi();
      // Check version number
      if (jbi.getVersion().doubleValue() != 1.0) {
        throw new JBIException("version attribute should be '1.0'");
      }
      // Check that it is a component
      if (!jbi.isSetServiceAssembly()) {
        throw new JBIException("service-assembly should be set");
      }
      // Move unzipped files to install dir
      String name = jbi.getServiceAssembly().getIdentification().getName();
      // Check that it is not already installed
      if (this.registry.getAssembly(name) != null) {
        throw new JBIException("Service assembly is already installed");
      }
      File installDir = Directories.getAssemblyInstallDir(this.container.getWorkingDir(), name);
View Full Code Here

TOP

Related Classes of com.sun.java.xml.ns.jbi.JbiDocument.Jbi

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.