Mail Archive Home | fractal-commits List | August 2008 Index
| <-- Date Index --> | <-- Thread Index --> |
Code cleanup.
--- trunk/juliac/examples/advanced/ultra-merge-comanche/src/main/java/example/comanche/ErrorRequestHandler.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/advanced/ultra-merge-comanche/src/main/java/example/comanche/ErrorRequestHandler.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -1,9 +1,8 @@
package example.comanche;
-import java.io.IOException;
public class ErrorRequestHandler implements RequestHandler {
- public void handleRequest (Request r) throws IOException {
+ public void handleRequest (Request r) {
r.out.print("HTTP/1.0 404 Not Found\n\n");
r.out.print("<html>Document not found.</html>");
}
--- trunk/juliac/examples/advanced/ultra-merge-comanche/src/test/java/example/comanche/ComancheTestCase.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/advanced/ultra-merge-comanche/src/test/java/example/comanche/ComancheTestCase.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -112,7 +112,11 @@
@Override
public void run() {
try {
- Runnable r = new Comanche();
+ String name = getClass().getPackage().getName()+".Comanche";
+ @SuppressWarnings("unchecked")
+ Class<? extends Runnable> cl =
+ (Class<? extends Runnable>) Class.forName(name);
+ Runnable r = cl.newInstance();
r.run();
}
catch(Exception e) {
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/BasicLogger.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/BasicLogger.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -4,32 +4,27 @@
import java.util.List;
import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class BasicLogger implements Logger {
- public void foo( I.IInner ii ) {
-
- }
public void log(String msg) {
System.out.println(msg);
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ return interfaces.toArray(new String[interfaces.size()]);
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/ErrorRequestHandler.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/ErrorRequestHandler.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -1,33 +1,30 @@
package example.comanche;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class ErrorRequestHandler implements RequestHandler {
- public void handleRequest(Request r) throws IOException {
+ public void handleRequest(Request r) {
r.out.print("HTTP/1.0 404 Not Found\n\n");
r.out.print("<html>Document not found.</html>");
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ return ((String[])(interfaces.toArray(new String[]{ })));
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/FileRequestHandler.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/FileRequestHandler.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -8,8 +8,6 @@
import java.util.List;
import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class FileRequestHandler implements RequestHandler {
public void handleRequest(Request r) throws IOException {
@@ -26,20 +24,20 @@
}
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ return interfaces.toArray(new String[interfaces.size()]);
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/I.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/I.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -1,6 +0,0 @@
-package example.comanche;
-
-public interface I {
-
- public interface IInner {}
-}
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/Logger.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/Logger.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -3,5 +3,4 @@
public interface Logger {
void log(String msg);
- void foo( I.IInner ii );
}
\ No newline at end of file
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/MultiThreadScheduler.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/MultiThreadScheduler.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -4,28 +4,26 @@
import java.util.List;
import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class MultiThreadScheduler implements Scheduler {
public void schedule(Runnable task) {
new Thread(task).start();
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ return interfaces.toArray(new String[interfaces.size()]);
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/RequestAnalyzer.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/RequestAnalyzer.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -10,7 +10,6 @@
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class RequestAnalyzer implements RequestHandler , BindingController {
@@ -31,7 +30,7 @@
r.s.close();
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException {
if (clientItfName.equals("a")) {
if (!(RequestHandler.class.isAssignableFrom(serverItf.getClass()))) {
throw new IllegalBindingException(((("server interfaces connected to " + clientItfName) + " must be instances of ") + (RequestHandler.class.getName())));
@@ -50,10 +49,10 @@
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- __interfaces__.add("a");
- __interfaces__.add("l");
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ interfaces.add("a");
+ interfaces.add("l");
+ return interfaces.toArray(new String[interfaces.size()]);
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
@@ -66,7 +65,7 @@
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
if (clientItfName.equals("a")) {
rh = null;
return ;
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/RequestDispatcher.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/RequestDispatcher.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -2,7 +2,6 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -10,38 +9,36 @@
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class RequestDispatcher implements RequestHandler , BindingController {
- private Map handlers = new TreeMap();
+ private Map<String,RequestHandler> handlers = new TreeMap<String,RequestHandler>();
- public void handleRequest(Request r) throws IOException {
- Iterator i = handlers.values().iterator();
- while (i.hasNext()) {
+ public void handleRequest(Request r) {
+ for (RequestHandler h : handlers.values()) {
try {
- ((RequestHandler)(i.next())).handleRequest(r);
+ h.handleRequest(r);
return ;
} catch (IOException _) {
}
}
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException {
if (clientItfName.startsWith("h")) {
if (!(RequestHandler.class.isAssignableFrom(serverItf.getClass()))) {
throw new IllegalBindingException(((("server interfaces connected to " + clientItfName) + " must be instances of ") + (RequestHandler.class.getName())));
}
- handlers.put(clientItfName ,serverItf);
+ handlers.put(clientItfName, (RequestHandler) serverItf);
return ;
}
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- __interfaces__.addAll(handlers.keySet());
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ interfaces.addAll(handlers.keySet());
+ return interfaces.toArray(new String[interfaces.size()]);
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
@@ -51,7 +48,7 @@
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
if (handlers.containsKey(clientItfName)) {
handlers.remove(clientItfName);
return ;
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/RequestReceiver.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/RequestReceiver.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -9,7 +9,6 @@
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class RequestReceiver implements Runnable , BindingController {
@@ -39,7 +38,7 @@
}
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException {
if (clientItfName.equals("s")) {
if (!(Scheduler.class.isAssignableFrom(serverItf.getClass()))) {
throw new IllegalBindingException(((("server interfaces connected to " + clientItfName) + " must be instances of ") + (Scheduler.class.getName())));
@@ -58,10 +57,10 @@
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- __interfaces__.add("s");
- __interfaces__.add("rh");
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ interfaces.add("s");
+ interfaces.add("rh");
+ return interfaces.toArray(new String[interfaces.size()]);
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
@@ -74,7 +73,7 @@
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
if (clientItfName.equals("s")) {
s = null;
return ;
--- trunk/juliac/examples/comanche/src/main/java/example/comanche/SequentialScheduler.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/main/java/example/comanche/SequentialScheduler.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -4,20 +4,18 @@
import java.util.List;
import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
public class SequentialScheduler implements Scheduler {
public void schedule(Runnable task) {
task.run();
}
- public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
+ List<String> __interfaces__ = new ArrayList<String>();
return ((String[])(__interfaces__.toArray(new String[]{ })));
}
@@ -25,7 +23,7 @@
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
- public void unbindFc(String clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
+ public void unbindFc(String clientItfName) throws NoSuchInterfaceException {
throw new NoSuchInterfaceException((("Client interface \'" + clientItfName) + "\' is undefined."));
}
--- trunk/juliac/examples/comanche/src/test/java/example/comanche/ComancheTestCase.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/comanche/src/test/java/example/comanche/ComancheTestCase.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -32,6 +32,7 @@
import junit.framework.TestCase;
import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.factory.Factory;
/**
* Program for testing the Comanche example.
@@ -114,7 +115,12 @@
@Override
public void run() {
try {
- Component comanche = new Comanche().newFcInstance();
+ String name = getClass().getPackage().getName()+".Comanche";
+ @SuppressWarnings("unchecked")
+ Class<? extends Factory> cl =
+ (Class<? extends Factory>) Class.forName(name);
+ Factory f = cl.newInstance();
+ Component comanche = f.newFcInstance();
Runnable r = (Runnable) comanche.getFcInterface("r");
r.run();
}
--- trunk/juliac/examples/helloworld/src/main/java/example/hw/ClientImpl.java 2008-08-28 18:35:46 UTC (rev 8405)
+++ trunk/juliac/examples/helloworld/src/main/java/example/hw/ClientImpl.java 2008-08-28 20:53:46 UTC (rev 8406)
@@ -31,9 +31,9 @@
}
public String[] listFc() {
- List __interfaces__ = new ArrayList();
- __interfaces__.add("s");
- return ((String[])(__interfaces__.toArray(new String[]{ })));
+ List<String> interfaces = new ArrayList<String>();
+ interfaces.add("s");
+ return interfaces.toArray(new String[interfaces.size()]);
}
public Object lookupFc(String clientItfName) throws NoSuchInterfaceException {
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.