WebAppItem.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: WebAppItem.java,v 1.5 2004/03/22 14:53:19 danesa Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.service.container;
00027 
00028 import javax.management.ObjectName;
00029 
00033 public class WebAppItem extends ContainerItem {
00034 
00035 // --------------------------------------------------------- Constants
00036 
00037     public final static String LABEL_ROOT_WEBMODULE = "ROOT";
00038 
00039 // --------------------------------------------------------- Properties Variables
00040 
00041     private String objectName = null;
00042     private String pathContext = null;
00043     private String labelPathContext = null;
00044     private boolean deployed = false;
00045 
00046 // --------------------------------------------------------- Constructors
00047 
00048     public WebAppItem() {
00049     }
00050 
00051     public WebAppItem(ObjectName p_ObjectName) {
00052         setObjectName(p_ObjectName.toString());
00053         setName(p_ObjectName.getKeyProperty("name"));
00054         setPathContext(extractPathContext(getName()));
00055     }
00056 
00057     public WebAppItem(String p_PathContext, String p_ObjectName) {
00058         setPathContext(p_PathContext);
00059         setObjectName(p_ObjectName);
00060     }
00061 
00062 // --------------------------------------------------------- Public static Methods
00063 
00064     public static String extractLabelPathContext(String p_Name) {
00065         String s = p_Name;
00066         if ((s != null) && (s.length() > 0)) {
00067             // Delete HOST
00068             s = extractPathContext(p_Name);
00069             // Delete '/'
00070             if (s.charAt(0) == '/') {
00071                 s = s.substring(1);
00072                 if (s.length() == 0) {
00073                     s = LABEL_ROOT_WEBMODULE;
00074                 }
00075             }
00076         }
00077         return s;
00078     }
00079 
00080     public static String extractPathContext(String p_Name) {
00081         String s = p_Name;
00082         // Delete //HOST
00083         int iPos = s.indexOf("//");
00084         if (iPos > -1) {
00085             s = s.substring(iPos + 2);
00086             iPos = s.indexOf("/");
00087             if (iPos > -1) {
00088                 s = s.substring(iPos);
00089             }
00090         }
00091         return s;
00092     }
00093 
00094 // --------------------------------------------------------- Properties Methods
00095 
00096     public String getPathContext() {
00097         return pathContext;
00098     }
00099 
00100     public void setPathContext(String pathContext) {
00101         this.pathContext = pathContext;
00102         this.labelPathContext = extractLabelPathContext(pathContext);
00103     }
00104 
00105     public boolean isDeployed() {
00106         return deployed;
00107     }
00108 
00109     public String getLabelPathContext() {
00110         return labelPathContext;
00111     }
00112 
00118     public void setPath(String p_Path) {
00119         super.setPath(p_Path);
00120         if (getPath() != null) {
00121             deployed = true;
00122         }
00123     }
00124 }

Generated on Tue Feb 15 15:05:31 2005 for JOnAS by  doxygen 1.3.9.1