[rules-users] Using XMLGregorianCalendar for @timestamp metadata

Davide Sottara dsotty at gmail.com
Thu May 2 15:19:22 EDT 2013


Jaxb supports binding customizations and has plugin for code enhancement,
I'm just not sure if you'd be able to inject them in the appropriate place.

Unfortunately no, there's no way to add **methods** in a rule. There's
something
very experimental in the sense of interface injection and mixins, but it
would
be an overkill in your case.

If you can't intercept the facts before they are inserted in the WM, you
can still use
a subclass to extends the JAXB-generated class, with a copy constructor
and the
timestamp method, and add a rule like this:

declare ExtendedClass
@role(event)
@timestamp(longTimestamp)
end

rule "swap"
salience 99999
no-loop  <-- must fire only once for each object. no-loop may not be
enough, depending on
                    whether you later modify/update the object or not.
Other options are available
when
  $x : BaseClass()
then
  retract( $x );
  insert( new ExtendedClass( $x ) );
end



 
On 05/02/2013 12:05 PM, ScalaEnthusiast wrote:
> That is possible with subclassing, as the class is being created by a jaxb
> conversion for a web service call. If I owned the class, it wouldn't be an
> issue - just trying to not change what we are provided by a third party. 
>
> Is there a way to add an attribute in the rule itself and populate with a
> method call?
>
> SE
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Using-XMLGregorianCalendar-for-timestamp-metadata-tp4023636p4023640.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list