Source Code Cross Referenced for InMemoryBpmScriptLifeCycle.java in  » Workflow-Engines » bpmscript » org » bpmscript » jbi » component » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » bpmscript » org.bpmscript.jbi.component 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.bpmscript.jbi.component;
018:
019:        import java.util.Arrays;
020:        import java.util.LinkedList;
021:        import java.util.List;
022:
023:        import javax.jbi.JBIException;
024:        import javax.xml.namespace.QName;
025:
026:        import org.apache.servicemix.common.BaseComponent;
027:        import org.apache.servicemix.common.BaseLifeCycle;
028:        import org.apache.servicemix.common.Endpoint;
029:        import org.apache.servicemix.common.xbean.XBeanServiceUnit;
030:        import org.bpmscript.IProcess;
031:        import org.bpmscript.IProcessExecutor;
032:        import org.bpmscript.IProcessInstanceManager;
033:        import org.bpmscript.IProcessManager;
034:        import org.bpmscript.InMemoryProcessExecutor;
035:        import org.bpmscript.InMemoryProcessManager;
036:        import org.bpmscript.XStreamMarshaler;
037:        import org.bpmscript.jbi.PojoServiceEndpoint;
038:        import org.bpmscript.remote.RemoteProcessManager;
039:
040:        /**
041:         * Fast in memory lifecycle. Constructs only in memory versions of the
042:         * process managers etc.
043:         */
044:        public class InMemoryBpmScriptLifeCycle extends BaseLifeCycle {
045:
046:            protected IProcessManager processManager;
047:            protected IProcessInstanceManager processInstanceManager;
048:            protected IProcessExecutor processExecutor;
049:            protected String defaultNamespace = "http://bpmscript.org/jbi";
050:            protected List<String> libraries = new LinkedList<String>(
051:                    Arrays
052:                            .asList(new String(
053:                                    "classpath:/org/bpmscript/jbi/component/bpmscriptlibrary.js")));
054:            protected Endpoint alarmEndpoint = null;
055:            protected CorellationEndpoint corellationEndpoint = null;
056:            protected PojoServiceEndpoint remoteProcessManagerEndpoint = null;
057:            protected XBeanServiceUnit defaultServiceUnit = null;
058:            protected XBeanServiceUnit processServiceUnit = null;
059:
060:            public InMemoryBpmScriptLifeCycle(BaseComponent component) {
061:                super (component);
062:            }
063:
064:            @Override
065:            protected void doInit() throws Exception {
066:                super .doInit();
067:                // TODO: consider changing this or throwing an exception
068:                if (processManager == null && processInstanceManager == null) {
069:                    InMemoryProcessManager defaultProcessManager = new InMemoryProcessManager();
070:                    processManager = defaultProcessManager;
071:                    processInstanceManager = defaultProcessManager;
072:                }
073:                if (processExecutor == null) {
074:                    InMemoryProcessExecutor defaultProcessExecutor = new InMemoryProcessExecutor();
075:                    defaultProcessExecutor.setLibraries(libraries);
076:                    defaultProcessExecutor.setProcessManager(processManager);
077:                    processExecutor = defaultProcessExecutor;
078:                }
079:                if (alarmEndpoint == null) {
080:                    alarmEndpoint = new AlarmEndpoint();
081:                    alarmEndpoint.setService(new QName(defaultNamespace,
082:                            "alarm"));
083:                    alarmEndpoint.setEndpoint("alarm");
084:                }
085:                if (remoteProcessManagerEndpoint == null) {
086:                    remoteProcessManagerEndpoint = new PojoServiceEndpoint();
087:                    remoteProcessManagerEndpoint.setService(new QName(
088:                            defaultNamespace, "remoteProcessManager"));
089:                    remoteProcessManagerEndpoint.setEndpoint("processManager");
090:                    remoteProcessManagerEndpoint
091:                            .setMarshaler(new XStreamMarshaler());
092:                    RemoteProcessManager remoteProcessManager = new RemoteProcessManager();
093:                    remoteProcessManager.setProcessManager(processManager);
094:                    remoteProcessManagerEndpoint.setPojo(remoteProcessManager);
095:                }
096:                if (corellationEndpoint == null) {
097:                    corellationEndpoint = new CorellationEndpoint();
098:                    corellationEndpoint.setService(new QName(defaultNamespace,
099:                            "corellator"));
100:                    corellationEndpoint.setEndpoint("corellator");
101:                    corellationEndpoint
102:                            .setLibrary("classpath:/org/bpmscript/jbi/component/corellation.js");
103:                }
104:                defaultServiceUnit = new XBeanServiceUnit();
105:                defaultServiceUnit.setComponent(component);
106:
107:                alarmEndpoint.setServiceUnit(defaultServiceUnit);
108:                remoteProcessManagerEndpoint.setServiceUnit(defaultServiceUnit);
109:                corellationEndpoint.setServiceUnit(defaultServiceUnit);
110:
111:                defaultServiceUnit.addEndpoint(alarmEndpoint);
112:                defaultServiceUnit.addEndpoint(remoteProcessManagerEndpoint);
113:                defaultServiceUnit.addEndpoint(corellationEndpoint);
114:
115:                defaultServiceUnit.setName("default");
116:
117:                processServiceUnit = new XBeanServiceUnit();
118:                processServiceUnit.setName("process");
119:                processServiceUnit.setComponent(component);
120:
121:                // TODO: we'll have to rethink if we don't want to distribute
122:                // processes to containers that don't expect them.
123:                List<IProcess> primaryProcesses = processManager
124:                        .getPrimaryProcesses();
125:                for (IProcess process : primaryProcesses) {
126:                    ProcessEndpoint processEndpoint = new ProcessEndpoint();
127:                    processEndpoint.setService(new QName(defaultNamespace,
128:                            process.getName()));
129:                    processEndpoint.setProcessId(process.getId());
130:                    processEndpoint
131:                            .setProcessInstanceManager(processInstanceManager);
132:                    processEndpoint.setProcessExecutor(processExecutor);
133:                    processEndpoint.setServiceUnit(processServiceUnit);
134:                    processEndpoint.setEndpoint(process.getName());
135:                    processServiceUnit.addEndpoint(processEndpoint);
136:                }
137:
138:                component.getRegistry().registerServiceUnit(defaultServiceUnit);
139:                component.getRegistry().registerServiceUnit(processServiceUnit);
140:            }
141:
142:            @Override
143:            public void start() throws JBIException {
144:                super .start();
145:                try {
146:                    defaultServiceUnit.start();
147:                    processServiceUnit.start();
148:                } catch (Exception e) {
149:                    throw new JBIException(e);
150:                }
151:            }
152:
153:            @Override
154:            public void stop() throws JBIException {
155:                super .stop();
156:                try {
157:                    defaultServiceUnit.stop();
158:                    processServiceUnit.stop();
159:                } catch (Exception e) {
160:                    throw new JBIException(e);
161:                }
162:            }
163:
164:            @Override
165:            public void shutDown() throws JBIException {
166:                super .shutDown();
167:                try {
168:                    defaultServiceUnit.shutDown();
169:                    processServiceUnit.shutDown();
170:                } catch (Exception e) {
171:                    throw new JBIException(e);
172:                }
173:            }
174:
175:            public IProcessManager getProcessManager() {
176:                return processManager;
177:            }
178:
179:            public void setProcessManager(IProcessManager processManager) {
180:                this .processManager = processManager;
181:            }
182:
183:            public String getDefaultNamespace() {
184:                return defaultNamespace;
185:            }
186:
187:            public void setDefaultNamespace(String defaultNamespace) {
188:                this .defaultNamespace = defaultNamespace;
189:            }
190:
191:            public IProcessExecutor getProcessExecutor() {
192:                return processExecutor;
193:            }
194:
195:            public void setProcessExecutor(IProcessExecutor processExecutor) {
196:                this .processExecutor = processExecutor;
197:            }
198:
199:            public List<String> getLibraries() {
200:                return libraries;
201:            }
202:
203:            public void setLibraries(List<String> libraries) {
204:                this .libraries = libraries;
205:            }
206:
207:            public XBeanServiceUnit getProcessServiceUnit() {
208:                return processServiceUnit;
209:            }
210:
211:            public void setProcessServiceUnit(
212:                    XBeanServiceUnit processServiceUnit) {
213:                this .processServiceUnit = processServiceUnit;
214:            }
215:
216:            public void setAlarmEndpoint(Endpoint alarmEndpoint) {
217:                this.alarmEndpoint = alarmEndpoint;
218:            }
219:
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.