1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.neo4j.server.webadmin.rest.representations;
21
22 import java.util.ArrayList;
23
24 import javax.management.openmbean.CompositeData;
25
26 import org.neo4j.server.rest.repr.ListRepresentation;
27 import org.neo4j.server.rest.repr.ObjectRepresentation;
28 import org.neo4j.server.rest.repr.Representation;
29 import org.neo4j.server.rest.repr.ValueRepresentation;
30
31 public class JmxCompositeDataRepresentation extends ObjectRepresentation
32 {
33 protected CompositeData data;
34
35 public JmxCompositeDataRepresentation( CompositeData data )
36 {
37 super( "jmxCompositeData" );
38 this.data = data;
39 }
40
41 @Mapping( "type" )
42 public ValueRepresentation getType()
43 {
44 return ValueRepresentation.string( data.getCompositeType().getTypeName() );
45 }
46
47
48 @Mapping( "description" )
49 public ValueRepresentation getDescription()
50 {
51 return ValueRepresentation.string( data.getCompositeType().getDescription() );
52 }
53
54 @Mapping( "value" )
55 public ListRepresentation getValue()
56 {
57
58 JmxAttributeRepresentationDispatcher representationDispatcher = new JmxAttributeRepresentationDispatcher();
59 ArrayList<Representation> values = new ArrayList<Representation>();
60 for ( Object key : data.getCompositeType().keySet() )
61 {
62 String name = key.toString();
63 String description = data.getCompositeType().getDescription( name );
64
65
66 Representation value = representationDispatcher.dispatch( data.get( name ) , "");
67
68 values.add( new NameDescriptionValueRepresentation( name, description, value ) );
69 }
70
71 return new ListRepresentation( "value", values );
72 }
73 }