Re: Multiple Trigger Problem
Tucanette <tucanette <at> googlemail.com>
2010-04-04 17:54:11 GMT
Hi,
Thanks a lot for your support!
I have a solution running and tested for about a month.
This is a summary to be used by other users having similar problems.
Unfortunately the solution proposed by Adam Retter did not work for me.
The MasterTrigger does not return, the thread gets stuck.
What I did instead was to keep MyTrigger class unchanged.
I also kept the VersioningTrigger class unchanged.
In my solution the MasterTrigger extends the VersioningTrigger class and
has an instance variable of MyTrigger class.
MyTrigger as well as VersioningTrigger can be tested and used separately
or together using the MasterTrigger.
Each of the methods prepare, configure, startElement and finish calls the method of the instance variable
first
and then the same method of the super class - the VersioningTrigger class.
Below is the simplified code:
--
public class MasterTrigger extends VersioningTrigger {
private MyTrigger myTrigger;
public MasterTrigger() {
super();
myTrigger = new MyTrigger();
}
public void configure(DBBroker broker, Collection parent, Map parameters) throws CollectionConfigurationException{
myTrigger.configure(broker, parent, parameters);
super.configure(broker, parent, parameters);
}
public void prepare(int arg0, DBBroker arg1, Txn arg2, XmldbURI arg3,
DocumentImpl arg4) throws TriggerException {
myTrigger.prepare(arg0, arg1, arg2, arg3, arg4);
super.prepare(arg0, arg1, arg2, arg3, arg4);
}
public void startElement(String namespaceURI, String localName,
String qname, Attributes attributes) throws SAXException {
myTrigger.startElement(namespaceURI, localName, qname, attributes);
super.startElement(namespaceURI, localName, qname, attributes);
}
public void finish(int arg0, DBBroker arg1, Txn arg2, XmldbURI arg3,
DocumentImpl arg4) {
myTrigger.finish(arg0, arg1, arg2, arg3, arg4);
super.finish(arg0, arg1, arg2, arg3, arg4);
}
}
--
In order to participate in a bigger application,
it would be great to have a transaction manager as well as support for XA transactions.
Regards
Simone
-----Ursprüngliche Nachricht-----
Von: Adam Retter [mailto:adam <at> exist-db.org]
Gesendet: Donnerstag, 4. März 2010 10:28
An: Tucanette
Cc: exist-open <at> lists.sourceforge.net; Evgeny Gazdovsky
Betreff: Re: [Exist-open] Multiple Trigger Problem
On 3 March 2010 09:44, Tucanette <tucanette <at> googlemail.com> wrote:
> Hi,
>
> currently I am using one trigger to ensure referential integrity beyond xml document boundaries.
> That trigger is written in Java. Additionally I would like to have the versioning feature of exist-db in my application.
>
> I have a few questions:
> 1. Evgeny is it possible to specify the sequence in which the triggers are fired?
>
> 2. When will the branch with the new trigger design be available in the trunk or a release?
>
> 3. Using the current release 1.4 of exist, how do I call from one master trigger the code of two other triggers?
> Which method is being called, to ensure the life cycle of a trigger with calling prepare, configure,
finish ...?
> Simply asked from a master trigger, how do I call the two other java trigger?
For your master Trigger create a Java Class which extends
FilteringTrigger, and then from each of the methods that you have to
implement, call the corresponding method on The Versioning Trigger and
your own Trigger.
e.g.
public class MasterTrigger extends FilteringTrigger {
private VersioningTrigger versioningTrigger = new VersioningTrigger();
private MyTrigger myTrigger = new MyTrigger();
public void configure(DBBroker broker, Collection parent, Map
parameters) throws CollectionConfigurationException {
versioingTrigger.configure(broker, parent, parameters);
myTrigger.configure(broker, parent, parameters);
}
etc. etc.
>
> Regards
>
> Simone
>
>
> -----Ursprüngliche Nachricht-----
> Von: Adam Retter [mailto:adam <at> exist-db.org]
> Gesendet: Dienstag, 2. März 2010 14:46
> An: Tucanette
> Cc: exist-open <at> lists.sourceforge.net; Evgeny Gazdovsky
> Betreff: Re: [Exist-open] Multiple Trigger Problem
>
> If you look at the code here for the function createTrigger() -
> https://exist.svn.sourceforge.net/svnroot/exist/trunk/eXist/src/org/exist/collections/CollectionConfiguration.java
>
> It would seem to me that you can only register one trigger per-event.
> You have two triggers that you both want to response to the events
> "store" and "update".
>
> We should change the Triggers code ideally so you can have any number
> of triggers per event, I think Evgeny may have been attempting this in
> his triggers branch of the code base. I am not sure of the status of
> that, how well tested it is or when it will be integrated back into
> trunk - Evgeny?
>
> In the meantime, you could simply create a Trigger in Java that
> encapsulates those two triggers and passes off the events to them one
> after another.
>
> Cheers Adam.
>
> On 28 February 2010 23:02, Tucanette <tucanette <at> googlemail.com> wrote:
>> Hi,
>>
>>
>>
>> I would like to have the versioning trigger and also my own trigger to be
>> fired on the same update event.
>>
>> I am running exist db 1.4.
>>
>>
>>
>> My configuration looks like this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <collection xmlns="http://exist-db.org/collection-config/1.0">
>>
>> <triggers>
>>
>> <trigger event="store,remove,update"
>> class="org.exist.versioning.VersioningTrigger"><parameter name="overwrite"
>> value="yes"/></trigger>
>>
>> <trigger event="store,update"
>> class="de.tucanette.myapp.trigger.ReferentialIntegrityTrigger"/>
>>
>> </triggers>
>>
>> <validation mode="yes"/>
>>
>> </collection>
>>
>>
>>
>> However, only the second trigger in the configuration list is being
>> executed.
>>
>> Separately configured each of the triggers works fine.
>>
>>
>>
>> Can someone help me solve the problem?
>>
>>
>>
>> Regards,
>>
>> Simone
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Exist-open mailing list
>> Exist-open <at> lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/exist-open
>>
>>
>
>
>
> --
> Adam Retter
>
> eXist Developer
> { United Kingdom }
> adam <at> exist-db.org
> irc://irc.freenode.net/existdb
>
>
--
--
Adam Retter
eXist Developer
{ United Kingdom }
adam <at> exist-db.org
irc://irc.freenode.net/existdb
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Exist-open mailing list
Exist-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/exist-open