[Registry-dev] svn commit r16708 - in trunk/registry/modules:
core/src/main/java/org/wso2/registry
core/src/main/java/org/wso2/registry/aspects
core/src/main/java/org/wso2/registry/jdbc
core/src/test/java/org/wso2/registry/jdbc
webapps/src/main/java/org/wso2/registry/web/utils
svn at wso2.org
svn at wso2.org
Thu May 8 09:33:02 PDT 2008
Author: glen
Date: Thu May 8 09:32:58 2008
New Revision: 16708
Log:
* Refactor Aspect.transition() -> Aspect.invoke()
* Fix array code for returning available aspects
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Aspect.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/SimpleLifecycleTest.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/LifecycleUtil.java
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Aspect.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Aspect.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Aspect.java Thu May 8 09:32:58 2008
@@ -18,9 +18,6 @@
*/
package org.wso2.registry;
-import org.wso2.registry.Resource;
-import org.wso2.registry.Registry;
-import org.wso2.registry.RegistryException;
import org.wso2.registry.jdbc.handlers.RequestContext;
public abstract class Aspect {
@@ -48,15 +45,16 @@
public abstract void associate(Resource resource, Registry registry) throws RegistryException;
/**
- * Do something (change state) - action names are aspect-specific, and it's up to the
- * implementation to decide if a given transition is allowed, and what to do if so.
+ * Do something - action names are aspect-specific, and it's up to the
+ * implementation to decide if a given action is allowed, and what to do if so.
+ * Action invocations can (and often do) have persistent side-effects in the Registry.
*
* @param context the RequestContext containing all the state about this request
* @param action action to perform
* @throws org.wso2.registry.RegistryException
* If the condition is not met or some thing is wrong
*/
- public abstract void transition(RequestContext context, String action) throws RegistryException;
+ public abstract void invoke(RequestContext context, String action) throws RegistryException;
/**
* Get a list of available actions for the resource in the RequestContext, taking into account
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java Thu May 8 09:32:58 2008
@@ -61,7 +61,7 @@
* @throws org.wso2.registry.RegistryException
* If the condition is not met or some thing is wrong
*/
- public void transition(RequestContext context, String action) throws RegistryException {
+ public void invoke(RequestContext context, String action) throws RegistryException {
if (!ACTION.equals(action)) {
throw new RegistryException("Unsupported lifecycle action '" + action +
"'. Only valid action is '" + ACTION + "'");
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java Thu May 8 09:32:58 2008
@@ -47,6 +47,7 @@
import java.util.Map;
import java.util.Date;
import java.util.HashMap;
+import java.util.Set;
/**
* JDBC based implementation of the Registry. This will be used mostly as the back-end by other
@@ -626,7 +627,8 @@
}
public String[] getAvailableAspects() {
- return (String[])aspects.keySet().toArray();
+ final Set<String> keys = aspects.keySet();
+ return keys.toArray(new String[keys.size()]);
}
public void addAspect(String name, Aspect aspect) throws RegistryException {
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/TransactionalJDBCRegistry.java Thu May 8 09:32:58 2008
@@ -837,7 +837,8 @@
}
public String[] getAvailableAspects() {
- return (String[])aspects.keySet().toArray(); // TODO - which aspects, here or context?
+ final Set<String> keys = aspects.keySet(); // TODO - which aspects, here or context?
+ return keys.toArray(new String[keys.size()]);
}
public void addAspect(String name, Aspect aspect) throws RegistryException {
@@ -902,7 +903,7 @@
// throw new RegistryException("No aspect are associated with the resource");
// }
- aspect.transition(context, action);
+ aspect.invoke(context, action);
put(resourcePath, resource);
}
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/SimpleLifecycleTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/SimpleLifecycleTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/SimpleLifecycleTest.java Thu May 8 09:32:58 2008
@@ -32,7 +32,7 @@
resource.setProperty(STATE_PROP, INIT);
}
- public void transition(RequestContext context, String action) throws RegistryException {
+ public void invoke(RequestContext context, String action) throws RegistryException {
if (!ACTION.equals(action)) {
throw new RegistryException("Wrong action");
}
@@ -71,6 +71,14 @@
registry.addAspect(LIFECYCLE, new SimpleLifecycle());
+ String [] aspects = registry.getAvailableAspects();
+ assertTrue(aspects.length > 0);
+ boolean found = false;
+ for (String aspect : aspects) {
+ if (aspect.equals(LIFECYCLE)) found = true;
+ }
+ assertTrue("Lifecycle not found in available aspects", found);
+
Resource resource = registry.newResource();
resource.setDescription("My thing");
registry.put(RESOURCE, resource);
Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/LifecycleUtil.java
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/LifecycleUtil.java (original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/LifecycleUtil.java Thu May 8 09:32:58 2008
@@ -22,13 +22,13 @@
public static final String INIT = "init";
public static final String FINAL = "final";
- public static final String ACTION = "transition";
+ public static final String ACTION = "invoke";
public void associate(Resource resource, Registry registry) throws RegistryException {
resource.setProperty(STATE_PROP, INIT);
}
- public void transition(RequestContext context, String action) throws RegistryException {
+ public void invoke(RequestContext context, String action) throws RegistryException {
if (!ACTION.equals(action)) {
throw new RegistryException("Wrong action");
}
More information about the Registry-dev
mailing list