[jboss-as7-dev] Read sub-model operation question

Brian Stansberry brian.stansberry at redhat.com
Tue Jan 11 09:11:06 EST 2011


On 1/11/11 7:36 AM, Kabir Khan wrote:
> I have the following model:
>
> Model {"profile" =>  {
>          "profileA" =>  {
>              "name" =>  "Profile A",
>              "content" =>  [
>                  1,
>                  2
>              ]
>          },
>          "profileC" =>  {"name" =>  "Profile C"}
>      }}
>
> This is the operation descriptor:
>
> {
>      "operation-name" =>  "read-sub-model",
>      "description" =>  "Reads a model node's sub values",
>      "request-properties" =>  {"recursive" =>  {
>              "type" =>  BOOLEAN,
>              "description" =>  "Whether to get the children recursively. If absent, false is the default",
>              "required" =>  false,
>              "nillable" =>  true
>          }}
> }
>
> I call it with:
> {
>      "operation-name" =>  "read-sub-model",
>      "address" =>  [
>          "profile",
>          "profileA"
>      ],
>      "request-properties" =>  {"recursive" =>  true}
> }
>
> In my operation handler I see:
>
>
> {
>      "name" =>  "Profile A",
>      "content" =>  [
>          1,
>          2
>      ]
> }
>
> The question is when calling resultHandler.handleResultFragment() what do I pass in for the location parameter?
>
> If I use '{"profile", "profileA"}' I get this returned to the client:
>
> {"profile" =>  {"profileA" =>  {
>              "name" =>  "Profile A",
>              "content" =>  [
>                  1,
>                  2
>              ]
>          }}}
>
> If I use {} I get this returned:
> {
>      "name" =>  "Profile A",
>      "content" =>  [
>          1,
>          2
>      ]
> }
>

The latter. The "profile" =>  { "profileA" bit is part of the parent 
sub-model. It's the bit between {}  (i.e.  { "name" => .... } ) is a 
representation of an object. The "profileA" => { ... } is analogous to a 
field in a containing object referring to that object.

> Also, I am not clear on what to return if recursive == false?
>

My thinking was:

{
      "name" =>  "Profile A",
      "subsystem" =>  {
          "jmx" => {},
          "web" => {}
      }
}

with the {} meaning "jmx" is undefined. Users can call keys() on the 
"subsystem" node to get the set of children names. If users then queried 
for the jmx subsystem, they could set the result on that node.

An alternative is:

{
      "name" =>  "Profile A",
      "subsystem" =>  [
          "jmx",
          "web"
      ]
}

that is, just return the names of the children as a list. Problem there 
is that makes the "subsystem" node ModelType.LIST, so the user can't 
later use it to insert the children. So IMO that's not the way to do it.

>
> _______________________________________________
> jboss-as7-dev mailing list
> jboss-as7-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev


-- 
Brian Stansberry
Principal Software Engineer
JBoss by Red Hat



More information about the jboss-as7-dev mailing list