Source Code Cross Referenced for EndpointBase.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » console » client » endpoint » 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 » cbesb 1.2 » com.bostechcorp.cbesb.console.client.endpoint 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id: EndpointLifeCycle.java 10517 2007-12-04 04:55:41Z lzheng $
023:         */
024:        package com.bostechcorp.cbesb.console.client.endpoint;
025:
026:        import java.util.Vector;
027:
028:        import com.bostechcorp.cbesb.console.client.Admin;
029:        import com.bostechcorp.cbesb.console.client.AdminEndPoints;
030:        import com.bostechcorp.cbesb.console.client.ConsoleCallback;
031:        import com.bostechcorp.cbesb.console.client.ICallbackHandler;
032:        import com.bostechcorp.cbesb.console.client.StyleConstants;
033:        import com.bostechcorp.cbesb.console.client.dialogs.EndpointOperDialog;
034:        import com.bostechcorp.cbesb.console.client.dialogs.MessageViewDialog;
035:        import com.bostechcorp.cbesb.console.common.BaseRPCResultInfo;
036:        import com.bostechcorp.cbesb.console.common.JmxEndpointInfo;
037:        import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
038:        import com.bostechcorp.cbesb.console.pub.JmxAssemblyObj;
039:        import com.bostechcorp.cbesb.console.pub.JmxComponentObj;
040:        import com.bostechcorp.cbesb.console.pub.JmxEndpointObj;
041:        import com.google.gwt.core.client.GWT;
042:        import com.google.gwt.user.client.ui.Button;
043:        import com.google.gwt.user.client.ui.ClickListener;
044:        import com.google.gwt.user.client.ui.Grid;
045:        import com.google.gwt.user.client.ui.HTMLTable;
046:        import com.google.gwt.user.client.ui.PushButton;
047:        import com.google.gwt.user.client.ui.Tree;
048:        import com.google.gwt.user.client.ui.TreeItem;
049:        import com.google.gwt.user.client.ui.TreeListener;
050:        import com.google.gwt.user.client.ui.VerticalPanel;
051:        import com.google.gwt.user.client.ui.Widget;
052:
053:        public abstract class EndpointBase extends AdminEndPoints implements 
054:                TreeListener {
055:
056:            protected IEndpointView endpointView;
057:            protected EndpointSettingCallback settingCalllback = new EndpointSettingCallback(
058:                    this );
059:            private EndpointOperCallback operCallback = new EndpointOperCallback(
060:                    this );
061:            SettingCallback settingCallback = new SettingCallback(this );
062:
063:            public EndpointBase() {
064:                super ();
065:                init();
066:            }
067:
068:            public class EndpointOperListener implements  ClickListener {
069:
070:                public void onClick(Widget sender) {
071:                    curComponentItem = tree.getSelectedItem().getParentItem();
072:                    if (operDialog == null)
073:                        operDialog = new EndpointOperDialog(saName,
074:                                componentName, endpointName, status,
075:                                (EndpointBase) this Admin);
076:                    else
077:                        showWaitingDialog();
078:                }
079:
080:                private String endpointName = "";
081:
082:                private String status = "";
083:
084:                private String componentName = "";
085:                private String saName = "";
086:
087:                public EndpointOperListener(String saName,
088:                        String componentName, String endpointName, String status) {
089:                    super ();
090:                    this .endpointName = endpointName;
091:                    this .status = status;
092:                    this .componentName = componentName;
093:                    this .saName = saName;
094:                }
095:
096:            }
097:
098:            public ConsoleCallback getStatusOperCallback() {
099:                return operCallback;
100:            }
101:
102:            class EndpointOperCallback extends ConsoleCallback {
103:
104:                public EndpointOperCallback(Admin admin) {
105:                    super (admin);
106:                }
107:
108:                public void handleSuccess(Object result) {
109:                    if (result instanceof  JmxComponentObj) {
110:                        JmxComponentObj componentObj = (JmxComponentObj) result;
111:                        curComponentItem.removeItems();
112:                        curComponentItem.addItem(buildHtmlTable(componentObj));
113:
114:                        startPollingFlag();
115:                        polling();
116:                    } else {
117:                        System.out
118:                                .println("unexpected callback object, expecting JmxComponentObj");
119:                    }
120:                    operDialog = null;
121:
122:                }
123:
124:                public void handleExtFailure(Object result) {
125:                    super .handleExtFailure(result);
126:                    operDialog = null;
127:                    startPollingFlag();
128:                    polling();
129:
130:                }
131:
132:            }
133:
134:            public class EndpointSettingListener implements  ClickListener {
135:
136:                public void onClick(Widget sender) {
137:                    showWaitingDialog();
138:                    curComponentItem = tree.getSelectedItem().getParentItem();
139:                    stopPollingFlag();
140:                    getJmxOperationAsyncFromModule().getPropertyObjects(saName,
141:                            componentName, endpointName, suName, role,
142:                            settingCalllback);
143:
144:                }
145:
146:                private String endpointName = "";
147:
148:                private String suName = "";
149:
150:                private String role = "";
151:
152:                private String componentName = "";
153:
154:                private String saName = "";
155:
156:                public EndpointSettingListener(String saName, String compName,
157:                        String endpointName, String suName, String role) {
158:                    super ();
159:                    this .endpointName = endpointName;
160:                    this .suName = suName;
161:                    this .role = role;
162:                    this .componentName = compName;
163:                    this .saName = saName;
164:                }
165:
166:            }
167:
168:            class EndpointSettingCallback extends ConsoleCallback {
169:
170:                public EndpointSettingCallback(Admin admin) {
171:                    super (admin);
172:                }
173:
174:                public void handleSuccess(Object result) {
175:                    if (result instanceof  JmxEndpointInfo) {
176:                        JmxEndpointInfo ep = (JmxEndpointInfo) result;
177:
178:                        JmxEndpointObj endpointObj = ep.getCurEndpointObj();
179:                        endpointView.showSettingDialog(endpointObj);
180:
181:                    }
182:
183:                    else {
184:                        System.out
185:                                .println("unexpected callback object, expecting JmxEndpointInfo");
186:                    }
187:                }
188:            }
189:
190:            protected static final int TYPE_ASSEMBLY = 0;
191:
192:            protected static final int TYPE_COMPONENT = 1;
193:
194:            protected static final int TYPE_ENDPOINT = 2;
195:
196:            VerticalPanel mainPanel = new VerticalPanel();
197:
198:            // TabPanel tabPanel;
199:
200:            VerticalPanel endpointPanel;
201:
202:            protected Tree tree = new Tree();
203:
204:            protected TreeItem curComponentItem = null;
205:
206:            // private Button refreshButton;
207:
208:            protected JmxAssemblyObj[] saList;
209:
210:            protected String[] itemArray;
211:
212:            protected String[] expandArray;
213:
214:            protected String[] lastSaArray = null;
215:
216:            protected String[] lastExpandArray = null;
217:
218:            protected String lastSelLocation = null;
219:
220:            protected String curSelLocation = null;
221:
222:            protected boolean readOnly = true;
223:
224:            protected class CbesbItem {
225:
226:                public String location;
227:
228:                public int type;
229:
230:                public int index = -1;
231:
232:                public CbesbItem(String location, int type, int index) {
233:                    super ();
234:                    this .location = location;
235:                    this .type = type;
236:
237:                    this .index = index;
238:                }
239:            }
240:
241:            protected void init() {
242:                initContent();
243:                initWidget(mainPanel);
244:
245:            }
246:
247:            private void initContent() {
248:                endpointPanel = new VerticalPanel();
249:                // endpointPanel.add(new
250:                // HTML("<head>"+((ConsoleMessages)GWT.create(ConsoleMessages.class)).waiting()+"</head>"));
251:                mainPanel.add(endpointPanel);
252:            }
253:
254:            public void onTreeItemSelected(TreeItem item) {
255:                if (item.getUserObject() != null) {
256:                    CbesbItem cbesbItem = (CbesbItem) item.getUserObject();
257:                    this .curSelLocation = cbesbItem.location;
258:                }
259:            }
260:
261:            public void onTreeItemStateChanged(TreeItem item) {
262:                if (item.getUserObject() != null) {
263:                    CbesbItem cbesbItem = (CbesbItem) item.getUserObject();
264:                    if (cbesbItem.type < TYPE_ENDPOINT) {
265:                        int index = cbesbItem.index;
266:                        if (item.getState()) {
267:                            this .expandArray[index] = "1";
268:                        } else {
269:                            this .expandArray[index] = "0";
270:                        }
271:                    }
272:                }
273:            }
274:
275:            private int findIndex(String[] array, String value) {
276:                for (int i = 0; i < array.length; i++) {
277:                    if (array[i].equals(value))
278:                        return i;
279:                }
280:                return -1;
281:            }
282:
283:            protected String getExpandState(String itemName) {
284:                if (this .lastExpandArray != null) {
285:                    int index = findIndex(this .lastSaArray, itemName);
286:                    if (index > -1)
287:                        return this .lastExpandArray[index];
288:                    else
289:                        return "1";
290:
291:                } else
292:                    return "1";
293:            }
294:
295:            protected int calculateLen() {
296:                int len = 0;
297:                for (int i = 0; i < saList.length; i++) {
298:                    len++;
299:                    for (int j = 0; j < saList[i].getComponentList().length; j++) {
300:                        len++;
301:                    }
302:                }
303:                return len;
304:            }
305:
306:            protected HTMLTable buildHtmlTable(JmxComponentObj component) {
307:
308:                int titileLen = 0;
309:
310:                if (component.getDisplayTitles() != null)
311:                    titileLen = component.getDisplayTitles().length;
312:
313:                Grid table = new Grid(component.getEndpointList().length + 1,
314:                        titileLen + 2);
315:                table.setStyleName(StyleConstants.TABLE_STYLE);
316:                table.getRowFormatter().setStyleName(0,
317:                        StyleConstants.TABLE_HEADER_STYLE);
318:
319:                table.setText(0, 0, ((ConsoleMessages) GWT
320:                        .create(ConsoleMessages.class)).messageName());
321:                table.setText(0, 1, ((ConsoleMessages) GWT
322:                        .create(ConsoleMessages.class)).Status());
323:                for (int i = 0; i < titileLen; i++) {
324:                    table.setText(0, i + 2, component.getDisplayTitles()[i]);
325:                }
326:
327:                for (int i = 0; i < component.getEndpointList().length; i++) {
328:                    JmxEndpointObj endpoint = component.getEndpointList()[i];
329:                    PushButton link = new PushButton(endpoint.getName());
330:                    link
331:                            .setStylePrimaryName(StyleConstants.PUSHBUTTON_TEXT_LEFT_STYLE);
332:
333:                    link.addClickListener(new EndpointSettingListener(endpoint
334:                            .getSaName(), endpoint.getComponentName(), endpoint
335:                            .getName(), endpoint.getSuName(), endpoint
336:                            .getRole()));
337:                    table.setWidget(i + 1, 0, link);
338:                    if (endpoint.getRole().equalsIgnoreCase("consumer")) {
339:                        table.getRowFormatter().setStyleName(i + 1,
340:                                StyleConstants.TABLE_C_TD_STYLE);
341:
342:                        endpointView.setStatusCell(table, i + 1, endpoint);
343:                    } else {
344:                        table.setText(i + 1, 1, endpoint.getStatus());
345:                        table.getRowFormatter().setStyleName(i + 1,
346:                                StyleConstants.TABLE_TD_STYLE);
347:                        if (JmxEndpointInfo.isDownStatus(endpoint.getStatus()))
348:                            table.getCellFormatter().setStyleName(i + 1, 1,
349:                                    StyleConstants.TABLE_C_SHUTDOWN_STYLE);
350:                        else
351:                            table.getCellFormatter().setStyleName(i + 1, 1,
352:                                    StyleConstants.TABLE_C_STARTED_STYLE);
353:
354:                    }
355:                    for (int j = 0; j < ((endpoint.getDisplayValues() != null) ? endpoint
356:                            .getDisplayValues().length
357:                            : 0); j++) {
358:                        String value = endpoint.getDisplayValues()[j];
359:                        if (value == null)
360:                            value = "";
361:                        if (value.length() == 0)
362:                            value += " ";
363:                        table.setText(i + 1, j + 2, value);
364:                    }
365:                }
366:
367:                return table;
368:            }
369:
370:            protected HTMLTable buildHtmlStatisticsTable(Vector endpointList) {
371:                Grid table = new Grid(endpointList.size() + 1, 4);
372:                table.setStyleName(StyleConstants.TABLE_STYLE);
373:                table.getRowFormatter().setStyleName(0,
374:                        StyleConstants.TABLE_HEADER_STYLE);
375:
376:                table.setText(0, 0, ((ConsoleMessages) GWT
377:                        .create(ConsoleMessages.class)).messageName());
378:                table.setText(0, 1, ((ConsoleMessages) GWT
379:                        .create(ConsoleMessages.class)).messageCounts());
380:                table.setText(0, 2, ((ConsoleMessages) GWT
381:                        .create(ConsoleMessages.class)).messagePerSecond());
382:                table.setText(0, 3, ((ConsoleMessages) GWT
383:                        .create(ConsoleMessages.class)).latency());
384:
385:                for (int i = 0; i < endpointList.size(); i++) {
386:                    JmxEndpointObj endpoint = (JmxEndpointObj) endpointList
387:                            .get(i);
388:                    Button link = new Button(endpoint.getName());
389:                    link
390:                            .setStylePrimaryName(StyleConstants.PUSHBUTTON_TEXT_LEFT_STYLE);
391:
392:                    link.addClickListener(new EndpointSettingListener(endpoint
393:                            .getSaName(), endpoint.getComponentName(), endpoint
394:                            .getName(), endpoint.getSuName(), endpoint
395:                            .getRole()));
396:                    table.setWidget(i + 1, 0, link);
397:                    table.setText(i + 1, 1, String.valueOf(endpoint
398:                            .getMessagesCount()));
399:                    table.setText(i + 1, 2, String.valueOf(endpoint
400:                            .getMessagesPerSecond()));
401:                    table.setText(i + 1, 3, String.valueOf(endpoint
402:                            .getLatency()));
403:                    if (endpoint.getRole().equalsIgnoreCase("consumer")) {
404:                        table.getRowFormatter().setStyleName(i + 1,
405:                                StyleConstants.TABLE_C_TD_STYLE);
406:                    } else {
407:                        table.getRowFormatter().setStyleName(i + 1,
408:                                StyleConstants.TABLE_TD_STYLE);
409:                    }
410:                }
411:
412:                return table;
413:            }
414:
415:            protected abstract void drawTree();
416:
417:            protected void clearTree() {
418:                tree.removeItems();
419:            }
420:
421:            public void startEndpoint(String saName, String componentName,
422:                    String endpointName) {
423:                stopPollingFlag();
424:                getJmxOperationAsyncFromModule().startEndpoint(saName,
425:                        componentName, endpointName, getStatusOperCallback());
426:            }
427:
428:            public void stopEndpoint(String saName, String componentName,
429:                    String endpointName) {
430:                stopPollingFlag();
431:                getJmxOperationAsyncFromModule().stopEndpoint(saName,
432:                        componentName, endpointName, getStatusOperCallback());
433:            }
434:
435:            public void cycleEndpoint(String saName, String componentName,
436:                    String endpointName) {
437:                stopPollingFlag();
438:                getJmxOperationAsyncFromModule().cycleEndpoint(saName,
439:                        componentName, endpointName, getStatusOperCallback());
440:            }
441:
442:            public void setPropertyObjects(String saName, String suName,
443:                    String componentName, String endpointName, String type,
444:                    String[][] newProperties) {
445:                showWaitingDialog();
446:                getJmxOperationAsyncFromModule().setPropertyObjects(saName,
447:                        suName, componentName, endpointName, type,
448:                        newProperties, settingCallback);
449:
450:            }
451:
452:            public void deletePropertyObjects(String saName, String suName,
453:                    String endpointName, String type) {
454:                showWaitingDialog();
455:                getJmxOperationAsyncFromModule().deletePropertyObjects(saName,
456:                        suName, endpointName, type, settingCallback);
457:
458:            }
459:
460:            public class SettingCallback extends ConsoleCallback {
461:
462:                public SettingCallback(ICallbackHandler handler) {
463:                    super (handler);
464:                }
465:
466:                public void handleSuccess(Object result) {
467:                    if (result instanceof  BaseRPCResultInfo) {
468:                        BaseRPCResultInfo info = (BaseRPCResultInfo) result;
469:                        if (info.getCallType() == JmxEndpointInfo.DELETE_PROPERTY_OBJECTS) {
470:                            MessageViewDialog.showInfo(((ConsoleMessages) GWT
471:                                    .create(ConsoleMessages.class))
472:                                    .redeployPrompt(info.getSource()));
473:                        }
474:                    }
475:
476:                    refresh();
477:
478:                }
479:
480:            }
481:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.