AbstractAddStepHandler handling

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

AbstractAddStepHandler handling

David Bosschaert
Hi all,

While I'm writing a bunch of AbstractAddStepHandler subclasses for the
parsing of my subsystem I was thinking the following...

Typically these have the following methods:
   protected void populateModel(ModelNode operation, ModelNode model) {
     // parse data out of operation and put into model
   }

   protected void performRuntime(OperationContext context, ModelNode
operation, ModelNode model,...) {
     // take action, which typically means:
     // read data out of model and do something with it
   }

This typically means that I have to parse the stuff in performRuntime
again (from ModelNode->native objects), either out of model or reparse
the operation. It would be nice if the result of the parsing in
populateModel could be cached somehow so that you could re-use it in
performRuntime?

Any ideas here? Is this already possible? Or should I be doing things
differently?

Cheers,

David
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: AbstractAddStepHandler handling

Emanuel Muckenhuber
There is no need to subclass this handler. I'd suggest you use the
OperationStepHandler interface directly and add the 5 lines this handler
does. At least that's what i'm doing.

On 07/22/2011 01:03 PM, David Bosschaert wrote:

> Hi all,
>
> While I'm writing a bunch of AbstractAddStepHandler subclasses for the
> parsing of my subsystem I was thinking the following...
>
> Typically these have the following methods:
>     protected void populateModel(ModelNode operation, ModelNode model) {
>       // parse data out of operation and put into model
>     }
>
>     protected void performRuntime(OperationContext context, ModelNode
> operation, ModelNode model,...) {
>       // take action, which typically means:
>       // read data out of model and do something with it
>     }
>
> This typically means that I have to parse the stuff in performRuntime
> again (from ModelNode->native objects), either out of model or reparse
> the operation. It would be nice if the result of the parsing in
> populateModel could be cached somehow so that you could re-use it in
> performRuntime?
>
> Any ideas here? Is this already possible? Or should I be doing things
> differently?
>
> Cheers,
>
> David
> _______________________________________________
> jboss-as7-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev

_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: AbstractAddStepHandler handling

David Bosschaert
Thanks Emanuel,

I was trying to stay as close as possible to [1] but this is of course a
solution.
We might update the doc to mention it...

Cheers,

David

[1] https://docs.jboss.org/author/display/AS7/Extending+JBoss+AS+7

On 22/07/2011 13:07, Emanuel Muckenhuber wrote:

> There is no need to subclass this handler. I'd suggest you use the
> OperationStepHandler interface directly and add the 5 lines this handler
> does. At least that's what i'm doing.
>
> On 07/22/2011 01:03 PM, David Bosschaert wrote:
>> Hi all,
>>
>> While I'm writing a bunch of AbstractAddStepHandler subclasses for the
>> parsing of my subsystem I was thinking the following...
>>
>> Typically these have the following methods:
>>      protected void populateModel(ModelNode operation, ModelNode model) {
>>        // parse data out of operation and put into model
>>      }
>>
>>      protected void performRuntime(OperationContext context, ModelNode
>> operation, ModelNode model,...) {
>>        // take action, which typically means:
>>        // read data out of model and do something with it
>>      }
>>
>> This typically means that I have to parse the stuff in performRuntime
>> again (from ModelNode->native objects), either out of model or reparse
>> the operation. It would be nice if the result of the parsing in
>> populateModel could be cached somehow so that you could re-use it in
>> performRuntime?
>>
>> Any ideas here? Is this already possible? Or should I be doing things
>> differently?
>>
>> Cheers,
>>
>> David
>> _______________________________________________
>> jboss-as7-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
> _______________________________________________
> jboss-as7-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev

_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: AbstractAddStepHandler handling

Emanuel Muckenhuber
Hmm, ok good point - i will add that to the docs.

The AbstractAddStepHandler is a nice util if this scheme works for you.
However we also find cases where this default behavior does not apply,
so it's hard to generalize. That's why i would rather suggest you create
your own subclass, before you get a headache trying to use this one :)

On 07/22/2011 02:44 PM, David Bosschaert wrote:

