/** * Returns module info describing the current state of the module. * * @param inInitiatedFlows the set of IDs for the data flows that this * module has initiated * @param inParticipatingFlows the set of IDs for the data flows that this * module is participating in. * * @return the module info. */ final ModuleInfo getModuleInfo(DataFlowID[] inInitiatedFlows, DataFlowID[] inParticipatingFlows) { return new ModuleInfo(getURN(), getState(), inInitiatedFlows, inParticipatingFlows, getCreated(), getStarted(), getStopped(), isAutoStart(), isAutoCreated(), this instanceof DataReceiver, this instanceof DataEmitter, this instanceof DataFlowRequester, getLastStartFailure(), getLastStopFailure(), mLock.getReadLockCount(), mLock.isWriteLocked(), mLock.getQueueLength()); }
if(inModule != null && inModule.isAutoCreated()) { Lock moduleLock = inModule.getLock().writeLock(); if(!mModules.has(inModule.getURN())) { return; mDataFlows.getFlowsParticipatingNotInitiated(inModule.getURN()); if(flows == null || flows.isEmpty()) { Messages.LOG_DELETE_AUTO_CREATED_MODULE.info( this, inModule.getURN(), inFlowID); try { stopModule(inModule); deleteModule(inModule.getURN()); } catch (Exception e) { Messages.LOG_DELETE_AUTO_CREATED_MODULE_FAIL.warn(this, e, inModule.getURN());
Lock moduleLock = inModule.getLock().writeLock(); ModuleState state = inModule.getState(); if(!state.canBeStopped()) { throw new ModuleStateException(new I18NBoundMessage3P( Messages.MODULE_NOT_STOPPED_STATE_INCORRECT, inModule.getURN().toString(), state, ModuleState.STOPPABLE_STATES.toString())); if(inModule.getURN().equals(SinkModuleFactory.INSTANCE_URN)) { throw new ModuleException(Messages.CANNOT_STOP_SINK_MODULE); getFlowsParticipatingNotInitiated(inModule.getURN()); if(participating != null && (!participating.isEmpty())) { throw new DataFlowException(new I18NBoundMessage2P( Messages.CANNOT_STOP_MODULE_DATAFLOWS, inModule.getURN().toString(), participating.toString())); inModule.setState(ModuleState.STOPPING); } finally { moduleLock.unlock(); inModule.preStop(); initiated = mDataFlows.getInitiatedFlows(inModule.getURN()); if (initiated != null) { for(DataFlowID flowID: initiated) {
Lock moduleLock = inModule.getLock().writeLock(); getModule(inModule.getURN()); ModuleState state = inModule.getState(); if(!state.canBeStarted()) { throw new ModuleStateException(new I18NBoundMessage3P( Messages.MODULE_NOT_STARTED_STATE_INCORRECT, inModule.getURN().toString(), state, ModuleState.STARTABLE_STATES.toString())); inModule.setState(ModuleState.STARTING); } finally { moduleLock.unlock(); throw new ModuleCreationException(e, new I18NBoundMessage1P(Messages.CANNOT_AUTOWIRE_MODULE, inModule.getURN())); inModule.preStart(); startSucceeded = true; Messages.LOG_MODULE_STARTED.info(this, inModule.getURN()); } catch(ModuleException e) { inModule.setLastStartFailure(e.getLocalizedDetail()); Messages.LOG_START_MODULE_FAILED.warn(this,inModule.getURN(),e.getI18NBoundMessage().getText()); throw e; } finally { try {
requesterLock = inRequester.getLock().readLock(); requesterLock.lock(); ModuleState state = inRequester.getState(); if (!(state.canRequestFlows())) { throw new ModuleStateException(new I18NBoundMessage3P( Messages.DATAFLOW_FAILED_REQ_MODULE_STATE_INCORRECT, inRequester.getURN().toString(), state, ModuleState.REQUEST_FLOW_STATES.toString())); modules[modules.length - 1].getURN())) && modules[modules.length - 1].getLock().readLock().lock(); throw new DataFlowException(new I18NBoundMessage1P( Messages.MODULE_NOT_EMITTER, module.getURN().toString())); throw new DataFlowException(new I18NBoundMessage1P( Messages.MODULE_NOT_RECEIVER, module.getURN().toString())); (!module.getState().canParticipateFlows())) { throw new ModuleStateException(new I18NBoundMessage3P( Messages.DATAFLOW_FAILED_PCPT_MODULE_STATE_INCORRECT, module.getURN().toString(), module.getState(), ModuleState.PARTICIPATE_FLOW_STATES.toString())); inRequester == null
/** * The receiver module's URN. * * @return receiver module's URN. */ final ModuleURN getReceiverURN() { return mReceiver.getURN(); }
urn = module.getURN(); if(module.isAutoStart()) { startModule(module);
/** * Returns detailed information on the module given its URN. * * @param inModuleURN the module URN * * @return the detailed module information. * * @throws ModuleNotFoundException if a module with the supplied * URN was not found * @throws InvalidURNException if the supplied URN was invalid. */ public ModuleInfo getModuleInfo(ModuleURN inModuleURN) throws ModuleNotFoundException, InvalidURNException { Module module = getModule(inModuleURN); Set<DataFlowID> initiatedFlows = mDataFlows.getInitiatedFlows(inModuleURN); Set<DataFlowID> participatingFlows = mDataFlows.getFlowsParticipating(inModuleURN); return module.getModuleInfo( initiatedFlows == null ? null : initiatedFlows.toArray(new DataFlowID[initiatedFlows.size()]), participatingFlows == null ? null : participatingFlows.toArray(new DataFlowID[participatingFlows.size()])); }
ModuleURN providerURN = module.getURN().parent(); assert providerURN != null; if(!getModuleFactory(providerURN).isMultipleInstances()) { inModuleURN.toString())); Lock moduleLock = module.getLock().writeLock(); if(!module.getState().canBeDeleted()) { throw new ModuleStateException(new I18NBoundMessage3P( Messages.DELETE_FAILED_MODULE_STATE_INCORRECT, inModuleURN.toString(), module.getState(), ModuleState.DELETABLE_STATES.toString())); inModuleURN.getValue())); mModules.remove(module.getURN()); Messages.LOG_MODULE_DELETED.info(this, inModuleURN); } finally {
/** * The emitter module's URN. * * @return emitter module's URN. */ final ModuleURN getEmitterURN() { return mEmitter.getURN(); }
try { if(inRequester != null) { requesterLock = inRequester.getLock().readLock(); ModuleState state = inRequester.getState(); if (!state.canCancelFlows()) { throw new ModuleStateException(new I18NBoundMessage4P( Messages.CANCEL_FAILED_MODULE_STATE_INCORRECT, inFlowID.getValue(), inRequester.getURN().toString(), state, ModuleState.CANCEL_FLOW_STATES.toString())); : inRequester.getURN()); dataFlowInfo = flow.toDataFlowInfo();
/** * Adds a new module instance to be tracked. * * @param inModule the module instance to track. */ synchronized void add(Module inModule) { mModules.put(inModule.getURN(), inModule); }
@Override public final void send(Object inData) { //ignore data if the request has been canceled if(mRequestCanceled) { return; } mEmitted.incrementAndGet(); SLF4JLoggerProxy.debug(this,"Module {} emitted \"{}\"", //$NON-NLS-1$ mEmitter.getURN(), inData); process(inData); }
return createModuleImpl(inProviderURN, inParameters).getURN();
/** * Cancels the data flow as requested by either the emitter * or receiver module. * * @param inRequester the module requesting cancellation of * the data flow. */ private void cancelDataFlow(Module inRequester) { try { mManager.cancel(mFlowID,inRequester); } catch (Exception e) { Messages.LOG_UNEXPECTED_ERROR_CANCELING_FLOW.error(this, e, mFlowID, inRequester.getURN()); } } /* (non-Javadoc)
@Override public final void dataEmitError(I18NBoundMessage inMessage, boolean inStopDataFlow) { if(mRequestCanceled) { return; } mEmitErrors.incrementAndGet(); mLastEmitError = inMessage.getText(); Messages.LOG_MODULE_EMIT_ERROR.warn(this, mEmitter.getURN(), inMessage.getText()); if(inStopDataFlow) { cancelDataFlow(mEmitter); } }
if(applicationContext == null) { Messages.NO_APPLICATION_CONTEXT_MODULE.warn(this, inModule.getURN()); if(inModule.getClass().isAnnotationPresent(AutowiredModule.class)) { throw new ModuleException(new I18NBoundMessage1P(Messages.MODULE_REQUIRES_AUTOWIRING, inModule.getURN())); Messages.CANNOT_AUTOWIRE_MODULE.warn(this, e, inModule.getURN()); throw new ModuleException(e, new I18NBoundMessage1P(Messages.CANNOT_AUTOWIRE_MODULE, inModule.getURN()));