KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > catalina > ConnectorItem


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: ConnectorItem.java,v 1.7 2004/10/15 06:58:18 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.catalina;
27
28 import java.io.Serializable JavaDoc;
29
30 import javax.management.ObjectName JavaDoc;
31
32 import org.objectweb.jonas.jmx.JonasManagementRepr;
33
34 /**
35  * @author Michel-Ange ANTON
36  */

37 public class ConnectorItem implements Serializable JavaDoc {
38
39 // --------------------------------------------------------- Properties Variables
40

41     private String JavaDoc objectName = null;
42     private String JavaDoc port = null;
43     private String JavaDoc address = null;
44     private String JavaDoc scheme = null;
45     private String JavaDoc connectorType = null;
46     private boolean applicationServerPort = false;
47
48 // --------------------------------------------------------- Constructors
49

50     public ConnectorItem() {
51     }
52
53     public ConnectorItem(ObjectName JavaDoc p_OnConnector, int p_ApplicationServerPort)
54         throws Exception JavaDoc {
55         setObjectName(p_OnConnector.toString());
56         setPort(p_OnConnector.getKeyProperty("port"));
57         applicationServerPort = port.equals(String.valueOf(p_ApplicationServerPort));
58         setAddress((String JavaDoc) JonasManagementRepr.getAttribute(p_OnConnector, "address"));
59         setScheme((String JavaDoc) JonasManagementRepr.getAttribute(p_OnConnector, "scheme"));
60
61         String JavaDoc sHandlerClassName = (String JavaDoc) JonasManagementRepr.getAttribute(p_OnConnector
62             , "protocolHandlerClassName");
63         int period = sHandlerClassName.lastIndexOf('.');
64         String JavaDoc sHandlerType = sHandlerClassName.substring(period + 1);
65         setConnectorType("HTTPS");
66         if ("JkCoyoteHandler".equalsIgnoreCase(sHandlerType)) {
67             setConnectorType("AJP");
68         }
69         else if (("Http11Protocol".equalsIgnoreCase(sHandlerType) == true)
70             && ("http".equalsIgnoreCase(getScheme()) == true)) {
71             setConnectorType("HTTP");
72         }
73     }
74
75 // --------------------------------------------------------- Properties Methods
76

77     public String JavaDoc getPort() {
78         return port;
79     }
80
81     public void setPort(String JavaDoc port) {
82         this.port = port;
83     }
84
85     public String JavaDoc getAddress() {
86         return address;
87     }
88
89     public void setAddress(String JavaDoc address) {
90         this.address = address;
91     }
92
93     public String JavaDoc getScheme() {
94         return scheme;
95     }
96
97     public void setScheme(String JavaDoc scheme) {
98         this.scheme = scheme;
99     }
100
101     public String JavaDoc getObjectName() {
102         return objectName;
103     }
104
105     public void setObjectName(String JavaDoc objectName) {
106         this.objectName = objectName;
107     }
108
109     public String JavaDoc getConnectorType() {
110         return connectorType;
111     }
112
113     public void setConnectorType(String JavaDoc connectorType) {
114         this.connectorType = connectorType;
115     }
116
117     public boolean isApplicationServerPort() {
118         return applicationServerPort;
119     }
120
121     public String JavaDoc getLabel() {
122         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(getPort());
123         if (getAddress() != null) {
124             sb.append(" (");
125             sb.append(getAddress());
126             sb.append(")");
127         }
128         return sb.toString();
129     }
130 }
Popular Tags