001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.server.webapp;
031:
032: import java.util.Date;
033:
034: import com.caucho.management.server.HostMXBean;
035: import com.caucho.management.server.SessionManagerMXBean;
036: import com.caucho.management.server.WebAppMXBean;
037: import com.caucho.server.deploy.DeployControllerAdmin;
038: import com.caucho.server.host.Host;
039: import com.caucho.util.L10N;
040:
041: /**
042: * The admin implementation for a web-app.
043: */
044: public class WebAppAdmin extends
045: DeployControllerAdmin<WebAppController> implements WebAppMXBean {
046: private static final L10N L = new L10N(WebAppAdmin.class);
047:
048: public WebAppAdmin(WebAppController controller) {
049: super (controller);
050: }
051:
052: //
053: // Hierarchy attributes
054: //
055:
056: /**
057: * Returns the owning host
058: */
059: public HostMXBean getHost() {
060: Host host = getController().getHost();
061:
062: if (host != null)
063: return host.getAdmin();
064: else
065: return null;
066: }
067:
068: public SessionManagerMXBean getSessionManager() {
069: WebApp app = getWebApp();
070:
071: if (app == null)
072: return null;
073:
074: return app.getSessionManager().getAdmin();
075: }
076:
077: //
078: // Configuration attribute
079: //
080:
081: /**
082: * Returns the context path
083: */
084: public String getContextPath() {
085: return getController().getContextPath();
086: }
087:
088: //
089: // error statistics
090: //
091:
092: public long getStatus500CountTotal() {
093: return getWebApp().getStatus500CountTotal();
094: }
095:
096: public Date getStatus500LastTime() {
097: long lastTime = getWebApp().getStatus500LastTime();
098:
099: if (lastTime > 0)
100: return new Date(lastTime);
101: else
102: return null;
103: }
104:
105: //
106: // statistics
107: //
108:
109: public int getRequestCount() {
110: return getWebApp().getRequestCount();
111: }
112:
113: public long getRequestCountTotal() {
114: return getController().getLifetimeConnectionCount();
115: }
116:
117: public long getRequestTimeTotal() {
118: return getController().getLifetimeConnectionTime();
119: }
120:
121: public long getRequestReadBytesTotal() {
122: return getController().getLifetimeReadBytes();
123: }
124:
125: public long getRequestWriteBytesTotal() {
126: return getController().getLifetimeWriteBytes();
127: }
128:
129: public long getClientDisconnectCountTotal() {
130: return getController().getLifetimeClientDisconnectCount();
131: }
132:
133: /**
134: * Returns the active webApp.
135: */
136: protected WebApp getWebApp() {
137: return getController().getWebApp();
138: }
139:
140: }
|