Source Code Cross Referenced for ClusterUtilities.java in  » ESB » open-esb » com » sun » jbi » jsf » util » 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.util 
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-2007 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:        /*
038:         *  ClusterUtilties.java
039:         *
040:         */
041:
042:        package com.sun.jbi.jsf.util;
043:
044:        import com.sun.appserv.management.config.ClusteredServerConfig;
045:        import com.sun.enterprise.tools.admingui.util.AMXUtil;
046:        import com.sun.enterprise.tools.admingui.util.GuiUtil;
047:        import com.sun.jbi.ui.common.JBIAdminCommands;
048:        import com.sun.jbi.ui.common.JBIComponentInfo;
049:        import com.sun.jbi.ui.common.ServiceAssemblyInfo;
050:        import com.sun.jbi.jsf.bean.SelectableJBIComponentInfo;
051:        import com.sun.jbi.jsf.bean.SelectableJBIServiceAssemblyInfo;
052:        import com.sun.jbi.jsf.util.JBIConstants;
053:        import com.sun.jbi.jsf.util.JBILogger;
054:        import com.sun.jbi.jsf.util.SharedConstants;
055:        import java.util.ArrayList;
056:        import java.util.Iterator;
057:        import java.util.List;
058:        import java.util.logging.Logger;
059:        import java.util.Map;
060:        import java.util.Properties;
061:        import java.util.Set;
062:        import java.util.TreeSet;
063:
064:        /**
065:         *
066:         * Provides utilities for cluster profile related tables
067:         *
068:         **/
069:
070:        public final class ClusterUtilities {
071:
072:            //Get Logger to log fine mesages for debugging
073:            private static Logger sLog = JBILogger.getInstance();
074:
075:            static {
076:                sJac = BeanUtilities.getClient();
077:            }
078:
079:            public static List findBindingComponentsForTarget(String aTarget) {
080:                List result = new ArrayList(); // default to empty list
081:                List compInfoList = null;
082:                if (null != sJac) {
083:                    try {
084:                        String queryResult = sJac
085:                                .listBindingComponents(aTarget);
086:                        compInfoList = JBIComponentInfo
087:                                .readFromXmlText(queryResult);
088:
089:                    } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
090:                        sLog
091:                                .fine("ClusterUtilities.findBindingComponentsForTarget("
092:                                        + aTarget
093:                                        + "), caught jbiRemoteEx="
094:                                        + jbiRemoteEx);
095:                        jbiRemoteEx.printStackTrace(System.err);
096:                    }
097:                }
098:                if (null != compInfoList) {
099:                    Iterator components = compInfoList.iterator();
100:                    while (components.hasNext()) {
101:                        JBIComponentInfo component = (JBIComponentInfo) components
102:                                .next();
103:                        SelectableJBIComponentInfo selectableComponent = new SelectableJBIComponentInfo(
104:                                component);
105:                        result.add(selectableComponent);
106:                    }
107:                }
108:
109:                sLog.fine("ClusterUtilities.findBindingComponentsForTarget("
110:                        + aTarget + "), result=" + result);
111:
112:                return result;
113:            }
114:
115:            public static List findServiceAssembliesForTarget(String aTarget) {
116:                List result = new ArrayList();
117:                List saInfoList = null;
118:                if (null != sJac) {
119:                    try {
120:                        String queryResult = sJac
121:                                .listServiceAssemblies(aTarget);
122:                        sLog
123:                                .fine("ClusterUtilities.findServiceAssembliesForTarget("
124:                                        + aTarget
125:                                        + "), queryResult="
126:                                        + queryResult);
127:
128:                        saInfoList = ServiceAssemblyInfo
129:                                .readFromXmlTextWithProlog(queryResult);
130:                        sLog
131:                                .fine("ClusterUtilities.findServiceAssembliesForTarget("
132:                                        + aTarget
133:                                        + "), saInfoList="
134:                                        + saInfoList);
135:
136:                    } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
137:                        sLog
138:                                .fine("ClusterUtilities.findServiceAssembliesForTarget("
139:                                        + aTarget
140:                                        + "), caught jbiRemoteEx="
141:                                        + jbiRemoteEx);
142:                        jbiRemoteEx.printStackTrace(System.err);
143:                    }
144:                }
145:                if (null != saInfoList) {
146:                    Iterator deployments = saInfoList.iterator();
147:                    while (deployments.hasNext()) {
148:                        ServiceAssemblyInfo deployment = (ServiceAssemblyInfo) deployments
149:                                .next();
150:                        SelectableJBIServiceAssemblyInfo selectableDeployment = new SelectableJBIServiceAssemblyInfo(
151:                                deployment);
152:                        result.add(selectableDeployment);
153:                    }
154:                }
155:
156:                sLog.fine("ClusterUtilities.findServiceAssembliesForTarget("
157:                        + aTarget + "), result=" + result);
158:
159:                return result;
160:            }
161:
162:            public static List findServiceEnginesForTarget(String aTarget) {
163:                List result = new ArrayList();
164:                List compInfoList = null;
165:                if (null != sJac) {
166:                    try {
167:                        String queryResult = sJac.listServiceEngines(aTarget);
168:                        compInfoList = JBIComponentInfo
169:                                .readFromXmlText(queryResult);
170:
171:                    } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
172:                        sLog
173:                                .fine("ClusterUtilities.findServiceEnginesForTarget("
174:                                        + aTarget
175:                                        + "), caught jbiRemoteEx="
176:                                        + jbiRemoteEx);
177:                        jbiRemoteEx.printStackTrace(System.err);
178:                    }
179:                }
180:                if (null != compInfoList) {
181:                    Iterator components = compInfoList.iterator();
182:                    while (components.hasNext()) {
183:                        JBIComponentInfo component = (JBIComponentInfo) components
184:                                .next();
185:                        SelectableJBIComponentInfo selectableComponent = new SelectableJBIComponentInfo(
186:                                component);
187:                        result.add(selectableComponent);
188:                    }
189:                }
190:
191:                sLog.fine("ClusterUtilities.findServiceEnginesForTarget("
192:                        + aTarget + "), result=" + result);
193:
194:                return result;
195:            }
196:
197:            public static List findSharedLibrariesForTarget(String aTarget) {
198:                List result = new ArrayList();
199:                List compInfoList = null;
200:                if (null != sJac) {
201:                    try {
202:                        String queryResult = sJac.listSharedLibraries(aTarget);
203:                        compInfoList = JBIComponentInfo
204:                                .readFromXmlText(queryResult);
205:
206:                    } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
207:                        sLog
208:                                .fine("ClusterUtilities.findSharedLibrariesForTarget("
209:                                        + aTarget
210:                                        + "), caught jbiRemoteEx="
211:                                        + jbiRemoteEx);
212:                        jbiRemoteEx.printStackTrace(System.err);
213:                    }
214:                }
215:                if (null != compInfoList) {
216:                    Iterator components = compInfoList.iterator();
217:                    while (components.hasNext()) {
218:                        JBIComponentInfo component = (JBIComponentInfo) components
219:                                .next();
220:                        SelectableJBIComponentInfo selectableComponent = new SelectableJBIComponentInfo(
221:                                component);
222:                        result.add(selectableComponent);
223:                    }
224:                }
225:
226:                sLog.fine("ClusterUtilities.findSharedLibrariesForTarget("
227:                        + aTarget + ") result=" + result);
228:                return result;
229:            }
230:
231:            /**
232:             * returns a sorted list of all cluster and stand-alone instance targets
233:             */
234:            public static List findAllNonDomainTargets() {
235:                ArrayList result = null;
236:
237:                Set clusterSet = AMXUtil.getDomainConfig()
238:                        .getClusterConfigMap().keySet();
239:                Set serverSet = AMXUtil.getDomainConfig()
240:                        .getStandaloneServerConfigMap().keySet();
241:
242:                Set targetsSet = new TreeSet(clusterSet);
243:                targetsSet.addAll(serverSet);
244:
245:                result = new ArrayList(targetsSet);
246:                sLog.fine("ClusterUtilities.findAllNonDomainTargets(), result="
247:                        + result);
248:
249:                return result;
250:            }
251:
252:            public static List findTargetsForNameByType(String aName,
253:                    String aType) {
254:                List result = new ArrayList();
255:                sLog.fine("ClusterUtilities.findTargetsForNameByType(" + aName
256:                        + ", " + aType + ")");
257:
258:                List sortedTargetsList = findAllNonDomainTargets();
259:
260:                Iterator targetsIt = sortedTargetsList.iterator();
261:                while (targetsIt.hasNext()) {
262:                    String nextTarget = (String) targetsIt.next();
263:
264:                    if (null != sJac) {
265:                        try {
266:                            String queryResult = "";
267:
268:                            boolean isServiceAssembly = false;
269:                            if (JBIConstants.JBI_BINDING_COMPONENT_TYPE
270:                                    .equals(aType)) {
271:
272:                                queryResult = sJac.showBindingComponent(aName,
273:                                        SharedConstants.NO_STATE_CHECK,
274:                                        SharedConstants.NO_LIBRARY_CHECK,
275:                                        SharedConstants.NO_DEPLOYMENT_CHECK,
276:                                        nextTarget);
277:                            } else if (JBIConstants.JBI_SERVICE_ENGINE_TYPE
278:                                    .equals(aType)) {
279:                                queryResult = sJac.showServiceEngine(aName,
280:                                        SharedConstants.NO_STATE_CHECK,
281:                                        SharedConstants.NO_LIBRARY_CHECK,
282:                                        SharedConstants.NO_DEPLOYMENT_CHECK,
283:                                        nextTarget);
284:                            } else if (JBIConstants.JBI_SERVICE_ASSEMBLY_TYPE
285:                                    .equals(aType)) {
286:                                isServiceAssembly = true;
287:                                queryResult = sJac.showServiceAssembly(aName,
288:                                        SharedConstants.NO_STATE_CHECK,
289:                                        SharedConstants.NO_COMPONENT_CHECK,
290:                                        nextTarget);
291:                            } else if (JBIConstants.JBI_SHARED_LIBRARY_TYPE
292:                                    .equals(aType)) {
293:
294:                                queryResult = sJac.showSharedLibrary(aName,
295:                                        SharedConstants.NO_COMPONENT_CHECK,
296:                                        nextTarget);
297:                            }
298:
299:                            // get a list (empty or single element) from the query, based on type=SA or not.
300:                            List list = (isServiceAssembly) ? ServiceAssemblyInfo
301:                                    .readFromXmlTextWithProlog(queryResult)
302:                                    : JBIComponentInfo
303:                                            .readFromXmlText(queryResult);
304:
305:                            // if the list is non-empty, the component or SA  is installed or deployed on this target
306:                            if (1 == list.size()) {
307:                                Properties targetProperties = new Properties();
308:                                targetProperties.setProperty(
309:                                        SharedConstants.KEY_NAME, nextTarget);
310:                                result.add(targetProperties);
311:
312:                                sLog
313:                                        .fine("ClusterUtilities.findTargetsForNameByType("
314:                                                + aName
315:                                                + ", "
316:                                                + aType
317:                                                + "), nextTarget="
318:                                                + nextTarget
319:                                                + ", queryResult="
320:                                                + queryResult);
321:
322:                            }
323:                        } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
324:                            sLog
325:                                    .fine("ClusterUtilities.findTargetsForNameByType("
326:                                            + aName
327:                                            + ", "
328:                                            + aType
329:                                            + "), caught jbiRemoteEx="
330:                                            + jbiRemoteEx);
331:                            jbiRemoteEx.printStackTrace(System.err);
332:                        }
333:                    }
334:                }
335:
336:                sLog
337:                        .fine("ClusterUtilities.findTargetsForNameByType(...). result="
338:                                + result);
339:
340:                return result;
341:            }
342:
343:            /**
344:             * Get the Cluster name for a cluster instance.  This method will
345:             * return the name of the cluster for a cluster instance.  If the 
346:             * instance specified is not a cluster instance, the instance name 
347:             * will be returned.
348:             *	@param	aInstanceName  The name of the instance
349:             *  @return the cluster name or the given aInstanceName
350:             */
351:            public static String getInstanceDomainCluster(String aInstanceName) {
352:                String clusterName = aInstanceName;
353:                List allNonDomainTargets = ClusterUtilities
354:                        .findAllNonDomainTargets();
355:                List allTargets = new ArrayList(allNonDomainTargets);
356:                Iterator targetIt = allTargets.iterator();
357:                while (targetIt.hasNext()) {
358:                    String target = (String) targetIt.next();
359:                    if (ClusterUtilities.isCluster(target)) {
360:                        Map<String, ClusteredServerConfig> serverMap = AMXUtil
361:                                .getDomainConfig().getClusterConfigMap().get(
362:                                        target).getClusteredServerConfigMap();
363:                        List instancesForOneCluster = new ArrayList();
364:                        if (null != serverMap) {
365:                            for (String key : serverMap.keySet()) {
366:                                String name = serverMap.get(key).getName();
367:                                if (name.equalsIgnoreCase(aInstanceName)) {
368:                                    clusterName = target;
369:                                    return clusterName;
370:                                }
371:                            }
372:                        }
373:                    }
374:                }
375:                return clusterName;
376:            }
377:
378:            public static boolean isClusterProfile() {
379:                boolean result = AMXUtil.supportCluster();
380:                sLog.fine("ClusterUtilities.isClusterProfile(). result="
381:                        + result);
382:                return result;
383:            }
384:
385:            public static boolean isCluster(String aClusterOrServerName) {
386:                Set clusterSet = AMXUtil.getDomainConfig()
387:                        .getClusterConfigMap().keySet();
388:                boolean result = clusterSet.contains(aClusterOrServerName);
389:                sLog.fine("ClusterUtilities.isCluster(" + aClusterOrServerName
390:                        + "). result=" + result);
391:                return result;
392:            }
393:
394:            public static boolean isServer(String aClusterOrServerName) {
395:                Set serverSet = AMXUtil.getDomainConfig()
396:                        .getStandaloneServerConfigMap().keySet();
397:                boolean result = serverSet.contains(aClusterOrServerName);
398:                sLog.fine("ClusterUtilities.isServer(" + aClusterOrServerName
399:                        + "). result=" + result);
400:                return result;
401:            }
402:
403:            public static SelectableJBIComponentInfo[] getCompStatus(
404:                    String aType) {
405:                sLog.fine("ClusterUtilities.getCompStatus(" + aType + ")1");
406:                SelectableJBIComponentInfo[] resultDomainComponentsArray = new SelectableJBIComponentInfo[0];
407:
408:                Map queryMapResult = getAllTargetCompInfosByType(aType);
409:
410:                if (null != queryMapResult) {
411:                    resultDomainComponentsArray = findDomainComponents(queryMapResult);
412:
413:                    // process all domain components
414:                    for (int i = 0; i < resultDomainComponentsArray.length; ++i) {
415:                        // process all targets, looking for this component
416:
417:                        String name = resultDomainComponentsArray[i].getName();
418:
419:                        int disabledCount = 0;
420:                        int enabledCount = 0;
421:
422:                        Set targetNames = queryMapResult.keySet();
423:                        Iterator targets = targetNames.iterator();
424:
425:                        processAllNonDomainTargets: while (targets.hasNext()) {
426:                            String nextTarget = (String) targets.next();
427:                            if (JBIAdminCommands.DOMAIN_TARGET_KEY
428:                                    .equals(nextTarget)) {
429:                                continue processAllNonDomainTargets;
430:                            }
431:
432:                            String info = (String) queryMapResult
433:                                    .get(nextTarget);
434:
435:                            List list = JBIComponentInfo.readFromXmlText(info);
436:
437:                            if (0 < list.size()) {
438:                                Iterator components = list.iterator();
439:
440:                                processOnlyTargetComponent: while (components
441:                                        .hasNext()) {
442:                                    JBIComponentInfo targetCompInfo = (JBIComponentInfo) components
443:                                            .next();
444:
445:                                    if (!name.equals(targetCompInfo.getName())) // skip "other" components
446:                                    {
447:                                        continue processOnlyTargetComponent;
448:                                    }
449:
450:                                    if ("Started"
451:                                            .equalsIgnoreCase(targetCompInfo
452:                                                    .getState())) {
453:                                        ++enabledCount;
454:                                    } else {
455:                                        ++disabledCount;
456:                                    }
457:                                }
458:                            }
459:                        }
460:
461:                        // summarizes for this component (i.e. updates the summary state)
462:                        summarizeStateForComponent(
463:                                resultDomainComponentsArray[i], enabledCount,
464:                                disabledCount);
465:                    }
466:
467:                }
468:                return resultDomainComponentsArray;
469:            }
470:
471:            public static SelectableJBIServiceAssemblyInfo[] getSaStatus() {
472:                sLog.fine("ClusterUtilities.getSaStatus()1");
473:
474:                SelectableJBIServiceAssemblyInfo[] resultDomainServiceAssembliesArray = new SelectableJBIServiceAssemblyInfo[0];
475:
476:                Map queryMapResult = getAllTargetSaInfos();
477:
478:                if (null != queryMapResult) {
479:                    resultDomainServiceAssembliesArray = findDomainDeployments(queryMapResult);
480:
481:                    // process all domain deployments
482:                    for (int i = 0; i < resultDomainServiceAssembliesArray.length; ++i) {
483:                        // process all targets, looking for this saonent
484:
485:                        String name = resultDomainServiceAssembliesArray[i]
486:                                .getName();
487:
488:                        int disabledCount = 0;
489:                        int enabledCount = 0;
490:
491:                        Set targetNames = queryMapResult.keySet();
492:                        Iterator targets = targetNames.iterator();
493:
494:                        processAllNonDomainTargets: while (targets.hasNext()) {
495:                            String nextTarget = (String) targets.next();
496:                            if (JBIAdminCommands.DOMAIN_TARGET_KEY
497:                                    .equals(nextTarget)) {
498:                                continue processAllNonDomainTargets;
499:                            }
500:
501:                            String info = (String) queryMapResult
502:                                    .get(nextTarget);
503:
504:                            List list = ServiceAssemblyInfo
505:                                    .readFromXmlTextWithProlog(info);
506:
507:                            if (0 < list.size()) {
508:                                Iterator deployments = list.iterator();
509:
510:                                processOnlyTargetServiceAssembly: while (deployments
511:                                        .hasNext()) {
512:                                    ServiceAssemblyInfo targetSaInfo = (ServiceAssemblyInfo) deployments
513:                                            .next();
514:
515:                                    if (!name.equals(targetSaInfo.getName())) // skip "other" deployments
516:                                    {
517:                                        continue processOnlyTargetServiceAssembly;
518:                                    }
519:
520:                                    if ("Started".equalsIgnoreCase(targetSaInfo
521:                                            .getState())) {
522:                                        ++enabledCount;
523:                                    } else {
524:                                        ++disabledCount;
525:                                    }
526:                                }
527:                            }
528:                        }
529:
530:                        // summarizes for this saonent (i.e. updates the summary state)
531:                        summarizeStateForDeployment(
532:                                resultDomainServiceAssembliesArray[i],
533:                                enabledCount, disabledCount);
534:                    }
535:
536:                }
537:                return resultDomainServiceAssembliesArray;
538:            }
539:
540:            /**
541:             * get all the JBIComponentInfos for all targets, including the domain target.
542:             * @returns a Map of targets to the ServiceAssemblies deployed on them
543:             */
544:            private static Map getAllTargetCompInfosByType(String aType) {
545:                Map queryMapResult = null;
546:
547:                sLog.fine("ClusterUtilities.getAllTargetCompInfosByType("
548:                        + aType + ")");
549:
550:                List allTargets = findAllNonDomainTargets();
551:                allTargets.add(JBIAdminCommands.DOMAIN_TARGET_KEY);
552:
553:                String[] allTargetsArray = (String[]) allTargets
554:                        .toArray(new String[] {});
555:
556:                sLog.fine("ClusterUtilities..getAllTargetCompInfosByType("
557:                        + aType + ")2, allTargetsArray=" + allTargetsArray
558:                        + ", .length=" + allTargetsArray.length);
559:
560:                if (null != sJac) {
561:                    try {
562:                        // get all components of this request's component type, mapped by target name
563:
564:                        if (JBIConstants.JBI_BINDING_COMPONENT_TYPE
565:                                .equals(aType)) {
566:                            queryMapResult = sJac
567:                                    .listBindingComponents(allTargetsArray);
568:                        } else // service engines
569:                        {
570:                            queryMapResult = sJac
571:                                    .listServiceEngines(allTargetsArray);
572:                        }
573:                    } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
574:                        // TBD use logging warning
575:                        sLog
576:                                .fine("ClusterUtilities.getAllTargetCompInfosByType("
577:                                        + aType
578:                                        + "): caught jbiRemoteEx="
579:                                        + jbiRemoteEx);
580:                    }
581:
582:                }
583:
584:                sLog.fine("ClusterUtilities.getAllTargetCompInfosByType("
585:                        + aType + "), queryMapResult=" + queryMapResult);
586:
587:                return queryMapResult;
588:            }
589:
590:            /**
591:             * get all the ServiceAssemblyInfos for all targets, including the domain target.
592:             * @returns a Map of targets to the ServiceAssemblies deployed on them
593:             */
594:            private static Map getAllTargetSaInfos() {
595:                Map queryMapResult = null;
596:
597:                sLog.fine("ClusterUtilities.getAllTargetSaInfos()");
598:
599:                List allTargets = findAllNonDomainTargets();
600:                allTargets.add(JBIAdminCommands.DOMAIN_TARGET_KEY);
601:
602:                String[] allTargetsArray = (String[]) allTargets
603:                        .toArray(new String[] {});
604:
605:                sLog
606:                        .fine("ClusterUtilities..getAllTargetSaInfosByType()2, allTargetsArray="
607:                                + allTargetsArray
608:                                + ", .length="
609:                                + allTargetsArray.length);
610:
611:                if (null != sJac) {
612:                    try {
613:                        // get all deployments, mapped by target name
614:
615:                        queryMapResult = sJac
616:                                .listServiceAssemblies(allTargetsArray);
617:                    } catch (com.sun.jbi.ui.common.JBIRemoteException jbiRemoteEx) {
618:                        sLog
619:                                .fine("ClusterUtilities.getAllTargetSaInfos(): caught jbiRemoteEx="
620:                                        + jbiRemoteEx);
621:                    }
622:
623:                }
624:
625:                sLog
626:                        .fine("ClusterUtilities.getAllTargetSaInfos(), queryMapResult="
627:                                + queryMapResult);
628:
629:                return queryMapResult;
630:            }
631:
632:            /**
633:             *
634:             */
635:            private static SelectableJBIComponentInfo[] findDomainComponents(
636:                    Map aQueryMap) {
637:                SelectableJBIComponentInfo[] result = new SelectableJBIComponentInfo[0];
638:
639:                sLog.fine("ClusterUtilities.findDomainComponents(" + aQueryMap
640:                        + ")");
641:
642:                Set targetNames = aQueryMap.keySet();
643:                Iterator targets = targetNames.iterator();
644:
645:                findDomainComponents: while (targets.hasNext()) {
646:                    String nextTarget = (String) targets.next();
647:                    if (JBIAdminCommands.DOMAIN_TARGET_KEY.equals(nextTarget)) {
648:                        String info = (String) aQueryMap.get(nextTarget); // domain target
649:
650:                        List list = JBIComponentInfo.readFromXmlText(info); // all "known" components
651:
652:                        result = new SelectableJBIComponentInfo[list.size()];
653:
654:                        for (int i = 0; i < result.length; ++i) {
655:                            result[i] = new SelectableJBIComponentInfo(
656:                                    (JBIComponentInfo) list.get(i));
657:                        }
658:
659:                        break;
660:                    }
661:                }
662:
663:                sLog.fine("ClusterUtilities.findDomainComponents(" + aQueryMap
664:                        + "), result=" + result + ", .length=" + result.length);
665:
666:                return result;
667:            }
668:
669:            /**
670:             *
671:             */
672:            private static SelectableJBIServiceAssemblyInfo[] findDomainDeployments(
673:                    Map aQueryMap) {
674:                SelectableJBIServiceAssemblyInfo[] result = new SelectableJBIServiceAssemblyInfo[0];
675:
676:                sLog.fine("ClusterUtilities.findDomainDeployments(" + aQueryMap
677:                        + ")");
678:
679:                Set targetNames = aQueryMap.keySet();
680:                Iterator targets = targetNames.iterator();
681:
682:                findDomainDeployments: while (targets.hasNext()) {
683:                    String nextTarget = (String) targets.next();
684:                    if (JBIAdminCommands.DOMAIN_TARGET_KEY.equals(nextTarget)) {
685:                        String info = (String) aQueryMap.get(nextTarget); // domain target
686:
687:                        List list = ServiceAssemblyInfo
688:                                .readFromXmlTextWithProlog(info); // all "known" deployments
689:
690:                        result = new SelectableJBIServiceAssemblyInfo[list
691:                                .size()];
692:
693:                        for (int i = 0; i < result.length; ++i) {
694:                            result[i] = new SelectableJBIServiceAssemblyInfo(
695:                                    (ServiceAssemblyInfo) list.get(i));
696:                        }
697:
698:                        break;
699:                    }
700:                }
701:
702:                sLog.fine("ClusterUtilities.findDomainDeployments(" + aQueryMap
703:                        + "), result=" + result + ", .length=" + result.length);
704:
705:                return result;
706:            }
707:
708:            /**
709:             *
710:             */
711:            private static void summarizeStateForComponent(
712:                    SelectableJBIComponentInfo aComp, int anEnabledCount,
713:                    int aDisabledCount) {
714:
715:                sLog.fine("ClusterUtilities.summarizeStateForComponent("
716:                        + aComp + ", " + anEnabledCount + ", " + aDisabledCount
717:                        + ")");
718:                if (0 < anEnabledCount) {
719:                    if (0 == aDisabledCount) {
720:                        aComp
721:                                .setSummaryStatus(I18nUtilities
722:                                        .getResourceString("jbi.operations.enabled.on.all.targets"));
723:                    } else if (1 == anEnabledCount) // some disabled, but only 1 enabled
724:                    {
725:                        aComp
726:                                .setSummaryStatus(I18nUtilities
727:                                        .getResourceString("jbi.operations.enabled.on.one.target"));
728:                    } else if (1 < anEnabledCount) // some disabled, and more than 1 enabled
729:                    {
730:                        Object[] args = { anEnabledCount };
731:                        String enabledOnNTargets = GuiUtil
732:                                .getMessage(
733:                                        I18nUtilities
734:                                                .getResourceString("jbi.operations.enabled.on.n.targets"),
735:                                        args);
736:
737:                        aComp.setSummaryStatus(enabledOnNTargets);
738:                    }
739:                } else // not enabled anywhere
740:                {
741:                    if (0 == aDisabledCount) // implies no targets
742:                    {
743:                        aComp
744:                                .setSummaryStatus(I18nUtilities
745:                                        .getResourceString("jbi.operations.no.targets"));
746:                    } else // disabled on all targets
747:                    {
748:                        aComp
749:                                .setSummaryStatus(I18nUtilities
750:                                        .getResourceString("jbi.operations.disabled.on.all.targets"));
751:                    }
752:                }
753:                sLog
754:                        .fine("ClusterUtilities.summarizeStateForComponent(), summary="
755:                                + aComp.getSummaryStatus());
756:
757:            }
758:
759:            /**
760:             *
761:             */
762:            private static void summarizeStateForDeployment(
763:                    SelectableJBIServiceAssemblyInfo anSa, int anEnabledCount,
764:                    int aDisabledCount) {
765:
766:                sLog.fine("ClusterUtilities.summarizeStateForDeployment("
767:                        + anSa + ", " + anEnabledCount + ", " + aDisabledCount
768:                        + ")");
769:
770:                if (0 < anEnabledCount) {
771:                    if (0 == aDisabledCount) {
772:                        anSa
773:                                .setSummaryStatus(I18nUtilities
774:                                        .getResourceString("jbi.operations.enabled.on.all.targets"));
775:                    } else if (1 == anEnabledCount) // some disabled, but only 1 enabled
776:                    {
777:                        anSa
778:                                .setSummaryStatus(I18nUtilities
779:                                        .getResourceString("jbi.operations.enabled.on.one.target"));
780:                    } else if (1 < anEnabledCount) // some disabled, and more than 1 enabled
781:                    {
782:                        Object[] args = { anEnabledCount };
783:                        String enabledOnNTargets = GuiUtil
784:                                .getMessage(
785:                                        I18nUtilities
786:                                                .getResourceString("jbi.operations.enabled.on.n.targets"),
787:                                        args);
788:
789:                        anSa.setSummaryStatus(enabledOnNTargets);
790:                    }
791:                } else // not enabled anywhere
792:                {
793:                    if (0 == aDisabledCount) // implies no targets
794:                    {
795:                        anSa
796:                                .setSummaryStatus(I18nUtilities
797:                                        .getResourceString("jbi.operations.no.targets"));
798:                    } else // disabled on all targets
799:                    {
800:                        anSa
801:                                .setSummaryStatus(I18nUtilities
802:                                        .getResourceString("jbi.operations.disabled.on.all.targets"));
803:                    }
804:                }
805:                sLog
806:                        .fine("ClusterUtilities.summarizeStateForDeployment(), summary="
807:                                + anSa.getSummaryStatus());
808:
809:            }
810:
811:            /**
812:             * cached JBI Admin Commands client
813:             */
814:            private static JBIAdminCommands sJac;
815:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.