You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2004/07/17 05:33:02 UTC
cvs commit: incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/cluster/topology TopologyManagerEditorTest.java
gdamour 2004/07/16 20:33:02
Modified: sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology
TopologyManager.java
Added: sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology
TopologyManagerEditor.java
sandbox/messaging/src/test/org/apache/geronimo/messaging/cluster/topology
TopologyManagerEditorTest.java
Log:
TopologyManager PropertyEditor. TopologyManager must be Serializable as it is a GBean persistent attribute.
Revision Changes Path
1.2 +8 -2 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology/TopologyManager.java
Index: TopologyManager.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology/TopologyManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TopologyManager.java 10 Jun 2004 23:12:25 -0000 1.1
+++ TopologyManager.java 17 Jul 2004 03:33:02 -0000 1.2
@@ -17,6 +17,7 @@
package org.apache.geronimo.messaging.cluster.topology;
+import java.io.Serializable;
import java.util.Set;
import org.apache.geronimo.messaging.NodeInfo;
@@ -27,10 +28,15 @@
* <BR>
* For instance, nodes could be organized in ring, mesh, hypercube,
* torus et cetera.
+ * <BR>
+ * A TopologyManager is not required to be thread-safe.
+ * <BR>
+ * Implementation node: a TopologyManager is a Serializable as it is a GBean
+ * persistent attribute.
*
* @version $Revision$ $Date$
*/
-public interface TopologyManager
+public interface TopologyManager extends Serializable
{
/**
1.1 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology/TopologyManagerEditor.java
Index: TopologyManagerEditor.java
===================================================================
/**
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.geronimo.messaging.cluster.topology;
import java.beans.PropertyEditorSupport;
import java.lang.reflect.Constructor;
import org.apache.geronimo.common.propertyeditor.PropertyEditorException;
/**
* TopologyManagerEditor.
* <BR>
* Based on a text, it tries to load a TopologyManager having the name:
* org.apache.geronimo.messaging.cluster.topology.<text>TopologyManager
*
* @version $Revision: 1.1 $ $Date: 2004/07/17 03:33:02 $
*/
public class TopologyManagerEditor
extends PropertyEditorSupport
{
private TopologyManager manager;
public void setAsText(String text) throws IllegalArgumentException {
String className = "org.apache.geronimo.messaging.cluster.topology." +
text + "TopologyManager";
Class clazz;
try {
clazz = getClass().getClassLoader().loadClass(className);
Constructor constructor = clazz.getConstructor(null);
manager = (TopologyManager) constructor.newInstance(null);
} catch (Exception e) {
throw new PropertyEditorException(e);
}
}
public Object getValue() {
return manager;
}
}
1.1 incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/cluster/topology/TopologyManagerEditorTest.java
Index: TopologyManagerEditorTest.java
===================================================================
/**
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.geronimo.messaging.cluster.topology;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import org.apache.geronimo.common.propertyeditor.PropertyEditorException;
import junit.framework.TestCase;
/**
*
* @version $Revision: 1.1 $ $Date: 2004/07/17 03:33:02 $
*/
public class TopologyManagerEditorTest
extends TestCase
{
public void testOK() throws Exception {
String type = "Ring";
PropertyEditor ed =
PropertyEditorManager.findEditor(TopologyManager.class);
ed.setAsText(type);
Object opaque = ed.getValue();
assertTrue(opaque instanceof RingTopologyManager);
}
public void testNOK() throws Exception {
String type = "Ring2";
PropertyEditor ed =
PropertyEditorManager.findEditor(TopologyManager.class);
try {
ed.setAsText(type);
fail("Undefined TopologyManager");
} catch (PropertyEditorException e) {
}
}
}