Commit d32fb1d635c16dc02b80b9c8a1cf564b0444cbda
1 parent
dbc9dcc2
Exists in
master
Resolvido bug em que tipo da operação (ACTION, INFO, etc.) era ignorado
pela extensão demoiselle-jmx.
Showing
3 changed files
with
35 additions
and
18 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationType.java
@@ -36,7 +36,6 @@ | @@ -36,7 +36,6 @@ | ||
36 | */ | 36 | */ |
37 | package br.gov.frameworkdemoiselle.annotation; | 37 | package br.gov.frameworkdemoiselle.annotation; |
38 | 38 | ||
39 | -import javax.management.MBeanOperationInfo; | ||
40 | 39 | ||
41 | 40 | ||
42 | /** | 41 | /** |
@@ -56,34 +55,25 @@ public enum OperationType { | @@ -56,34 +55,25 @@ public enum OperationType { | ||
56 | * ManagedOperation is write-only, it causes the application | 55 | * ManagedOperation is write-only, it causes the application |
57 | * to change some of it's behaviour but doesn't return any kind of information | 56 | * to change some of it's behaviour but doesn't return any kind of information |
58 | */ | 57 | */ |
59 | - ACTION(MBeanOperationInfo.ACTION) | 58 | + ACTION |
60 | , | 59 | , |
61 | /** | 60 | /** |
62 | * ManagedOperation is read-only, it will operate over data provided by the application and return some information, | 61 | * ManagedOperation is read-only, it will operate over data provided by the application and return some information, |
63 | * but will not change the application in any way. | 62 | * but will not change the application in any way. |
64 | */ | 63 | */ |
65 | - INFO(MBeanOperationInfo.INFO) | 64 | + INFO |
66 | , | 65 | , |
67 | /** | 66 | /** |
68 | * ManagedOperation is read-write, it will both change the way the application work and return some information regarding | 67 | * ManagedOperation is read-write, it will both change the way the application work and return some information regarding |
69 | * the result of the operation. | 68 | * the result of the operation. |
70 | */ | 69 | */ |
71 | - ACTION_INFO(MBeanOperationInfo.ACTION_INFO) | 70 | + ACTION_INFO |
72 | , | 71 | , |
73 | /** | 72 | /** |
74 | * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an operation, | 73 | * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an operation, |
75 | * the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the operation works. | 74 | * the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the operation works. |
76 | */ | 75 | */ |
77 | - UNKNOWN(MBeanOperationInfo.UNKNOWN); | 76 | + UNKNOWN |
78 | 77 | ||
79 | - private int operationTypeValue; | ||
80 | - | ||
81 | - private OperationType(int type){ | ||
82 | - this.operationTypeValue = type; | ||
83 | - } | ||
84 | - | ||
85 | - public int getValue(){ | ||
86 | - return operationTypeValue; | ||
87 | - } | ||
88 | 78 | ||
89 | } | 79 | } |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagedType.java
@@ -47,6 +47,7 @@ import javax.inject.Qualifier; | @@ -47,6 +47,7 @@ import javax.inject.Qualifier; | ||
47 | import br.gov.frameworkdemoiselle.DemoiselleException; | 47 | import br.gov.frameworkdemoiselle.DemoiselleException; |
48 | import br.gov.frameworkdemoiselle.annotation.ManagedOperation; | 48 | import br.gov.frameworkdemoiselle.annotation.ManagedOperation; |
49 | import br.gov.frameworkdemoiselle.annotation.ManagedProperty; | 49 | import br.gov.frameworkdemoiselle.annotation.ManagedProperty; |
50 | +import br.gov.frameworkdemoiselle.annotation.OperationType; | ||
50 | import br.gov.frameworkdemoiselle.annotation.ManagedProperty.ManagedPropertyAccess; | 51 | import br.gov.frameworkdemoiselle.annotation.ManagedProperty.ManagedPropertyAccess; |
51 | import br.gov.frameworkdemoiselle.annotation.OperationParameter; | 52 | import br.gov.frameworkdemoiselle.annotation.OperationParameter; |
52 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 53 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
@@ -163,6 +164,7 @@ public class ManagedType { | @@ -163,6 +164,7 @@ public class ManagedType { | ||
163 | Class<?>[] parameterTypes = method.getParameterTypes(); | 164 | Class<?>[] parameterTypes = method.getParameterTypes(); |
164 | Annotation[][] parameterAnnotations = method.getParameterAnnotations(); | 165 | Annotation[][] parameterAnnotations = method.getParameterAnnotations(); |
165 | ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length]; | 166 | ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length]; |
167 | + OperationType operationType = opAnnotation.type(); | ||
166 | 168 | ||
167 | for (int i = 0; i < parameterTypes.length; i++) { | 169 | for (int i = 0; i < parameterTypes.length; i++) { |
168 | OperationParameter paramAnnotation = null; | 170 | OperationParameter paramAnnotation = null; |
@@ -181,7 +183,7 @@ public class ManagedType { | @@ -181,7 +183,7 @@ public class ManagedType { | ||
181 | 183 | ||
182 | // Com todas as informações, criamos nossa instância de MethodDetail e | 184 | // Com todas as informações, criamos nossa instância de MethodDetail e |
183 | // acrescentamos na lista de todas as operações. | 185 | // acrescentamos na lista de todas as operações. |
184 | - MethodDetail detail = new MethodDetail(method, opAnnotation.description(), parameterDetails); | 186 | + MethodDetail detail = new MethodDetail(method, opAnnotation.description(), operationType, parameterDetails); |
185 | operationMethods.put(method.getName(), detail); | 187 | operationMethods.put(method.getName(), detail); |
186 | } | 188 | } |
187 | } | 189 | } |
@@ -326,12 +328,15 @@ public class ManagedType { | @@ -326,12 +328,15 @@ public class ManagedType { | ||
326 | 328 | ||
327 | private final ParameterDetail[] parameterTypers; | 329 | private final ParameterDetail[] parameterTypers; |
328 | 330 | ||
329 | - private String description; | 331 | + private final String description; |
332 | + | ||
333 | + private final OperationType type; | ||
330 | 334 | ||
331 | - public MethodDetail(Method method, String description, ParameterDetail[] parameterTypers) { | 335 | + public MethodDetail(Method method, String description, OperationType type,ParameterDetail[] parameterTypers) { |
332 | super(); | 336 | super(); |
333 | this.method = method; | 337 | this.method = method; |
334 | this.description = description; | 338 | this.description = description; |
339 | + this.type = type; | ||
335 | this.parameterTypers = parameterTypers; | 340 | this.parameterTypers = parameterTypers; |
336 | } | 341 | } |
337 | 342 | ||
@@ -347,6 +352,10 @@ public class ManagedType { | @@ -347,6 +352,10 @@ public class ManagedType { | ||
347 | return description; | 352 | return description; |
348 | } | 353 | } |
349 | 354 | ||
355 | + public OperationType getType() { | ||
356 | + return type; | ||
357 | + } | ||
358 | + | ||
350 | } | 359 | } |
351 | 360 | ||
352 | public final class ParameterDetail { | 361 | public final class ParameterDetail { |
impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/DynamicMBeanProxy.java
@@ -212,9 +212,27 @@ public class DynamicMBeanProxy implements DynamicMBean { | @@ -212,9 +212,27 @@ public class DynamicMBeanProxy implements DynamicMBean { | ||
212 | 212 | ||
213 | // Com todas as informações, criamos nossa instância de MBeanOperationInfo e | 213 | // Com todas as informações, criamos nossa instância de MBeanOperationInfo e |
214 | // acrescentamos na lista de todas as operações. | 214 | // acrescentamos na lista de todas as operações. |
215 | + int operationType = 0; | ||
216 | + switch(methodDetail.getType()){ | ||
217 | + case ACTION: | ||
218 | + operationType = MBeanOperationInfo.ACTION; | ||
219 | + break; | ||
220 | + | ||
221 | + case INFO: | ||
222 | + operationType = MBeanOperationInfo.INFO; | ||
223 | + break; | ||
224 | + | ||
225 | + case ACTION_INFO: | ||
226 | + operationType = MBeanOperationInfo.ACTION_INFO; | ||
227 | + break; | ||
228 | + | ||
229 | + default: | ||
230 | + operationType = MBeanOperationInfo.UNKNOWN; | ||
231 | + } | ||
232 | + | ||
215 | MBeanOperationInfo operation = new MBeanOperationInfo(methodDetail.getMethod().getName(), | 233 | MBeanOperationInfo operation = new MBeanOperationInfo(methodDetail.getMethod().getName(), |
216 | methodDetail.getDescription(), parameters, methodDetail.getMethod().getReturnType().getName(), | 234 | methodDetail.getDescription(), parameters, methodDetail.getMethod().getReturnType().getName(), |
217 | - MBeanOperationInfo.ACTION_INFO); | 235 | + operationType); |
218 | 236 | ||
219 | operations.add(operation); | 237 | operations.add(operation); |
220 | 238 |