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


001:        /*
002:         *  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         *  Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         *  The contents of this file are subject to the terms of either the GNU
007:         *  General Public License Version 2 only ("GPL") or the Common Development
008:         *  and Distribution License("CDDL") (collectively, the "License").  You
009:         *  may not use this file except in compliance with the License. You can obtain
010:         *  a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011:         *  or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
012:         *  language governing permissions and limitations under the License.
013:         *
014:         *  When distributing the software, include this License Header Notice in each
015:         *  file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016:         *  Sun designates this particular file as subject to the "Classpath" exception
017:         *  as provided by Sun in the GPL Version 2 section of the License file that
018:         *  accompanied this code.  If applicable, add the following below the License
019:         *  Header, with the fields enclosed by brackets [] replaced by your own
020:         *  identifying information: "Portions Copyrighted [year]
021:         *  [name of copyright owner]"
022:         *
023:         *  Contributor(s):
024:         *
025:         *  If you wish your version of this file to be governed by only the CDDL or
026:         *  only the GPL Version 2, indicate your decision by adding "[Contributor]
027:         *  elects to include this software in this distribution under the [CDDL or GPL
028:         *  Version 2] license."  If you don't indicate a single choice of license, a
029:         *  recipient has the option to distribute your version of this file under
030:         *  either the CDDL, the GPL Version 2 or to extend the choice of license to
031:         *  its licensees as provided above.  However, if you add GPL Version 2 code
032:         *  and therefore, elected the GPL Version 2 license, then the option applies
033:         *  only if the new code is made subject to such option by the copyright
034:         *  holder.
035:         */
036:        /*
037:         *  InstallationBean.java
038:         */
039:
040:        package com.sun.jbi.jsf.bean;
041:
042:        import com.sun.data.provider.TableDataProvider;
043:        import com.sun.data.provider.impl.ObjectListDataProvider;
044:        import com.sun.enterprise.tools.admingui.util.GuiUtil;
045:        import com.sun.jbi.jsf.util.BeanUtilities;
046:        import com.sun.jbi.jsf.util.I18nUtilities;
047:        import com.sun.jbi.jsf.util.JBIConstants;
048:        import com.sun.jbi.jsf.util.JBILogger;
049:        import com.sun.jbi.jsf.util.SharedConstants;
050:        import com.sun.jbi.ui.common.JBIAdminCommands;
051:        import com.sun.jbi.ui.common.JBIManagementMessage;
052:        import com.sun.jbi.ui.common.JBIRemoteException;
053:        import com.sun.webui.jsf.model.Option;
054:        import java.util.ArrayList;
055:        import java.util.List;
056:        import java.util.Properties;
057:        import java.util.logging.Level;
058:        import java.util.logging.Logger;
059:        import javax.management.openmbean.CompositeData;
060:
061:        /**
062:         * Description of the Class
063:         *
064:         * @author   Sun Microsystems Inc.
065:         */
066:        public class InstallationBean {
067:
068:            /**
069:             * Description of the Field
070:             */
071:            public static final String DEFAULT_PE_TARGET = JBIAdminCommands.SERVER_TARGET_KEY;
072:
073:            /**
074:             * Gets the ResultDetails attribute of the InstallationBean object
075:             *
076:             * @return   The ResultDetails value
077:             */
078:            public String getResultDetails() {
079:                // only once
080:                mIsAlertNeeded = false;
081:                sLog.fine("InstallationBean.getResultDetails()="
082:                        + mResultDetails + ")");
083:                return mResultDetails;
084:            }
085:
086:            /**
087:             * Gets the ResultSummary attribute of the InstallationBean object
088:             *
089:             * @return   The ResultSummary value
090:             */
091:            public String getResultSummary() {
092:                sLog.fine("InstallationBean.getResultSummary()="
093:                        + mResultSummary + ")");
094:                return mResultSummary;
095:            }
096:
097:            /**
098:             * Gets the IsAlertNeeded attribute of the InstallationBean object
099:             *
100:             * @return   The IsAlertNeeded value
101:             */
102:            public Boolean getIsAlertNeeded() {
103:                Boolean result = null;
104:                result = new Boolean(mIsAlertNeeded);
105:                sLog.fine("InstallationBean.isAlertNeeded()=" + result + ")");
106:                return result;
107:            }
108:
109:            /**
110:             * Get the mUploadSelected variable for cleaning up temporary uploaded
111:             * files
112:             *
113:             * @return   mUploadSelected boolean false if copy path was selected
114:             */
115:
116:            public boolean getUploadSelected() {
117:                sLog.fine("InstallationBean.getUploadSelected()="
118:                        + mUploadSelected + ")");
119:                return mUploadSelected;
120:            }
121:
122:            /**
123:             * Gets the TargetNames attribute of the InstallationBean object
124:             *
125:             * @return   The TargetNames value
126:             */
127:            public String[] getTargetNames() {
128:                return mTargetNames;
129:            }
130:
131:            /**
132:             * Set the mUploadSelected variable true for cleaning up temporary
133:             * uploaded files
134:             *
135:             * @param uploadSelected  boolean false if copy path was selected
136:             */
137:            public void setUploadPathSelected(boolean uploadSelected) {
138:                sLog.fine("InstallationBean.setUploadSelected("
139:                        + uploadSelected + ")");
140:                mUploadSelected = uploadSelected;
141:            }
142:
143:            /**
144:             * Sets the TargetNames attribute of the InstallationBean object
145:             *
146:             * @param aTargetNames  The new TargetNames value
147:             */
148:            public void setTargetNames(String[] aTargetNames) {
149:                mTargetNames = aTargetNames;
150:            }
151:
152:            /**
153:             * Set the mUploadSelected variable true for cleaning up temporary
154:             * uploaded files
155:             *
156:             * @param aSource  Properties containing the parameters
157:             * @param aTarget  the name of the target to install to
158:             * @return         result Properteis contain the result information
159:             */
160:            public Properties installValidatedArchive(Properties aSource,
161:                    String aTarget) {
162:                Properties result = aSource;
163:                String jbiType = aSource.getProperty("type");
164:                String archiveName = aSource.getProperty("archiveName");
165:                String archivePath = aSource.getProperty("path");
166:
167:                result = tryInstallToOneTarget(archiveName, archivePath,
168:                        jbiType, aTarget, result);
169:                return result;
170:            }
171:
172:            /**
173:             * Description of the Method
174:             *
175:             * @param aSource  Description of Parameter
176:             * @return         Description of the Returned Value
177:             */
178:            public Properties installValidatedArchive(Properties aSource) {
179:                final String TARGET_DOMAIN = JBIAdminCommands.DOMAIN_TARGET_KEY;
180:
181:                Properties result = aSource;
182:
183:                sLog.fine("InstallationBean.installValidatedArchive(" + aSource
184:                        + "), mTargetNames=" + mTargetNames);
185:
186:                String archivePath = aSource.getProperty("path");
187:                String jbiType = aSource.getProperty("type");
188:                String archiveName = aSource.getProperty("archiveName");
189:
190:                if (null != mTargetNames) {
191:                    /*
192:                     *  For PE with clusters (or EE) this list could have zero targets, implying domain only
193:                     */
194:                    if (0 == mTargetNames.length) {
195:                        // DOMAIN-only
196:
197:                        sLog.fine("InstallationBean.installValidatedArchive("
198:                                + aSource + ") install to \"domain\"");
199:                        result = tryInstallToOneTarget(null, archivePath,
200:                                jbiType, TARGET_DOMAIN, result);
201:                    }
202:                    /*
203:                     *  For PE without clusters this list will have one "server" target only
204:                     *  For PE with clusters (or EE) this list will have one or more named targets only
205:                     */
206:                    else {
207:                        for (int i = 0; i < mTargetNames.length; ++i) {
208:                            sLog
209:                                    .fine("InstallationBean.installValidatedArchive("
210:                                            + aSource
211:                                            + ") install to \""
212:                                            + mTargetNames[i] + "\"");
213:                            result = tryInstallToOneTarget(archiveName,
214:                                    archivePath, jbiType, mTargetNames[i],
215:                                    result);
216:                        }
217:                    }
218:                }
219:
220:                sLog.fine("InstallationBean.installValidatedArchive(), result="
221:                        + result);
222:                return result;
223:            }
224:
225:            /**
226:             * Description of the Method
227:             *
228:             * @param anArchivePath  Description of Parameter
229:             * @param aTarget        Description of Parameter
230:             * @return               Description of the Returned Value
231:             */
232:            public Properties runAppConfigVerifier(String anArchivePath,
233:                    String aTarget) {
234:                Properties result = new Properties();
235:
236:                sLog.fine("InstallationBean.runAppConfigVerifier("
237:                        + anArchivePath + ", " + aTarget + ")");
238:
239:                String details = "";
240:
241:                try {
242:                    JBIAdminCommands jac = BeanUtilities.getClient();
243:
244:                    CompositeData compData = jac.verifyApplication(
245:                            anArchivePath, aTarget, false, null, false);
246:
247:                    Object allComponentsInstalled = compData
248:                            .get("AllComponentsInstalled");
249:                    if ((null != allComponentsInstalled)
250:                            && (allComponentsInstalled instanceof  Boolean)
251:                            && (((Boolean) allComponentsInstalled)
252:                                    .booleanValue())) {
253:                        // check for unsatisfied app config
254:                        boolean isVerified = true;
255:                        String[] endpointNames = { "EndpointName",
256:                                "ServiceUnitName", "ComponentName", "Status", };
257:
258:                        Object endpointInfo = compData.get("EndpointInfo");
259:                        if ((null != endpointInfo)
260:                                && (endpointInfo instanceof  CompositeData[])
261:                                && (0 < ((CompositeData[]) endpointInfo).length)) {
262:                            CompositeData[] endpointInfos = (CompositeData[]) endpointInfo;
263:                            for (int ii = 0; ii < endpointInfos.length; ++ii) {
264:                                Object[] endpointValues = endpointInfos[ii]
265:                                        .getAll(endpointNames);
266:                                String epName = (String) endpointValues[0];
267:                                String epSuName = (String) endpointValues[1];
268:                                String epCompName = (String) endpointValues[2];
269:                                String epStatus = (String) endpointValues[3];
270:                                if ("UNRESOLVED".equals(epStatus)) {
271:                                    Object[] args = { epName, epSuName,
272:                                            epCompName, aTarget };
273:                                    details += GuiUtil
274:                                            .getMessage(
275:                                                    I18nUtilities
276:                                                            .getResourceString("jbi.app.verification.unresolved.endpoint"),
277:                                                    args)
278:                                            + "<br />";
279:                                    isVerified = false;
280:                                }
281:                                sLog
282:                                        .fine("InstallationBean.runAppConfigVerifier("
283:                                                + anArchivePath
284:                                                + ", "
285:                                                + aTarget
286:                                                + "), epName="
287:                                                + epName
288:                                                + ", epSuName="
289:                                                + epSuName
290:                                                + ", epCompName="
291:                                                + epCompName
292:                                                + ", epStatus="
293:                                                + epStatus);
294:
295:                            }
296:                        }
297:
298:                        sLog.fine("InstallationBean.runAppConfigVerifier("
299:                                + anArchivePath + ", " + aTarget
300:                                + "), compData=" + compData + ", isVerified="
301:                                + isVerified);
302:                        if (isVerified) {
303:                            result.put("success-result", compData.toString());
304:                        } else {
305:                            result.put("failure-result", details);
306:                        }
307:                    } else {
308:                        Object missingComponentsList = compData
309:                                .get("MissingComponentsList");
310:                        if ((null != missingComponentsList)
311:                                && (missingComponentsList instanceof  String[])
312:                                && (0 < ((String[]) missingComponentsList).length)) {
313:                            String[] missingComponents = (String[]) missingComponentsList;
314:                            for (int ii = 0; ii < missingComponents.length; ++ii) {
315:                                Object[] args = { missingComponents[ii],
316:                                        aTarget };
317:                                details += GuiUtil
318:                                        .getMessage(
319:                                                I18nUtilities
320:                                                        .getResourceString("jbi.app.verification.required.component.not.installed"),
321:                                                args)
322:                                        + "<br />";
323:                            }
324:                        } else {
325:                            details += I18nUtilities
326:                                    .getResourceString("jbi.app.verification.failure.reason.unknown");
327:                        }
328:                        result.put("failure-result", details);
329:                    }
330:                } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
331:                    sLog.log(Level.FINE,
332:                            ("ShowBean.check() caught jrEx=" + jrEx), jrEx);
333:                    result.put("failure-result", jrEx.toString());
334:                    // TBD ManagementMessge
335:                }
336:                sLog.fine("InstallationBean.runAppConfigVerifier("
337:                        + anArchivePath + ", " + aTarget + "), result="
338:                        + result);
339:
340:                return result;
341:            }
342:
343:            //Get Logger to log fine mesages for debugging
344:            private static Logger sLog = JBILogger.getInstance();
345:
346:            /**
347:             * Description of the Method
348:             *
349:             * @param anArchiveName  Description of Parameter
350:             * @param anArchivePath  Description of Parameter
351:             * @param aJbiType       Description of Parameter
352:             * @param aTargetName    Description of Parameter
353:             * @param aSource        Description of Parameter
354:             * @return               Description of the Returned Value
355:             */
356:            private Properties tryInstallToOneTarget(String anArchiveName,
357:                    String anArchivePath, String aJbiType, String aTargetName,
358:                    Properties aSource) {
359:                Properties result = aSource;
360:
361:                mIsAlertNeeded = false;
362:                String installResult = "unknown";
363:
364:                try {
365:                    installResult = installValidatedArchiveToTarget(
366:                            anArchiveName, anArchivePath, aJbiType, aTargetName);
367:                    result.setProperty(SharedConstants.SUCCESS_RESULT,
368:                            installResult);
369:                    sLog
370:                            .fine("InstallationBean.tryInstallToOneTarget(...), result="
371:                                    + result);
372:                } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
373:                    sLog
374:                            .log(
375:                                    Level.FINE,
376:                                    ("InstallationBean.tryInstallToOneTarget() caught jbiRemoteEx=" + jbiRemoteEx),
377:                                    jbiRemoteEx);
378:
379:                    JBIManagementMessage mgmtMsg = BeanUtilities
380:                            .extractJBIManagementMessage(jbiRemoteEx);
381:                    if (mgmtMsg == null) {
382:                        String internalErrorMsg = I18nUtilities
383:                                .getResourceString("jbi.internal.error.invalid.remote.exception");
384:                        result.setProperty(SharedConstants.INTERNAL_ERROR,
385:                                internalErrorMsg);
386:                    } else {
387:                        String msg = mgmtMsg.getMessage();
388:                        result.setProperty(SharedConstants.FAILURE_RESULT, msg);
389:                    }
390:                }
391:                sLog.fine("InstallationBean.tryInstallToOneTarget("
392:                        + aTargetName + ", " + aJbiType
393:                        + ", <properties>), result=" + result);
394:                return result;
395:            }
396:
397:            /**
398:             * Description of the Method
399:             *
400:             * @param anArchiveName                                 Description of
401:             *      Parameter
402:             * @param anArchivePath                                 Description of
403:             *      Parameter
404:             * @param aJbiType                                      Description of
405:             *      Parameter
406:             * @param aTarget                                       Description of
407:             *      Parameter
408:             * @return                                              Description of the
409:             *      Returned Value
410:             * @exception com.sun.jbi.ui.common.JBIRemoteException  Description of
411:             *      Exception
412:             */
413:            private String installValidatedArchiveToTarget(
414:                    String anArchiveName, String anArchivePath,
415:                    String aJbiType, String aTarget)
416:                    throws com.sun.jbi.ui.common.JBIRemoteException {
417:                String result = "";
418:                sLog.fine("InstallationBean.installValidatedArihiveToTarget("
419:                        + anArchivePath + ", " + aJbiType + ", " + aTarget);
420:
421:                JBIAdminCommands jac = BeanUtilities.getClient();
422:
423:                if (null != jac) {
424:                    if ((JBIConstants.JBI_BINDING_COMPONENT_TYPE
425:                            .equals(aJbiType))
426:                            || (JBIConstants.JBI_SERVICE_ENGINE_TYPE
427:                                    .equals(aJbiType))) {
428:                        CompConfigBean compConfigBean = BeanUtilities
429:                                .getCompConfigBean();
430:
431:                        Properties configProps = compConfigBean
432:                                .getCompInstallationConfigProperties();
433:
434:                        if (configProps == null || configProps.size() == 0) {
435:                            if (anArchiveName != null) {
436:                                result = jac.installComponentFromDomain(
437:                                        anArchiveName, aTarget);
438:                            } else {
439:                                result = jac.installComponent(anArchivePath,
440:                                        aTarget);
441:                            }
442:
443:                        } else {
444:                            if (anArchiveName != null) {
445:                                result = jac.installComponentFromDomain(
446:                                        anArchiveName, configProps, aTarget);
447:                            } else {
448:                                result = jac.installComponent(anArchivePath,
449:                                        configProps, aTarget);
450:                            }
451:                        }
452:
453:                    } else if (JBIConstants.JBI_SERVICE_ASSEMBLY_TYPE
454:                            .equals(aJbiType)) {
455:                        if (anArchiveName != null) {
456:                            result = jac.deployServiceAssemblyFromDomain(
457:                                    anArchiveName, aTarget);
458:                        } else {
459:                            result = jac.deployServiceAssembly(anArchivePath,
460:                                    aTarget);
461:                        }
462:                    } else if (JBIConstants.JBI_SHARED_LIBRARY_TYPE
463:                            .equals(aJbiType)) {
464:                        if (anArchiveName != null) {
465:                            result = jac.installSharedLibraryFromDomain(
466:                                    anArchiveName, aTarget);
467:                        } else {
468:                            result = jac.installSharedLibrary(anArchivePath,
469:                                    aTarget);
470:                        }
471:                    }
472:                } else {
473:                    sLog
474:                            .fine("InstallationBean.installValidatedArchiveToTarget() TBD generate internal error alert, and log");
475:                    mIsAlertNeeded = true;
476:                    mResultSummary = I18nUtilities
477:                            .getResourceString("jbi.ee.install.impossible");
478:                    mResultDetails = I18nUtilities
479:                            .getResourceString("jbi.ee.install.impossible.details");
480:                }
481:
482:                sLog
483:                        .fine("InstallationBean.installValdidatedArchiveToTargetToTarget(...), result="
484:                                + result);
485:                return result;
486:            }
487:
488:            private Option[] mAllTargets = null;
489:            private String[] mTargetNames = new String[] { DEFAULT_PE_TARGET };
490:            private boolean mIsAlertNeeded;
491:            private String mResultDetails;
492:            private String mResultSummary;
493:            private boolean mUploadSelected;
494:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.