Source Code Cross Referenced for Engine3Deployer.java in  » ESB » open-esb » com » sun » jbi » ui » ant » test » engine3 » rt » 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.ui.ant.test.engine3.rt 
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:         * @(#)Engine3Deployer.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.ui.ant.test.engine3.rt;
030:
031:        import com.sun.jbi.management.ComponentMessageHolder;
032:        import java.util.HashMap;
033:        import java.util.Map;
034:        import java.util.logging.Level;
035:        import javax.jbi.component.ServiceUnitManager;
036:        import javax.jbi.management.DeploymentException;
037:
038:        /**
039:         * fix it
040:         * @author Sun Microsystems, Inc.
041:         */
042:        public class Engine3Deployer implements  ServiceUnitManager {
043:            /**
044:             * fix it
045:             */
046:            private Engine3Runtime mContext;
047:            /**
048:             * fix it
049:             */
050:            private Map mDeployMap;
051:
052:            private static String DEPLOY_FAIL_SU_NAME = "ant_test_engine_3_su1";
053:            private static String UNDEPLOY_FAIL_SU_NAME = "ant_test_engine_3_su2";
054:
055:            //    private static String TEST_DEPLOY_FAILURE = "test-deploy-failure";
056:            //    private static String TEST_UNDEPLOY_FAILURE = "test-undeploy-failure";
057:            //    private String mTestType = TEST_UNDEPLOY_FAILURE;
058:
059:            /**
060:             * Creates a new instance of Binding1Deployer
061:             * @param ctx fix it
062:             */
063:            public Engine3Deployer(Engine3Runtime ctx) {
064:                this .mDeployMap = new HashMap();
065:
066:                this .mContext = ctx;
067:
068:            }
069:
070:            /**
071:             * fix it
072:             * @param asaId fix it
073:             * @param asaJarPath fix it
074:             * @throws DeploymentException fix it
075:             * @return fix it
076:             */
077:            public String deploy(String asaId, String asaJarPath)
078:                    throws DeploymentException {
079:                // this.mContext.getLogger().log(Level.INFO, "");
080:                System.out.println("ANT_ENGINE3: Deploying " + asaId);
081:
082:                String asaInfo = (String) this .mDeployMap.get(asaId);
083:                if (asaInfo != null) {
084:                    // throw already exists
085:                    String exMsg = createExceptionMessage(
086:                            this .mContext.getId(), "deploy", "FAILED",
087:                            "ANT_E3_0001", asaId, "ASA " + asaId
088:                                    + " Already Exists", null);
089:                    throw new DeploymentException(exMsg);
090:                } else {
091:                    if (DEPLOY_FAIL_SU_NAME.equalsIgnoreCase(asaId)) {
092:                        // throw already exists
093:                        String exMsg = createExceptionMessage(
094:                                this .mContext.getId(),
095:                                "deploy",
096:                                "FAILED",
097:                                "ANT_E3_0003",
098:                                asaId,
099:                                asaId
100:                                        + " is not a valid SU. Deployment failed.",
101:                                null);
102:                        throw new DeploymentException(exMsg);
103:                        // return exMsg;
104:                    }
105:
106:                    this .mDeployMap.put(asaId, asaJarPath);
107:                    // return "Deployed " + asaId;
108:                    try {
109:                        ComponentMessageHolder compMsgHolder = new ComponentMessageHolder(
110:                                "STATUS_MSG");
111:                        compMsgHolder.setComponentName(this .mContext.getId());
112:                        compMsgHolder.setTaskName("deploy");
113:                        compMsgHolder.setTaskResult("SUCCESS");
114:
115:                        return this .mContext.getMgmtMsgBuilder()
116:                                .buildComponentMessage(compMsgHolder);
117:
118:                        /*
119:                        return this.mContext.getMgmtMsgBuilder().buildComponentTaskStatusMessage(
120:                        this.mContext.getId(),
121:                        "deploy","SUCCESS", null
122:                        );
123:                         */
124:                    } catch (Exception ex) {
125:                        ex.printStackTrace();
126:                        return null;
127:                    }
128:
129:                }
130:            }
131:
132:            /**
133:             * fix it
134:             * @param asaId fix it
135:             * @return fix it
136:             */
137:            public String getDeploymentInfo(String asaId) {
138:                // Should throw exception if asaId not exists
139:                return (String) this .mDeployMap.get(asaId);
140:            }
141:
142:            /**
143:             * fix it
144:             * @return fix it
145:             */
146:            public String[] getDeployments() {
147:                return (String[]) this .mDeployMap.keySet().toArray(
148:                        new String[0]);
149:            }
150:
151:            /**
152:             * fix it
153:             * @param asaId fix it
154:             * @return fix it
155:             */
156:            public boolean isDeployed(String asaId) {
157:                return (this .mDeployMap.get(asaId) != null);
158:            }
159:
160:            /**
161:             * fix it
162:             * @param asaId fix it
163:             * @throws DeploymentException fix it
164:             * @return fix it
165:             */
166:            public String undeploy(String asaId, String asaJarPath)
167:                    throws DeploymentException {
168:                if (UNDEPLOY_FAIL_SU_NAME.equalsIgnoreCase(asaId)) {
169:                    // throw already exists
170:                    String exMsg = createExceptionMessage(
171:                            this .mContext.getId(), "undeploy", "FAILED",
172:                            "ANT_E3_0003", asaId,
173:                            asaId + " is not a valid SU. Undeployment Failed.",
174:                            null);
175:                    throw new DeploymentException(exMsg);
176:                    // return exMsg;
177:                }
178:
179:                String asaInfo = (String) this .mDeployMap.remove(asaId);
180:                if (asaInfo == null) {
181:                    // throw exception
182:                    String exMsg = createExceptionMessage(
183:                            this .mContext.getId(), "undeploy", "FAILED",
184:                            "ANT_E3_0002", asaId, "ASA with " + asaId
185:                                    + " Not Found", null);
186:                    throw new DeploymentException(exMsg);
187:                } else {
188:                    // return "Undeployed " + asaId;
189:                    try {
190:                        ComponentMessageHolder compMsgHolder = new ComponentMessageHolder(
191:                                "STATUS_MSG");
192:                        compMsgHolder.setComponentName(this .mContext.getId());
193:                        compMsgHolder.setTaskName("undeploy");
194:                        compMsgHolder.setTaskResult("SUCCESS");
195:
196:                        return this .mContext.getMgmtMsgBuilder()
197:                                .buildComponentMessage(compMsgHolder);
198:
199:                        /*
200:                        return this.mContext.getMgmtMsgBuilder().buildComponentTaskStatusMessage(
201:                        this.mContext.getId(),
202:                        "undeploy","SUCCESS", null
203:                        );
204:                         */
205:                    } catch (Exception ex) {
206:                        ex.printStackTrace();
207:                        return null;
208:                    }
209:
210:                }
211:            }
212:
213:            /**
214:             * helper method to create XML exception string.
215:             *
216:             * @param compid Component id.
217:             * @param oper operation like deploy or undeploy
218:             * @param status success r failure
219:             * @param loctoken some failure string token like SEQ_300001
220:             * @param locparam parameters for error message.
221:             * @param locmessage error message.
222:             * @param stckTrElem stack trace of exception.
223:             *
224:             * @return XML string.
225:             */
226:            private String createExceptionMessage(String compid, String oper,
227:                    String status, String loctoken, String locparam,
228:                    String locmessage, Throwable exObj) {
229:
230:                String[] locParams = new String[1];
231:                locParams[0] = locparam;
232:
233:                ComponentMessageHolder msgMap = new ComponentMessageHolder(
234:                        "EXCEPTION_MSG");
235:
236:                msgMap.setComponentName(compid);
237:                msgMap.setTaskName(oper);
238:                msgMap.setTaskResult(status);
239:                if ("SUCCESS".equalsIgnoreCase(status)) {
240:                    msgMap.setExceptionMessageType("INFO");
241:                } else {
242:                    msgMap.setExceptionMessageType("ERROR");
243:                }
244:                msgMap.setLocToken(1, loctoken);
245:                msgMap.setLocParam(1, locParams);
246:                msgMap.setLocMessage(1, locmessage);
247:                msgMap.setExceptionObject(exObj);
248:
249:                /*
250:                msgMap.put("COMPONENTID", compid);
251:                msgMap.put("TASKIDENTIFIER", oper);
252:                msgMap.put("TASKRSLTSTATUS", status);
253:                msgMap.put("COMPONENTEXLOCTOKEN", loctoken);
254:                msgMap.put("COMPONENTEXLOCPARAM", locparam);
255:                msgMap.put("COMPONENTEXLOCMESSAGE", locmessage);
256:                msgMap.put("COMPONENTEXSTACKTRACE", sb.toString());
257:                 */
258:
259:                String retMsg = null;
260:
261:                try {
262:                    retMsg = this .mContext.getMgmtMsgBuilder()
263:                            .buildComponentMessage(msgMap);
264:                } catch (Exception e) {
265:                    this .mContext.getLogger().log(Level.INFO,
266:                            "Failed to create Mgmt Msg", e);
267:                }
268:
269:                return retMsg;
270:            }
271:
272:            /**
273:             * Initialize the deployment. This is the first phase of a two-phase
274:             * start, where the component must prepare to receive service requests
275:             * related to the deployment (if any).
276:             * @param serviceUnitName the name of the Service Unit being initialized.
277:             * @param serviceUnitRootPath the full path to the Service Unit artifact
278:             * root directory.
279:             * @throws javax.jbi.management.DeploymentException if the Service Unit is
280:             * not deployed, or is in an incorrect state.
281:             */
282:            public void init(String serviceUnitName, String serviceUnitRootPath)
283:                    throws javax.jbi.management.DeploymentException {
284:            }
285:
286:            /**
287:             * Shut down the deployment. This causes the deployment to return to the
288:             * state it was in after <code>deploy()</code> and before <code>init()</code>.
289:             * @param serviceUnitName the name of the Service Unit being shut down.
290:             * @throws javax.jbi.management.DeploymentException if the Service Unit
291:             * is not deployed, or is in an incorrect state.
292:             */
293:            public void shutDown(String serviceUnitName)
294:                    throws javax.jbi.management.DeploymentException {
295:            }
296:
297:            /**
298:             * Start the deployment. This is the second phase of a two-phase start,
299:             * where the component can now initiate service requests related to the
300:             * deployment.
301:             * @param serviceUnitName the name of the Service Unit being started.
302:             * @throws javax.jbi.management.DeploymentException if the Service Unit
303:             * is not deployed, or is in an incorrect state.
304:             */
305:            public void start(String serviceUnitName)
306:                    throws javax.jbi.management.DeploymentException {
307:            }
308:
309:            /**
310:             * Stop the deployment. This causes the component to cease generating
311:             * service requests related to the deployment. This returns the deployment
312:             * to a state equivalent to after <code>init()</code> was called.
313:             * @param serviceUnitName the name of the Service Unit being stopped.
314:             * @throws javax.jbi.management.DeploymentException if the Service Unit
315:             * is not deployed, or is in an incorrect state.
316:             */
317:            public void stop(String serviceUnitName)
318:                    throws javax.jbi.management.DeploymentException {
319:            }
320:
321:        }
w_w___w__.j___a__va_2__s._c_o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.