protected ProcessorImpl()

in taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/impl/ProcessorImpl.java [98:192]


	protected ProcessorImpl() {
		// Set a default name
		name = "UnnamedProcessor" + (pNameCounter++);

		/*
		 * Create iteration stack, configure it to send jobs and completion
		 * events to the dispatch stack.
		 */
		iterationStack = new IterationStrategyStackImpl() {
			@Override
			protected void receiveEventFromStrategy(IterationInternalEvent<?> e) {
				dispatchStack.receiveEvent(e);
			}
		};
		iterationStack.addStrategy(new IterationStrategyImpl());

		// Configure dispatch stack to push output events to the crystalizer
		dispatchStack = new DispatchStackImpl() {
			@Override
			protected String getProcessName() {
				return ProcessorImpl.this.name;
			}

			@Override
			public Processor getProcessor() {
				return ProcessorImpl.this;
			}

			/**
			 * Called when an event bubbles out of the top of the dispatch
			 * stack. In this case we pass it into the crystalizer.
			 */
			@Override
			protected void pushEvent(IterationInternalEvent<?> e) {
				crystalizer.receiveEvent(e);
			}

			/**
			 * Iterate over all the preconditions and return true if and only if
			 * all are satisfied for the given process identifier.
			 */
			@Override
			protected boolean conditionsSatisfied(String owningProcess) {
				for (Condition c : conditions)
					if (c.isSatisfied(owningProcess) == false)
						return false;
				return true;
			}

			@Override
			protected List<? extends Activity<?>> getActivities() {
				return ProcessorImpl.this.getActivityList();
			}

			/**
			 * We've finished here, set the satisfied property on any controlled
			 * condition objects to true and notify the targets.
			 */
			@Override
			protected void finishedWith(String owningProcess) {
				if (!controlledConditions.isEmpty()) {
					String enclosingProcess = owningProcess.substring(0,
							owningProcess.lastIndexOf(':'));
					for (ConditionImpl ci : controlledConditions) {
						ci.satisfy(enclosingProcess);
						ci.getTarget().getDispatchStack()
								.satisfyConditions(enclosingProcess);
					}
				}
				/*
				 * Tell whoever is interested that the processor has finished
				 * executing
				 */
				processorFinishedMultiCaster.notify(new ProcessorFinishedEvent(
						this.getProcessor(), owningProcess));
			}

			@Override
			public void receiveMonitorableProperty(MonitorableProperty<?> prop,
					String processID) {
				synchronized (monitorables) {
					Set<MonitorableProperty<?>> props = monitorables
							.get(processID);
					if (props == null) {
						props = new HashSet<>();
						monitorables.put(processID, props);
					}
					props.add(prop);
				}
			}
		};

		// Configure crystalizer to send realized events to the output ports
		crystalizer = new ProcessorCrystalizerImpl(this);
	}