You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Yahoo <ha...@yahoo.de> on 2014/03/13 11:09:23 UTC

Jexl in embedded Pipeline

How can I use Jexl in an embadded Pipline ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Jexl in embedded Pipeline

Posted by Yahoo <ha...@yahoo.de>.
Hello Greg,

I got  what I was looking for by using a programmed Pipeline.
Starting with Velocity to fill up an xmlstring with Hibernate bean data.
The only problem is that sometimes when I call Hibernate I get an error 
because there is no Hibernate session.
Maybe the reason is how I placed the lazy loading filte in the web.xm.

When I have time I investgate several other opportunities.

JAXBGenerator here I am missing some fields. I still don't know what is 
the reason. Maybe because I mix up different annotations.(Hibernate,  JAXB)

What is also working is simple calling the cocoon pipline snippets by 
localhost:8888

I am also trying to get the result of the URLResponse in the 
application. But till now I was not successful.

I also succeeded to replace Velocity by using the StringGenerator.

The last aspect I am investigating is using more cloud technology by 
sending only links.
But here I have to think about that the Information should not publicly 
accessible.

Greetings
Heiner


Am 14.03.2014 08:25, schrieb gelo1234:
> Cocoon 3 pipelines are either SAX or StAX events based so they operate 
> upon xml data. If you could feed XML into another pipeline component 
> that's fine. Just ask yourself if you really need Cocoon for the task 
> you are trying to complete.
>
> Greetings,
> Greg
>
>
> 2014-03-14 6:13 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de 
> <ma...@yahoo.de>>:
>
>     I found what I want todo. It's not  Jexl it's the VelocityEngine I
>     need.
>     Here is the example from spring mail.
>
>         MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
>                  message.setTo(user.getEmailAddress());
>                  message.setFrom("webmaster@csonth.gov.uk"  <ma...@csonth.gov.uk>);/// could be parameterized.../
>                  Map model = new HashMap();
>                  model.put("user", user);
>                  String text = VelocityEngineUtils.mergeTemplateIntoString(
>                     velocityEngine, "com/dns/registration-confirmation.vm", model);
>                  message.setText(text, true);
>
>
>     In my case the text comes from an inline Cocoon Pipeline.
>     I could first import the template use the Velocity Engine and then
>     give it to the Pipeline.
>     or is there possibility to make the job done by the pipeline .
>
>     Am 13.03.2014 19:34, schrieb gelo1234:
>>     I don't know about the attachments but a clean Cocoon3 extension
>>     for sending emails you can find here:
>>
>>     https://github.com/alveolo/butterfly/blob/master/cocoon/src/test/java/org/alveolo/butterfly/test/cocoon/email/MailSerializerTest.java
>>
>>     Greetings,
>>     Greg
>>
>>
>>     2014-03-13 15:02 GMT+01:00 Piratenvisier
>>     <hansheinrichbraun@yahoo.de <ma...@yahoo.de>>:
>>
>>         An application like this I use already.
>>         Thorsten Scherler made this email Application for me.
>>         The important point: I want to send an email and the Email
>>         Text and the attachements are produced by cocoon pipelines.
>>         This a an important part of my cocoon 2.10 application which
>>         I wanted to transfer to 3.0
>>
>>         Am 13.03.2014 14:23, schrieb gelo1234:
>>>         I got lost with your explanation :) It's a kind of awkward
>>>         thing to me that you are actually trying to do with that code.
>>>
>>>
>>>         Why not making it clean:
>>>
>>>         1. First you need a String-Template match to serialize the
>>>         Hibernate bean -> output XML with final values
>>>
>>>         <map:match  pattern="hibernate/bean">
>>>                  <map:generate  src="bean.xml"  type="stringtemplate"  />
>>>                  <map:serialize  type="xml"  />
>>>         </map:match>
>>>         where bean.xml is your [input]
>>>
>>>         You can now feed angebot bean data into hibernate/bean pipe
>>>         above (to get it serialized):
>>>         <map:match  pattern="hibernate/{id}">
>>>                  <controller:call  controller="rest-controller"  select="BeanController">
>>>                    <map:parameter  name="id"  value="{map:id}"  />
>>>                  </controller:call>
>>>         </map:match>
>>>
>>>
>>>         @RESTController
>>>         public  class  BeanController  implements  Get  {
>>>
>>>              @SitemapParameter
>>>              private  String  id;
>>>
>>>              @RequestParameter
>>>              private  String  name;
>>>            
>>>              // through injection or other way
>>>
>>>              HibernateDAO dao;
>>>
>>>               public  RestResponse  doGet()  throws  Exception  {
>>>                  Map<String,  Object>  data=  new  HashMap<String,  Object>();
>>>                  data.put("angebot",  dao.getAngebotBean(id));
>>>                  data.put("name",  this.name);
>>>
>>>                  return  new  Page("servlet:/hibernate/bean",  data);
>>>              }
>>>         }
>>>         At this point you got your Hibernate bean serialized (into
>>>         XML data).
>>>
>>>         2. Second you can go for XSLT Transformer and transform XML
>>>         into anything you want
>>>
>>>         You don't need any JEXL here.
>>>
>>>
>>>         Greetings,
>>>         Greg
>>>
>>>
>>>
>>>
>>>         2014-03-13 13:30 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de
>>>         <ma...@yahoo.de>>:
>>>
>>>             I used the EmailPlainPipe from the distribution:
>>>               byte[] bytes = (byte[]) parameters.get("input");
>>>                     XMLGenerator generator = new XMLGenerator(bytes);
>>>             this.addComponent(generator);
>>>                     byte[] xsl = (byte[]) parameters.get("xsl");
>>>                     Source xslSource = new StreamSource(new
>>>             ByteArrayInputStream(xsl));
>>>                     XSLTTransformer transformer = new XSLTTransformer(
>>>                             xslSource, new Date().getTime());
>>>                     // pass all parameter to the xslTransformer
>>>             transformer.setParameters(parameters);
>>>             this.addComponent(transformer);
>>>             this.addComponent(TextSerializer.createPlainSerializer());
>>>             super.setup(outputStream, parameters);
>>>             where input is:
>>>             <?xml version="1.0" encoding="UTF-8"?>
>>>             <angebot>
>>>               <id>$name$$angebot.id <http://angebot.id>$</id>
>>>              <anganz>$angebot.anganz$</anganz>
>>>             <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
>>>             </angebot>
>>>             xsl is the identity
>>>             angebot is a Hibernate Bean.
>>>             how do feed the pipeline with this Bean that it is used 
>>>             by Jexl to resolve the input String.
>>>
>>>
>>>             Am 13.03.2014 12:55, schrieb gelo1234:
>>>>             With servlet-sitemaps Jexl can be used within any
>>>>             pipeline as {jexl:.....} value.
>>>>
>>>>             Please show example of your embedded pipeline ?
>>>>
>>>>             Greetings,
>>>>             Greg
>>>>
>>>>
>>>>             2014-03-13 11:09 GMT+01:00 Yahoo
>>>>             <hansheinrichbraun@yahoo.de
>>>>             <ma...@yahoo.de>>:
>>>>
>>>>                 How can I use Jexl in an embadded Pipline ?
>>>>
>>>>                 ---------------------------------------------------------------------
>>>>                 To unsubscribe, e-mail:
>>>>                 users-unsubscribe@cocoon.apache.org
>>>>                 <ma...@cocoon.apache.org>
>>>>                 For additional commands, e-mail:
>>>>                 users-help@cocoon.apache.org
>>>>                 <ma...@cocoon.apache.org>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Re: calling a sitemap-snippet from within a program

