Joerg Heinicke skrev:
On 17.05.2007 13:27, Daniel Fagerstrom wrote:
...
So what is important here is that it is the file source in the example above that is input to the generator, not the servlet service. The servlet service is something that the input generator is redirected to.

That's internal detail and out of any interest for the user. At the end you only get data from the service generator. The rest is implementation detail. The implementation could also be that this param is just passed as string and the servlet service does all the rest.

I find it hard to consider what a reader reads from an implementation detail. Just to make sure that we talk about the same thing I'll give two use cases.

Reading
=======
Consider that you just want to read from a servlet service (through an ordinary HTTP GET), then you don't use the servlet service generator at all, you instead use the file generator:

<map:generate src="servlet:my/{1}" type="file"/>

Posting
=======
Say that you want to read a CSV file but that the XML output from the standard CSV generator doesn't fit the rest of your webapp. One possibility would be that you implemented an own generator:

<map:generate src="{1}.csv" type"mycsv"/>
...

But that would be a lot of work for just changing an XML format, so you would probably prefer to write a resource or having something like:

<map:generate src="{1}.csv" type"csv"/>
<map:transform src="csv2mycsv.xsl"/>
...

everywhere in your sitemaps.

With the servlet service generator you could instead implement the above functionality as a service:

In the "util" servlet service:

<map:match pattern="mycsv">
  <map:generate src="service-consumer:" type="csv"/>
  <map:transform src="csv2mycsv.xsl"/>
  <map:serialize type="xml"/>
</map:match>

Then you can just call it in some other sitemap using the servlet service generator:

<map:generate src="{1}.csv" type="servletService">
 <map:parameter name="service" value="servlet:util:/mycsv"/>
</map:generate>
...

======

The mycsv example above was a typical use case for how the servlet service generator is intended to be used. It replaces the virtual sitemap components that we had an experimental implementation of before.

And in the example above I would say that the "{1}.csv" input file is from the users POV the important thing. That the transformation from the csv input file to the wanted XML format is done with a servlet service that happen to be at some particular URI instead of using some custom csv generator, that is an implementation detail.

/Daniel

Reply via email to