[daisy] Problem presavehook generating xinfo-info file

Bruno Dumon bruno at outerthought.org
Wed Oct 11 11:31:06 CDT 2006


Hi,

On Wed, 2006-10-11 at 16:44 +0200, Bart Van den Abeele wrote:
> Hi again :-),
> 
> This afternoon i tried to customize a presavehook and i succeeded!  I 
> started naming it PostSaveHook because that was the intention, but at 
> this moment it still is a presavehook.

There are no post-save hooks, at least not with that name, though if you
want to do something after a document is created, there are two
possibilities:

* assynchronously (prefered): by listening to JMS events.

* synchronously: by using repository.addListener(...)

The JMS-based listener can run in or outside the repository server VM,
the synchronous listener should run in the repository VM.

In case of JMS, be sure to create a durable JMS subscription in order to
receive all events.

The synchronous listeners are basically post-save (or post-delete,
post-create) hooks. For both pre-save hooks and synchronous listeners,
be sure to make their overhead minimal, especially for documents where
they don't have to do anything, since these are executed in the
'cricital path', i.e. they block the further execution of the request.

> 
> The only thing that went wrong was the generation of the xinfo-file of 
> my java file by maven.  It generated the following:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE type PUBLIC "-//AVALON/Type DTD Version 1.0//EN" 
> "http://avalon.apache.org/dtds/meta/type_1_1.dtd" >
> 
> <type>
>   <info>
>     <name>scandocument-postsavehook</name>
>     <version>1.0.0</version>
>     <lifestyle>singleton</lifestyle>
>     <collection>hard</collection>
>   </info>
> </type>
> 
> and had to generate:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE type PUBLIC "-//AVALON/Type DTD Version 1.0//EN" 
> "http://avalon.apache.org/dtds/meta/type_1_1.dtd" >
> 
> <type>
>   <info>
>     <name>scandocument-postsavehook</name>
>     <version>1.0.0</version>
>     <lifestyle>singleton</lifestyle>
>     <collection>hard</collection>
>   </info>
>     <dependencies>
>     <dependency key="postsavehook-registrar" 
> type="org.outerj.daisy.repository.PreSaveHookRegistrar"/>
>   </dependencies>
> </type>
> 
> So i mannualy adapted this file in the jar, deployed it and everything 
> worked fine.
> When i didn't add these lines, the daisy-repository 2.0 dev wouldn't 
> start and generate an error about not finding the key 
> postsavehook-registrar.

You're probably missing the @avalon.dependency key on the service method
in your component class, just do the same as in the image pre-save hook:

    /**
     * @avalon.dependency key="presavehook-registrar" type="org.outerj.daisy.repository.PreSaveHookRegistrar"
     */
    public void service(ServiceManager serviceManager) throws ServiceException {
        this.serviceManager = serviceManager;
        preSaveHookRegistrar = (PreSaveHookRegistrar)serviceManager.lookup("presavehook-registrar");
        preSaveHookRegistrar.registerPreSaveHook(this);
    }

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno at outerthought.org                          bruno at apache.org



More information about the daisy mailing list