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$
023: */
024: package com.bostechcorp.cbesb.console.client;
025:
026: import com.bostechcorp.cbesb.console.client.dialogs.EndpointOperDialogBase;
027: import com.bostechcorp.cbesb.console.common.Constants;
028: import com.bostechcorp.cbesb.console.rpc.PollingNotification;
029: import com.bostechcorp.cbesb.console.rpc.PollingNotificationAsync;
030: import com.google.gwt.core.client.GWT;
031: import com.google.gwt.user.client.rpc.AsyncCallback;
032: import com.google.gwt.user.client.rpc.ServiceDefTarget;
033:
034: public abstract class AdminEndPoints extends Admin {
035: protected boolean bShow = false;
036: protected boolean bPolling = false;
037: public EndpointOperDialogBase operDialog = null;
038:
039: public class StopPollingCallback implements AsyncCallback {
040:
041: public StopPollingCallback() {
042:
043: }
044:
045: //override, do nothing
046: public void onFailure(Throwable caught) {
047:
048: }
049:
050: // do nothing here
051: public void onSuccess(Object result) {
052: // TODO Auto-generated method stub
053:
054: }
055:
056: }
057:
058: /**
059: * The policy for polling is: If we do any operation, we should stop polling.
060: * After we get the result, we need to start polling.
061: */
062: public void onHide() {
063: stopShowFlag();
064: stopPollingFlag();
065: }
066:
067: protected void onDetach() {
068: stopPollingFlag();
069: super .onDetach();
070: }
071:
072: public void onShow() {
073: startShowFlag();
074: initRefresh();
075: }
076:
077: protected void stopShowFlag() {
078: bShow = false;
079: }
080:
081: protected void startShowFlag() {
082: bShow = true;
083: }
084:
085: protected void stopPollingFlag() {
086: bPolling = false;
087: getJmxOperationAsyncFromModule().stopPollingNotification(
088: new StopPollingCallback());
089: }
090:
091: protected void startPollingFlag() {
092: bPolling = true;
093: }
094:
095: public boolean canPolling() {
096: return bShow && bPolling;
097: }
098:
099: protected abstract void doPolling();
100:
101: protected void polling() {
102: if (canPolling()) {
103: doPolling();
104: }
105: }
106:
107: /**
108: * First time when use click the munu,
109: *
110: */
111: public abstract void initRefresh();
112:
113: protected PollingNotificationAsync polling = null;
114:
115: public PollingNotificationAsync getPollingAsyncFromModule() {
116: if (polling == null) {
117: polling = (PollingNotificationAsync) GWT
118: .create(PollingNotification.class);
119: ServiceDefTarget jmxConnectTarget = (ServiceDefTarget) polling;
120: String relativeUrl = GWT.getModuleBaseURL()
121: + Constants.POLLING_NOTIFICATION_SERVLET;
122: jmxConnectTarget.setServiceEntryPoint(relativeUrl);
123: }
124: return polling;
125: }
126: }
|