Posted by gelo1234 <ge...@gmail.com>.
Hi,

1. Yes, it's possible. Since all sitemap matching URL's are actually kind
of HTTP Servlets, you can just use any http client (e.g. Apache HttpClient)
to invoke the servlet and get the response (if that is outside Cocoon):

HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("http://www.test.com/servlet.xml");
HttpResponse response = client.execute(request);
*// Get the response*
BufferedReader rd = new BufferedReader
  (new InputStreamReader(response.getEntity().getContent()));

String line = "";while ((line = rd.readLine()) != null) {
  ...
}


2. You can invoke any sitemap-servlet from within cocoon pipeline of course:
http://wiki.apache.org/cocoon/IntegrateAServlet

3. If you want to invoke sitemap-servlet from Cocoon API, first you need to
decide at which step that action need to be taken. If it's a Starter, you
can use XMLGenerator with given URL:

URL base = this.getClass().getResource("http://www.test.com/");
Pipeline<SAXPipelineComponent> pipeline = new
NonCachingPipeline<SAXPipelineComponent>();
pipeline.addComponent(new XMLGenerator(new URL(base, "servlet.xml")));


If it's somewhere in the middle of the pipeline, you can use
IncludeTransformer that will call your servlet-service:

pipeline.addComponent(new XIncludeTransformer("servlet_calling_include.xml"));


where:

servlet_calling_include.xml


<data_from_servlet><i:include
src="servlet:/data/servlet"/></data_from_servlet>


Hope that helps.

Greetings,
Greg



2014-03-21 9:14 GMT+01:00 Yahoo <ha...@yahoo.de>:

>
> Hello Greg,
>
> is it possible  to call a sitemap-snippet within a program an getting the
> respone inside a program?
>
> H.Braun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

calling a sitemap-snippet from within a program

Posted by Yahoo <ha...@yahoo.de>.
Hello Greg,

is it possible  to call a sitemap-snippet within a program an getting 
the respone inside a program?

H.Braun

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Jexl in embedded Pipeline

Posted by Yahoo <ha...@yahoo.de>.
You are right. The only reason I didn't leave Cocoon is its automatic 
production of pdf from xml.
The surrounding became very tediously.
I just found out that there is some difference between Jexl and Velocity 
expressions.
But I think I can now try to upgrade my former cocoon email adaption.

