Source Code Cross Referenced for SchedulingProfilerBean.java in  » Portal » Open-Portal » com » sun » portal » admin » console » subscriptions » 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 » Portal » Open Portal » com.sun.portal.admin.console.subscriptions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2005 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */package com.sun.portal.admin.console.subscriptions;
013:
014:        import java.util.*;
015:        import java.util.logging.Level;
016:        import java.io.*;
017:
018:        import javax.faces.context.FacesContext;
019:        import javax.faces.application.FacesMessage;
020:        import javax.faces.component.UIComponent;
021:        import javax.faces.event.*;
022:        import javax.faces.validator.*;
023:        import javax.faces.el.ValueBinding;
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.management.*;
026:
027:        import com.sun.web.ui.model.*;
028:        import com.sun.web.ui.event.*;
029:        import com.sun.web.ui.component.*;
030:
031:        import com.sun.data.provider.*;
032:        import com.sun.data.provider.impl.ObjectListDataProvider;
033:
034:        import com.sun.cacao.agent.JmxClient;
035:
036:        import com.sun.portal.admin.common.AttrOptionConstants;
037:        import com.sun.portal.admin.common.util.*;
038:        import com.sun.portal.admin.console.common.PSBaseBean;
039:
040:        public class SchedulingProfilerBean extends PSBaseBean {
041:
042:            private String cachedPortalServer = null;
043:            private String cachedDN = null;
044:
045:            private String startCommand = null;
046:            private String stopCommand = null;
047:
048:            private DataProvider startSchedules = null;
049:            private TableRowGroup tableRowGroup1 = null;
050:            private TableSelectPhaseListener tspl1 = null;
051:            private ArrayList toBeDeleted1 = null;
052:
053:            private DataProvider stopSchedules = null;
054:            private TableRowGroup tableRowGroup2 = null;
055:            private TableSelectPhaseListener tspl2 = null;
056:            private ArrayList toBeDeleted2 = null;
057:
058:            public SchedulingProfilerBean() {
059:                tspl1 = new TableSelectPhaseListener();
060:                toBeDeleted1 = new ArrayList();
061:
062:                tspl2 = new TableSelectPhaseListener();
063:                toBeDeleted2 = new ArrayList();
064:            }
065:
066:            public Option[] getAvailableDaysOfTheWeek() {
067:                Option[] options = new Option[8];
068:                options[0] = new Option("", getLocalizedString("subscriptions",
069:                        "subscriptions.general.select"));
070:                options[1] = new Option("0", getLocalizedString(
071:                        "subscriptions", "date.sunday"));
072:                options[2] = new Option("1", getLocalizedString(
073:                        "subscriptions", "date.monday"));
074:                options[3] = new Option("2", getLocalizedString(
075:                        "subscriptions", "date.tuesday"));
076:                options[4] = new Option("3", getLocalizedString(
077:                        "subscriptions", "date.wednesday"));
078:                options[5] = new Option("4", getLocalizedString(
079:                        "subscriptions", "date.thursday"));
080:                options[6] = new Option("5", getLocalizedString(
081:                        "subscriptions", "date.friday"));
082:                options[7] = new Option("6", getLocalizedString(
083:                        "subscriptions", "date.saturday"));
084:                return options;
085:            }
086:
087:            public Option[] getAvailableHours() {
088:                Option[] options = new Option[13];
089:                options[0] = new Option("", getLocalizedString("subscriptions",
090:                        "subscriptions.general.select"));
091:                options[1] = new Option("0", getLocalizedString(
092:                        "subscriptions", "time.12"));
093:                options[2] = new Option("1", getLocalizedString(
094:                        "subscriptions", "time.1"));
095:                options[3] = new Option("2", getLocalizedString(
096:                        "subscriptions", "time.2"));
097:                options[4] = new Option("3", getLocalizedString(
098:                        "subscriptions", "time.3"));
099:                options[5] = new Option("4", getLocalizedString(
100:                        "subscriptions", "time.4"));
101:                options[6] = new Option("5", getLocalizedString(
102:                        "subscriptions", "time.5"));
103:                options[7] = new Option("6", getLocalizedString(
104:                        "subscriptions", "time.6"));
105:                options[8] = new Option("7", getLocalizedString(
106:                        "subscriptions", "time.7"));
107:                options[9] = new Option("8", getLocalizedString(
108:                        "subscriptions", "time.8"));
109:                options[10] = new Option("9", getLocalizedString(
110:                        "subscriptions", "time.9"));
111:                options[11] = new Option("10", getLocalizedString(
112:                        "subscriptions", "time.10"));
113:                options[12] = new Option("11", getLocalizedString(
114:                        "subscriptions", "time.11"));
115:                return options;
116:            }
117:
118:            public Option[] getAvailableMinutes() {
119:                Option[] options = new Option[61];
120:                options[0] = new Option("", getLocalizedString("subscriptions",
121:                        "subscriptions.general.select"));
122:                options[1] = new Option("0", getLocalizedString(
123:                        "subscriptions", "time.00"));
124:                options[2] = new Option("1", getLocalizedString(
125:                        "subscriptions", "time.01"));
126:                options[3] = new Option("2", getLocalizedString(
127:                        "subscriptions", "time.02"));
128:                options[4] = new Option("3", getLocalizedString(
129:                        "subscriptions", "time.03"));
130:                options[5] = new Option("4", getLocalizedString(
131:                        "subscriptions", "time.04"));
132:                options[6] = new Option("5", getLocalizedString(
133:                        "subscriptions", "time.05"));
134:                options[7] = new Option("6", getLocalizedString(
135:                        "subscriptions", "time.06"));
136:                options[8] = new Option("7", getLocalizedString(
137:                        "subscriptions", "time.07"));
138:                options[9] = new Option("8", getLocalizedString(
139:                        "subscriptions", "time.08"));
140:                options[10] = new Option("9", getLocalizedString(
141:                        "subscriptions", "time.09"));
142:                options[11] = new Option("10", getLocalizedString(
143:                        "subscriptions", "time.10"));
144:                options[12] = new Option("11", getLocalizedString(
145:                        "subscriptions", "time.11"));
146:                options[13] = new Option("12", getLocalizedString(
147:                        "subscriptions", "time.12"));
148:                options[14] = new Option("13", getLocalizedString(
149:                        "subscriptions", "time.13"));
150:                options[15] = new Option("14", getLocalizedString(
151:                        "subscriptions", "time.14"));
152:                options[16] = new Option("15", getLocalizedString(
153:                        "subscriptions", "time.15"));
154:                options[17] = new Option("16", getLocalizedString(
155:                        "subscriptions", "time.16"));
156:                options[18] = new Option("17", getLocalizedString(
157:                        "subscriptions", "time.17"));
158:                options[19] = new Option("18", getLocalizedString(
159:                        "subscriptions", "time.18"));
160:                options[20] = new Option("19", getLocalizedString(
161:                        "subscriptions", "time.19"));
162:                options[21] = new Option("20", getLocalizedString(
163:                        "subscriptions", "time.20"));
164:                options[22] = new Option("21", getLocalizedString(
165:                        "subscriptions", "time.21"));
166:                options[23] = new Option("22", getLocalizedString(
167:                        "subscriptions", "time.22"));
168:                options[24] = new Option("23", getLocalizedString(
169:                        "subscriptions", "time.23"));
170:                options[25] = new Option("24", getLocalizedString(
171:                        "subscriptions", "time.24"));
172:                options[26] = new Option("25", getLocalizedString(
173:                        "subscriptions", "time.25"));
174:                options[27] = new Option("26", getLocalizedString(
175:                        "subscriptions", "time.26"));
176:                options[28] = new Option("27", getLocalizedString(
177:                        "subscriptions", "time.27"));
178:                options[29] = new Option("28", getLocalizedString(
179:                        "subscriptions", "time.28"));
180:                options[30] = new Option("29", getLocalizedString(
181:                        "subscriptions", "time.29"));
182:                options[31] = new Option("30", getLocalizedString(
183:                        "subscriptions", "time.30"));
184:                options[32] = new Option("31", getLocalizedString(
185:                        "subscriptions", "time.31"));
186:                options[33] = new Option("32", getLocalizedString(
187:                        "subscriptions", "time.32"));
188:                options[34] = new Option("33", getLocalizedString(
189:                        "subscriptions", "time.33"));
190:                options[35] = new Option("34", getLocalizedString(
191:                        "subscriptions", "time.34"));
192:                options[36] = new Option("35", getLocalizedString(
193:                        "subscriptions", "time.35"));
194:                options[37] = new Option("36", getLocalizedString(
195:                        "subscriptions", "time.36"));
196:                options[38] = new Option("37", getLocalizedString(
197:                        "subscriptions", "time.37"));
198:                options[39] = new Option("38", getLocalizedString(
199:                        "subscriptions", "time.38"));
200:                options[40] = new Option("39", getLocalizedString(
201:                        "subscriptions", "time.39"));
202:                options[41] = new Option("40", getLocalizedString(
203:                        "subscriptions", "time.40"));
204:                options[42] = new Option("41", getLocalizedString(
205:                        "subscriptions", "time.41"));
206:                options[43] = new Option("42", getLocalizedString(
207:                        "subscriptions", "time.42"));
208:                options[44] = new Option("43", getLocalizedString(
209:                        "subscriptions", "time.43"));
210:                options[45] = new Option("44", getLocalizedString(
211:                        "subscriptions", "time.44"));
212:                options[46] = new Option("45", getLocalizedString(
213:                        "subscriptions", "time.45"));
214:                options[47] = new Option("46", getLocalizedString(
215:                        "subscriptions", "time.46"));
216:                options[48] = new Option("47", getLocalizedString(
217:                        "subscriptions", "time.47"));
218:                options[49] = new Option("48", getLocalizedString(
219:                        "subscriptions", "time.48"));
220:                options[50] = new Option("49", getLocalizedString(
221:                        "subscriptions", "time.49"));
222:                options[51] = new Option("50", getLocalizedString(
223:                        "subscriptions", "time.50"));
224:                options[52] = new Option("51", getLocalizedString(
225:                        "subscriptions", "time.51"));
226:                options[53] = new Option("52", getLocalizedString(
227:                        "subscriptions", "time.52"));
228:                options[54] = new Option("53", getLocalizedString(
229:                        "subscriptions", "time.53"));
230:                options[55] = new Option("54", getLocalizedString(
231:                        "subscriptions", "time.54"));
232:                options[56] = new Option("55", getLocalizedString(
233:                        "subscriptions", "time.55"));
234:                options[57] = new Option("56", getLocalizedString(
235:                        "subscriptions", "time.56"));
236:                options[58] = new Option("57", getLocalizedString(
237:                        "subscriptions", "time.57"));
238:                options[59] = new Option("58", getLocalizedString(
239:                        "subscriptions", "time.58"));
240:                options[60] = new Option("59", getLocalizedString(
241:                        "subscriptions", "time.59"));
242:                return options;
243:            }
244:
245:            public Option[] getAvailableMeridiems() {
246:                Option[] options = new Option[3];
247:                options[0] = new Option("", getLocalizedString("subscriptions",
248:                        "subscriptions.general.select"));
249:                options[1] = new Option("am", getLocalizedString(
250:                        "subscriptions", "time.am"));
251:                options[2] = new Option("pm", getLocalizedString(
252:                        "subscriptions", "time.pm"));
253:                return options;
254:            }
255:
256:            public DataProvider getStartSchedules() {
257:                if (needRefresh()) {
258:                    retrieveCommands();
259:                    retrieveStartSchedules();
260:                    retrieveStopSchedules();
261:                }
262:                return startSchedules;
263:            }
264:
265:            public void setStartSchedules(DataProvider startSchedules) {
266:                this .startSchedules = startSchedules;
267:            }
268:
269:            public TableRowGroup getTableRowGroup1() {
270:                return tableRowGroup1;
271:            }
272:
273:            public void setTableRowGroup1(TableRowGroup tableRowGroup1) {
274:                this .tableRowGroup1 = tableRowGroup1;
275:            }
276:
277:            public Object getSelected1() {
278:                return tspl1.getSelected(getTableRow1());
279:            }
280:
281:            public void setSelected1(Object object) {
282:                tspl1.setSelected(getTableRow1(), object);
283:            }
284:
285:            public String createStart() {
286:                ObjectListDataProvider oldp = (ObjectListDataProvider) stopSchedules;
287:                oldp.commitChanges();
288:
289:                boolean canAdd = true;
290:                oldp = (ObjectListDataProvider) startSchedules;
291:                oldp.commitChanges();
292:                List l = oldp.getList();
293:                for (int index = 0; index < l.size(); index++) {
294:                    ProfilerScheduleBean psb = (ProfilerScheduleBean) l
295:                            .get(index);
296:                    if (!psb.initialized()) {
297:                        canAdd = false;
298:                    }
299:                }
300:                if (canAdd) {
301:                    oldp.addObject(new ProfilerScheduleBean(startCommand, ""));
302:                    oldp.commitChanges();
303:                }
304:                return null;
305:            }
306:
307:            public String deleteStart() {
308:                ObjectListDataProvider oldp = (ObjectListDataProvider) stopSchedules;
309:                oldp.commitChanges();
310:
311:                oldp = (ObjectListDataProvider) startSchedules;
312:                oldp.commitChanges();
313:                List l = oldp.getList();
314:                RowKey[] rowKeys = tableRowGroup1.getRenderedRowKeys();
315:                for (int index = 0; index < rowKeys.length; index++) {
316:                    RowKey rowKey = rowKeys[index];
317:                    if (tspl1.isSelected(rowKey)) {
318:                        ProfilerScheduleBean psb = (ProfilerScheduleBean) l
319:                                .get(Integer.parseInt(rowKey.getRowId()));
320:                        toBeDeleted1.add(psb.getSchedule());
321:                        oldp.removeRow(rowKey);
322:                    }
323:                }
324:                oldp.commitChanges();
325:                tspl1.clear();
326:                return null;
327:            }
328:
329:            public DataProvider getStopSchedules() {
330:                if (needRefresh()) {
331:                    retrieveCommands();
332:                    retrieveStartSchedules();
333:                    retrieveStopSchedules();
334:                }
335:                return stopSchedules;
336:            }
337:
338:            public void setStopSchedules(DataProvider stopSchedules) {
339:                this .stopSchedules = stopSchedules;
340:            }
341:
342:            public TableRowGroup getTableRowGroup2() {
343:                return tableRowGroup2;
344:            }
345:
346:            public void setTableRowGroup2(TableRowGroup tableRowGroup2) {
347:                this .tableRowGroup2 = tableRowGroup2;
348:            }
349:
350:            public Object getSelected2() {
351:                return tspl2.getSelected(getTableRow2());
352:            }
353:
354:            public void setSelected2(Object object) {
355:                tspl2.setSelected(getTableRow2(), object);
356:            }
357:
358:            public String createStop() {
359:                ObjectListDataProvider oldp = (ObjectListDataProvider) startSchedules;
360:                oldp.commitChanges();
361:
362:                boolean canAdd = true;
363:                oldp = (ObjectListDataProvider) stopSchedules;
364:                oldp.commitChanges();
365:                List l = oldp.getList();
366:                for (int index = 0; index < l.size(); index++) {
367:                    ProfilerScheduleBean psb = (ProfilerScheduleBean) l
368:                            .get(index);
369:                    if (!psb.initialized()) {
370:                        canAdd = false;
371:                    }
372:                }
373:                if (canAdd) {
374:                    oldp.addObject(new ProfilerScheduleBean(stopCommand, ""));
375:                    oldp.commitChanges();
376:                }
377:                return null;
378:            }
379:
380:            public String deleteStop() {
381:                ObjectListDataProvider oldp = (ObjectListDataProvider) startSchedules;
382:                oldp.commitChanges();
383:
384:                oldp = (ObjectListDataProvider) stopSchedules;
385:                oldp.commitChanges();
386:                List l = oldp.getList();
387:                RowKey[] rowKeys = tableRowGroup2.getRenderedRowKeys();
388:                for (int index = 0; index < rowKeys.length; index++) {
389:                    RowKey rowKey = rowKeys[index];
390:                    if (tspl2.isSelected(rowKey)) {
391:                        ProfilerScheduleBean psb = (ProfilerScheduleBean) l
392:                                .get(Integer.parseInt(rowKey.getRowId()));
393:                        toBeDeleted2.add(psb.getSchedule());
394:                        oldp.removeRow(rowKey);
395:                    }
396:                }
397:                oldp.commitChanges();
398:                tspl2.clear();
399:                return null;
400:            }
401:
402:            public String save() {
403:                saveStart();
404:                toBeDeleted1.clear();
405:                saveStop();
406:                toBeDeleted2.clear();
407:
408:                retrieveStartSchedules();
409:                retrieveStopSchedules();
410:                return null;
411:            }
412:
413:            public String reset() {
414:                toBeDeleted1.clear();
415:                toBeDeleted2.clear();
416:
417:                retrieveStartSchedules();
418:                retrieveStopSchedules();
419:                return null;
420:            }
421:
422:            private boolean needRefresh() {
423:                boolean refresh = false;
424:
425:                String portalServer = (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
426:                if (cachedPortalServer == null
427:                        || !cachedPortalServer.equals(portalServer)) {
428:                    refresh = true;
429:                }
430:                cachedPortalServer = portalServer;
431:
432:                String dn = (String) getCurrentDN();
433:                if (cachedDN == null || !cachedDN.equals(dn)) {
434:                    refresh = true;
435:                }
436:                cachedDN = dn;
437:
438:                if (startSchedules == null) {
439:                    refresh = true;
440:                }
441:                if (stopSchedules == null) {
442:                    refresh = true;
443:                }
444:
445:                return refresh;
446:            }
447:
448:            /* windows "at" command remove the quotation of the task command if not needed.
449:             * so we do the same to construct the command or we will not be able to match the tasks submitted here
450:             */
451:            private static String quoted(String v) {
452:                String osName = System.getProperty("os.name");
453:                if (osName.startsWith("Windows") && v != null
454:                        && v.indexOf(" ") > 0) {
455:                    return "\"" + v + "\"";
456:                }
457:                return v;
458:            }
459:
460:            private static String getScript(String cmd) {
461:                if (System.getProperty("os.name").startsWith("Windows")) {
462:                    return cmd + ".bat";
463:                }
464:                return cmd;
465:            }
466:
467:            private void retrieveCommands() {
468:                try {
469:                    LinkedList path = new LinkedList();
470:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
471:                    path.addFirst("scheduler");
472:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
473:                            AdminClientUtil.SCHEDULER_MBEAN_TYPE, path);
474:                    String psDir = (String) getMBeanServerConnection()
475:                            .getAttribute(on, "PSDir");
476:                    startCommand = psDir + File.separator + "lib"
477:                            + File.separator + getScript("profiler")
478:                            + " run -p " + quoted(cachedPortalServer) + " -o "
479:                            + quoted(cachedDN);
480:                    stopCommand = psDir + File.separator + "lib"
481:                            + File.separator + getScript("profiler")
482:                            + " stop -p " + quoted(cachedPortalServer) + " -o "
483:                            + quoted(cachedDN);
484:                } catch (Exception e) {
485:                    log(
486:                            Level.SEVERE,
487:                            "SchedulingProfilerBean.retrieveCommands() : Exception",
488:                            e);
489:                }
490:            }
491:
492:            private void retrieveStartSchedules() {
493:                ArrayList al = new ArrayList();
494:                try {
495:                    LinkedList path = new LinkedList();
496:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
497:                    path.addFirst("scheduler");
498:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
499:                            AdminClientUtil.SCHEDULER_MBEAN_TYPE, path);
500:
501:                    Object[] params = { startCommand };
502:                    String[] signatures = { "java.lang.String" };
503:                    ArrayList data = (ArrayList) getMBeanServerConnection()
504:                            .invoke(on, "getSchedules", params, signatures);
505:                    for (int index = 0; index < data.size(); index++) {
506:                        String string = (String) data.get(index);
507:                        String[] strings = string.split("\\|");
508:                        al.add(new ProfilerScheduleBean(startCommand,
509:                                strings[1].trim()));
510:                    }
511:                } catch (Exception e) {
512:                    log(
513:                            Level.SEVERE,
514:                            "SchedulingProfilerBean.retrieveStartSchedules() : Exception",
515:                            e);
516:                }
517:                startSchedules = new ObjectListDataProvider(al);
518:            }
519:
520:            private void saveStart() {
521:                ArrayList al = new ArrayList();
522:
523:                ObjectListDataProvider oldp = (ObjectListDataProvider) startSchedules;
524:                oldp.commitChanges();
525:                List l = oldp.getList();
526:                for (int index = 0; index < l.size(); index++) {
527:                    ProfilerScheduleBean psb = (ProfilerScheduleBean) l
528:                            .get(index);
529:                    if (!psb.schedule.equals("")) {
530:                        toBeDeleted1.add(psb.getSchedule());
531:                    }
532:                    if (psb.initialized()) {
533:                        al.add(psb.getNewSchedule());
534:                    }
535:                }
536:
537:                try {
538:                    LinkedList path = new LinkedList();
539:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
540:                    path.addFirst("scheduler");
541:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
542:                            AdminClientUtil.SCHEDULER_MBEAN_TYPE, path);
543:
544:                    if (toBeDeleted1.size() > 0) {
545:                        Object[] params = { toBeDeleted1 };
546:                        String[] signatures = { "java.util.List" };
547:                        getMBeanServerConnection().invoke(on, "unschedule",
548:                                params, signatures);
549:                    }
550:                    if (al.size() > 0) {
551:                        Object[] params = { al };
552:                        String[] signatures = { "java.util.List" };
553:                        getMBeanServerConnection().invoke(on, "schedule",
554:                                params, signatures);
555:                    }
556:                } catch (Exception e) {
557:                    log(Level.SEVERE,
558:                            "SchedulingProfilerBean.saveStart() : Exception", e);
559:                }
560:            }
561:
562:            private void retrieveStopSchedules() {
563:                ArrayList al = new ArrayList();
564:                try {
565:                    LinkedList path = new LinkedList();
566:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
567:                    path.addFirst("scheduler");
568:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
569:                            AdminClientUtil.SCHEDULER_MBEAN_TYPE, path);
570:
571:                    Object[] params = { stopCommand };
572:                    String[] signatures = { "java.lang.String" };
573:                    ArrayList data = (ArrayList) getMBeanServerConnection()
574:                            .invoke(on, "getSchedules", params, signatures);
575:                    for (int index = 0; index < data.size(); index++) {
576:                        String string = (String) data.get(index);
577:                        String[] strings = string.split("\\|");
578:                        al.add(new ProfilerScheduleBean(stopCommand, strings[1]
579:                                .trim()));
580:                    }
581:                } catch (Exception e) {
582:                    log(
583:                            Level.SEVERE,
584:                            "SchedulingProfilerBean.retrieveStopSchedules() : Exception",
585:                            e);
586:                }
587:                stopSchedules = new ObjectListDataProvider(al);
588:            }
589:
590:            private void saveStop() {
591:                ArrayList al = new ArrayList();
592:
593:                ObjectListDataProvider oldp = (ObjectListDataProvider) stopSchedules;
594:                oldp.commitChanges();
595:                List l = oldp.getList();
596:                for (int index = 0; index < l.size(); index++) {
597:                    ProfilerScheduleBean psb = (ProfilerScheduleBean) l
598:                            .get(index);
599:                    if (!psb.schedule.equals("")) {
600:                        toBeDeleted2.add(psb.getSchedule());
601:                    }
602:                    if (psb.initialized()) {
603:                        al.add(psb.getNewSchedule());
604:                    }
605:                }
606:
607:                try {
608:                    LinkedList path = new LinkedList();
609:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
610:                    path.addFirst("scheduler");
611:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
612:                            AdminClientUtil.SCHEDULER_MBEAN_TYPE, path);
613:
614:                    if (toBeDeleted2.size() > 0) {
615:                        Object[] params = { toBeDeleted2 };
616:                        String[] signatures = { "java.util.List" };
617:                        getMBeanServerConnection().invoke(on, "unschedule",
618:                                params, signatures);
619:                    }
620:                    if (al.size() > 0) {
621:                        Object[] params = { al };
622:                        String[] signatures = { "java.util.List" };
623:                        getMBeanServerConnection().invoke(on, "schedule",
624:                                params, signatures);
625:                    }
626:                } catch (Exception e) {
627:                    log(Level.SEVERE,
628:                            "SchedulingProfilerBean.saveStop() : Exception", e);
629:                }
630:            }
631:
632:            private RowKey getTableRow1() {
633:                FacesContext fc = FacesContext.getCurrentInstance();
634:                ValueBinding vb = fc.getApplication().createValueBinding(
635:                        "#{startSchedule.tableRow}");
636:                return (RowKey) vb.getValue(fc);
637:            }
638:
639:            private RowKey getTableRow2() {
640:                FacesContext fc = FacesContext.getCurrentInstance();
641:                ValueBinding vb = fc.getApplication().createValueBinding(
642:                        "#{stopSchedule.tableRow}");
643:                return (RowKey) vb.getValue(fc);
644:            }
645:
646:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.