Source Code Cross Referenced for ServiceManager.java in  » Workflow-Engines » Dalma » com » sun » jbi » engine » sequencing » 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 » Dalma » com.sun.jbi.engine.sequencing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
002:
003:        /*
004:         * ServiceManager.java
005:         *
006:         * SUN PROPRIETARY/CONFIDENTIAL.
007:         * This software is the proprietary information of Sun Microsystems, Inc.
008:         * Use is subject to license terms.
009:         *
010:         */
011:        package com.sun.jbi.engine.sequencing;
012:
013:        import com.sun.jbi.engine.sequencing.servicelist.ServicelistBean;
014:        import com.sun.jbi.engine.sequencing.util.StringTranslator;
015:        import com.sun.jbi.engine.sequencing.util.UtilBase;
016:
017:        import java.util.Iterator;
018:        import java.util.Vector;
019:        import java.util.logging.Logger;
020:
021:        import javax.jbi.component.ComponentContext;
022:        import javax.jbi.servicedesc.ServiceEndpoint;
023:
024:        import javax.xml.namespace.QName;
025:
026:        /**
027:         * Manages all the stopping and starting of services.
028:         *
029:         * @author Sun Microsystems, Inc.
030:         */
031:        public class ServiceManager extends UtilBase implements 
032:                SequencingEngineResources {
033:            /**
034:             * Wait time for thread.
035:             */
036:            private static final long WAIT_TIME = 2000;
037:
038:            /**
039:             * Binding Channel.
040:             */
041:            private ComponentContext mContext;
042:
043:            /**
044:             * Deployment Registry.
045:             */
046:            private DeploymentRegistry mRegistry;
047:
048:            /**
049:             * Logger object.
050:             */
051:            private Logger mLog;
052:
053:            /**
054:             * Translator object for internationalization.
055:             */
056:            private StringTranslator mTranslator;
057:
058:            /**
059:             * List of active services.
060:             */
061:            private Vector mActiveServices;
062:
063:            /**
064:             * Creates a new ServiceManager object.
065:             */
066:            public ServiceManager() {
067:                mRegistry = DeploymentRegistry.getInstance();
068:                mActiveServices = new Vector();
069:                mLog = SequencingEngineContext.getInstance().getLogger();
070:                mTranslator = new StringTranslator();
071:            }
072:
073:            /**
074:             * Sets the channel object.
075:             *
076:             * @param ctx engine channel object.
077:             */
078:            public void setContext(ComponentContext ctx) {
079:                mContext = ctx;
080:            }
081:
082:            /**
083:             * Returns the number of services actually running.
084:             *
085:             * @return int number of running services.
086:             */
087:            public int getRunningServicesCount() {
088:                int count = 0;
089:
090:                return count;
091:            }
092:
093:            /**
094:             * Activates all the registered Services.
095:             */
096:            public void activateServices() {
097:                /*Query Registry and get services
098:                 */
099:                Iterator iter = mRegistry.listAllServices();
100:
101:                if (iter == null) {
102:                    mLog.info(mTranslator.getString(SEQ_NO_SERVICES));
103:
104:                    return;
105:                }
106:
107:                while (iter.hasNext()) {
108:                    String ep = (String) iter.next();
109:                    ServicelistBean eb = mRegistry.findService(ep);
110:
111:                    if (eb == null) {
112:                        mLog.severe(mTranslator.getString(
113:                                SEQ_START_SERVICE_FAILED, ep));
114:                        setError(mTranslator.getString(
115:                                SEQ_START_SERVICE_FAILED, ep));
116:
117:                        continue;
118:                    }
119:
120:                    startDeployment(eb.getDeploymentId());
121:                }
122:
123:                mLog.fine(mTranslator.getString(SEQ_ACTIVATE_SERVICES_DONE));
124:            }
125:
126:            /**
127:             * Starts a deployment.
128:             *
129:             * @param asid sub-assembly id
130:             */
131:            public void startDeployment(String asid) {
132:                mLog.fine(mTranslator.getString(SEQ_START_DEPLOYMENT, asid));
133:
134:                ServicelistBean eb = (ServicelistBean) mRegistry
135:                        .getService(asid);
136:                clear();
137:
138:                if (eb == null) {
139:                    mLog.severe(mTranslator.getString(
140:                            SEQ_START_DEPLOYMENT_FAILED_BEANNULL, asid));
141:
142:                    setError(mTranslator.getString(
143:                            SEQ_START_DEPLOYMENT_FAILED_BEANNULL, asid));
144:
145:                    return;
146:                }
147:
148:                try {
149:                    ServiceEndpoint ref = mContext.activateEndpoint(new QName(
150:                            eb.getNamespace(), eb.getServicename()), eb
151:                            .getEndpointName());
152:                    eb.setServiceReference(ref);
153:                    mLog.fine(mTranslator.getString(
154:                            SEQ_ACTIVATE_INBOUND_SUCCESS, eb.getServicename()));
155:                } catch (javax.jbi.JBIException me) {
156:                    mLog.severe(mTranslator.getString(
157:                            SEQ_ACTIVATE_INBOUND_FAILED, eb.getServicename()));
158:                    mLog.severe(me.getMessage());
159:                    setError(mTranslator.getString(SEQ_ACTIVATE_INBOUND_FAILED,
160:                            eb.getServicename()));
161:                    setException(me);
162:                }
163:
164:                mLog.fine(mTranslator.getString(SEQ_START_DEPLOYMENT_SUCCESS,
165:                        asid));
166:            }
167:
168:            /**
169:             * Stops all running services.
170:             */
171:            public void stopAllServices() {
172:                if (mActiveServices == null) {
173:                    return;
174:                }
175:
176:                if (mActiveServices.isEmpty()) {
177:                    return;
178:                }
179:
180:                MessageRegistry reg = MessageRegistry.getInstance();
181:
182:                if (!reg.isEmpty()) {
183:                    try {
184:                        Thread.sleep(WAIT_TIME);
185:                    } catch (Exception e) {
186:                        ;
187:                    }
188:                }
189:
190:                if (!reg.isEmpty()) {
191:                    mLog.info(mTranslator.getString(SEQ_STOP_ACTIVE_EXCHANGE));
192:                } else {
193:                    mLog.info(mTranslator.getString(SEQ_STOP_EXCHANGES_DONE));
194:                }
195:            }
196:
197:            /**
198:             * Stops a deployment.
199:             *
200:             * @param asid sub-assembly id
201:             */
202:            public void stopDeployment(String asid) {
203:                super .clear();
204:
205:                Iterator iter = mActiveServices.iterator();
206:                mLog.info(mTranslator.getString(SEQ_STOP_DEPLOYMENT, asid));
207:
208:                ServicelistBean sb = mRegistry.getService(asid);
209:
210:                if (sb == null) {
211:                    setError(mTranslator.getString(SEQ_STOP_DEPLOYMENT_FAILED));
212:                }
213:
214:                if (sb.isExecuting()) {
215:                    setError(mTranslator.getString(SEQ_DEPLOYMENT_EXECUTING,
216:                            asid));
217:
218:                    return;
219:                }
220:
221:                try {
222:                    mContext.deactivateEndpoint(sb.getServiceReference());
223:                } catch (Exception e) {
224:                    setError("Cannot deactivate endpoint");
225:                    setException(e);
226:                }
227:
228:                mLog.info(mTranslator.getString(SEQ_STOP_DEPLOYMENT_SUCCESS,
229:                        asid));
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.