Source Code Cross Referenced for TransformationEngineSUManager.java in  » ESB » open-esb » com » sun » jbi » engine » xslt » 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.xslt 
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:         * @(#)TransformationEngineSUManager.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.xslt;
030:
031:        import com.sun.jbi.engine.xslt.util.DeployHelper;
032:        import com.sun.jbi.engine.xslt.util.DeploymentLister;
033:        import com.sun.jbi.engine.xslt.util.ServiceManager;
034:        import com.sun.jbi.engine.xslt.util.StringTranslator;
035:
036:        import java.io.File;
037:
038:        import java.util.logging.Logger;
039:
040:        import javax.jbi.component.ComponentContext;
041:        import javax.jbi.component.ServiceUnitManager;
042:        import com.sun.jbi.common.management.ComponentMessageHolder;
043:        import javax.jbi.management.DeploymentException;
044:        import com.sun.jbi.common.management.ManagementMessageBuilder;
045:        import javax.jbi.messaging.MessagingException;
046:        import com.sun.jbi.common.Util;
047:
048:        import javax.management.ObjectInstance;
049:        import javax.management.ObjectName;
050:
051:        /**
052:         *
053:         * @author Sun Microsystems, Inc.
054:         */
055:        public class TransformationEngineSUManager implements 
056:                ServiceUnitManager, TEResources {
057:            /**
058:             *    
059:             */
060:            private static final int BUFFER = 2048;
061:
062:            /**
063:             *    
064:             */
065:            private ComponentContext mContext = null;
066:
067:            /**
068:             *    
069:             */
070:            private Logger mLogger = null;
071:
072:            /**
073:             *    
074:             */
075:            private ManagementMessageBuilder mBuildManagementMessage;
076:
077:            /**
078:             *    
079:             */
080:            private ServiceManager mServiceManager = null;
081:
082:            /**
083:             *    
084:             */
085:            private StringTranslator mTranslator = null;
086:
087:            /**
088:             *    
089:             */
090:            private String[] mAppsDeployed;
091:
092:            /**
093:             * Creates a new TransformationEngineSUManager object.
094:             */
095:            public TransformationEngineSUManager() {
096:                mTranslator = new StringTranslator("com.sun.jbi.engine.xslt",
097:                        this .getClass().getClassLoader());
098:                mServiceManager = ServiceManager.getInstance();
099:
100:            }
101:
102:            /**
103:             * Sets the ComponentContext object on the TransformationEngineSUManager object.
104:             *
105:             * @param ctx ComponentContext object required for Deployment
106:             *
107:             */
108:            public void setContext(ComponentContext ctx) {
109:                mContext = ctx;
110:                mLogger = TransformationEngineContext.getInstance().getLogger(
111:                        "");
112:                mBuildManagementMessage = Util.createManagementMessageBuilder();
113:            }
114:
115:            /**
116:             * Returns a boolean value indicating whether the Service Unit is currently
117:             * deployed.
118:             *
119:             * @param serviceUnitID - Id of the Service Unit
120:             *
121:             * @return boolean value indicating whether the Sercvice Unit is currently
122:             *         deployed
123:             */
124:            public boolean isDeployed(String serviceUnitID) {
125:                return mServiceManager.getDeploymentStatus(serviceUnitID);
126:            }
127:
128:            /**
129:             * Returns a description of a deployed sub-assembly.
130:             *
131:             * @param serviceUnitID - ID of the Service Unit
132:             *
133:             * @return Description for the given Service Unit
134:             */
135:            public String getDeploymentInfo(String serviceUnitID) {
136:                return null;
137:            }
138:
139:            // ***************************************************************//
140:
141:            /**
142:             * Returns a list of all application sub-assemblies (Service Unit's)
143:             * currently deployed in to the named component.  This method is a
144:             * convenience wrapper for the same operation in the DeployerMBean.
145:             *
146:             * @return array of Service Unit ID strings.
147:             */
148:            public String[] getDeployments() {
149:                if ((mContext == null) || (mContext.getInstallRoot() == null)) {
150:                    return null;
151:                }
152:
153:                mAppsDeployed = DeploymentLister
154:                        .getFolderNameListing(new File(mContext
155:                                .getInstallRoot()
156:                                + File.separatorChar
157:                                + mTranslator.getString(TEResources.SYSTEM)
158:                                + File.separatorChar
159:                                + mTranslator.getString(TEResources.DEPLOYMENT)));
160:
161:                return mAppsDeployed;
162:            }
163:
164:            //***************************************************************//
165:            //******* Implementation of ServiceUnitManager interface ********//
166:            //***************************************************************//
167:
168:            /**
169:             * Initiate a Service Deployment.
170:             *
171:             * @param serviceUnitID - ID of the Service Unit being deployed
172:             * @param serviceUnitRootPath - Full path to the Service Unit root.
173:             *
174:             * @return NOT YET DOCUMENTED
175:             *
176:             * @throws DeploymentException Deployer Exception
177:             */
178:            public String deploy(String serviceUnitID,
179:                    String serviceUnitRootPath) throws DeploymentException {
180:                String retMsg = null;
181:
182:                mLogger
183:                        .finer("TransformationEngineSUManager::deploy serviceUnitRootPath = "
184:                                + serviceUnitRootPath);
185:
186:                if (mServiceManager.getDeploymentStatus(serviceUnitID)) {
187:                    mLogger
188:                            .severe(serviceUnitID
189:                                    + mTranslator
190:                                            .getString(TEResources.ALREADY_DEPLOYED_ON_TE));
191:                    throw new DeploymentException(
192:                            createExceptionMessage(
193:                                    mContext.getComponentName(),
194:                                    "deploy",
195:                                    "FAILED",
196:                                    "TESE_30001",
197:                                    serviceUnitID,
198:                                    "Duplicate Service Unit ID {1} not supported",
199:                                    null));
200:                }
201:
202:                mServiceManager.setComponentContext(mContext);
203:
204:                /**
205:                 * You have to call initialize deployments here because, thats where
206:                 * the schema check and data check are made, you want to fail the
207:                 * deployment if the artifact fails validation. The same stuff is done
208:                 * in init also during component starts , but if you dont do it here u
209:                 * cannot fail deployments because of invalid data
210:                 */
211:                try {
212:                    initializeDeployment(serviceUnitID, serviceUnitRootPath);
213:
214:                    /*
215:                     * Do not start deployments here.
216:                     * The Deployment service will call init and start separately
217:                     * after finidhing the deploy method
218:                     */
219:                } catch (DeploymentException de) {
220:                    throw de;
221:                } catch (Exception e) {
222:                    throw new DeploymentException(createExceptionMessage(
223:                            mContext.getComponentName(), "deploy", "FAILED",
224:                            "TESE_212", serviceUnitID, mTranslator
225:                                    .getString(TE_CANNOT_CREATE_XML_MESSAGE,
226:                                            serviceUnitID), e));
227:                }
228:
229:                try {
230:                    ComponentMessageHolder compMsgHolder = new ComponentMessageHolder(
231:                            "STATUS_MSG");
232:                    compMsgHolder.setComponentName(mContext.getComponentName());
233:                    compMsgHolder.setTaskName("deploy");
234:                    compMsgHolder.setTaskResult(mTranslator
235:                            .getString(TEResources.SUCCESS));
236:
237:                    retMsg = mBuildManagementMessage
238:                            .buildComponentMessage(compMsgHolder);
239:                } catch (Exception ex) {
240:                    mLogger
241:                            .severe(mTranslator
242:                                    .getString(TEResources.TE_CANNOT_CREATE_XML_MESSAGE)
243:                                    + ex.getMessage());
244:                }
245:
246:                return retMsg;
247:            }
248:
249:            /**
250:             * Initializes the deployments, parses and loads the config file.
251:             *
252:             * @param suId service unit id.
253:             * @param suPath service unit path.
254:             *
255:             * @throws javax.jbi.management.DeploymentException deploy exception.
256:             * @throws DeploymentException
257:             */
258:            private void initializeDeployment(String serviceUnitID,
259:                    String serviceUnitRootPath)
260:                    throws javax.jbi.management.DeploymentException {
261:
262:                DeployHelper dh = new DeployHelper(serviceUnitID,
263:                        serviceUnitRootPath, mContext);
264:
265:                if (dh.isValid()) {
266:                    dh.doDeploy();
267:                } else {
268:                    mLogger.severe(dh.getError());
269:
270:                    Exception e = dh.getException();
271:
272:                    if (e != null) {
273:                        throw new DeploymentException(createExceptionMessage(
274:                                mContext.getComponentName(), "deploy",
275:                                "FAILED", "TESE_218", "", dh.getError(), e));
276:                    } else {
277:                        throw new DeploymentException(createExceptionMessage(
278:                                mContext.getComponentName(), "deploy",
279:                                "FAILED", "TESE_223", "", dh.getError(), null));
280:                    }
281:                }
282:            }
283:
284:            /**
285:             * Initialize the deployment. This is the first phase of a two-phase start,
286:             * where the component must prepare  to receive service requests related
287:             * to the deployment (if any).
288:             *
289:             * @param serviceUnitID service unit ID
290:             * @param serviceUnitRootPath service unit Root Path
291:             *
292:             * @throws DeploymentException deployement exception
293:             */
294:            public void init(String serviceUnitID, String serviceUnitRootPath)
295:                    throws DeploymentException {
296:                mLogger.finer("init called for " + serviceUnitID);
297:                try {
298:                    initializeDeployment(serviceUnitID, serviceUnitRootPath);
299:
300:                    /*
301:                     * Do not start deployments here.
302:                     * The Deployment service will call init and start separately
303:                     * after finidhing the deploy method
304:                     */
305:                } catch (DeploymentException de) {
306:                    throw de;
307:                } catch (Exception e) {
308:                    throw new DeploymentException(createExceptionMessage(
309:                            mContext.getComponentName(), "deploy", "FAILED",
310:                            "TESE_316", serviceUnitID, mTranslator
311:                                    .getString(TE_CANNOT_CREATE_XML_MESSAGE,
312:                                            serviceUnitID), e));
313:                }
314:            }
315:
316:            /**
317:             * Shut down the deployment. This causes the deployment to return to the
318:             * state it was in after deploy() and before init().
319:             *
320:             * @param serviceUnitID service unit ID
321:             *
322:             * @throws DeploymentException deployment exception
323:             */
324:            public void shutDown(String serviceUnitID)
325:                    throws DeploymentException {
326:                mLogger.finer("shutDown called for " + serviceUnitID);
327:            }
328:
329:            /**
330:             * Start the deployment. This is the second phase of a two-phase start,
331:             * where the component can now  initiate service requests related to the
332:             * deployment.
333:             *
334:             * @param serviceUnitID service unit ID
335:             *
336:             * @throws DeploymentException deployment exception
337:             */
338:            public void start(String serviceUnitID) throws DeploymentException {
339:                mLogger.finer("start called for " + serviceUnitID);
340:
341:                boolean status = mServiceManager
342:                        .getDeploymentStatus(serviceUnitID);
343:
344:                if (!status) {
345:                    throw new DeploymentException(serviceUnitID
346:                            + " Is Not Deployed. Check.");
347:                }
348:
349:                try {
350:                    mServiceManager.startServices(serviceUnitID);
351:                } catch (Exception e) {
352:                    throw new DeploymentException(createExceptionMessage(
353:                            mContext.getComponentName(), "start", "FAILED",
354:                            "TESE_332", " ",
355:                            "Unable to start services for SU ID: "
356:                                    + serviceUnitID, e));
357:                }
358:            }
359:
360:            /**
361:             * Stop the deployment. This causes the component to cease generating
362:             * service requests related to the deployment.  This returns the
363:             * deployment to a state equivalent to after init() was called
364:             *
365:             * @param serviceUnitID service unit ID
366:             *
367:             * @throws DeploymentException deployment exception
368:             */
369:            public void stop(String serviceUnitID) throws DeploymentException {
370:                mLogger.finer("stop called for " + serviceUnitID);
371:
372:                boolean status = mServiceManager
373:                        .getDeploymentStatus(serviceUnitID);
374:
375:                if (!status) {
376:                    throw new DeploymentException(serviceUnitID
377:                            + " Is Not Deployed. Check.");
378:                }
379:
380:                try {
381:                    mServiceManager.stopServices(serviceUnitID);
382:                } catch (Exception e) {
383:                    e.printStackTrace();
384:                    throw new DeploymentException(createExceptionMessage(
385:                            mContext.getComponentName(), "stop", "FAILED",
386:                            "TESE_383", " ",
387:                            "Unable to stop services for SU ID:."
388:                                    + serviceUnitID, e));
389:                }
390:            }
391:
392:            /**
393:             * Cancel a Service Deployment.  If the deployment is in use (has
394:             * dependencies), then will operation may fail.
395:             *
396:             * @param serviceUnitID - ID of the Service Unit being undeployed
397:             * @param serviceUnitRootPath - Full path to the Service Unit root.
398:             *
399:             * @return NOT YET DOCUMENTED
400:             *
401:             * @throws DeploymentException deployment exception
402:             */
403:            public String undeploy(String serviceUnitID,
404:                    String serviceUnitRootPath) throws DeploymentException {
405:                String retMsg = null;
406:
407:                boolean status = mServiceManager
408:                        .getDeploymentStatus(serviceUnitID);
409:
410:                if (!status) {
411:                    throw new DeploymentException(serviceUnitID
412:                            + " Is Not Deployed. Check.");
413:                }
414:
415:                try {
416:                    mServiceManager.destroyServices(serviceUnitID);
417:                } catch (Exception e) {
418:                    e.printStackTrace();
419:                    throw new DeploymentException(createExceptionMessage(
420:                            mContext.getComponentName(), "undeploy", "FAILED",
421:                            "TESE_441", " ",
422:                            "Unable to destroy services for SU ID:."
423:                                    + serviceUnitID, e));
424:                }
425:
426:                try {
427:                    ComponentMessageHolder compMsgHolder = new ComponentMessageHolder(
428:                            "STATUS_MSG");
429:                    compMsgHolder.setComponentName(mContext.getComponentName());
430:                    compMsgHolder.setTaskName("undeploy");
431:                    compMsgHolder.setTaskResult(mTranslator
432:                            .getString(TEResources.SUCCESS));
433:
434:                    retMsg = mBuildManagementMessage
435:                            .buildComponentMessage(compMsgHolder);
436:                } catch (Exception ex) {
437:                    mLogger.severe(mTranslator
438:                            .getString(TEResources.CANNOT_CREATE_XML_MESSAGE)
439:                            + ex.getMessage());
440:                }
441:
442:                return retMsg;
443:            }
444:
445:            /**
446:             * helper method to create XML exception string.
447:             *
448:             * @param compid Component id.
449:             * @param oper operation like deploy or undeploy
450:             * @param status success r failure
451:             * @param loctoken some failure string token like SEQ_300001
452:             * @param locparam parameters for error message.
453:             * @param locmessage error message.
454:             * @param exObj stack trace of exception.
455:             *
456:             * @return XML string.
457:             */
458:            private String createExceptionMessage(String compid, String oper,
459:                    String status, String loctoken, String locparam,
460:                    String locmessage, Throwable exObj) {
461:                String retMsg = null;
462:
463:                String[] locParams = new String[1];
464:                locParams[0] = locparam;
465:
466:                ComponentMessageHolder msgMap = new ComponentMessageHolder(
467:                        "EXCEPTION_MSG");
468:
469:                msgMap.setComponentName(compid);
470:                msgMap.setTaskName(oper);
471:                msgMap.setTaskResult(status);
472:                msgMap.setLocToken(1, loctoken);
473:                msgMap.setLocParam(1, locParams);
474:                msgMap.setLocMessage(1, locmessage);
475:                msgMap.setExceptionObject(exObj);
476:
477:                try {
478:                    retMsg = mBuildManagementMessage
479:                            .buildComponentMessage(msgMap);
480:                } catch (Exception e) {
481:                    mLogger.severe(mTranslator
482:                            .getString(TEResources.CANNOT_CREATE_MGMT_XML_MSG)
483:                            + e.getMessage());
484:                }
485:
486:                return retMsg;
487:            }
488:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.