📄 jlisttestobjectfactorytask.java
字号:
/**
* $Log: JListTestObjectFactoryTask.java,v $
* Revision 1.2 2003/03/12 14:58:16 willaxt
* adjusted to new exception handling of communication exceptions
* adjusted to call getPanel() because member of super class is no longer public
*
* Revision 1.1 2003/02/01 00:29:20 mwulff
* initial version
*
*/
package de.fhm.jkf.test.cl;
import de.fhm.jkf.comm.cl.JKFFactory;
import de.fhm.jkf.comm.cl.ObjectFactory;
import de.fhm.jkf.comm.clsv.RemoteObjectCreationException;
import de.fhm.jkf.gui.CommunicationTask;
import de.fhm.jkf.gui.JKFView;
import de.fhm.jkf.test.clsv.Hello;
import de.fhm.jkf.test.clsv.ParameterTester;
import de.fhm.jkf.test.clsv.TimeReceiver;
/**
* <br><br><center><table border="1" width="80%"><hr>
* <strong><a href="http://jkf.sourceforge.net">The JKF Project</a></strong>
* <p>
* Copyright (C) 2002 by Marten Wulff
* <p>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* <p>
* You should have received a copy of the <a href="http://www.gnu.org/copyleft/lesser.html">
* GNU Lesser General Public License</a> along with this library; if not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
* <hr></table></center>
*
* @author marten wulff
* @version 1.0
*/
public class JListTestObjectFactoryTask extends CommunicationTask {
private StringBuffer result = new StringBuffer();
/**
* Constructor for JListTestObjectFactoryTask.
* @param panel
*/
public JListTestObjectFactoryTask(JKFView panel) {
super(panel);
}
/* (non-Javadoc)
* @see de.fhm.jkf.gui.CommunicationTask#doPresentation()
*/
public void doPresentation() {
JListTestTO o = new JListTestTO();
o.setText(result.toString());
try{
super.getPanel().setTransferObject(o);
}catch(Exception ex) {
ex.printStackTrace();
}
}
/* (non-Javadoc)
* @see de.fhm.jkf.gui.CommunicationTask#doQuery()
*/
public void doQuery() {
ObjectFactory factory = JKFFactory.instance().getFactory();
result.append(
"\n\n******************** "
+ this.getClass().getName()
+ " ***************************\n");
try {
result.append("========== Creating TimerImpl ==========\n");
// simply a remote object with a default constructor
TimeReceiver time =
(TimeReceiver) factory.createObject(
TimeReceiver.class,
"de.fhm.jkf.test.sv.TimeReceiverImpl",
null);
result.append("========== TimerImpl created ==========\n");
result.append("========== Calling Timer.getTime() ==========\n");
result.append(new java.util.Date((time.getTime()).longValue()).toString() + "\n");
// set the reference to null, to check remote gc
time = null;
} catch (RemoteObjectCreationException roce) {
result.append(roce.getMessage() + "\n");
}
// testing a remote Object with constructor that takes a parameter
Object[] p = new Object[1];
p[0] = new String("Marten");
result.append("========== Creating HelloImpl with param (Marten) ==========\n");
try {
Hello hello =
(Hello) factory.createObject(
Hello.class,
"de.fhm.jkf.test.sv.HelloImpl",
p);
result.append("========== " + hello.sayHello() + " ==========\n");
result.append("========== Testing SessionHandling --> calling same object again ==========\n");
result.append("========== " + hello.sayHello() + " ==========\n");
// test the session handling and let's see if we get
//the same object againg
result.append("========== Calling Hello.sayHello(\"Dude\") ==========\n");
result.append("========== " + hello.sayHello("Dude") + " ==========\n");
} catch (RemoteObjectCreationException roce) {
result.append(roce.getMessage() + "\n");
}
// Testing parameter stuff
p = new Object[1];
p[0] = new Integer(5);
try{
ParameterTester tester = (ParameterTester)factory.createObject(
ParameterTester.class,
"de.fhm.jkf.test.sv.ParameterTesterImpl",
p);
result.append("========== Calling ParameterTester.takeIntAndGiveInt(1) ==========\n");
int res1 = tester.takeIntAndGiveInt(1);
result.append("========== Result: " + res1 + " ==========\n");
result.append("========== Calling ParameterTester.takeIntAndGiveInteger(2) ==========\n");
Integer res2 = tester.takeIntAndGiveInteger(2);
result.append("========== Result: " + res2 + " ==========\n");
result.append("========== Calling ParameterTester.takeIntegerAndGiveInt(3) ==========\n");
int res3 = tester.takeIntegerAndGiveInt(new Integer(3));
result.append("========== Result: " + res3 + " ==========\n");
result.append("========== Calling ParameterTester.takeIntegerAndGiveInteger(4) ==========\n");
Integer res4 = tester.takeIntegerAndGiveInteger(new Integer(4));
result.append("========== Result: " + res4 + " ==========\n");
result.append("========== Calling ParameterTester.noArg() ==========\n");
String res = tester.noArg();
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester..takeBooleanAndGiveBooleanObject(boolean) ==========\n");
Boolean bo = tester.takeBooleanAndGiveBooleanObject(true);
result.append("========== Result: " + bo + " ==========\n");
result.append("========== Calling ParameterTester.takeBooleanObjectAndGiveBoolean(Boolean) ==========\n");
boolean b = tester.takeBooleanObjectAndGiveBoolean(new Boolean(true));
result.append("========== Result: " + b + " ==========\n");
result.append("========== Calling ParameterTester.doubleName(Integer, String) ==========\n");
res = tester.doubleName(new Integer(4), "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.doubleName(Boolean, String) ==========\n");
res = tester.doubleName(new Boolean(true), "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.doubleName(boolean, String) ==========\n");
res = tester.doubleName(true, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(short, String) ==========\n");
res = tester.methodName((short)1, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(int, String) ==========\n");
res = tester.methodName(5, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(long, String) ==========\n");
res = tester.methodName((long)5, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(float, String) ==========\n");
res = tester.methodName((float)5.5, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(double, String) ==========\n");
res = tester.methodName((double)5.5, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(char, String) ==========\n");
res = tester.methodName('5', "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(boolean, String) ==========\n");
res = tester.methodName(false, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.methodName(byte, String) ==========\n");
res = tester.methodName((byte)5, "Marten");
result.append("========== Result: " + res + " ==========\n");
result.append("========== Calling ParameterTester.toString() in superclass ==========\n");
res = tester.toString();
result.append("========== Result: " + res + " ==========\n");
} catch(Exception ex) {
result.append(ex.getMessage() + "\n");
}
}
/* (non-Javadoc)
* @see de.fhm.jkf.thread.cl.InterruptableTask#interrupt()
*/
public void interrupt() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -