Source Code Cross Referenced for BpmScriptDeployer.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.io.File;
020:        import java.io.FileNotFoundException;
021:        import java.io.IOException;
022:
023:        import javax.jbi.management.DeploymentException;
024:        import javax.xml.namespace.QName;
025:
026:        import org.apache.servicemix.common.AbstractDeployer;
027:        import org.apache.servicemix.common.BaseComponent;
028:        import org.apache.servicemix.common.Endpoint;
029:        import org.apache.servicemix.common.ServiceUnit;
030:        import org.bpmscript.BpmScriptException;
031:        import org.bpmscript.FileUtils;
032:        import org.bpmscript.IProcessInstanceManager;
033:        import org.bpmscript.IProcessManager;
034:
035:        public class BpmScriptDeployer extends AbstractDeployer {
036:
037:            public BpmScriptDeployer(BaseComponent component) {
038:                super (component);
039:            }
040:
041:            protected boolean validate(Endpoint endpoint)
042:                    throws DeploymentException {
043:                if (endpoint instanceof  ProcessEndpoint == false) {
044:                    throw new DeploymentException(
045:                            "Endpoint should be a ProcessEndpoint");
046:                }
047:                ((ProcessEndpoint) endpoint).validate();
048:                return true;
049:            }
050:
051:            public ServiceUnit deploy(String serviceUnitName,
052:                    String serviceUnitRootPath) throws DeploymentException {
053:
054:                BpmScriptLifeCycle lifeCycle = (BpmScriptLifeCycle) component
055:                        .getLifeCycle();
056:                IProcessInstanceManager processInstanceManager = lifeCycle
057:                        .getProcessInstanceManager();
058:                IProcessManager processManager = lifeCycle.getProcessManager();
059:                logger.info("Deploying service unit " + serviceUnitName);
060:
061:                String processId;
062:                try {
063:                    processId = processManager.createProcess("serviceunit",
064:                            serviceUnitName, true);
065:                    processManager.addSourceToProcess(processId, "main",
066:                            FileUtils.getFileContents(serviceUnitRootPath,
067:                                    "main.js"), true);
068:                    processManager.setProcessAsPrimary(processId);
069:
070:                    ServiceUnit serviceUnit = new ServiceUnit(component);
071:                    serviceUnit.setName(serviceUnitName);
072:                    serviceUnit.setRootPath(serviceUnitRootPath);
073:
074:                    QName service = new QName(lifeCycle.getDefaultNamespace(),
075:                            serviceUnitName);
076:
077:                    // TODO: create a service unit for each end point rather than bunging them
078:                    // all in the same service unit
079:                    if (component.getComponentContext().getEndpoint(service,
080:                            serviceUnitName) == null) {
081:                        ProcessEndpoint processEndpoint = new ProcessEndpoint();
082:                        processEndpoint.setProcessId(processId);
083:                        processEndpoint
084:                                .setProcessInstanceManager(processInstanceManager);
085:                        processEndpoint.setProcessExecutor(lifeCycle
086:                                .getProcessExecutor());
087:                        processEndpoint.setServiceUnit(serviceUnit);
088:                        processEndpoint.setService(service);
089:                        processEndpoint.setEndpoint(serviceUnitName);
090:                        serviceUnit.addEndpoint(processEndpoint);
091:                    } else {
092:                        logger
093:                                .info("endpoint already registered, updating service unit");
094:                    }
095:
096:                    logger.info("done");
097:                    return serviceUnit;
098:                } catch (BpmScriptException e) {
099:                    throw new DeploymentException(e);
100:                } catch (FileNotFoundException e) {
101:                    throw new DeploymentException(e);
102:                } catch (IOException e) {
103:                    throw new DeploymentException(e);
104:                }
105:            }
106:
107:            public boolean canDeploy(String serviceUnitName,
108:                    String serviceUnitRootPath) {
109:                File main = new File(serviceUnitRootPath, getMainFile() + ".js");
110:                if (logger.isDebugEnabled()) {
111:                    logger.debug("Looking for " + main + ": " + main.exists());
112:                }
113:                return main.exists();
114:            }
115:
116:            private String getMainFile() {
117:                return "main";
118:            }
119:
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.