Changeset 294 for tools

Show
Ignore:
Timestamp:
04/15/09 11:47:32 (17 months ago)
Author:
anton
Message:

Templates moved to services, MIME types processing added

Location:
tools/routingservice/branches/wrs-2.0
Files:
9 added
1 removed
10 modified

Legend:

Unmodified
Added
Removed
  • tools/routingservice/branches/wrs-2.0/data/resources.xml

    r291 r294  
    66                <description>My test profile I use for testing</description> 
    77                <parameters> 
    8                         <parameter name="srid" type="integer" key="srid" value="4301" /> 
     8                        <parameter name="srid" type="integer" key="srid" value="4326" /> 
    99                        <parameter name="units" type="string" key="units" value="dd" /> 
    10                         <parameter name="box" type="double" key="box" value="0.01" /> 
     10                        <parameter name="box" type="double" key="box" value="0.1" /> 
    1111                        <parameter name="cost_value" type="string" key="cost_value" value="length" /> 
     12                        <parameter name="reverse_cost_value" type="string" key="reverse_cost_value" value="reverse_cost" /> 
    1213                        <parameter name="directed" type="boolean" key="directed" 
    1314                                value="true" /> 
     
    1920                        <parameter name="cost" type="double" key="length(the_geom)"/> 
    2021                        <parameter name="line" type="geometry" key="astext(the_geom)"/>  
     22                        <parameter name="polygon" type="geometry" key="astext(the_geom)"/> 
    2123                                                 
    2224                </parameters> 
  • tools/routingservice/branches/wrs-2.0/data/services.xml

    r291 r294  
    11<?xml version="1.0"?> 
    2 <services 
    3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    4 xsi:noNamespaceSchemaLocation="http://wrs.postlbs.org/xsd/1.1.0/service.xsd" 
    5 > 
     2<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     3        xsi:noNamespaceSchemaLocation="http://wrs.postlbs.org/xsd/1.1.0/service.xsd"> 
    64        <service name="route" title="Shortest path"> 
    75                <description>Returns a shortest path between points A and B</description> 
     6                <templates> 
     7                        <template name="gml" format="xml" url="./data/templates/route/route_gml.st"/> 
     8                </templates> 
    89                <in> 
    9                         <parameter key="startX" type="double" name="x1"/> 
    10                         <parameter key="startY" type="double" name="y1"/> 
    11                         <parameter key="endX" type="double" name="x2"/> 
    12                         <parameter key="endY" type="double" name="y2"/>                  
    13                 </in>            
     10                        <parameter key="startX" type="double" name="x1" /> 
     11                        <parameter key="startY" type="double" name="y1" /> 
     12                        <parameter key="endX" type="double" name="x2" /> 
     13                        <parameter key="endY" type="double" name="y2" /> 
     14                </in> 
    1415                <out> 
    15                         <parameter name="id" type="integer" key="id"/> 
    16                         <parameter name="cost" type="double" key="cost"/> 
    17                         <parameter name="line" type="geometry" key="the_geom"/> 
    18                 </out>           
     16                        <parameter name="id" type="integer" key="id" /> 
     17                        <parameter name="cost" type="double" key="cost" /> 
     18                        <parameter name="line" type="geometry" key="the_geom" /> 
     19                </out> 
    1920        </service> 
    20          
     21        <service name="catch" title="Catchment area"> 
     22                <description>Returns a polygon representing a catchment area for going from point A within distance D</description> 
     23                <templates> 
     24                        <template name="kml" format="xml" url="./data/templates/route/route_kml.st"/> 
     25                </templates> 
     26                <in> 
     27                        <parameter key="startX" type="double" name="x1" /> 
     28                        <parameter key="startY" type="double" name="y1" /> 
     29                        <parameter key="distance" type="double" name="distance" /> 
     30                </in> 
     31                <out> 
     32                        <parameter name="polygon" type="geometry" key="the_geom" /> 
     33                </out> 
     34        </service> 
     35 
    2136</services> 
  • tools/routingservice/branches/wrs-2.0/src/WRS.java

    r291 r294  
    3232import util.conf.Configuration; 
    3333import util.conf.Configuration.Includes.Include; 
     34import util.format.FillerFactory; 
    3435import util.format.FormatParser; 
    3536import util.format.GMLTemplateFiller; 
    3637import util.format.JSONParser; 
     38import util.format.ParserFactory; 
    3739import util.format.TemplateFiller; 
    3840import util.profile.Profiles; 
     
    6062        private Configuration conf; 
    6163 
    62         private Hashtable<String, Template> templates; 
    6364        private Hashtable<String, Service> services; 
    6465        private Hashtable<String, Profile> profiles; 
     
    6768        private static final String DEFAULT_VERSION = "1.1.0"; 
    6869 
    69         public enum Includes 
     70        private enum Includes 
    7071        { 
    7172                TEMPLATES, SERVICES, PROFILES, RESOURCES; 
    7273        } 
    7374 
    74         public enum ParameterSources 
     75        private enum ParameterSources 
    7576        { 
    7677                URL, PROFILE, RESOURCE; 
    7778        } 
    7879 
    79         public enum Formats 
    80         { 
    81                 JSON(JSONParser.class), GEOJSON(null), KML(null), GML(null), XLS(null), GEORSS( 
    82                                 null), GPX(null); 
    83  
    84                 private Class<? extends FormatParser> parserType; 
    85  
    86                 Formats(Class<? extends FormatParser> p) 
    87                 { 
    88                         this.parserType = p; 
    89                 } 
    90  
    91                 public FormatParser getInstance() throws InstantiationException, 
    92                                 IllegalAccessException 
    93                 { 
    94                         return parserType.newInstance(); 
    95                 } 
    96         } 
    97  
    98         public enum Fillers 
    99         { 
    100                 JSON(null), GEOJSON(null), KML(null), GML(GMLTemplateFiller.class), XLS( 
    101                                 null), GEORSS(null), GPX(null); 
    102  
    103                 private Class<? extends TemplateFiller> fillerType; 
    104  
    105                 Fillers(Class<? extends TemplateFiller> p) 
    106                 { 
    107                         this.fillerType = p; 
    108                 } 
    109  
    110                 public TemplateFiller getInstance() throws InstantiationException, 
    111                                 IllegalAccessException 
    112                 { 
    113                         return fillerType.newInstance(); 
    114                 } 
     80        private enum MIMETypes 
     81        { 
     82                TEXT 
     83                { 
     84                        MediaType getType() 
     85                        { 
     86                                return MediaType.TEXT_ALL; 
     87                        } 
     88                }, 
     89                JSON 
     90                { 
     91                        MediaType getType() 
     92                        { 
     93                                return MediaType.TEXT_JAVASCRIPT; 
     94                        } 
     95                }, 
     96                XML 
     97                { 
     98                        MediaType getType() 
     99                        { 
     100                                return MediaType.TEXT_XML; 
     101                        } 
     102                }; 
     103 
     104                abstract MediaType getType(); 
     105 
    115106        } 
    116107 
     
    127118                this.services = new Hashtable<String, Service>(); 
    128119                this.profiles = new Hashtable<String, Profile>(); 
    129                 this.templates = new Hashtable<String, Template>(); 
    130120 
    131121                this.conf = readConfig(args[0]); 
     
    185175                                                        try 
    186176                                                        { 
    187                                                                 TemplateFiller filler = Fillers.valueOf( 
    188                                                                                 templateName.toUpperCase()) 
     177                                                                TemplateFiller filler = FillerFactory.Fillers 
     178                                                                                .valueOf(templateName.toUpperCase()) 
    189179                                                                                .getInstance(); 
    190180                                                                result = filler.fillOutputTemplate( 
     
    255245                                } 
    256246 
    257                                 response.setEntity(result, MediaType.TEXT_ALL); 
     247                                String templateType = serviceRequest.getTemplate().getFormat(); 
     248                                response.setEntity(result, MIMETypes.valueOf( 
     249                                                templateType.toUpperCase()).getType()); 
    258250                        } 
    259251                }; 
     
    305297 
    306298                String tName = urlSplit[urlIndex].split("\\.")[1].split("\\?")[0]; 
    307                 Template cTemplate = this.templates.get(tName); 
     299                Template cTemplate = cService.getTemplates().get(tName); 
    308300 
    309301                if (cTemplate == null) 
     
    368360                        try 
    369361                        { 
    370                                 FormatParser parser = Formats.valueOf(name.toUpperCase()) 
    371                                                 .getInstance(); 
     362                                FormatParser parser = ParserFactory.Formats.valueOf( 
     363                                                name.toUpperCase()).getInstance(); 
    372364                                Hashtable<String, Parameter> params = parser.parse(value); 
    373365                                addParameters(request.getParameters(), params); 
     
    402394                        String key = it.next(); 
    403395                        String value = toAdd.get(key).getValue(); 
    404                          
     396 
    405397                        if (parameters.containsKey(key)) 
    406398                        { 
     
    448440                                switch (Includes.valueOf(inc.getName().toUpperCase())) 
    449441                                { 
    450                                 case TEMPLATES: 
    451                                         readTemplates(inc.getUrl()); 
    452                                         break; 
    453442                                case SERVICES: 
    454443                                        readServices(inc.getUrl()); 
     
    643632        } 
    644633 
    645         private void readTemplates(String url) 
    646         { 
     634        private Template readTemplate(util.service.Template temp) 
     635        { 
     636                Template template = new Template(temp.getName(), temp.getFormat()); 
     637 
     638                String body; 
    647639                try 
    648640                { 
    649                         System.out.println("Read templates from " + url + " file."); 
    650  
    651                         util.template.Templates templates = IOHelper.readConfig( 
    652                                         util.template.Templates.class, url); 
    653                         ListIterator<util.template.Templates.Template> li = templates 
    654                                         .getTemplate().listIterator(); 
    655  
    656                         while (li.hasNext()) 
    657                         { 
    658                                 util.template.Templates.Template temp = li.next(); 
    659                                 Template template = new Template(temp.getName(), temp 
    660                                                 .getFormat()); 
    661  
    662                                 ListIterator<Sref> si = temp.getServices().getSref() 
    663                                                 .listIterator(); 
    664                                 while (si.hasNext()) 
    665                                 { 
    666                                         Sref sref = si.next(); 
    667                                         Service service = this.services.get(sref.getRef()); 
    668                                         if (service != null) 
    669                                         { 
    670                                                 template.getServices().put(service.getName(), service); 
    671                                         } 
    672                                         else 
    673                                         { 
    674                                                 System.out.println("No such service: " + sref.getRef()); 
    675                                         } 
    676                                 } 
    677  
    678                                 String body = IOHelper.readFile(temp.getUrl()); 
    679                                 template.setBody(body); 
    680  
    681                                 this.templates.put(template.getName(), template); 
    682                         } 
    683                 } 
    684                 catch (SAXException e) 
    685                 { 
    686                         System.out.println("Wrong templates configuration file."); 
    687                 } 
    688                 catch (NullPointerException e) 
    689                 { 
    690                         System.out.println("Wrong templates configuration file."); 
     641                        body = IOHelper.readFile(temp.getUrl()); 
     642                        template.setBody(body); 
    691643                } 
    692644                catch (IOException e) 
    693645                { 
    694                         System.out.println("Can't open profiles configuration file."); 
    695                 } 
    696                 catch (ParserConfigurationException e) 
    697                 { 
    698                         System.out.println("Wrong templates configuration file."); 
    699                 } 
    700                 catch (JAXBException e) 
    701                 { 
    702                         System.out.println("Wrong templates configuration file."); 
    703                 } 
     646                        System.out 
     647                                        .println("Can't open template body file " + temp.getUrl()); 
     648                } 
     649 
     650                return template; 
    704651        } 
    705652 
     
    719666                                Service service = new Service(serv.getName()); 
    720667 
     668                                ListIterator<util.service.Template> tempi = serv.getTemplates() 
     669                                                .getTemplate().listIterator(); 
     670                                while (tempi.hasNext()) 
     671                                { 
     672                                        util.service.Template temp = tempi.next(); 
     673                                        Template template = readTemplate(temp); 
     674                                        service.getTemplates().put(template.getName(), template); 
     675                                } 
     676 
    721677                                ListIterator<Parameter> inpi = serv.getIn().getParameter() 
    722678                                                .listIterator(); 
  • tools/routingservice/branches/wrs-2.0/src/handler/PgRoutingHandler.java

    r291 r294  
    4545                        ArrayList getParameters() 
    4646                        { 
    47                                 String[] p = { "table", "x1", "y1", "x2", "y2", "box", "cost_value", 
    48                                                 "directed", "hasrc" }; 
     47                                String[] p = { "table", "x1", "y1", "x2", "y2", "box", 
     48                                                "cost_value", "reverse_cost_value", "directed", "hasrc" }; 
     49                                return new ArrayList(Arrays.asList(p)); 
     50                        } 
     51                }, 
     52                CATCH 
     53                { 
     54                        ArrayList getParameters() 
     55                        { 
     56                                String[] p = { "table", "x1", "y1", "distance", "box", "cost_value", 
     57                                                "reverse_cost_value", "directed", "hasrc" }; 
    4958                                return new ArrayList(Arrays.asList(p)); 
    5059                        } 
     
    6069                this.functions.put("route", "shootingstar_sp_smart"); 
    6170                this.functions.put("travel", "tsp_astar_directed_smart"); 
     71                this.functions.put("catch", "driving_distance"); 
    6272        } 
    6373 
     
    7383                        String query = fillQueryTemplate(this.resource.getQuery(), request 
    7484                                        .getService(), request.getParameters()); 
     85                         
     86                        System.out.println("Query:" + query); 
    7587 
    7688                        ObjectPool<Connection> pool = this.resource.getPool(); 
     
    173185                                Parameter p = parameters.get(key); 
    174186                                String value = p.getValue(); 
    175                                 if (p.getType().toLowerCase().equals( 
    176                                                 STRING)) 
     187                                if (p.getType().toLowerCase().equals(STRING)) 
    177188                                { 
    178189                                        value = "'" + value + "'"; 
  • tools/routingservice/branches/wrs-2.0/src/model/Service.java

    r290 r294  
    11package model; 
    22 
    3 import java.util.ArrayList; 
    4 import java.util.Hashtable; 
    53import java.util.HashMap; 
    64 
     
    1614        private HashMap<String, Parameter> out; 
    1715         
     16        private HashMap<String, Template> templates; 
    1817 
    1918        public Service(String name) 
     
    2322                this.in = new HashMap<String, Parameter>(); 
    2423                this.out = new HashMap<String, Parameter>(); 
     24                this.templates = new HashMap<String, Template>(); 
    2525        } 
    2626 
     
    6565        } 
    6666 
     67        public HashMap<String, Template> getTemplates() 
     68        { 
     69                return templates; 
     70        } 
     71 
    6772} 
  • tools/routingservice/branches/wrs-2.0/src/model/Template.java

    r287 r294  
    11package model; 
    2  
    3 import java.util.Hashtable; 
    42 
    53public class Template 
     
    86        private String name; 
    97        private String format; 
    10         private Hashtable<String, Service> services; 
     8 
    119 
    1210        public Template(String name, String format) 
     
    1513                this.name = name; 
    1614                this.format = format; 
    17                 this.services = new Hashtable<String, Service>(); 
    1815        } 
    1916 
     
    3835        } 
    3936 
    40         public Hashtable<String, Service> getServices() 
    41         { 
    42                 return services; 
    43         } 
    44  
    4537} 
  • tools/routingservice/branches/wrs-2.0/src/util/format/FormatParser.java

    r290 r294  
    1111        protected enum DataTypes 
    1212        { 
    13                 POINTS, LINES, ADDRESSES; 
     13                POINTS, LINES, ADDRESSES, DISTANCE, UOM, LOCALE, CRS, REQUEST_ID, CREDENTIALS; 
    1414        } 
    1515        protected abstract Vector<Parameter> parseInput(String text); 
  • tools/routingservice/branches/wrs-2.0/src/util/format/JSONParser.java

    r291 r294  
    4444                                                x.setValue(sst.nextToken()); 
    4545                                                x.setType(ResourceHandler.DOUBLE); 
    46                                                  
     46 
    4747                                                params.add(x); 
    4848 
     
    5252                                                y.setValue(sst.nextToken()); 
    5353                                                y.setType(ResourceHandler.DOUBLE); 
    54                                                  
     54 
    5555                                                params.add(x); 
    5656                                                params.add(y); 
    5757                                                ++i; 
    5858                                        } 
     59                                        break; 
     60                                case DISTANCE: 
     61                                        String distance = json.getString(key); 
     62                                        Parameter dist = new Parameter(); 
     63                                        dist.setName("distance"); 
     64                                        dist.setSource("url"); 
     65                                        dist.setValue(distance); 
     66                                        dist.setType(ResourceHandler.DOUBLE); 
     67                                        params.add(dist); 
    5968                                        break; 
    6069                                } 
  • tools/routingservice/branches/wrs-2.0/src/util/service/ObjectFactory.java

    r287 r294  
    33// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
    44// Any modifications to this file will be lost upon recompilation of the source schema.  
    5 // Generated on: 2009.03.26 at 04:38:38 PM JST  
     5// Generated on: 2009.04.15 at 11:15:28 AM JST  
    66// 
    77 
     
    4040 
    4141    /** 
     42     * Create an instance of {@link Services.Service.In } 
     43     *  
     44     */ 
     45    public Services.Service.In createServicesServiceIn() { 
     46        return new Services.Service.In(); 
     47    } 
     48 
     49    /** 
     50     * Create an instance of {@link Template } 
     51     *  
     52     */ 
     53    public Template createTemplate() { 
     54        return new Template(); 
     55    } 
     56 
     57    /** 
     58     * Create an instance of {@link Services } 
     59     *  
     60     */ 
     61    public Services createServices() { 
     62        return new Services(); 
     63    } 
     64 
     65    /** 
    4266     * Create an instance of {@link Services.Service.Out } 
    4367     *  
     
    4872 
    4973    /** 
    50      * Create an instance of {@link Services.Service.In } 
     74     * Create an instance of {@link Services.Service.Templates } 
    5175     *  
    5276     */ 
    53     public Services.Service.In createServicesServiceIn() { 
    54         return new Services.Service.In(); 
    55     } 
    56  
    57     /** 
    58      * Create an instance of {@link Services.Service } 
    59      *  
    60      */ 
    61     public Services.Service createServicesService() { 
    62         return new Services.Service(); 
     77    public Services.Service.Templates createServicesServiceTemplates() { 
     78        return new Services.Service.Templates(); 
    6379    } 
    6480 
     
    7288 
    7389    /** 
    74      * Create an instance of {@link Services } 
     90     * Create an instance of {@link Services.Service } 
    7591     *  
    7692     */ 
    77     public Services createServices() { 
    78         return new Services(); 
     93    public Services.Service createServicesService() { 
     94        return new Services.Service(); 
    7995    } 
    8096 
  • tools/routingservice/branches/wrs-2.0/src/util/service/Services.java

    r287 r294  
    33// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
    44// Any modifications to this file will be lost upon recompilation of the source schema.  
    5 // Generated on: 2009.03.26 at 04:38:38 PM JST  
     5// Generated on: 2009.04.15 at 11:15:28 AM JST  
    66// 
    77 
     
    3131 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
    3232 *       &lt;sequence> 
    33  *         &lt;element name="service"> 
     33 *         &lt;element name="service" maxOccurs="unbounded"> 
    3434 *           &lt;complexType> 
    3535 *             &lt;complexContent> 
     
    3737 *                 &lt;sequence> 
    3838 *                   &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/> 
     39 *                   &lt;element name="templates"> 
     40 *                     &lt;complexType> 
     41 *                       &lt;complexContent> 
     42 *                         &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
     43 *                           &lt;sequence> 
     44 *                             &lt;element ref="{}template" maxOccurs="unbounded"/> 
     45 *                           &lt;/sequence> 
     46 *                         &lt;/restriction> 
     47 *                       &lt;/complexContent> 
     48 *                     &lt;/complexType> 
     49 *                   &lt;/element> 
    3950 *                   &lt;element name="in"> 
    4051 *                     &lt;complexType> 
     
    8899     * Gets the value of the service property. 
    89100     *  
    90      * @return 
    91      *     possible object is 
    92      *     {@link Services.Service } 
    93      *      
     101     * <p> 
     102     * This accessor method returns a reference to the live list, 
     103     * not a snapshot. Therefore any modification you make to the 
     104     * returned list will be present inside the JAXB object. 
     105     * This is why there is not a <CODE>set</CODE> method for the service property. 
     106     *  
     107     * <p> 
     108     * For example, to add a new item, do as follows: 
     109     * <pre> 
     110     *    getService().add(newItem); 
     111     * </pre> 
     112     *  
     113     *  
     114     * <p> 
     115     * Objects of the following type(s) are allowed in the list 
     116     * {@link Services.Service } 
     117     *  
     118     *  
    94119     */ 
    95120    public List<Services.Service> getService() { 
    96         return service; 
    97     } 
    98  
    99     /** 
    100      * Sets the value of the service property. 
    101      *  
    102      * @param value 
    103      *     allowed object is 
    104      *     {@link Services.Service } 
    105      *      
    106      */ 
    107     public void setService(List<Services.Service> value) { 
    108         this.service = value; 
     121        if (service == null) { 
     122            service = new ArrayList<Services.Service>(); 
     123        } 
     124        return this.service; 
    109125    } 
    110126 
     
    121137     *       &lt;sequence> 
    122138     *         &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/> 
     139     *         &lt;element name="templates"> 
     140     *           &lt;complexType> 
     141     *             &lt;complexContent> 
     142     *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
     143     *                 &lt;sequence> 
     144     *                   &lt;element ref="{}template" maxOccurs="unbounded"/> 
     145     *                 &lt;/sequence> 
     146     *               &lt;/restriction> 
     147     *             &lt;/complexContent> 
     148     *           &lt;/complexType> 
     149     *         &lt;/element> 
    123150     *         &lt;element name="in"> 
    124151     *           &lt;complexType> 
     
    157184    @XmlType(name = "", propOrder = { 
    158185        "description", 
     186        "templates", 
    159187        "in", 
    160188        "out" 
     
    164192        @XmlElement(required = true) 
    165193        protected String description; 
     194        @XmlElement(required = true) 
     195        protected Services.Service.Templates templates; 
    166196        @XmlElement(required = true) 
    167197        protected Services.Service.In in; 
     
    197227        public void setDescription(String value) { 
    198228            this.description = value; 
     229        } 
     230 
     231        /** 
     232         * Gets the value of the templates property. 
     233         *  
     234         * @return 
     235         *     possible object is 
     236         *     {@link Services.Service.Templates } 
     237         *      
     238         */ 
     239        public Services.Service.Templates getTemplates() { 
     240            return templates; 
     241        } 
     242 
     243        /** 
     244         * Sets the value of the templates property. 
     245         *  
     246         * @param value 
     247         *     allowed object is 
     248         *     {@link Services.Service.Templates } 
     249         *      
     250         */ 
     251        public void setTemplates(Services.Service.Templates value) { 
     252            this.templates = value; 
    199253        } 
    200254 
     
    439493        } 
    440494 
     495 
     496        /** 
     497         * <p>Java class for anonymous complex type. 
     498         *  
     499         * <p>The following schema fragment specifies the expected content contained within this class. 
     500         *  
     501         * <pre> 
     502         * &lt;complexType> 
     503         *   &lt;complexContent> 
     504         *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
     505         *       &lt;sequence> 
     506         *         &lt;element ref="{}template" maxOccurs="unbounded"/> 
     507         *       &lt;/sequence> 
     508         *     &lt;/restriction> 
     509         *   &lt;/complexContent> 
     510         * &lt;/complexType> 
     511         * </pre> 
     512         *  
     513         *  
     514         */ 
     515        @XmlAccessorType(XmlAccessType.FIELD) 
     516        @XmlType(name = "", propOrder = { 
     517            "template" 
     518        }) 
     519        public static class Templates { 
     520 
     521            @XmlElement(required = true) 
     522            protected List<Template> template; 
     523 
     524            /** 
     525             * Gets the value of the template property. 
     526             *  
     527             * <p> 
     528             * This accessor method returns a reference to the live list, 
     529             * not a snapshot. Therefore any modification you make to the 
     530             * returned list will be present inside the JAXB object. 
     531             * This is why there is not a <CODE>set</CODE> method for the template property. 
     532             *  
     533             * <p> 
     534             * For example, to add a new item, do as follows: 
     535             * <pre> 
     536             *    getTemplate().add(newItem); 
     537             * </pre> 
     538             *  
     539             *  
     540             * <p> 
     541             * Objects of the following type(s) are allowed in the list 
     542             * {@link Template } 
     543             *  
     544             *  
     545             */ 
     546            public List<Template> getTemplate() { 
     547                if (template == null) { 
     548                    template = new ArrayList<Template>(); 
     549                } 
     550                return this.template; 
     551            } 
     552 
     553        } 
     554 
    441555    } 
    442556