Package org.osgi.service.subsystem

Examples of org.osgi.service.subsystem.SubsystemException


    public IDirectory convertNested() {
      try {
        return FileSystem.getFSRoot(url.openStream());
      }
      catch (IOException e) {
        throw new SubsystemException(e);
      }
    }
View Full Code Here


      SubsystemResource ssr = createSubsystemResource(location, content, parent);
      result = Activator.getInstance().getSubsystems().getSubsystemByLocation(location);
      if (result != null) {
        checkLifecyclePermission(result);
        if (!region.contains(result))
          throw new SubsystemException("Location already exists but existing subsystem is not part of target region: " + location);
        if (!(result.getSymbolicName().equals(ssr.getSubsystemManifest().getSubsystemSymbolicNameHeader().getSymbolicName())
            && result.getVersion().equals(ssr.getSubsystemManifest().getSubsystemVersionHeader().getVersion())
            && result.getType().equals(ssr.getSubsystemManifest().getSubsystemTypeHeader().getType())))
          throw new SubsystemException("Location already exists but symbolic name, version, and type are not the same: " + location);
        return (BasicSubsystem)ResourceInstaller.newInstance(coordination, result, parent).install();
      }
      result = (BasicSubsystem)region.find(
          ssr.getSubsystemManifest().getSubsystemSymbolicNameHeader().getSymbolicName(),
          ssr.getSubsystemManifest().getSubsystemVersionHeader().getVersion());
      if (result != null) {
        checkLifecyclePermission(result);
        if (!result.getType().equals(ssr.getSubsystemManifest().getSubsystemTypeHeader().getType()))
          throw new SubsystemException("Subsystem already exists in target region but has a different type: " + location);
        return (BasicSubsystem)ResourceInstaller.newInstance(coordination, result, parent).install();
      }
      result = createSubsystem(ssr);
      checkLifecyclePermission(result);
      return (BasicSubsystem)ResourceInstaller.newInstance(coordination, result, parent).install();
    }
    catch (Throwable t) {
      coordination.fail(t);
    }
    finally {
      if (!embedded) {
        try {
          coordination.end();
        }
        catch (CoordinationException e) {
          Throwable t = e.getCause();
          if (t instanceof SubsystemException)
            throw (SubsystemException)t;
          if (t instanceof SecurityException)
            throw (SecurityException)t;
          throw new SubsystemException(t);
        }
      }
    }
    return result;
  }
View Full Code Here

        }
        return new ByteArrayInputStream(baos.toByteArray());
      }
    }
    catch (Exception e) {
      throw new SubsystemException(e);
    }
  }
View Full Code Here

      // locations during installation.
      try {
        name = file.toURL().toString();
      }
      catch (MalformedURLException e) {
        throw new SubsystemException(e);
      }
    }
    int index = name.lastIndexOf('/');
    if (index == -1 || index == name.length() - 1)
      return name;
View Full Code Here

        }
        catch (SubsystemException e) {
          throw e;
        }
        catch (Exception e) {
          throw new SubsystemException(e);
        }
        Coordination coordination = Utils.createCoordination();
        try {
          root = new BasicSubsystem(resource);
          // TODO This initialization is a bit brittle. The root subsystem
View Full Code Here

  @Override
  public Object run() {
    State state = target.getState();
    // The following states are illegal.
    if (EnumSet.of(State.INSTALL_FAILED, State.UNINSTALLED, State.UNINSTALLING).contains(state))
      throw new SubsystemException("Cannot stop from state " + state);
    // The following states must wait.
    if (EnumSet.of(State.INSTALLING, State.RESOLVING, State.STARTING, State.STOPPING).contains(state)) {
      waitForStateChange();
      return new StartAction(instigator, requestor, target).run();
    }
    // The following states mean the requested state has already been attained.
    if (State.ACTIVE.equals(state))
      return null;
    // Always start if target is content of requestor.
    if (!Utils.isContent(requestor, target)) {
      // Aways start if target is a dependency of requestor.
      if (!Utils.isDependency(requestor, target)) {
        // Always start if instigator equals target (explicit start).
        if (!instigator.equals(target)) {
          // Don't start if instigator is root (restart) and target is not ready.
          if (instigator.isRoot() && !target.isReadyToStart()) {
            return null;
          }
        }
      }
    }
    // Resolve if necessary.
    if (State.INSTALLED.equals(state))
      resolve(target);
    target.setState(State.STARTING);
    // TODO Need to hold a lock here to guarantee that another start
    // operation can't occur when the state goes to RESOLVED.
    // Start the subsystem.
    Coordination coordination = Activator.getInstance()
        .getCoordinator()
        .create(target.getSymbolicName() + '-' + target.getSubsystemId(), 0);
    try {
      List<Resource> resources = new ArrayList<Resource>(Activator.getInstance().getSubsystems().getResourcesReferencedBy(target));
      SubsystemContentHeader header = target.getSubsystemManifest().getSubsystemContentHeader();
      if (header != null)
        Collections.sort(resources, new StartResourceComparator(header));
      for (Resource resource : resources)
        startResource(resource, coordination);
      target.setState(State.ACTIVE);
    } catch (Throwable t) {
      coordination.fail(t);
      // TODO Need to reinstate complete isolation by disconnecting the
      // region and transition to INSTALLED.
    } finally {
      try {
        coordination.end();
      } catch (CoordinationException e) {
        target.setState(State.RESOLVED);
        Throwable t = e.getCause();
        if (t instanceof SubsystemException)
          throw (SubsystemException)t;
        throw new SubsystemException(t);
      }
    }
    return null;
  }
View Full Code Here

            .adapt(FrameworkWiring.class).resolveBundles(bundles)) {
          logger.error(
              "Unable to resolve bundles for subsystem/version/id {}/{}/{}: {}",
              new Object[] { subsystem.getSymbolicName(), subsystem.getVersion(),
                  subsystem.getSubsystemId(), bundles });
          throw new SubsystemException("Framework could not resolve the bundles");
        }
        setExportIsolationPolicy(subsystem);
      }
      // No need to propagate a RESOLVED event if this is a persisted
      // subsystem already in the RESOLVED state.
      if (State.RESOLVING.equals(subsystem.getState()))
        subsystem.setState(State.RESOLVED);
    }
    catch (Throwable t) {
      subsystem.setState(State.INSTALLED);
      if (t instanceof SubsystemException)
        throw (SubsystemException)t;
      throw new SubsystemException(t);
    }
  }
View Full Code Here

      startBundleResource(resource, coordination);
    else if (IdentityNamespace.TYPE_FRAGMENT.equals(type)) {
      // Fragments are not started.
    }
    else
      throw new SubsystemException("Unsupported resource type: " + type);
  }
View Full Code Here

    this.disableRootCheck = disableRootCheck;
  }
 
  protected void checkRoot() {
    if (!disableRootCheck && target.isRoot())
      throw new SubsystemException("This operation may not be performed on the root subsystem");
  }
View Full Code Here

    synchronized (target) {
      try {
        target.wait();
      }
      catch (InterruptedException e) {
        throw new SubsystemException(e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.osgi.service.subsystem.SubsystemException

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.