Source Code Cross Referenced for SequencingEngineSUManager.java in  » ESB » open-esb » 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 » ESB » open esb » com.sun.jbi.engine.sequencing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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