- Timestamp:
- 03/26/09 13:58:46 (18 months ago)
- Location:
- tools/routingservice/branches/wrs-2.0
- Files:
-
- 2 added
- 6 modified
-
data/config/configuration.xml (modified) (1 diff)
-
data/resources.xml (added)
-
lib/commons-collections-3.2.1.jar (added)
-
src/WRS.java (modified) (9 diffs)
-
src/model/Profile.java (modified) (4 diffs)
-
src/model/Resource.java (modified) (1 diff)
-
src/util/resource/ObjectFactory.java (modified) (3 diffs)
-
src/util/resource/Resources.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/routingservice/branches/wrs-2.0/data/config/configuration.xml
r285 r286 7 7 <log level="5" url="./logs/wrs-log.log"/> 8 8 <includes> 9 <include name="services" url="./data/services.xml"/> 9 10 <include name="templates" url="./data/templates.xml"/> 10 <include name=" services" url="./data/services.xml"/>11 <include name="resources" url="./data/resources.xml"/> 11 12 <include name="profiles" url="./data/profiles.xml"/> 12 <include name="resources" url="./data/resources.xml"/>13 13 </includes> 14 14 </configuration> -
tools/routingservice/branches/wrs-2.0/src/WRS.java
r285 r286 1 1 import java.io.IOException; 2 import java.util.Enumeration; 2 3 import java.util.Hashtable; 3 4 import java.util.ListIterator; … … 13 14 import org.xml.sax.SAXException; 14 15 15 16 16 import util.IOHelper; 17 17 import util.Log; 18 import util.Parameter; 18 19 import util.conf.Configuration; 19 20 import util.conf.Configuration.Includes.Include; 20 21 import util.profile.Profiles; 21 22 import util.profile.Profiles.Profile.Resources.Rref; 22 23 import util.resource.Resources; 23 24 24 25 public class WRS … … 38 39 39 40 public WRS(String[] args) 40 { 41 { 41 42 if (!checkParams(args)) 42 43 { … … 44 45 System.out.println("Usage: java WRS configuration.xml"); 45 46 System.exit(0); 46 } 47 47 } 48 49 this.resources = new Hashtable(); 50 48 51 this.conf = readConfig(args[0]); 49 52 … … 78 81 { 79 82 Include inc = li.next(); 80 83 81 84 switch (Includes.valueOf(inc.getName().toUpperCase())) 82 85 { … … 119 122 private void readResources(String url) 120 123 { 121 System.out.println("Read resources from "+url+" file."); 124 System.out.println("Read resources from " + url + " file."); 125 Resources resources; 126 try 127 { 128 resources = IOHelper.readConfig(Resources.class, url); 129 ListIterator<util.resource.Resources.Resource> li = resources 130 .getResource().listIterator(); 131 while (li.hasNext()) 132 { 133 util.resource.Resources.Resource res = li.next(); 134 Resource resource = new Resource(res.getName(), res.getType()); 135 136 ListIterator<Parameter> pi = res.getParameters().getParameter() 137 .listIterator(); 138 while (pi.hasNext()) 139 { 140 Parameter p = pi.next(); 141 if (p.getSource() == null) 142 p.setSource("resource"); 143 resource.getParameters().put(p.getName(), p); 144 } 145 146 this.resources.put(resource.getName(), resource); 147 } 148 149 } 150 catch (SAXException e) 151 { 152 System.out.println("Wrong resources configuration file."); 153 } 154 catch (IOException e) 155 { 156 System.out.println("Can't open resources configuration file."); 157 } 158 catch (ParserConfigurationException e) 159 { 160 System.out.println("Wrong resources configuration file."); 161 } 162 catch (JAXBException e) 163 { 164 System.out.println("Wrong resources configuration file."); 165 } 122 166 123 167 } … … 125 169 private void readProfiles(String url) 126 170 { 127 System.out.println("Read profiles from " +url+" file.");171 System.out.println("Read profiles from " + url + " file."); 128 172 try 129 173 { 130 174 Profiles profiles = IOHelper.readConfig(Profiles.class, url); 131 ListIterator<util.profile.Profiles.Profile> li = profiles.getProfile().listIterator(); 132 while(li.hasNext()) 175 ListIterator<util.profile.Profiles.Profile> li = profiles 176 .getProfile().listIterator(); 177 while (li.hasNext()) 133 178 { 134 179 util.profile.Profiles.Profile prof = li.next(); 135 180 Profile profile = new Profile(prof.getName()); 136 181 profile.setDescription(prof.getDescription()); 137 ListIterator<Rref> ri = prof.getResources().getRref().listIterator(); 138 while(ri.hasNext()) 182 ListIterator<Rref> ri = prof.getResources().getRref() 183 .listIterator(); 184 while (ri.hasNext()) 139 185 { 140 186 Rref rref = ri.next(); 141 187 142 188 try 143 189 { 144 190 Resource res = this.resources.get(rref.getRef()); 145 if (res != null)191 if (res != null) 146 192 { 147 //TODO copy parameters from the resource 148 profile.getResources().add(res); 193 Enumeration<String> pi = res.getParameters().keys(); 194 while (pi.hasMoreElements()) 195 { 196 String pk = pi.nextElement(); 197 profile.getParameters().put(pk, 198 res.getParameters().get(pk)); 199 } 200 201 profile.getResources().put(res.getName(), res); 202 } 203 else 204 { 205 System.out.println("No such resource: " 206 + rref.getRef()); 149 207 } 150 208 } 151 209 catch (NullPointerException e) 152 210 { 153 System.out.println("No such resource: "+rref.getRef()); 211 System.out.println("Resource " + rref.getRef() 212 + " is not properly configured"); 154 213 } 214 215 } 216 217 ListIterator<Parameter> pi = prof.getParameters() 218 .getParameter().listIterator(); 219 while (pi.hasNext()) 220 { 221 Parameter p = pi.next(); 222 if (p.getSource() == null) 223 p.setSource("profile"); 224 profile.getParameters().put(p.getName(), p); 155 225 } 156 226 } … … 177 247 private void readTemplates(String url) 178 248 { 179 System.out.println("Read templates from " +url+" file.");249 System.out.println("Read templates from " + url + " file."); 180 250 181 251 } … … 183 253 private void readServices(String url) 184 254 { 185 System.out.println("Read services from " +url+" file.");255 System.out.println("Read services from " + url + " file."); 186 256 } 187 257 -
tools/routingservice/branches/wrs-2.0/src/model/Profile.java
r285 r286 1 1 package model; 2 2 3 import java.util. ArrayList;3 import java.util.HashMap; 4 4 import java.util.Hashtable; 5 6 import org.apache.commons.collections.map.MultiValueMap; 5 7 6 8 import util.Parameter; … … 10 12 private String name; 11 13 private String description; 12 private Hashtable<String, Parameter> parameters; 13 private ArrayList<Resource> resources; 14 private MultiValueMap parameters; 15 private Hashtable<String, Resource> resources; 16 private Hashtable<String, Service> services; 14 17 15 18 public Profile(String name) … … 17 20 super(); 18 21 this.name = name; 22 23 HashMap<String, Parameter> hm = new HashMap<String, Parameter>(); 24 parameters = MultiValueMap.decorate(hm); 25 26 //parameters = new MultiValueMap(); 27 resources = new Hashtable<String, Resource>(); 28 services = new Hashtable<String, Service>(); 29 19 30 } 20 31 … … 39 50 } 40 51 41 public Hashtable<String, Parameter>getParameters()52 public MultiValueMap getParameters() 42 53 { 43 54 return parameters; 44 55 } 45 56 46 public void setParameters(Hashtable<String, Parameter> parameters)47 {48 this.parameters = parameters;49 }50 57 51 public ArrayList<Resource> getResources()58 public Hashtable<String, Resource> getResources() 52 59 { 53 60 return resources; 54 61 } 55 62 56 public void setResources( ArrayList<Resource> resources)63 public void setResources(Hashtable<String, Resource> resources) 57 64 { 58 65 this.resources = resources; 59 66 } 60 67 61 public void addResource(Resource resource)62 {63 this.resources.add(resource);64 }65 66 68 } -
tools/routingservice/branches/wrs-2.0/src/model/Resource.java
r285 r286 25 25 this.name = name; 26 26 this.type = type; 27 28 parameters = new Hashtable<String, Parameter>(); 29 services = new Hashtable<String, Service>(); 27 30 } 31 32 public String getName() 33 { 34 return name; 35 } 28 36 29 37 public String getDescription() -
tools/routingservice/branches/wrs-2.0/src/util/resource/ObjectFactory.java
r285 r286 3 3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 4 4 // Any modifications to this file will be lost upon recompilation of the source schema. 5 // Generated on: 2009.03.2 5 at 04:41:37PM JST5 // Generated on: 2009.03.26 at 01:00:53 PM JST 6 6 // 7 7 … … 48 48 49 49 /** 50 * Create an instance of {@link Resources.Resource.Parameters }51 *52 */53 public Resources.Resource.Parameters createResourcesResourceParameters() {54 return new Resources.Resource.Parameters();55 }56 57 /**58 * Create an instance of {@link Resources }59 *60 */61 public Resources createResources() {62 return new Resources();63 }64 65 /**66 50 * Create an instance of {@link Resources.Resource.Services.Sref } 67 51 * … … 87 71 } 88 72 73 /** 74 * Create an instance of {@link Resources } 75 * 76 */ 77 public Resources createResources() { 78 return new Resources(); 79 } 80 81 /** 82 * Create an instance of {@link Resources.Resource.Parameters } 83 * 84 */ 85 public Resources.Resource.Parameters createResourcesResourceParameters() { 86 return new Resources.Resource.Parameters(); 87 } 88 89 89 } -
tools/routingservice/branches/wrs-2.0/src/util/resource/Resources.java
r285 r286 3 3 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 4 4 // Any modifications to this file will be lost upon recompilation of the source schema. 5 // Generated on: 2009.03.2 5 at 04:41:37PM JST5 // Generated on: 2009.03.26 at 01:00:53 PM JST 6 6 // 7 7 … … 31 31 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 32 32 * <sequence> 33 * <element name="resource" >33 * <element name="resource" maxOccurs="unbounded"> 34 34 * <complexType> 35 35 * <complexContent> … … 104 104 105 105 @XmlElement(required = true) 106 protected Resources.Resourceresource;106 protected List<Resources.Resource> resource; 107 107 108 108 /** 109 109 * Gets the value of the resource property. 110 110 * 111 * @return 112 * possible object is 113 * {@link Resources.Resource } 114 * 111 * <p> 112 * This accessor method returns a reference to the live list, 113 * not a snapshot. Therefore any modification you make to the 114 * returned list will be present inside the JAXB object. 115 * This is why there is not a <CODE>set</CODE> method for the resource property. 116 * 117 * <p> 118 * For example, to add a new item, do as follows: 119 * <pre> 120 * getResource().add(newItem); 121 * </pre> 122 * 123 * 124 * <p> 125 * Objects of the following type(s) are allowed in the list 126 * {@link Resources.Resource } 127 * 128 * 115 129 */ 116 public Resources.Resource getResource() { 117 return resource; 118 } 119 120 /** 121 * Sets the value of the resource property. 122 * 123 * @param value 124 * allowed object is 125 * {@link Resources.Resource } 126 * 127 */ 128 public void setResource(Resources.Resource value) { 129 this.resource = value; 130 public List<Resources.Resource> getResource() { 131 if (resource == null) { 132 resource = new ArrayList<Resources.Resource>(); 133 } 134 return this.resource; 130 135 } 131 136
