Beispiel #1
0
  public ProcessingStep create(
      IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    IExtension extension =
        registry.getExtension(PROCESSING_STEPS_EXTENSION_ID, descriptor.getProcessorId());
    Exception error;
    if (extension != null) {
      IConfigurationElement[] config = extension.getConfigurationElements();
      try {
        Object object = config[0].createExecutableExtension("class"); // $NON-NLS-1$
        ProcessingStep step = (ProcessingStep) object;
        step.initialize(agent, descriptor, context);
        return step;
      } catch (Exception e) {
        error = e;
      }
    } else
      error =
          new ProcessingStepHandlerException(
              NLS.bind(
                  Messages.cannot_get_extension,
                  PROCESSING_STEPS_EXTENSION_ID,
                  descriptor.getProcessorId()));

    int severity = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO;
    ProcessingStep result = new EmptyProcessingStep();
    result.setStatus(
        new Status(
            severity,
            Activator.ID,
            Messages.cannot_instantiate_step + descriptor.getProcessorId(),
            error));
    return result;
  }
Beispiel #2
0
 /**
  * Check to see that we have processors for all the steps in the given descriptor
  *
  * @param descriptor the descriptor to check
  * @return whether or not processors for all the descriptor's steps are installed
  */
 public static boolean canProcess(IArtifactDescriptor descriptor) {
   IExtensionRegistry registry = RegistryFactory.getRegistry();
   IExtensionPoint point = registry.getExtensionPoint(PROCESSING_STEPS_EXTENSION_ID);
   if (point == null) return false;
   IProcessingStepDescriptor[] steps = descriptor.getProcessingSteps();
   for (int i = 0; i < steps.length; i++) {
     if (point.getExtension(steps[i].getProcessorId()) == null) return false;
   }
   return true;
 }
  private void initRegistry() {
    registry = RegistryFactory.getRegistry(application);
    if (registry instanceof AbstractRegistry) {
      ((AbstractRegistry) registry).setNode(node);
    }
    registry.subscribe(
        node,
        new NotifyListener() {
          private final Logger NOTIFY_LOGGER = LoggerFactory.getLogger(NotifyListener.class);

          @Override
          public void notify(NotifyEvent event, List<Node> nodes) {
            if (CollectionUtils.isEmpty(nodes)) {
              return;
            }
            switch (event) {
              case ADD:
                for (NodeChangeListener listener : nodeChangeListeners) {
                  try {
                    listener.addNodes(nodes);
                  } catch (Throwable t) {
                    NOTIFY_LOGGER.error(
                        "{} add nodes failed , cause: {}",
                        listener.getClass().getName(),
                        t.getMessage(),
                        t);
                  }
                }
                break;
              case REMOVE:
                for (NodeChangeListener listener : nodeChangeListeners) {
                  try {
                    listener.removeNodes(nodes);
                  } catch (Throwable t) {
                    NOTIFY_LOGGER.error(
                        "{} remove nodes failed , cause: {}",
                        listener.getClass().getName(),
                        t.getMessage(),
                        t);
                  }
                }
                break;
            }
          }
        });
  }
Beispiel #4
0
  // main ..........(SL: now renamed).................................................
  public void start() {

    // EditorServer server ;

    //
    // if(args.length == 1)
    // server = new EditorServer(args[0], "No Name", "No Description") ;
    // else
    // server = new EditorServer(null, args[0], args[1]) ;

    // final EditorServer self = server ;

    Session editorSession = null;
    this.textChannel = null;
    this.textChannelConsumer = null;

    URLString url = null;
    String sessionType = null;
    String hostname = null;
    int hostport = 0;

    if (EditorServer_Debug) System.err.println("EditorServer: main.");

    hostname = "localhost";
    hostport = 4461;
    sessionType = "socket";
    url = URLString.createSessionURL(hostname, hostport, sessionType, sessionName);

    if (EditorServer_Debug) System.err.println("EditorServer: main: url: " + url.toString());

    try {

      /* Registry running?  Start it if it isn't. */

      if (RegistryFactory.registryExists(sessionType) == false) {
        RegistryFactory.startRegistry(sessionType);
      }

      /* Create a session, [re]bind it and create a channel. */

      this.client = new NetworkedClient("Server");
      editorSession = SessionFactory.createSession(this.client, url, true);

      // setup text channel
      this.textChannel = editorSession.createChannel(this.client, "TextChannel", true, true, true);
      this.textChannelConsumer = new TextChannelConsumer(this);
      this.textChannel.addConsumer(this.client, this.textChannelConsumer);

      // setup client channel
      this.clientChannel =
          editorSession.createChannel(this.client, "ClientChannel", true, true, true);
      this.clientChannelConsumer = new ClientChannelConsumer(this);
      this.clientChannel.addConsumer(this.client, this.clientChannelConsumer);
      this.clientChannel.addChannelListener(
          new ChannelAdaptor() {
            public void channelConsumerAdded(ChannelEvent event) {
              self.clientAppeared();
            }
          });

      System.err.println("Setup and bound Editor server.");
    } catch (JSDTException e) {
      System.err.println("EditorServer: main: shared data exception: " + e);
      if (EditorServer_Debug) {
        e.printStackTrace();
      }
    }

    this.pack();
    // on Linux, this seems to be the only way to set JFrame sizes
    // (i.e. resize it after packing (which seems to defeat the
    // purpose of packing)!)
    this.setSize(new Dimension(800, 600));
    this.setVisible(true);
  }