Source Code Cross Referenced for SequencingEngineSUManager.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:         * SequencingEngineSUManager.java
005:         *
006:         * SUN PROPRIETARY/CONFIDENTIAL
007:         * This software is the proprietary information of Sun Microsystems, Inc.
008:         * Use is subject to license term
009:         */
010:        package com.sun.jbi.engine.sequencing;
011:
012:        import com.sun.jbi.common.Util;
013:        import com.sun.jbi.common.management.ComponentMessageHolder;
014:        import com.sun.jbi.common.management.ManagementMessageBuilder;
015:        import com.sun.jbi.engine.sequencing.servicelist.ServicelistBean;
016:        import com.sun.jbi.engine.sequencing.servicelist.ServicelistReader;
017:        import com.sun.jbi.engine.sequencing.util.DeployHelper;
018:        import com.sun.jbi.engine.sequencing.util.StringTranslator;
019:
020:        import java.util.logging.Logger;
021:
022:        import javax.jbi.component.ComponentContext;
023:        import javax.jbi.management.DeploymentException;
024:
025:        /**
026:         * Service unit manager for SE.
027:         *
028:         * @author Sun Microsystems, Inc.
029:         */
030:        public class SequencingEngineSUManager implements 
031:                javax.jbi.component.ServiceUnitManager,
032:                SequencingEngineResources {
033:            /**
034:             * Component Context.
035:             */
036:            private ComponentContext mContext;
037:
038:            /**
039:             * Helper class for deployment.
040:             */
041:            private DeployHelper mHelper;
042:
043:            /**
044:             * Logger.
045:             */
046:            private Logger mLog;
047:
048:            /**
049:             * Deployer messages.
050:             */
051:            private ManagementMessageBuilder mBuildManagementMessage;
052:
053:            /**
054:             * Service manager which takes care of starting/stopping services.
055:             */
056:            private ServiceManager mManager;
057:
058:            /**
059:             * i18n.
060:             */
061:            private StringTranslator mTranslator;
062:
063:            /**
064:             * Creates a new instance of FileBindingSUManager.
065:             */
066:            public SequencingEngineSUManager() {
067:                mLog = SequencingEngineContext.getInstance().getLogger();
068:                mTranslator = new StringTranslator();
069:            }
070:
071:            /**
072:             * Returns a list of all application sub-assemblies (ASA's) currently
073:             * deployed in to the named component.  This method is a convenient
074:             * wrapper for the same operation in the DeployerMBean.
075:             *
076:             * @return array of SU UUID strings.
077:             */
078:            public String[] getDeployments() {
079:                DeploymentRegistry dr = DeploymentRegistry.getInstance();
080:
081:                return dr.getAllDeployments();
082:            }
083:
084:            /**
085:             * Sets the component context, and SU manager.
086:             *
087:             * @param ctx component context.
088:             * @param manager su manager.
089:             */
090:            public void setValues(ComponentContext ctx, ServiceManager manager) {
091:                mContext = ctx;
092:                mManager = manager;
093:                mBuildManagementMessage = Util.createManagementMessageBuilder();
094:            }
095:
096:            /**
097:             * This method is called by the framework when a deployment request comes
098:             * for the file binding.
099:             *
100:             * @param suId Service unit id.
101:             * @param suPath Service unit path.
102:             *
103:             * @return status message.
104:             *
105:             * @throws javax.jbi.management.DeploymentException deploy exception.
106:             * @throws DeploymentException
107:             */
108:            public String deploy(String suId, String suPath)
109:                    throws javax.jbi.management.DeploymentException {
110:                DeploymentRegistry dr = DeploymentRegistry.getInstance();
111:                String retMsg = null;
112:
113:                if (dr.getDeploymentStatus(suId)) {
114:                    mLog.severe(mTranslator.getString(SEQ_DUPLICATE_DEPLOYMENT,
115:                            suId));
116:                    throw new DeploymentException(createExceptionMessage(
117:                            mContext.getComponentName(), "deploy", "FAILED",
118:                            "SEQ_30001", suId, mTranslator.getString(
119:                                    SEQ_DUPLICATE_DEPLOYMENT, suId), null));
120:                }
121:
122:                try {
123:                    initializeDeployment(suId, suPath);
124:                } catch (DeploymentException de) {
125:                    throw de;
126:                } catch (Exception e) {
127:                    throw new DeploymentException(createExceptionMessage(
128:                            mContext.getComponentName(), "deploy", "FAILED",
129:                            "SEQ_30009", suId, mTranslator.getString(
130:                                    SEQ_XML_STRING_CREATION_FAILED, suId), e));
131:                }
132:
133:                try {
134:                    ComponentMessageHolder compMsgHolder = new ComponentMessageHolder(
135:                            "STATUS_MSG");
136:                    compMsgHolder.setComponentName(mContext.getComponentName());
137:                    compMsgHolder.setTaskName("deploy");
138:                    compMsgHolder.setTaskResult("SUCCESS");
139:
140:                    retMsg = mBuildManagementMessage
141:                            .buildComponentMessage(compMsgHolder);
142:                } catch (Exception e) {
143:                    mLog.severe(mTranslator
144:                            .getString(SEQ_XML_STRING_CREATION_FAILED));
145:                    mLog.severe(e.getMessage());
146:                }
147:
148:                return retMsg;
149:            }
150:
151:            /**
152:             * This method is called by the framework when the deployment has to be \
153:             * initialised , just before starting it.
154:             *
155:             * @param suId service unit id.
156:             * @param suPath service unit path.
157:             *
158:             * @throws javax.jbi.management.DeploymentException DeploymentException
159:             * @throws DeploymentException
160:             */
161:            public void init(String suId, String suPath)
162:                    throws javax.jbi.management.DeploymentException {
163:                DeploymentRegistry dr = DeploymentRegistry.getInstance();
164:
165:                if (!dr.getDeploymentStatus(suId)) {
166:                    try {
167:                        initializeDeployment(suId, suPath);
168:                    } catch (DeploymentException de) {
169:                        throw de;
170:                    } catch (Exception e) {
171:                        throw new DeploymentException(createExceptionMessage(
172:                                mContext.getComponentName(), "deploy",
173:                                "FAILED", "SEQ_30009", suId, mTranslator
174:                                        .getString(
175:                                                SEQ_XML_STRING_CREATION_FAILED,
176:                                                suId), e));
177:                    }
178:                }
179:
180:            }
181:
182:            /**
183:             * Shuts down the service unit.
184:             *
185:             * @param str su id.
186:             *
187:             * @throws javax.jbi.management.DeploymentException depl exception
188:             */
189:            public void shutDown(String str)
190:                    throws javax.jbi.management.DeploymentException {
191:            }
192:
193:            /**
194:             * Starts an SU.
195:             *
196:             * @param suId su id.
197:             *
198:             * @throws javax.jbi.management.DeploymentException DeploymentException
199:             * @throws DeploymentException
200:             */
201:            public void start(String suId)
202:                    throws javax.jbi.management.DeploymentException {
203:
204:                try {
205:                    mManager.startDeployment(suId);
206:                } catch (Exception e) {
207:                    e.printStackTrace();
208:                    throw new DeploymentException(createExceptionMessage(
209:                            mContext.getComponentName(), "deploy", "FAILED",
210:                            "SEQ_30009", suId, mTranslator.getString(
211:                                    SEQ_START_DEPLOYMENT_FAILED, suId), e));
212:                }
213:
214:                if (!mManager.isValid()) {
215:                    mLog.severe(mTranslator.getString(
216:                            SEQ_START_DEPLOYMENT_FAILED, suId));
217:                    mLog.severe(mManager.getError());
218:                    throw new DeploymentException(createExceptionMessage(
219:                            mContext.getComponentName(), "deploy", "FAILED",
220:                            "SEQ_30009", suId, mManager.getError(), null));
221:                }
222:
223:            }
224:
225:            /**
226:             * Stops an SU.
227:             *
228:             * @param suId su id.
229:             *
230:             * @throws javax.jbi.management.DeploymentException DeploymentException
231:             * @throws DeploymentException
232:             */
233:            public void stop(String suId)
234:                    throws javax.jbi.management.DeploymentException {
235:                mManager.stopDeployment(suId);
236:
237:                if (!mManager.isValid()) {
238:                    throw new DeploymentException(createExceptionMessage(
239:                            mContext.getComponentName(), "deploy", "FAILED",
240:                            "SEQ_30009", suId, mManager.getError(), null));
241:                }
242:            }
243:
244:            /**
245:             * Undeploys an SU.
246:             *
247:             * @param suId su id.
248:             * @param suPath su path.
249:             *
250:             * @return management message string.
251:             *
252:             * @throws javax.jbi.management.DeploymentException DeploymentException
253:             * @throws DeploymentException
254:             */
255:            public String undeploy(String suId, String suPath)
256:                    throws javax.jbi.management.DeploymentException {
257:                DeploymentRegistry dr = DeploymentRegistry.getInstance();
258:                ServicelistBean slb = dr.getService(suId);
259:
260:                if (slb == null) {
261:                    throw new DeploymentException(createExceptionMessage(
262:                            mContext.getComponentName(), "undeploy", "FAILED",
263:                            "SEQ_30006", "", "SU not deployed", null));
264:                }
265:
266:                try {
267:                    dr.deregisterService(slb.getNamespace()
268:                            + slb.getServicename() + slb.getEndpointName()
269:                            + slb.getOperation());
270:                } catch (Exception e) {
271:                    throw new DeploymentException(createExceptionMessage(
272:                            mContext.getComponentName(), "undeploy", "FAILED",
273:                            "SEQ_30006", "", e.getMessage(), e));
274:                }
275:
276:                String retMsg = null;
277:
278:                try {
279:                    ComponentMessageHolder compMsgHolder = new ComponentMessageHolder(
280:                            "STATUS_MSG");
281:                    compMsgHolder.setComponentName(mContext.getComponentName());
282:                    compMsgHolder.setTaskName("undeploy");
283:                    compMsgHolder.setTaskResult("SUCCESS");
284:
285:                    retMsg = mBuildManagementMessage
286:                            .buildComponentMessage(compMsgHolder);
287:                } catch (Exception e) {
288:                    mLog.severe(mTranslator
289:                            .getString(SEQ_XML_STRING_CREATION_FAILED));
290:                    mLog.severe(e.getMessage());
291:                }
292:
293:                return retMsg;
294:            }
295:
296:            /**
297:             * helper method to create XML exception string.
298:             *
299:             * @param compid Component id.
300:             * @param oper operation like deploy or undeploy
301:             * @param status success r failure
302:             * @param loctoken some failure string token like SEQ_300001
303:             * @param locparam parameters for error message.
304:             * @param locmessage error message.
305:             * @param exObj stack trace of exception.
306:             *
307:             * @return XML string.
308:             */
309:            private String createExceptionMessage(String compid, String oper,
310:                    String status, String loctoken, String locparam,
311:                    String locmessage, Throwable exObj) {
312:                String[] locParams = new String[1];
313:                locParams[0] = locparam;
314:
315:                ComponentMessageHolder msgMap = new ComponentMessageHolder(
316:                        "EXCEPTION_MSG");
317:
318:                msgMap.setComponentName(compid);
319:                msgMap.setTaskName(oper);
320:                msgMap.setTaskResult(status);
321:                msgMap.setLocToken(1, loctoken);
322:                msgMap.setLocParam(1, locParams);
323:                msgMap.setLocMessage(1, locmessage);
324:                msgMap.setExceptionObject(exObj);
325:
326:                String retMsg = null;
327:
328:                try {
329:                    retMsg = mBuildManagementMessage
330:                            .buildComponentMessage(msgMap);
331:                } catch (Exception e) {
332:                    mLog.severe(mTranslator
333:                            .getString(SEQ_XML_STRING_CREATION_FAILED));
334:                    mLog.severe(e.getMessage());
335:                }
336:
337:                return retMsg;
338:            }
339:
340:            /**
341:             * initalises deployment.
342:             *
343:             * @param suId su id.
344:             * @param suPath su path.
345:             *
346:             * @throws javax.jbi.management.DeploymentException DeploymentException
347:             * @throws DeploymentException
348:             */
349:            private void initializeDeployment(String suId, String suPath)
350:                    throws javax.jbi.management.DeploymentException {
351:                mHelper = new DeployHelper(suId, suPath); // , mResolver);
352:                mHelper.doDeploy(true);
353:
354:                if (!mHelper.isValid()) {
355:                    mLog.severe(mHelper.getError());
356:
357:                    Exception e = mHelper.getException();
358:
359:                    if (e != null) {
360:                        throw new DeploymentException(createExceptionMessage(
361:                                mContext.getComponentName(), "deploy",
362:                                "FAILED", "SEQ_30005", "", mHelper.getError(),
363:                                e));
364:                    } else {
365:                        throw new DeploymentException(createExceptionMessage(
366:                                mContext.getComponentName(), "deploy",
367:                                "FAILED", "SEQ_30005", "", mHelper.getError(),
368:                                null));
369:                    }
370:                }
371:            }
372:
373:            /**
374:             * Starts a deployment.
375:             *
376:             * @param suId su id.
377:             *
378:             * @return management message string.
379:             */
380:            private String startDeployment(String suId) {
381:                String retMsg = null;
382:                mManager.startDeployment(suId);
383:
384:                try {
385:                    ComponentMessageHolder compMsgHolder = new ComponentMessageHolder(
386:                            "STATUS_MSG");
387:                    compMsgHolder.setComponentName(mContext.getComponentName());
388:                    compMsgHolder.setTaskName("deploy");
389:                    compMsgHolder.setTaskResult("SUCCESS");
390:
391:                    if (!mManager.isValid()) {
392:                        compMsgHolder.setTaskResult("FAILED");
393:                        compMsgHolder.setLocMessage(1, mManager.getError());
394:                    } else if (!mManager.getWarning().trim().equals("")) {
395:                        compMsgHolder.setStatusMessageType("WARNING");
396:                        compMsgHolder.setLocMessage(1, mManager.getWarning());
397:                    }
398:
399:                    retMsg = mBuildManagementMessage
400:                            .buildComponentMessage(compMsgHolder);
401:                } catch (Exception e) {
402:                    mLog.severe(mTranslator
403:                            .getString(SEQ_XML_STRING_CREATION_FAILED));
404:                    mLog.severe(e.getMessage());
405:                }
406:
407:                return retMsg;
408:            }
409:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.