Am 14.03.2014 08:25, schrieb gelo1234:
> Cocoon 3 pipelines are either SAX or StAX events based so they operate 
> upon xml data. If you could feed XML into another pipeline component 
> that's fine. Just ask yourself if you really need Cocoon for the task 
> you are trying to complete.
>
> Greetings,
> Greg
>
>
> 2014-03-14 6:13 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de 
> <ma...@yahoo.de>>:
>
>     I found what I want todo. It's not  Jexl it's the VelocityEngine I
>     need.
>     Here is the example from spring mail.
>
>         MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
>                  message.setTo(user.getEmailAddress());
>                  message.setFrom("webmaster@csonth.gov.uk"  <ma...@csonth.gov.uk>);/// could be parameterized.../
>                  Map model = new HashMap();
>                  model.put("user", user);
>                  String text = VelocityEngineUtils.mergeTemplateIntoString(
>                     velocityEngine, "com/dns/registration-confirmation.vm", model);
>                  message.setText(text, true);
>
>
>     In my case the text comes from an inline Cocoon Pipeline.
>     I could first import the template use the Velocity Engine and then
>     give it to the Pipeline.
>     or is there possibility to make the job done by the pipeline .
>
>     Am 13.03.2014 19:34, schrieb gelo1234:
>>     I don't know about the attachments but a clean Cocoon3 extension
>>     for sending emails you can find here:
>>
>>     https://github.com/alveolo/butterfly/blob/master/cocoon/src/test/java/org/alveolo/butterfly/test/cocoon/email/MailSerializerTest.java
>>
>>     Greetings,
>>     Greg
>>
>>
>>     2014-03-13 15:02 GMT+01:00 Piratenvisier
>>     <hansheinrichbraun@yahoo.de <ma...@yahoo.de>>:
>>
>>         An application like this I use already.
>>         Thorsten Scherler made this email Application for me.
>>         The important point: I want to send an email and the Email
>>         Text and the attachements are produced by cocoon pipelines.
>>         This a an important part of my cocoon 2.10 application which
>>         I wanted to transfer to 3.0
>>
>>         Am 13.03.2014 14:23, schrieb gelo1234:
>>>         I got lost with your explanation :) It's a kind of awkward
>>>         thing to me that you are actually trying to do with that code.
>>>
>>>
>>>         Why not making it clean:
>>>
>>>         1. First you need a String-Template match to serialize the
>>>         Hibernate bean -> output XML with final values
>>>
>>>         <map:match  pattern="hibernate/bean">
>>>                  <map:generate  src="bean.xml"  type="stringtemplate"  />
>>>                  <map:serialize  type="xml"  />
>>>         </map:match>
>>>         where bean.xml is your [input]
>>>
>>>         You can now feed angebot bean data into hibernate/bean pipe
>>>         above (to get it serialized):
>>>         <map:match  pattern="hibernate/{id}">
>>>                  <controller:call  controller="rest-controller"  select="BeanController">
>>>                    <map:parameter  name="id"  value="{map:id}"  />
>>>                  </controller:call>
>>>         </map:match>
>>>
>>>
>>>         @RESTController
>>>         public  class  BeanController  implements  Get  {
>>>
>>>              @SitemapParameter
>>>              private  String  id;
>>>
>>>              @RequestParameter
>>>              private  String  name;
>>>            
>>>              // through injection or other way
>>>
>>>              HibernateDAO dao;
>>>
>>>               public  RestResponse  doGet()  throws  Exception  {
>>>                  Map<String,  Object>  data=  new  HashMap<String,  Object>();
>>>                  data.put("angebot",  dao.getAngebotBean(id));
>>>                  data.put("name",  this.name);
>>>
>>>                  return  new  Page("servlet:/hibernate/bean",  data);
>>>              }
>>>         }
>>>         At this point you got your Hibernate bean serialized (into
>>>         XML data).
>>>
>>>         2. Second you can go for XSLT Transformer and transform XML
>>>         into anything you want
>>>
>>>         You don't need any JEXL here.
>>>
>>>
>>>         Greetings,
>>>         Greg
>>>
>>>
>>>
>>>
>>>         2014-03-13 13:30 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de
>>>         <ma...@yahoo.de>>:
>>>
>>>             I used the EmailPlainPipe from the distribution:
>>>               byte[] bytes = (byte[]) parameters.get("input");
>>>                     XMLGenerator generator = new XMLGenerator(bytes);
>>>             this.addComponent(generator);
>>>                     byte[] xsl = (byte[]) parameters.get("xsl");
>>>                     Source xslSource = new StreamSource(new
>>>             ByteArrayInputStream(xsl));
>>>                     XSLTTransformer transformer = new XSLTTransformer(
>>>                             xslSource, new Date().getTime());
>>>                     // pass all parameter to the xslTransformer
>>>             transformer.setParameters(parameters);
>>>             this.addComponent(transformer);
>>>             this.addComponent(TextSerializer.createPlainSerializer());
>>>             super.setup(outputStream, parameters);
>>>             where input is:
>>>             <?xml version="1.0" encoding="UTF-8"?>
>>>             <angebot>
>>>               <id>$name$$angebot.id <http://angebot.id>$</id>
>>>              <anganz>$angebot.anganz$</anganz>
>>>             <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
>>>             </angebot>
>>>             xsl is the identity
>>>             angebot is a Hibernate Bean.
>>>             how do feed the pipeline with this Bean that it is used 
>>>             by Jexl to resolve the input String.
>>>
>>>
>>>             Am 13.03.2014 12:55, schrieb gelo1234:
>>>>             With servlet-sitemaps Jexl can be used within any
>>>>             pipeline as {jexl:.....} value.
>>>>
>>>>             Please show example of your embedded pipeline ?
>>>>
>>>>             Greetings,
>>>>             Greg
>>>>
>>>>
>>>>             2014-03-13 11:09 GMT+01:00 Yahoo
>>>>             <hansheinrichbraun@yahoo.de
>>>>             <ma...@yahoo.de>>:
>>>>
>>>>                 How can I use Jexl in an embadded Pipline ?
>>>>
>>>>                 ---------------------------------------------------------------------
>>>>                 To unsubscribe, e-mail:
>>>>                 users-unsubscribe@cocoon.apache.org
>>>>                 <ma...@cocoon.apache.org>
>>>>                 For additional commands, e-mail:
>>>>                 users-help@cocoon.apache.org
>>>>                 <ma...@cocoon.apache.org>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Re: Jexl in embedded Pipeline

