KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > service > container > WebAppItem


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 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: WebAppItem.java,v 1.5 2004/03/22 14:53:19 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.service.container;
27
28 import javax.management.ObjectName JavaDoc;
29
30 /**
31  * @author Michel-Ange ANTON
32  */

33 public class WebAppItem extends ContainerItem {
34
35 // --------------------------------------------------------- Constants
36

37     public final static String JavaDoc LABEL_ROOT_WEBMODULE = "ROOT";
38
39 // --------------------------------------------------------- Properties Variables
40

41     private String JavaDoc objectName = null;
42     private String JavaDoc pathContext = null;
43     private String JavaDoc labelPathContext = null;
44     private boolean deployed = false;
45
46 // --------------------------------------------------------- Constructors
47

48     public WebAppItem() {
49     }
50
51     public WebAppItem(ObjectName JavaDoc p_ObjectName) {
52         setObjectName(p_ObjectName.toString());
53         setName(p_ObjectName.getKeyProperty("name"));
54         setPathContext(extractPathContext(getName()));
55     }
56
57     public WebAppItem(String JavaDoc p_PathContext, String JavaDoc p_ObjectName) {
58         setPathContext(p_PathContext);
59         setObjectName(p_ObjectName);
60     }
61
62 // --------------------------------------------------------- Public static Methods
63

64     public static String JavaDoc extractLabelPathContext(String JavaDoc p_Name) {
65         String JavaDoc s = p_Name;
66         if ((s != null) && (s.length() > 0)) {
67             // Delete HOST
68
s = extractPathContext(p_Name);
69             // Delete '/'
70
if (s.charAt(0) == '/') {
71                 s = s.substring(1);
72                 if (s.length() == 0) {
73                     s = LABEL_ROOT_WEBMODULE;
74                 }
75             }
76         }
77         return s;
78     }
79
80     public static String JavaDoc extractPathContext(String JavaDoc p_Name) {
81         String JavaDoc s = p_Name;
82         // Delete //HOST
83
int iPos = s.indexOf("//");
84         if (iPos > -1) {
85             s = s.substring(iPos + 2);
86             iPos = s.indexOf("/");
87             if (iPos > -1) {
88                 s = s.substring(iPos);
89             }
90         }
91         return s;
92     }
93
94 // --------------------------------------------------------- Properties Methods
95

96     public String JavaDoc getPathContext() {
97         return pathContext;
98     }
99
100     public void setPathContext(String JavaDoc pathContext) {
101         this.pathContext = pathContext;
102         this.labelPathContext = extractLabelPathContext(pathContext);
103     }
104
105     public boolean isDeployed() {
106         return deployed;
107     }
108
109     public String JavaDoc getLabelPathContext() {
110         return labelPathContext;
111     }
112
113     /**
114      * Extend parent method to set the property <code>deployed</code>.
115      *
116      * @param p_Path The complete path (docBase) of the web application
117      */

118     public void setPath(String JavaDoc p_Path) {
119         super.setPath(p_Path);
120         if (getPath() != null) {
121             deployed = true;
122         }
123     }
124 }
Popular Tags