use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testChannelClosed_StopWorkflow.
@Test
public void testChannelClosed_StopWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
ObjectName channelObj = channelManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
channelManagerProxy.requestClose(TIMEOUT_MILLIS);
try {
workflowManagerProxy.requestStop(TIMEOUT_MILLIS);
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(ClosedState.getInstance(), StoppedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testStart.
@Test
public void testStart() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
adapterManager.requestStart();
assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
workflowManagerProxy.requestStop(TIMEOUT_MILLIS);
assertEquals(StoppedState.getInstance(), workflowManagerProxy.getComponentState());
workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testMessageCounter_Enabled_AlreadyHasMessageCounter.
@Test
public void testMessageCounter_Enabled_AlreadyHasMessageCounter() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
Workflow workflow = createWorkflow("w1");
workflow.getInterceptors().add(new MessageMetricsInterceptor(getName(), null));
new WorkflowManager(workflow, channelManager);
assertEquals(2, workflow.getInterceptors().size());
assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
assertEquals(getName(), workflow.getInterceptors().get(0).getUniqueId());
assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class ChannelManager method addWorkflow.
@Override
public ObjectName addWorkflow(String xml) throws CoreException, IllegalStateException, MalformedObjectNameException {
ensureState(ClosedState.getInstance());
Workflow newWorkflow = (Workflow) DefaultMarshaller.getDefaultMarshaller().unmarshal(xml);
WorkflowManager workflowManager = new WorkflowManager(newWorkflow, this);
LifecycleHelper.prepare(newWorkflow);
// We don't need to "store" the XML at this point, as channelManager will eventually call
// addChild() and that's when that happens.
// marshalAndSendNotification();
getParent().childUpdated();
workflowManager.registerMBean();
return workflowManager.createObjectName();
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class ChannelManager method initMembers.
private void initMembers() throws MalformedObjectNameException, CoreException {
if (isEmpty(channel.getUniqueId())) {
throw new CoreException("No UniqueID, this channel cannot be managed");
}
// Builds up a name com.adaptris:type=Channel, adapter=<adapter-id,>, id=<channel-id>
myObjectName = ObjectName.getInstance(JMX_CHANNEL_TYPE + ADAPTER_PREFIX + parent.getUniqueId() + ID_PREFIX + getWrappedComponent().getUniqueId());
for (Workflow c : channel.getWorkflowList()) {
if (!isEmpty(c.getUniqueId())) {
addChild(new WorkflowManager(c, this, true), true);
}
}
addChildJmxComponentQuietly((ChildRuntimeInfoComponent) RuntimeInfoComponentFactory.create(this, channel.getMessageErrorHandler()));
marshalConfig();
}
Aggregations