Posted by gelo1234 <ge...@gmail.com>.
Cocoon 3 pipelines are either SAX or StAX events based so they operate upon
xml data. If you could feed XML into another pipeline component that's
fine. Just ask yourself if you really need Cocoon for the task you are
trying to complete.

Greetings,
Greg


2014-03-14 6:13 GMT+01:00 Yahoo <ha...@yahoo.de>:

>  I found what I want todo. It's not  Jexl it's the VelocityEngine I need.
> Here is the example from spring mail.
>
>    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
>             message.setTo(user.getEmailAddress());
>             message.setFrom("webmaster@csonth.gov.uk" <we...@csonth.gov.uk>); *// could be parameterized...*
>             Map model = new HashMap();
>             model.put("user", user);
>             String text = VelocityEngineUtils.mergeTemplateIntoString(
>                velocityEngine, "com/dns/registration-confirmation.vm", model);
>             message.setText(text, true);
>
>
> In my case the text comes from an inline Cocoon Pipeline.
> I could first import the template use the Velocity Engine and then give it
> to the Pipeline.
> or is there possibility to make the job done by the pipeline .
>
> Am 13.03.2014 19:34, schrieb gelo1234:
>
>  I don't know about the attachments but a clean Cocoon3 extension for
> sending emails you can find here:
>
>
> https://github.com/alveolo/butterfly/blob/master/cocoon/src/test/java/org/alveolo/butterfly/test/cocoon/email/MailSerializerTest.java
>
>  Greetings,
> Greg
>
>
> 2014-03-13 15:02 GMT+01:00 Piratenvisier <ha...@yahoo.de>:
>
>>  An application like this I use already.
>> Thorsten Scherler made this email Application for me.
>> The important point: I want to send an email and the Email Text and the
>> attachements are produced by cocoon pipelines.
>> This a an important part of my cocoon 2.10 application which I wanted to
>> transfer to 3.0
>>
>> Am 13.03.2014 14:23, schrieb gelo1234:
>>
>>  I got lost with your explanation :) It's a kind of awkward thing to me
>> that you are actually trying to do with that code.
>>
>>
>>  Why not making it clean:
>>
>>  1. First you need a String-Template match to serialize the Hibernate
>> bean -> output XML with final values
>>
>> <map:match pattern="hibernate/bean">
>>         <map:generate src="bean.xml" type="stringtemplate" />
>>         <map:serialize type="xml" /></map:match>
>>
>> where bean.xml is your [input]
>>
>>  You can now feed angebot bean data into hibernate/bean pipe above (to
>> get it serialized):
>>
>> <map:match pattern="hibernate/{id}">
>>         <controller:call controller="rest-controller" select="BeanController">
>>           <map:parameter name="id" value="{map:id}" />
>>         </controller:call></map:match>
>>
>> @RESTControllerpublic class BeanController implements Get {
>>
>>     @SitemapParameter
>>     private String id;
>>
>>     @RequestParameter
>>     private String name;
>>
>>
>>     // through injection or other way
>>
>>     HibernateDAO dao;
>>
>>
>>     public RestResponse doGet() throws Exception {
>>         Map<String, Object> data = new HashMap<String, Object>();
>>         data.put("angebot", dao.getAngebotBean(id));
>>         data.put("name", this.name);
>>
>>         return new Page("servlet:/hibernate/bean", data);
>>     }}
>>
>>  At this point you got your Hibernate bean serialized (into XML data).
>>
>>  2. Second you can go for XSLT Transformer and transform XML into
>> anything you want
>>
>>  You don't need any JEXL here.
>>
>>
>>  Greetings,
>> Greg
>>
>>
>>
>>
>>  2014-03-13 13:30 GMT+01:00 Yahoo <ha...@yahoo.de>:
>>
>>>  I used the EmailPlainPipe from the distribution:
>>>   byte[] bytes = (byte[]) parameters.get("input");
>>>         XMLGenerator generator = new XMLGenerator(bytes);
>>>         this.addComponent(generator);
>>>         byte[] xsl = (byte[]) parameters.get("xsl");
>>>         Source xslSource = new StreamSource(new
>>> ByteArrayInputStream(xsl));
>>>         XSLTTransformer transformer = new XSLTTransformer(
>>>                 xslSource, new Date().getTime());
>>>         // pass all parameter to the xslTransformer
>>>         transformer.setParameters(parameters);
>>>         this.addComponent(transformer);
>>>         this.addComponent(TextSerializer.createPlainSerializer());
>>>         super.setup(outputStream, parameters);
>>> where input is:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <angebot>
>>>   <id>$name$$angebot.id$</id>
>>>  <anganz>$angebot.anganz$</anganz>
>>> <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
>>> </angebot>
>>> xsl is the identity
>>> angebot is a Hibernate Bean.
>>> how do feed the pipeline with this Bean that it is used  by Jexl to
>>> resolve the input String.
>>>
>>>
>>> Am 13.03.2014 12:55, schrieb gelo1234:
>>>
>>>  With servlet-sitemaps Jexl can be used within any pipeline as
>>> {jexl:.....} value.
>>>
>>>  Please show example of your embedded pipeline ?
>>>
>>>  Greetings,
>>> Greg
>>>
>>>
>>> 2014-03-13 11:09 GMT+01:00 Yahoo <ha...@yahoo.de>:
>>>
>>>> How can I use Jexl in an embadded Pipline ?
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Re: Jexl in embedded Pipeline

Posted by Yahoo <ha...@yahoo.de>.
I found what I want todo. It's not  Jexl it's the VelocityEngine I need.
Here is the example from spring mail.

    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
             message.setTo(user.getEmailAddress());
             message.setFrom("webmaster@csonth.gov.uk");/// could be parameterized.../
             Map model = new HashMap();
             model.put("user", user);
             String text = VelocityEngineUtils.mergeTemplateIntoString(
                velocityEngine, "com/dns/registration-confirmation.vm", model);
             message.setText(text, true);


In my case the text comes from an inline Cocoon Pipeline.
I could first import the template use the Velocity Engine and then give 
it to the Pipeline.
or is there possibility to make the job done by the pipeline .

Am 13.03.2014 19:34, schrieb gelo1234:
> I don't know about the attachments but a clean Cocoon3 extension for 
> sending emails you can find here:
>
> https://github.com/alveolo/butterfly/blob/master/cocoon/src/test/java/org/alveolo/butterfly/test/cocoon/email/MailSerializerTest.java
>
> Greetings,
> Greg
>
>
> 2014-03-13 15:02 GMT+01:00 Piratenvisier <hansheinrichbraun@yahoo.de 
> <ma...@yahoo.de>>:
>
>     An application like this I use already.
>     Thorsten Scherler made this email Application for me.
>     The important point: I want to send an email and the Email Text
>     and the attachements are produced by cocoon pipelines.
>     This a an important part of my cocoon 2.10 application which I
>     wanted to transfer to 3.0
>
>     Am 13.03.2014 14:23, schrieb gelo1234:
>>     I got lost with your explanation :) It's a kind of awkward thing
>>     to me that you are actually trying to do with that code.
>>
>>
>>     Why not making it clean:
>>
>>     1. First you need a String-Template match to serialize the
>>     Hibernate bean -> output XML with final values
>>
>>     <map:match  pattern="hibernate/bean">
>>              <map:generate  src="bean.xml"  type="stringtemplate"  />
>>              <map:serialize  type="xml"  />
>>     </map:match>
>>     where bean.xml is your [input]
>>
>>     You can now feed angebot bean data into hibernate/bean pipe above
>>     (to get it serialized):
>>     <map:match  pattern="hibernate/{id}">
>>              <controller:call  controller="rest-controller"  select="BeanController">
>>                <map:parameter  name="id"  value="{map:id}"  />
>>              </controller:call>
>>     </map:match>
>>
>>
>>     @RESTController
>>     public  class  BeanController  implements  Get  {
>>
>>          @SitemapParameter
>>          private  String  id;
>>
>>          @RequestParameter
>>          private  String  name;
>>        
>>          // through injection or other way
>>
>>          HibernateDAO dao;
>>
>>           public  RestResponse  doGet()  throws  Exception  {
>>              Map<String,  Object>  data=  new  HashMap<String,  Object>();
>>              data.put("angebot",  dao.getAngebotBean(id));
>>              data.put("name",  this.name);
>>
>>              return  new  Page("servlet:/hibernate/bean",  data);
>>          }
>>     }
>>     At this point you got your Hibernate bean serialized (into XML data).
>>
>>     2. Second you can go for XSLT Transformer and transform XML into
>>     anything you want
>>
>>     You don't need any JEXL here.
>>
>>
>>     Greetings,
>>     Greg
>>
>>
>>
>>
>>     2014-03-13 13:30 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de
>>     <ma...@yahoo.de>>:
>>
>>         I used the EmailPlainPipe from the distribution:
>>           byte[] bytes = (byte[]) parameters.get("input");
>>                 XMLGenerator generator = new XMLGenerator(bytes);
>>                 this.addComponent(generator);
>>                 byte[] xsl = (byte[]) parameters.get("xsl");
>>                 Source xslSource = new StreamSource(new
>>         ByteArrayInputStream(xsl));
>>                 XSLTTransformer transformer = new XSLTTransformer(
>>                         xslSource, new Date().getTime());
>>                 // pass all parameter to the xslTransformer
>>         transformer.setParameters(parameters);
>>                 this.addComponent(transformer);
>>         this.addComponent(TextSerializer.createPlainSerializer());
>>                 super.setup(outputStream, parameters);
>>         where input is:
>>         <?xml version="1.0" encoding="UTF-8"?>
>>         <angebot>
>>           <id>$name$$angebot.id <http://angebot.id>$</id>
>>          <anganz>$angebot.anganz$</anganz>
>>         <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
>>         </angebot>
>>         xsl is the identity
>>         angebot is a Hibernate Bean.
>>         how do feed the pipeline with this Bean that it is used  by
>>         Jexl to resolve the input String.
>>
>>
>>         Am 13.03.2014 12:55, schrieb gelo1234:
>>>         With servlet-sitemaps Jexl can be used within any pipeline
>>>         as {jexl:.....} value.
>>>
>>>         Please show example of your embedded pipeline ?
>>>
>>>         Greetings,
>>>         Greg
>>>
>>>
>>>         2014-03-13 11:09 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de
>>>         <ma...@yahoo.de>>:
>>>
>>>             How can I use Jexl in an embadded Pipline ?
>>>
>>>             ---------------------------------------------------------------------
>>>             To unsubscribe, e-mail:
>>>             users-unsubscribe@cocoon.apache.org
>>>             <ma...@cocoon.apache.org>
>>>             For additional commands, e-mail:
>>>             users-help@cocoon.apache.org
>>>             <ma...@cocoon.apache.org>
>>>
>>>
>>
>>
>
>


