You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Steve K <sh...@myrealbox.com> on 2003/08/23 01:09:22 UTC

Developing a block

Hey folks --

I'm starting a new Cocoon application and I want to try to take advantage of 
the new 2.1 build system and the blocks stuff.  As I couldn't find any 
documentation on how to do this, I put together something and wanted to run 
it by all of you to let me know if I'm on the right track.  I added the 
following directory structure to the src/blocks dir:

testblock/
    conf/
        testblock.xmap
    java/
    lib/
    webapp/
        testblock/
            sitemap.xmap
    build.xml

conf/testblock.xmap inserts a match/mount into the main sitemap to mount my 
webapp/testblock/sitemap.xmap:

<xmap xpath="/sitemap/pipelines/pipeline" 
unless="match[@pattern='testblock']">
    <map:match pattern="testblock/**">
      <map:mount check-reload="yes" src="testblock/" uri-prefix="testblock"/>
    </map:match>
</xmap>

I created the webapp directory to hold all the stuff I need copied to 
build/webapp, and build.xml is the ant task that copies it:

<project default="main" basedir=".">
  <target name="main">
         <copy filtering="on" todir="${build.webapp}">
            <fileset dir="${block.dir}/webapp"/>
         </copy>
  </target>
</project>

Finally I added my new block to gump.xml:

  <project name="cocoon-block-testblock" status="unstable">
    <package>org.apache.cocoon</package>

    <ant target="gump-block">
      <property name="block-name" value="testblock"/>
      <property name="version" value="@@DATE@@"/>
    </ant>

    <depend project="cocoon" inherit="all"/>
    <work nested="tools/anttasks"/>
    <home nested="build/cocoon-@@DATE@@"/>

    <jar name="blocks/testblock-block.jar"/>

    <nag from="Gump" to="dev@cocoon.apache.org"/>
  </project>    

Doing a build webapp builds it and it all seems to work.

Does this seem right?  Is there anything else I should be doing?

Also, is there a way to hot-deploy blocks without restarting jetty?

cheers,
-steve

Re: Developing a block

Posted by Steve K <sh...@myrealbox.com>.
> everything you write down here looks ok
> (and confirmed by your own remark that it even works!)

Thank you for the reply.  Also, I just noticed that the build file that 
blocks-build.xsl only jars "org/**" classes -- this was a problem for me as 
my java classes are in the com.* package.  I had to edit the file to fix 
this.

cheers,
-steve

Re: Developing a block

Posted by Marc Portier <mp...@outerthought.org>.
Steve,

everything you write down here looks ok
(and confirmed by your own remark that it even works!)

hot-deploy in my experience works ok as long as none of the 
changes include class files or jars that need to be reloaded



just for completeness:
- 'real blocks' will be added in 2.2, that will change some stuff 
  for sure, see: 
http://wiki.cocoondev.org/Wiki.jsp?page=BlocksDefinition and a 
recent RT posting: 
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=106134587016684&w=2

- an alternative (while using similar techniques and having 
different benfits/downsides) approach to writing your own block 
in order to make a cocoon based app is here: 
http://wiki.cocoondev.org/Wiki.jsp?page=YourCocoonBasedProject


HTH,
-marc=


Steve K wrote:
> Hey folks --
> 
> I'm starting a new Cocoon application and I want to try to take advantage of 
> the new 2.1 build system and the blocks stuff.  As I couldn't find any 
> documentation on how to do this, I put together something and wanted to run 
> it by all of you to let me know if I'm on the right track.  I added the 
> following directory structure to the src/blocks dir:
> 
> testblock/
>     conf/
>         testblock.xmap
>     java/
>     lib/
>     webapp/
>         testblock/
>             sitemap.xmap
>     build.xml
> 
> conf/testblock.xmap inserts a match/mount into the main sitemap to mount my 
> webapp/testblock/sitemap.xmap:
> 
> <xmap xpath="/sitemap/pipelines/pipeline" 
> unless="match[@pattern='testblock']">
>     <map:match pattern="testblock/**">
>       <map:mount check-reload="yes" src="testblock/" uri-prefix="testblock"/>
>     </map:match>
> </xmap>
> 
> I created the webapp directory to hold all the stuff I need copied to 
> build/webapp, and build.xml is the ant task that copies it:
> 
> <project default="main" basedir=".">
>   <target name="main">
>          <copy filtering="on" todir="${build.webapp}">
>             <fileset dir="${block.dir}/webapp"/>
>          </copy>
>   </target>
> </project>
> 
> Finally I added my new block to gump.xml:
> 
>   <project name="cocoon-block-testblock" status="unstable">
>     <package>org.apache.cocoon</package>
> 
>     <ant target="gump-block">
>       <property name="block-name" value="testblock"/>
>       <property name="version" value="@@DATE@@"/>
>     </ant>
> 
>     <depend project="cocoon" inherit="all"/>
>     <work nested="tools/anttasks"/>
>     <home nested="build/cocoon-@@DATE@@"/>
> 
>     <jar name="blocks/testblock-block.jar"/>
> 
>     <nag from="Gump" to="dev@cocoon.apache.org"/>
>   </project>    
> 
> Doing a build webapp builds it and it all seems to work.
> 
> Does this seem right?  Is there anything else I should be doing?
> 
> Also, is there a way to hot-deploy blocks without restarting jetty?
> 
> cheers,
> -steve
> 

-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at              http://radio.weblogs.com/0116284/
mpo@outerthought.org                              mpo@apache.org