📄 integrationconfigurator.java
字号:
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as
* published by JBoss Inc.; either version 1.0 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
package org.jbpm.bpel.integration.server;
import javax.jms.JMSException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.bpel.BpelException;
import org.jbpm.bpel.app.AppDescriptor;
import org.jbpm.bpel.graph.def.BpelDefinition;
import org.jbpm.bpel.integration.jms.IntegrationControl;
import org.jbpm.bpel.integration.jms.JmsIntegrationServiceFactory;
/**
* @author Alejandro Guizar
* @version $Revision: 1.1 $ $Date: 2007/01/18 14:10:10 $
*/
public class IntegrationConfigurator implements ServletContextListener {
private static final Log log = LogFactory.getLog(IntegrationConfigurator.class);
public void contextInitialized(ServletContextEvent ev) {
// read the bpel app descriptor
AppDescriptor appDescriptor = AppDescriptor.readAppDescriptor();
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
// get the integration control of the process referenced in the descriptor
BpelDefinition processDefinition = appDescriptor.findProcessDefinition(jbpmContext);
IntegrationControl integrationControl = JmsIntegrationServiceFactory.getInstance(
jbpmConfiguration)
.getIntegrationControl(processDefinition);
// make the descriptor available to service activities
integrationControl.setAppDescriptor(appDescriptor);
// start receiving requests
integrationControl.enableInboundMessageActivities(jbpmContext);
// inject the integration control in the servlet context
ev.getServletContext().setAttribute(SoapHandler.INTEGRATION_CONTROL_ATTR,
integrationControl);
log.info("Message reception enabled for process: "
+ appDescriptor.getName());
}
catch (Exception e) {
jbpmContext.setRollbackOnly();
if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new BpelException("could not start bpel application", e);
}
finally {
jbpmContext.close();
}
}
public void contextDestroyed(ServletContextEvent ev) {
IntegrationControl integrationControl = (IntegrationControl) ev.getServletContext()
.getAttribute(SoapHandler.INTEGRATION_CONTROL_ATTR);
try {
integrationControl.disableInboundMessageActivities();
log.info("Message reception disabled for process: "
+ integrationControl.getAppDescriptor().getName());
}
catch (JMSException e) {
log.error("could not stop bpel application", e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -