You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Manri Offermann <ta...@eastbeam.co.jp> on 2005/03/19 14:39:21 UTC

3.1 - adding custom ServiceEncoder and custom Service

Hello all,

I am trying to add a custom ServiceEncoder and Service in tapestry 3.1, but 
still couldn't figure out how. The documentation says:

"Engine services are now defined using HiveMind, in the 
tapestry.services.ApplicationServices configuration point. "

but it doesn't say exactly how it is done ...

Does anybody have a sample of how to declare new Services in 3.1?


Thanks,

manri



for my simple TestServiceEncoder I have added the following

hivemodule.xml

 <contribution configuration-id="tapestry.url.ServiceEncoders">
  <my-service-encoder id="page" extension="html"/>
 </contribution>


How and where do I add this?

   <element name="my-service-encoder">
    <attribute name="id" required="true" unique="true"></attribute>
    <attribute name="before"></attribute>
    <attribute name="after"></attribute>
    <attribute name="extension" required="true"></attribute>
    <rules>
     <create-object
      class="org.apache.tapestry.services.impl.ServiceEncoderContribution"/>
     <read-attribute attribute="id" property="id"/>
     <read-attribute attribute="before" property="before"/>
     <read-attribute attribute="after" property="after"/>
     <invoke-parent method="addElement"/>
     <create-object
      class="com.eastbeam.ext.tapestry.encoder.TestServiceEncoder"/>
     <read-attribute attribute="extension" property="extension"/>
     <invoke-parent method="setEncoder"/>
    </rules>
   </element> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: 3.1 - adding custom ServiceEncoder and custom Service

Posted by Howard Lewis Ship <hl...@gmail.com>.
Examples from the Tapestry 3.1 workbench:

Contributing a service (overriding the factory home service) and
adding a chart service:

 <contribution configuration-id="tapestry.services.ApplicationServices">
    <service object="service:Home"/>
    <service object="service:Chart"/>
  </contribution>
 
  
  <service-point id="Chart"
interface="org.apache.tapestry.engine.IEngineService">
    <invoke-factory model="primitive">
      <construct class="org.apache.tapestry.workbench.chart.ChartService">
        <set-object property="exceptionReporter"
value="infrastructure:requestExceptionReporter"/>
      </construct>
    </invoke-factory>
  </service-point>
  
  <service-point id="Home"
interface="org.apache.tapestry.engine.IEngineService">
    <invoke-factory model="primitive">
      <construct class="org.apache.tapestry.workbench.WorkbenchHomeService">
        <set-object property="responseRenderer"
value="infrastructure:responseRenderer"/>
        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
        <set-object property="pageName"
value="app-property:org.apache.tapestry.home-page"/>
      </construct>
    </invoke-factory>
  </service-point>  


Enabling use of built-in service encoders:

  <contribution configuration-id="tapestry.url.ServiceEncoders">
    <page-service-encoder id="direct" extension="direct" service="direct"/>
    <page-service-encoder id="page" extension="page" service="page"/>
    <asset-encoder id="asset" path="/assets/"/>
    <extension-encoder id="ext" extension="svc" after="*"/>
  </contribution>

Extra web.xml configuration for those encoders:


  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>*.page</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>*.direct</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>*.svc</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>/assets/*</url-pattern>
  </servlet-mapping>


Contributing a custom (rather than built-in) encoder:

  <contribution configuration-id="tapestry.url.ServiceEncoders">
    <encoder id="...." object="service:MyEncoderService"/>
  </contribution>





On Sat, 19 Mar 2005 22:39:21 +0900, Manri Offermann
<ta...@eastbeam.co.jp> wrote:
> Hello all,
> 
> I am trying to add a custom ServiceEncoder and Service in tapestry 3.1, but
> still couldn't figure out how. The documentation says:
> 
> "Engine services are now defined using HiveMind, in the
> tapestry.services.ApplicationServices configuration point. "
> 
> but it doesn't say exactly how it is done ...
> 
> Does anybody have a sample of how to declare new Services in 3.1?
> 
> Thanks,
> 
> manri
> 
> for my simple TestServiceEncoder I have added the following
> 
> hivemodule.xml
> 
>  <contribution configuration-id="tapestry.url.ServiceEncoders">
>   <my-service-encoder id="page" extension="html"/>
>  </contribution>
> 
> How and where do I add this?
> 
>    <element name="my-service-encoder">
>     <attribute name="id" required="true" unique="true"></attribute>
>     <attribute name="before"></attribute>
>     <attribute name="after"></attribute>
>     <attribute name="extension" required="true"></attribute>
>     <rules>
>      <create-object
>       class="org.apache.tapestry.services.impl.ServiceEncoderContribution"/>
>      <read-attribute attribute="id" property="id"/>
>      <read-attribute attribute="before" property="before"/>
>      <read-attribute attribute="after" property="after"/>
>      <invoke-parent method="addElement"/>
>      <create-object
>       class="com.eastbeam.ext.tapestry.encoder.TestServiceEncoder"/>
>      <read-attribute attribute="extension" property="extension"/>
>      <invoke-parent method="setEncoder"/>
>     </rules>
>    </element>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org