> Thanks Emanuel,
>
> I was trying to stay as close as possible to [1] but this is of course a
> solution.
> We might update the doc to mention it...
>
> Cheers,
>
> David
>
> [1] https://docs.jboss.org/author/display/AS7/Extending+JBoss+AS+7
>
> On 22/07/2011 13:07, Emanuel Muckenhuber wrote:
>> There is no need to subclass this handler. I'd suggest you use the
>> OperationStepHandler interface directly and add the 5 lines this handler
>> does. At least that's what i'm doing.
>>
>> On 07/22/2011 01:03 PM, David Bosschaert wrote:
>>> Hi all,
>>>
>>> While I'm writing a bunch of AbstractAddStepHandler subclasses for the
>>> parsing of my subsystem I was thinking the following...
>>>
>>> Typically these have the following methods:
>>> protected void populateModel(ModelNode operation, ModelNode model) {
>>> // parse data out of operation and put into model
>>> }
>>>
>>> protected void performRuntime(OperationContext context, ModelNode
>>> operation, ModelNode model,...) {
>>> // take action, which typically means:
>>> // read data out of model and do something with it
>>> }
>>>
>>> This typically means that I have to parse the stuff in performRuntime
>>> again (from ModelNode->native objects), either out of model or reparse
>>> the operation. It would be nice if the result of the parsing in
>>> populateModel could be cached somehow so that you could re-use it in
>>> performRuntime?
>>>
>>> Any ideas here? Is this already possible? Or should I be doing things
>>> differently?
>>>
>>> Cheers,
>>>
>>> David
>>> _______________________________________________
>>> jboss-as7-dev mailing list
>>> [hidden email]
>>> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>> _______________________________________________
>> jboss-as7-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>

_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: AbstractAddStepHandler handling

Brian Stansberry
In reply to this post by David Bosschaert
Agreed, it would be better if populateModel returned <T> and
performRuntime took a <T> as a param. But that would need to be done in
a new base class, as this is already a widely used API.

Hardest part about it is coming up with a nice name for the new base
class, since the existing one has the obvious name. ;-)

On 7/22/11 7:44 AM, David Bosschaert wrote:

> Thanks Emanuel,
>
> I was trying to stay as close as possible to [1] but this is of course a
> solution.
> We might update the doc to mention it...
>
> Cheers,
>
> David
>
> [1] https://docs.jboss.org/author/display/AS7/Extending+JBoss+AS+7
>
> On 22/07/2011 13:07, Emanuel Muckenhuber wrote:
>> There is no need to subclass this handler. I'd suggest you use the
>> OperationStepHandler interface directly and add the 5 lines this handler
>> does. At least that's what i'm doing.
>>
>> On 07/22/2011 01:03 PM, David Bosschaert wrote:
>>> Hi all,
>>>
>>> While I'm writing a bunch of AbstractAddStepHandler subclasses for the
>>> parsing of my subsystem I was thinking the following...
>>>
>>> Typically these have the following methods:
>>>       protected void populateModel(ModelNode operation, ModelNode model) {
>>>         // parse data out of operation and put into model
>>>       }
>>>
>>>       protected void performRuntime(OperationContext context, ModelNode
>>> operation, ModelNode model,...) {
>>>         // take action, which typically means:
>>>         // read data out of model and do something with it
>>>       }
>>>
>>> This typically means that I have to parse the stuff in performRuntime
>>> again (from ModelNode->native objects), either out of model or reparse
>>> the operation. It would be nice if the result of the parsing in
>>> populateModel could be cached somehow so that you could re-use it in
>>> performRuntime?
>>>
>>> Any ideas here? Is this already possible? Or should I be doing things
>>> differently?
>>>
>>> Cheers,
>>>
>>> David
>>> _______________________________________________
>>> jboss-as7-dev mailing list
>>> [hidden email]
>>> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>> _______________________________________________
>> jboss-as7-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>
> _______________________________________________
> jboss-as7-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev


--
Brian Stansberry
Principal Software Engineer
JBoss by Red Hat
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev