Package javax.enterprise.deploy.spi.status

Examples of javax.enterprise.deploy.spi.status.ProgressEvent


        synchronized (this) {
            this.message = message;
            this.state = state;
            newStatus = new Status(command, action, state, message);
            toNotify = (ProgressListener[]) listeners.toArray(new ProgressListener[listeners.size()]);
            event = new ProgressEvent(this, null, newStatus);
        }

        for (int i = 0; i < toNotify.length; i++) {
            toNotify[i].handleProgressEvent(event);
        }
View Full Code Here


     *@return ProgressObject set to FAILED with linked cause reporting full error info
     */
    private ProgressObject prepareErrorProgressObject (CommandType commandType, Throwable thr) {
        DeploymentStatus ds = new DeploymentStatusImplWithError(CommandType.DISTRIBUTE, thr);
        SimpleProgressObjectImpl progressObj = new SimpleProgressObjectImpl(ds);
        ProgressEvent event = new ProgressEvent(progressObj, null /*targetModuleID */, ds);
        progressObj.fireProgressEvent(event);
        return progressObj;
    }
View Full Code Here

            deploymentStatus.setState(state); // retain current state
  }
       
        /* send notification */
  TargetModuleIDImpl tmi = new TargetModuleIDImpl(aTarget, moduleID);
  fireProgressEvent(new ProgressEvent(this, tmi, depStatus));
    }
View Full Code Here

     * receives notification of a progress event from one of our
     * registered interface.
     */
    public void handleProgressEvent(ProgressEvent progressEvent) {
       
        ProgressEvent forwardedEvent;
        DeploymentStatus forwardedDS = progressEvent.getDeploymentStatus();
       
        // we intercept all events...
        if (!forwardedDS.isRunning()) {
            // this mean we are either completed or failed...
            if (forwardedDS.isFailed()) {
                /*
                 *Once at least one operation fails, we know that the aggregate state will have
                 *to be failed.
                 */
                finalStateType = StateType.FAILED;
            }
           
            // since this is the completion event
            // we are done with that progress listener;
            Object source = progressEvent.getSource();
            if (source instanceof ProgressObject) {
                ProgressObject po = (ProgressObject) source;
                po.removeProgressListener(this);
               
                sources.remove(source);
               
                if (forwardedDS.isCompleted()) {
               
                    TargetModuleID[] ids = po.getResultTargetModuleIDs();
                    for (int i=0;i<ids.length;i++) {
                        targetModuleIDs.add(ids[i]);
                    }
                }
            } else {
                throw new RuntimeException(localStrings.getLocalString(
                    "enterprise.deployment.client.noprogressobject",
                    "Progress event does not contain a ProgressObject source"
                    ));
            }
           
            /*
             *Update the completionStatus by adding a stage to it and recording the completion
             *of this event as the newest stage.
             */
            updateCompletedStatus(forwardedDS);
           
            // now we change our event state to running.  We always forward every event from a
            // source to the listeners with "running" status because the sink is not yet completely
            // finished.  We will also send a final aggregate completion event
            // if this is a completion event from our last source (see below).
            DeploymentStatusImpl forwardedStatus = new DeploymentStatusImpl();
            forwardedStatus.setState(StateType.RUNNING);
            forwardedStatus.setMessage(forwardedDS.getMessage());
            forwardedStatus.setCommand(forwardedDS.getCommand());
            forwardedEvent = new ProgressEvent(this, progressEvent.getTargetModuleID(), forwardedStatus);
        } else {
            // This is a "running" event from one of our sources, so we just need to swap the source...
            forwardedEvent = new ProgressEvent(this, progressEvent.getTargetModuleID(),
                forwardedDS);
        }
       
        // we need to fire the received event to our listeners
        Collection clone;
        ProgressEvent finalEvent = null;
       
        synchronized(registeredPL) {
            clone = (Collection) registeredPL.clone();
            deliveredEvents.add(forwardedEvent);
            /*
             *If we are done with all of our sources, let's wrap up by creating a final event that will
             *be broadcast to the listeners along with the forwarded event.  Also create the completed status
             *that meets the requirements of the JESProgressObject interface.
             */
            if (sources.isEmpty()) {
                prepareCompletedStatus();
                DeploymentStatusImpl status = new DeploymentStatusImpl();
                status.setState(finalStateType);
                if (finalStateType.equals(StateType.FAILED)) {
                    status.setMessage(localStrings.getLocalString(
                        "enterprise.deployment.client.aggregatefailure",
                        "At least one operation failed"
                        ));
                } else {
                    status.setMessage(localStrings.getLocalString(
                        "enterprise.deployment.client.aggregatesuccess",
                        "All operations completed successfully"
                        ));
                }
                finalEvent = new ProgressEvent(this, progressEvent.getTargetModuleID(), status);
                deliveredEvents.add(finalEvent);
            }
        }       
       
        for (Iterator itr=clone.iterator();itr.hasNext();) {
View Full Code Here

            // now let's deliver all the events we already received.
            clone = (Collection) deliveredEvents.clone();
        }
       
        for (Iterator itr=clone.iterator();itr.hasNext();) {
            ProgressEvent pe = (ProgressEvent) itr.next();
            progressListener.handleProgressEvent(pe);
        }
    }
View Full Code Here

   public void sendProgressEvent(StateType stateType, String message, TargetModuleID moduleID)
   {
      log.trace("sendProgressEvent, state: "+stateType+", msg: "+message);
      deploymentStatus.setStateType(stateType);
      deploymentStatus.setMessage(message);
      ProgressEvent progressEvent = new ProgressEvent(this, moduleID, deploymentStatus);
      for (int i = 0; i < listeners.size(); i++)
      {
         ProgressListener progressListener = (ProgressListener)listeners.get(i);
         progressListener.handleProgressEvent(progressEvent);
      }
View Full Code Here

    public void stop() throws OperationUnsupportedException {
        throw new OperationUnsupportedException("stop not supported");
    }

    public void addProgressListener(ProgressListener pol) {
        ProgressEvent event = null;
        synchronized (this) {
            listeners.add(pol);
            event = this.event;
        }
        if (event != null) {
View Full Code Here

        synchronized (this) {
            this.message = message;
            this.state = state;
            newStatus = new Status(command, action, state, message);
            toNotify = (ProgressListener[]) listeners.toArray(new ProgressListener[listeners.size()]);
            event = new ProgressEvent(this, null, newStatus);
        }

        for (int i = 0; i < toNotify.length; i++) {
            toNotify[i].handleProgressEvent(event);
        }
View Full Code Here

    }

    ProgressEvent[] events = new ProgressEvent[_targetModuleIDs.length];

    for (int i = 0; i < _targetModuleIDs.length; i++)
      events[i] = new ProgressEvent(this, _targetModuleIDs[i], _status);

    for (ProgressListener listener : listeners) {
      for (ProgressEvent event : events)
        listener.handleProgressEvent(event);
    }
View Full Code Here

        private final DeploymentStatus deploymentStatus;

        public ProgressObjectImpl(CommandType command, Set<TargetModuleID> targetModuleIds) {
            this.targetModuleIds = targetModuleIds;
            deploymentStatus = new DeploymentStatusImpl(command);
            event = new ProgressEvent(this, null, deploymentStatus);
        }
View Full Code Here

TOP

Related Classes of javax.enterprise.deploy.spi.status.ProgressEvent

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.