You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Adam Ratcliffe <ad...@mrigitech.com> on 2005/01/14 04:56:17 UTC

RE: Using Cocoon's build system for my webappThanks Ada,

Hi Justin

Your component doesn't need to be a singleton, unless you want it to be, in
which
case it should implement the Avalon
org.apache.avalon.framework.thread.ThreadSafe interface.

My understanding is that the container (ECM) pools component instances, with
the pool
parameters configurable in cocoon.xconf. Maybe someone who is more familiar
with Cocoon
internals can give you some more pointers on pool configuration, to date I
haven't had any
problems with running with the system defaults.

The example I gave of looking up a component was using the flowscript
syntax. If you haven't
already read about flow it fulfils the controller role in cocoon MVC
applications, see
http://cocoon.apache.org/2.1/userdocs/flow/index.html. The sitemap matches
URIs to top-level
functions in the flow layer which in turn typically delegate business
functions to Java objects.

If you wanted to lookup your Avalon component from another component such as
a customer generator
you would use this syntax:

MyComponent comp =
(MyComponent)this.serviceManager.lookup(MyComponent.ROLE);

In this example your sitemap component would need to implement the
org.apache.avalon.framework.service.Servicable
interface so that it would be provided with a reference to the
ServiceManager when it was
instantiated.

As you may know the Avalon project has been closed, I believe some of the
docs have since been posted
to the Apache Excalibur site.

Cheers
Adam

-----Original Message-----
From: Justin Fagnani [mailto:justin3@fagnani.com]
Sent: Friday, 8 July 2005 2:36 a.m.
To: users@cocoon.apache.org
Subject: Re: Using Cocoon's build system for my webappThanks Ada,


Thanks Adam,

You answered most of my questions.

The only thing left (assuming I understand the wiki docs) is that the
component I'm setting up need to be a singleton instantiated when Cocoon
launches.

I remember using a ComponentManager to get my components. I didn't use XSP
much though, so I'm wondering if this:

> var myComp = cocoon.getComponent(Packages.com.example.MyComponent.ROLE);

Is how I would do it inside a Generator, or if that's maybe XSP specific. Is
the cocoon object now passed to pipeline components through the objectModel?

Also, I need to make sure that the instance I get is the same that was
created
at launch time. This is setup in the sitemap, right?

Ahh, knockin the rust off.

Thanks again,
  Justin

On Thursday 13 January 2005 19:05, Adam Ratcliffe wrote:
> Hi Justin
>
> The Cocoon wiki has some good resources on tailoring the Cocoon webapp and
> developing your project
> against it, see http://wiki.apache.org/cocoon/YourCocoonBasedProjectAnt16
> and http://wiki.apache.org/cocoon/ProjectBuilding
>
> The first doc has a link to an Ant build script that will help with
setting
> up a directory structure
> that decouples your project's resources from the cocoon source tree, and
> targets for patching the
> cocoon configuration files with your project's specific configuration.
>
> I've successfully used this approach to upgrade a webapp from the 2.1.5 to
> 2.1.6 release.
>
> If you're already familiar with developing Avalon components for Cocoon
> deploying them is
> not too difficult.  Briefly:
>
> - Create your component roles file e.g.
>
> <role-list>
>   <role name="com.example.MyComponent"
> 	shorthand="myComp"
> 	default-class="com.example.MyComponent"/>
> ...
> </role-list>
>
> - Register these with Cocoon by adding a 'user-roles' attribute to the
root
> element in cocoon.xconf
>
> <cocoon user-roles="my.roles">
>
> - The component's lifecycle methods will be invoked when you
lookup/release
> the component, for example
> in flowscript:
>
> var myComp = cocoon.getComponent(Packages.com.example.MyComponent.ROLE);
>
> HTH
> Adam
>
>
>
>
>
> -----Original Message-----
> From: Justin Fagnani [mailto:justin3@fagnani.com]
> Sent: Friday, 8 July 2005 1:33 a.m.
> To: users@cocoon.apache.org
> Subject: Using Cocoon's build system for my webapp
>
>
> Hello Cocoon'ers,
>
> It's been a long while since I've done any Cocoon work. I've been playing
> with
> the new (to me) build system and so far I like it. I've been able to
easily
> pair down the build with the local blocks and build properties.
>
> Now I want to start setting up the sitemap and writing some custom
> components.
> I'd like to use the current build system but I'm getting some errors.
Maybe
> it's not the right way to do it, but so far I haven't seen any
> documentation on what the suggested build setup is.
>
> First I figured I'd edit the sitemap in src/webapp. I removed some
unneeded
> matchers and quickly got errors with confpatch, specifically mount-table.
I
> added back the api section to the sitemap just to get going, but I wonder
> what the correct solution is.
>
> Should I create my own target xml file? Should I remove mount-table.xmap
> from
> src/confpatch ?
>
> My second issue has to do with components. I want to wrap an object as an
> Avalon component and have it instantiated when Cocoon is launched. Before
I
> did this with a user.roles file and editing cocoon.xconf. I went to the
> documentation to make sure I remembered how to do it, but I couldn't find
> much, just one reference to creating a my.roles file. To use the build
> system
> would I just put my.roles in the src/webapp/WEB-INF directory?
>
> My big concern is that it'll be difficult to upgrade when a new version of
> Cocoon comes out. On the other hand I've created a nice minimal Cocoon
> setup,
> but I might need more blocks later. I like the idea of being able to edit
> local.blocks.properties and get the blocks I need, and then rebuild my
> whole webapp.
>
> Any suggestions or advice would be greatly appreciated.
>
> Thanks,
>   Justin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org

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




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