1 23 package com.sun.enterprise.admin.wsmgmt.repository.impl.cache; 24 25 import java.util.List ; 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 import java.util.StringTokenizer ; 29 30 37 public class J2eeApplication { 38 39 46 J2eeApplication(String name, List ejb, List web) { 47 _name = name; 48 _ejbBundles = ejb; 49 _webBundles = web; 50 } 51 52 58 J2eeApplication(String key, String val) { 59 _name = key; 60 _ejbBundles = new ArrayList (); 61 _webBundles = new ArrayList (); 62 63 StringTokenizer st = new StringTokenizer (val, DELIM); 64 while (st.hasMoreTokens()) { 65 String m = st.nextToken(); 66 if (m.startsWith(EJB_KEY)) { 67 int ejbKeyLength = EJB_KEY.length(); 68 String ejbModule = m.substring(ejbKeyLength); 69 addEjbBundle(ejbModule); 70 71 } else if (m.startsWith(WEB_KEY)) { 72 int webKeyLength = WEB_KEY.length(); 73 String webModule = m.substring(webKeyLength); 74 addWebBundle(webModule); 75 } 76 } 77 } 78 79 84 public String getName() { 85 return _name; 86 } 87 88 93 String getPersistentValue() { 94 StringBuffer sb = new StringBuffer (); 95 96 for (Iterator iter=_ejbBundles.iterator(); iter.hasNext();) { 97 String ejb = (String ) iter.next(); 98 sb.append(EJB_KEY); 99 sb.append(ejb); 100 sb.append(DELIM); 101 } 102 103 for (Iterator iter=_webBundles.iterator(); iter.hasNext();) { 104 String web = (String ) iter.next(); 105 sb.append(WEB_KEY); 106 sb.append(web); 107 sb.append(DELIM); 108 } 109 110 String persistentValue = null; 111 int length = sb.length(); 112 if (length > 0) { 113 String val = sb.toString(); 114 persistentValue = val.substring(0, length-1); 115 } 116 return persistentValue; 117 } 118 119 124 public List getEjbBundles() { 125 return _ejbBundles; 126 } 127 128 133 void addEjbBundle(String name) { 134 _ejbBundles.add(name); 135 } 136 137 143 boolean removeEjbBundle(String name) { 144 return _ejbBundles.remove(name); 145 } 146 147 152 public List getWebBundles() { 153 return _webBundles; 154 } 155 156 161 void addWebBundle(String name) { 162 _webBundles.add(name); 163 } 164 165 171 boolean removeWebBundle(String name) { 172 return _webBundles.remove(name); 173 } 174 175 String _name = null; 177 List _ejbBundles = null; 178 List _webBundles = null; 179 static final String DELIM = ","; 180 static final String EJB_KEY = "EJB_"; 181 static final String WEB_KEY = "WEB_"; 182 } 183 | Popular Tags |