Description provider duplication example acme-subsystem

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

Description provider duplication example acme-subsystem

David Bosschaert
Hi Kabir,

Looking at the example acme-subsystem in [1] I noticed that there are 2
decription providers that contain the same attribute description. Once
in the TypeAddHandler and another one in SubsystemProviders.TYPE_CHILD.
They describe exactly the same property - the code seems to be copied. I
see that they are used in 2 places, the TypeAddHandler description is
used in registerOperationHandler() while SubsystemProviders.TYPE_CHILD
is used in the registerSubModel() call.

Is this duplication intentional/needed?

Thanks,

David

BTW here's the duplicated code:
public ModelNode getModelDescription(Locale locale) {
     ModelNode node = new ModelNode();
     node.get(DESCRIPTION).set("Contains information about a tracked
deployment type");
     node.get(ATTRIBUTES, "tick", DESCRIPTION).set("How often in
milliseconds to output the information about the tracked deployments");
     node.get(ATTRIBUTES, "tick", TYPE).set(ModelType.LONG);
     node.get(ATTRIBUTES, "tick", REQUIRED).set(true);
     node.get(ATTRIBUTES, "tick", DEFAULT).set(10000);
     return node;
}

[1] https://docs.jboss.org/author/display/AS7/Extending+JBoss+AS+7
_______________________________________________
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: Description provider duplication example acme-subsystem

Emanuel Muckenhuber
Yes, this duplication is intentional. The one used in registerSubModel()
is the model description of the sub-resource, the other describes the
'add' operation, which is creating the resource in the end. So in this
case it's quite likely that the subModel 'attributes' and operation
'request-parameters' are pretty similar. We are working on additional
utils which should help to reduce some of the duplications in future.
Does that answer you question?

On 07/26/2011 10:38 AM, David Bosschaert wrote:

> Hi Kabir,
>
> Looking at the example acme-subsystem in [1] I noticed that there are 2
> decription providers that contain the same attribute description. Once
> in the TypeAddHandler and another one in SubsystemProviders.TYPE_CHILD.
> They describe exactly the same property - the code seems to be copied. I
> see that they are used in 2 places, the TypeAddHandler description is
> used in registerOperationHandler() while SubsystemProviders.TYPE_CHILD
> is used in the registerSubModel() call.
>
> Is this duplication intentional/needed?
>
> Thanks,
>
> David
>
> BTW here's the duplicated code:
> public ModelNode getModelDescription(Locale locale) {
>       ModelNode node = new ModelNode();
>       node.get(DESCRIPTION).set("Contains information about a tracked
> deployment type");
>       node.get(ATTRIBUTES, "tick", DESCRIPTION).set("How often in
> milliseconds to output the information about the tracked deployments");
>       node.get(ATTRIBUTES, "tick", TYPE).set(ModelType.LONG);
>       node.get(ATTRIBUTES, "tick", REQUIRED).set(true);
>       node.get(ATTRIBUTES, "tick", DEFAULT).set(10000);
>       return node;
> }
>
> [1] https://docs.jboss.org/author/display/AS7/Extending+JBoss+AS+7
> _______________________________________________
> 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: Description provider duplication example acme-subsystem

David Bosschaert
Hi Emanuel,

> Does that answer you question?

Yes, it does - thanks! I can get around the code duplication by using a
method that can produce either attributes or request parameters.

Cheers,

David

On 26/07/2011 12:12, Emanuel Muckenhuber wrote:

> Yes, this duplication is intentional. The one used in registerSubModel()
> is the model description of the sub-resource, the other describes the
> 'add' operation, which is creating the resource in the end. So in this
> case it's quite likely that the subModel 'attributes' and operation
> 'request-parameters' are pretty similar. We are working on additional
> utils which should help to reduce some of the duplications in future.
> Does that answer you question?
>
> On 07/26/2011 10:38 AM, David Bosschaert wrote:
>> Hi Kabir,
>>
>> Looking at the example acme-subsystem in [1] I noticed that there are 2
>> decription providers that contain the same attribute description. Once
>> in the TypeAddHandler and another one in SubsystemProviders.TYPE_CHILD.
>> They describe exactly the same property - the code seems to be copied. I
>> see that they are used in 2 places, the TypeAddHandler description is
>> used in registerOperationHandler() while SubsystemProviders.TYPE_CHILD
>> is used in the registerSubModel() call.
>>
>> Is this duplication intentional/needed?
>>
>> Thanks,
>>
>> David
>>
>> BTW here's the duplicated code:
>> public ModelNode getModelDescription(Locale locale) {
>>        ModelNode node = new ModelNode();
>>        node.get(DESCRIPTION).set("Contains information about a tracked
>> deployment type");
>>        node.get(ATTRIBUTES, "tick", DESCRIPTION).set("How often in
>> milliseconds to output the information about the tracked deployments");
>>        node.get(ATTRIBUTES, "tick", TYPE).set(ModelType.LONG);
>>        node.get(ATTRIBUTES, "tick", REQUIRED).set(true);
>>        node.get(ATTRIBUTES, "tick", DEFAULT).set(10000);
>>        return node;
>> }
>>
>> [1] https://docs.jboss.org/author/display/AS7/Extending+JBoss+AS+7
>> _______________________________________________
>> 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