001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2003-2004 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: ConnectorItem.java 10100 2007-03-27 13:55:44Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.catalina;
025:
026: import java.io.Serializable;
027: import java.net.InetAddress;
028:
029: import javax.management.ObjectName;
030:
031: import org.objectweb.jonas.jmx.JonasManagementRepr;
032:
033: /**
034: * @author Michel-Ange ANTON
035: * @author danesa
036: */
037: public class ConnectorItem implements Serializable {
038:
039: // --------------------------------------------------------- Properties Variables
040:
041: private String objectName = null;
042: private String port = null;
043: private String address = null;
044: private String scheme = null;
045: private String connectorType = null;
046: private boolean applicationServerPort = false;
047:
048: // --------------------------------------------------------- Constructors
049:
050: public ConnectorItem() {
051: }
052:
053: public ConnectorItem(ObjectName p_OnConnector,
054: int p_ApplicationServerPort, String serverName)
055: throws Exception {
056: setObjectName(p_OnConnector.toString());
057: setPort(p_OnConnector.getKeyProperty("port"));
058: applicationServerPort = port.equals(String
059: .valueOf(p_ApplicationServerPort));
060: InetAddress address = (InetAddress) JonasManagementRepr
061: .getAttribute(p_OnConnector, "address", serverName);
062: if (address != null) {
063: setAddress(address.toString());
064: } else {
065: setAddress(null);
066: }
067: setScheme((String) JonasManagementRepr.getAttribute(
068: p_OnConnector, "scheme", serverName));
069:
070: String sHandlerClassName = (String) JonasManagementRepr
071: .getAttribute(p_OnConnector,
072: "protocolHandlerClassName", serverName);
073: int period = sHandlerClassName.lastIndexOf('.');
074: String sHandlerType = sHandlerClassName.substring(period + 1);
075: setConnectorType("HTTPS");
076: if ("JkCoyoteHandler".equalsIgnoreCase(sHandlerType)) {
077: setConnectorType("AJP");
078: } else if (("Http11Protocol".equalsIgnoreCase(sHandlerType))
079: && ("http".equalsIgnoreCase(getScheme()))) {
080: setConnectorType("HTTP");
081: }
082: }
083:
084: // --------------------------------------------------------- Properties Methods
085:
086: public String getPort() {
087: return port;
088: }
089:
090: public void setPort(String port) {
091: this .port = port;
092: }
093:
094: public String getAddress() {
095: if (address != null && address.startsWith("/")) {
096: address = address.substring(1);
097: }
098: return address;
099: }
100:
101: public void setAddress(String address) {
102: this .address = address;
103: }
104:
105: public String getScheme() {
106: return scheme;
107: }
108:
109: public void setScheme(String scheme) {
110: this .scheme = scheme;
111: }
112:
113: public String getObjectName() {
114: return objectName;
115: }
116:
117: public void setObjectName(String objectName) {
118: this .objectName = objectName;
119: }
120:
121: public String getConnectorType() {
122: return connectorType;
123: }
124:
125: public void setConnectorType(String connectorType) {
126: this .connectorType = connectorType;
127: }
128:
129: public boolean isApplicationServerPort() {
130: return applicationServerPort;
131: }
132:
133: public String getLabel() {
134: StringBuffer sb = new StringBuffer(getPort());
135: if (getAddress() != null) {
136: sb.append(" (");
137: sb.append(getAddress());
138: sb.append(")");
139: }
140: return sb.toString();
141: }
142: }
|