diff --git a/api/src/main/java/org/gatein/management/api/annotations/Managed.java b/api/src/main/java/org/gatein/management/api/annotations/Managed.java
index 05bfd8cd..280e6a43 100644
--- a/api/src/main/java/org/gatein/management/api/annotations/Managed.java
+++ b/api/src/main/java/org/gatein/management/api/annotations/Managed.java
@@ -35,12 +35,13 @@
public @interface Managed
{
/**
- * The value of the path (address) of the resource/operation
+ * The value of the path of the managed resource. ie: '/foo/bar' will be registered at address
+ * PathAddress.pathAddress("foo", "bar")
*/
- String[] value() default "";
+ String value() default "";
/**
- * The description of the resource/operation
+ * The description of the managed resource
*/
String description() default "";
}
diff --git a/core/src/main/java/org/gatein/management/core/spi/ExtensionContextImpl.java b/core/src/main/java/org/gatein/management/core/spi/ExtensionContextImpl.java
index 116aea03..69f7bcb8 100644
--- a/core/src/main/java/org/gatein/management/core/spi/ExtensionContextImpl.java
+++ b/core/src/main/java/org/gatein/management/core/spi/ExtensionContextImpl.java
@@ -112,32 +112,23 @@ public ComponentRegistration registerManagedComponent(Class> component)
Managed managed = component.getAnnotation(Managed.class);
if (managed == null) throw new RuntimeException(Managed.class + " annotation not present on " + component);
- //ManagedPath componentPath = component.getAnnotation(ManagedPath.class);
- String[] componentPath = managed.value();
- if (componentPath == null || componentPath.length == 0) throw new RuntimeException(Managed.class + " annotation must have a value other then default on " + component);
+ String componentName = managed.value();
+ if ("".equals(componentName)) throw new RuntimeException(Managed.class + " annotation must have a value (path) for component class " + component);
+ if (debug) log.debug("Registering managed component " + componentName);
- // Register component
- ComponentRegistration registration = null;
- for (String path : componentPath)
- {
- PathAddress address = PathAddress.pathAddress(path);
- String componentName = address.iterator().next();
- if (debug) log.debug("Registering managed component " + componentName);
-
- registration = registerManagedComponent(componentName);
- registration.registerManagedResource(description(managed.description()));
+ ComponentRegistration registration = registerManagedComponent(componentName);
+ registration.registerManagedResource(description(managed.description()));
- // Register operations
- AbstractManagedResource resource = registerManaged(managed, rootResource);
- Method[] methods = component.getMethods();
- for (Method method : methods)
+ // Register operations
+ AbstractManagedResource resource = registerManaged(managed, rootResource);
+ Method[] methods = component.getMethods();
+ for (Method method : methods)
+ {
+ Managed managedMethod = method.getAnnotation(Managed.class);
+ if (managedMethod != null)
{
- Managed managedMethod = method.getAnnotation(Managed.class);
- if (managedMethod != null)
- {
- if (debug) log.debug("Processing managed method " + getMethodName(method));
- registerManagedOperation(registerManaged(managedMethod, resource), method, component, componentName);
- }
+ if (debug) log.debug("Processing managed method " + getMethodName(method));
+ registerManagedOperation(registerManaged(managedMethod, resource), method, component, componentName);
}
}
@@ -146,32 +137,25 @@ public ComponentRegistration registerManagedComponent(Class> component)
private AbstractManagedResource registerManaged(Managed managed, AbstractManagedResource resource)
{
- String[] managedPaths = managed.value();
- if (managedPaths != null && managedPaths.length != 0)
+ PathAddress address = PathAddress.pathAddress(managed.value());
+ for (Iterator iterator = address.iterator(); iterator.hasNext();)
{
- for (String managedPath : managedPaths)
+ String path = iterator.next();
+ String description = "";
+ if (iterator.hasNext())
{
- PathAddress address = PathAddress.pathAddress(managedPath);
- Iterator iterator = address.iterator();
- while (iterator.hasNext())
- {
- String path = iterator.next();
- String description = "";
- if (iterator.hasNext())
- {
- description = managed.description();
- }
- AbstractManagedResource child = (AbstractManagedResource) resource.getSubResource(path);
- if (child == null)
- {
- if (log.isDebugEnabled()) log.debug("Registering sub resource " + path);
- child = (AbstractManagedResource) resource.registerSubResource(path, description(description));
- }
-
- resource = child;
- }
+ description = managed.description();
}
+ AbstractManagedResource child = (AbstractManagedResource) resource.getSubResource(path);
+ if (child == null)
+ {
+ if (log.isDebugEnabled()) log.debug("Registering sub resource " + path);
+ child = (AbstractManagedResource) resource.registerSubResource(path, description(description));
+ }
+
+ resource = child;
}
+
return resource;
}