1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.rhq.plugin;
25
26 import java.util.Map;
27 import java.util.Set;
28
29 import javax.naming.NamingException;
30
31 import org.jboss.managed.api.ManagedComponent;
32 import org.jboss.metatype.api.values.MetaValue;
33 import org.mc4j.ems.connection.EmsConnection;
34 import org.modeshape.rhq.plugin.util.ModeShapeManagementView;
35 import org.modeshape.rhq.plugin.util.ProfileServiceUtil;
36 import org.modeshape.rhq.plugin.util.PluginConstants.ComponentType;
37 import org.modeshape.rhq.plugin.util.PluginConstants.ComponentType.Engine;
38 import org.rhq.core.domain.configuration.Configuration;
39 import org.rhq.core.domain.measurement.AvailabilityType;
40 import org.rhq.core.domain.measurement.MeasurementReport;
41 import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
42 import org.rhq.core.pluginapi.inventory.CreateResourceReport;
43 import org.rhq.plugins.jbossas5.ApplicationServerComponent;
44 import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
45
46 public class EngineComponent extends Facet {
47
48
49
50
51
52
53 @Override
54 String getComponentType() {
55 return ComponentType.Engine.MODESHAPE_ENGINE;
56 }
57
58
59
60
61
62
63 @Override
64 public AvailabilityType getAvailability() {
65 AvailabilityType isRunning = AvailabilityType.DOWN;
66
67 try {
68 ManagedComponent mc = ProfileServiceUtil.getManagedEngine(this
69 .getConnection());
70 MetaValue running = ModeShapeManagementView
71 .executeManagedOperation(mc, "isRunning",
72 new MetaValue[] { null });
73 if (ProfileServiceUtil.booleanValue(running).equals(Boolean.TRUE)) {
74 isRunning = AvailabilityType.UP;
75 }
76 } catch (NamingException e) {
77 LOG.error("NamingException in getAvailability", e);
78 } catch (Exception e) {
79 LOG.error("Exception in getAvailability", e);
80 }
81
82 return isRunning;
83 }
84
85
86
87
88
89
90
91 @Override
92 protected void setOperationArguments(String name,
93 Configuration configuration, Map<String, Object> valueMap) {
94
95 if (name.equals(Engine.Operations.SHUTDOWN)) {
96
97 } else if (name.equals(Engine.Operations.RESTART)) {
98
99 }
100 }
101
102
103
104
105
106
107
108
109
110
111 @Override
112 public void getValues(MeasurementReport arg0,
113 Set<MeasurementScheduleRequest> arg1) throws Exception {
114 }
115
116
117
118
119
120
121 @Override
122 public CreateResourceReport createResource(CreateResourceReport arg0) {
123 return null;
124 }
125
126
127
128
129
130
131 @Override
132 public ProfileServiceConnection getConnection() {
133 return ((ApplicationServerComponent) this.resourceContext
134 .getParentResourceComponent()).getConnection();
135 }
136
137
138
139
140
141
142 @Override
143 public EmsConnection getEmsConnection() {
144 return null;
145 }
146
147 }