Java Reference
In-Depth Information
public
void contextInitialized(ServletContextEvent event) {
System.out.println("Initializing Workflow context...");
ServletContext context
#
event.getServletContext();
System.out.println("1) Definition of organization");
try
{
// We define two basic example profiles: professor and
// student; they are actors that can interact with WFMS
Actor prof
#
new
Actor("Prof Essor","professor");
Actor student
#
new
Actor("John Learner","student");
WfEngine.Organization org
#
new
WfEngine.Organization();
org.Add(prof);
org.Add(student);
context.setAttribute("organization",org);
System.out.println("2) Load definitions of processes");
// The processes are loaded from an xml file
WfEngine.Catalog cat
#
new
WfEngine.Catalog();
DocumentBuilder parser
#
DocumentBuilderFactory.
newInstance().newDocumentBuilder();
Document doc
#
parser.parse(
context.getResourceAsStream("test.xml"));
cat.Add(WfProcessDefinition.loadDefinitions(doc));
context.setAttribute("catalog",cat);
}
catch
(Exception e){
e.printStackTrace();
e.toString();
}
System.out.println("WfMS Initialization Completed.");
}
public
void contextDestroyed
(ServletContextEvent event) { }
}
The initial page is
Login.jsp
. To simplify the application we ignore all of the
security problems and allow the login without any authentication. The
Login
page presents a list of actors the user can choose to impersonate; they are
taken from the actors registered within the organization.
<%@
page contentType
#
"text/html" language
#
"java"
%>
<%@
page
import
#
"WfEngine.*, java.util.Iterator"
%>
<%
Organization org
#
(Organization)application.getAttribute
("organization");
%>
<html><head><title>
Workflow
</title></head>
<body><h1>
Workflow Login
</h1>
<table
>
<tr
>
<td
align
#
"center">