Re: Jexl in embedded Pipeline

Posted by gelo1234 <ge...@gmail.com>.
I don't know about the attachments but a clean Cocoon3 extension for
sending emails you can find here:

https://github.com/alveolo/butterfly/blob/master/cocoon/src/test/java/org/alveolo/butterfly/test/cocoon/email/MailSerializerTest.java

Greetings,
Greg


2014-03-13 15:02 GMT+01:00 Piratenvisier <ha...@yahoo.de>:

>  An application like this I use already.
> Thorsten Scherler made this email Application for me.
> The important point: I want to send an email and the Email Text and the
> attachements are produced by cocoon pipelines.
> This a an important part of my cocoon 2.10 application which I wanted to
> transfer to 3.0
>
> Am 13.03.2014 14:23, schrieb gelo1234:
>
>  I got lost with your explanation :) It's a kind of awkward thing to me
> that you are actually trying to do with that code.
>
>
>  Why not making it clean:
>
>  1. First you need a String-Template match to serialize the Hibernate
> bean -> output XML with final values
>
> <map:match pattern="hibernate/bean">
>         <map:generate src="bean.xml" type="stringtemplate" />
>         <map:serialize type="xml" /></map:match>
>
> where bean.xml is your [input]
>
>  You can now feed angebot bean data into hibernate/bean pipe above (to
> get it serialized):
>
> <map:match pattern="hibernate/{id}">
>         <controller:call controller="rest-controller" select="BeanController">
>           <map:parameter name="id" value="{map:id}" />
>         </controller:call></map:match>
>
> @RESTControllerpublic class BeanController implements Get {
>
>     @SitemapParameter
>     private String id;
>
>     @RequestParameter
>     private String name;
>
>
>     // through injection or other way
>
>     HibernateDAO dao;
>
>
>     public RestResponse doGet() throws Exception {
>         Map<String, Object> data = new HashMap<String, Object>();
>         data.put("angebot", dao.getAngebotBean(id));
>         data.put("name", this.name);
>
>         return new Page("servlet:/hibernate/bean", data);
>     }}
>
>  At this point you got your Hibernate bean serialized (into XML data).
>
>  2. Second you can go for XSLT Transformer and transform XML into
> anything you want
>
>  You don't need any JEXL here.
>
>
>  Greetings,
> Greg
>
>
>
>
>  2014-03-13 13:30 GMT+01:00 Yahoo <ha...@yahoo.de>:
>
>>  I used the EmailPlainPipe from the distribution:
>>   byte[] bytes = (byte[]) parameters.get("input");
>>         XMLGenerator generator = new XMLGenerator(bytes);
>>         this.addComponent(generator);
>>         byte[] xsl = (byte[]) parameters.get("xsl");
>>         Source xslSource = new StreamSource(new
>> ByteArrayInputStream(xsl));
>>         XSLTTransformer transformer = new XSLTTransformer(
>>                 xslSource, new Date().getTime());
>>         // pass all parameter to the xslTransformer
>>         transformer.setParameters(parameters);
>>         this.addComponent(transformer);
>>         this.addComponent(TextSerializer.createPlainSerializer());
>>         super.setup(outputStream, parameters);
>> where input is:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <angebot>
>>   <id>$name$$angebot.id$</id>
>>  <anganz>$angebot.anganz$</anganz>
>> <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
>> </angebot>
>> xsl is the identity
>> angebot is a Hibernate Bean.
>> how do feed the pipeline with this Bean that it is used  by Jexl to
>> resolve the input String.
>>
>>
>> Am 13.03.2014 12:55, schrieb gelo1234:
>>
>>  With servlet-sitemaps Jexl can be used within any pipeline as
>> {jexl:.....} value.
>>
>>  Please show example of your embedded pipeline ?
>>
>>  Greetings,
>> Greg
>>
>>
>> 2014-03-13 11:09 GMT+01:00 Yahoo <ha...@yahoo.de>:
>>
>>> How can I use Jexl in an embadded Pipline ?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>
>>
>
>

Re: Jexl in embedded Pipeline

Posted by Piratenvisier <ha...@yahoo.de>.
An application like this I use already.
Thorsten Scherler made this email Application for me.
The important point: I want to send an email and the Email Text and the 
attachements are produced by cocoon pipelines.
This a an important part of my cocoon 2.10 application which I wanted to 
transfer to 3.0

Am 13.03.2014 14:23, schrieb gelo1234:
> I got lost with your explanation :) It's a kind of awkward thing to me 
> that you are actually trying to do with that code.
>
>
> Why not making it clean:
>
> 1. First you need a String-Template match to serialize the Hibernate 
> bean -> output XML with final values
>
> <map:match  pattern="hibernate/bean">
>          <map:generate  src="bean.xml"  type="stringtemplate"  />
>          <map:serialize  type="xml"  />
> </map:match>
> where bean.xml is your [input]
>
> You can now feed angebot bean data into hibernate/bean pipe above (to 
> get it serialized):
> <map:match  pattern="hibernate/{id}">
>          <controller:call  controller="rest-controller"  select="BeanController">
>            <map:parameter  name="id"  value="{map:id}"  />
>          </controller:call>
> </map:match>
>
>
> @RESTController
> public  class  BeanController  implements  Get  {
>
>      @SitemapParameter
>      private  String  id;
>
>      @RequestParameter
>      private  String  name;
>    
>      // through injection or other way
>
>      HibernateDAO dao;
>
>       public  RestResponse  doGet()  throws  Exception  {
>          Map<String,  Object>  data=  new  HashMap<String,  Object>();
>          data.put("angebot",  dao.getAngebotBean(id));
>          data.put("name",  this.name);
>
>          return  new  Page("servlet:/hibernate/bean",  data);
>      }
> }
> At this point you got your Hibernate bean serialized (into XML data).
>
> 2. Second you can go for XSLT Transformer and transform XML into 
> anything you want
>
> You don't need any JEXL here.
>
>
> Greetings,
> Greg
>
>
>
>
> 2014-03-13 13:30 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de 
> <ma...@yahoo.de>>:
>
>     I used the EmailPlainPipe from the distribution:
>       byte[] bytes = (byte[]) parameters.get("input");
>             XMLGenerator generator = new XMLGenerator(bytes);
>             this.addComponent(generator);
>             byte[] xsl = (byte[]) parameters.get("xsl");
>             Source xslSource = new StreamSource(new
>     ByteArrayInputStream(xsl));
>             XSLTTransformer transformer = new XSLTTransformer(
>                     xslSource, new Date().getTime());
>             // pass all parameter to the xslTransformer
>             transformer.setParameters(parameters);
>             this.addComponent(transformer);
>     this.addComponent(TextSerializer.createPlainSerializer());
>             super.setup(outputStream, parameters);
>     where input is:
>     <?xml version="1.0" encoding="UTF-8"?>
>     <angebot>
>       <id>$name$$angebot.id <http://angebot.id>$</id>
>      <anganz>$angebot.anganz$</anganz>
>     <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
>     </angebot>
>     xsl is the identity
>     angebot is a Hibernate Bean.
>     how do feed the pipeline with this Bean that it is used by Jexl to
>     resolve the input String.
>
>
>     Am 13.03.2014 12:55, schrieb gelo1234:
>>     With servlet-sitemaps Jexl can be used within any pipeline as
>>     {jexl:.....} value.
>>
>>     Please show example of your embedded pipeline ?
>>
>>     Greetings,
>>     Greg
>>
>>
>>     2014-03-13 11:09 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de
>>     <ma...@yahoo.de>>:
>>
>>         How can I use Jexl in an embadded Pipline ?
>>
>>         ---------------------------------------------------------------------
>>         To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>         <ma...@cocoon.apache.org>
>>         For additional commands, e-mail: users-help@cocoon.apache.org
>>         <ma...@cocoon.apache.org>
>>
>>
>
>


Re: Jexl in embedded Pipeline

Posted by gelo1234 <ge...@gmail.com>.
I got lost with your explanation :) It's a kind of awkward thing to me that
you are actually trying to do with that code.


Why not making it clean:

1. First you need a String-Template match to serialize the Hibernate bean
-> output XML with final values

<map:match pattern="hibernate/bean">
        <map:generate src="bean.xml" type="stringtemplate" />
        <map:serialize type="xml" /></map:match>

where bean.xml is your [input]

You can now feed angebot bean data into hibernate/bean pipe above (to get
it serialized):

<map:match pattern="hibernate/{id}">
        <controller:call controller="rest-controller" select="BeanController">
          <map:parameter name="id" value="{map:id}" />
        </controller:call></map:match>


@RESTControllerpublic class BeanController implements Get {

    @SitemapParameter
    private String id;

    @RequestParameter
    private String name;

    // through injection or other way
    HibernateDAO dao;


    public RestResponse doGet() throws Exception {
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("angebot", dao.getAngebotBean(id));
        data.put("name", this.name);

        return new Page("servlet:/hibernate/bean", data);
    }}

At this point you got your Hibernate bean serialized (into XML data).

2. Second you can go for XSLT Transformer and transform XML into anything
you want

You don't need any JEXL here.


Greetings,
Greg




2014-03-13 13:30 GMT+01:00 Yahoo <ha...@yahoo.de>:

>  I used the EmailPlainPipe from the distribution:
>   byte[] bytes = (byte[]) parameters.get("input");
>         XMLGenerator generator = new XMLGenerator(bytes);
>         this.addComponent(generator);
>         byte[] xsl = (byte[]) parameters.get("xsl");
>         Source xslSource = new StreamSource(new ByteArrayInputStream(xsl));
>         XSLTTransformer transformer = new XSLTTransformer(
>                 xslSource, new Date().getTime());
>         // pass all parameter to the xslTransformer
>         transformer.setParameters(parameters);
>         this.addComponent(transformer);
>         this.addComponent(TextSerializer.createPlainSerializer());
>         super.setup(outputStream, parameters);
> where input is:
> <?xml version="1.0" encoding="UTF-8"?>
> <angebot>
>   <id>$name$$angebot.id$</id>
>  <anganz>$angebot.anganz$</anganz>
> <angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
> </angebot>
> xsl is the identity
> angebot is a Hibernate Bean.
> how do feed the pipeline with this Bean that it is used  by Jexl to
> resolve the input String.
>
>
> Am 13.03.2014 12:55, schrieb gelo1234:
>
>  With servlet-sitemaps Jexl can be used within any pipeline as
> {jexl:.....} value.
>
>  Please show example of your embedded pipeline ?
>
>  Greetings,
> Greg
>
>
> 2014-03-13 11:09 GMT+01:00 Yahoo <ha...@yahoo.de>:
>
>> How can I use Jexl in an embadded Pipline ?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>
>

Re: Jexl in embedded Pipeline

Posted by Yahoo <ha...@yahoo.de>.
I used the EmailPlainPipe from the distribution:
   byte[] bytes = (byte[]) parameters.get("input");
         XMLGenerator generator = new XMLGenerator(bytes);
         this.addComponent(generator);
         byte[] xsl = (byte[]) parameters.get("xsl");
         Source xslSource = new StreamSource(new ByteArrayInputStream(xsl));
         XSLTTransformer transformer = new XSLTTransformer(
                 xslSource, new Date().getTime());
         // pass all parameter to the xslTransformer
         transformer.setParameters(parameters);
         this.addComponent(transformer);
         this.addComponent(TextSerializer.createPlainSerializer());
         super.setup(outputStream, parameters);
where input is:
<?xml version="1.0" encoding="UTF-8"?>
<angebot>
   <id>$name$$angebot.id$</id>
  <anganz>$angebot.anganz$</anganz>
<angkurzbeschreibung>$angebot.angkurzbeschreibung$</angkurzbeschreibung>
</angebot>
xsl is the identity
angebot is a Hibernate Bean.
how do feed the pipeline with this Bean that it is used  by Jexl to 
resolve the input String.


Am 13.03.2014 12:55, schrieb gelo1234:
> With servlet-sitemaps Jexl can be used within any pipeline as 
> {jexl:.....} value.
>
> Please show example of your embedded pipeline ?
>
> Greetings,
> Greg
>
>
> 2014-03-13 11:09 GMT+01:00 Yahoo <hansheinrichbraun@yahoo.de 
> <ma...@yahoo.de>>:
>
>     How can I use Jexl in an embadded Pipline ?
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>     <ma...@cocoon.apache.org>
>     For additional commands, e-mail: users-help@cocoon.apache.org
>     <ma...@cocoon.apache.org>
>
>


Re: Jexl in embedded Pipeline

Posted by gelo1234 <ge...@gmail.com>.
With servlet-sitemaps Jexl can be used within any pipeline as {jexl:.....}
value.

Please show example of your embedded pipeline ?

Greetings,
Greg


2014-03-13 11:09 GMT+01:00 Yahoo <ha...@yahoo.de>:

> How can I use Jexl in an embadded Pipline ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>