📄 client.java
字号:
// $Id: Client.java,v 1.1 2003/11/08 16:32:23 per_nyfelt Exp $
import org.ozoneDB.*;
import car.Bus;
import car.BusImpl;
import car.Auto;
import car.AutoImpl;
/**
* Simple client program that accesses an object in a remote or local database
* server.<p>
*
* <i> Note: Do not use this sample to do any benchmarking if you are new to
* ozone! Use the OO1 sample for that. The code of OO1 is more complex and shows
* how to use ozone for 'real-world' applications. </i>
*
*
* @author <a href="http://www.softwarebuero.de/">SMB</a>
* @version $Revision: 1.1 $Date: 2003/11/08 16:32:23 $
*/
class Client {
public static void main( String[] args ) throws Exception {
ExternalDatabase db = ExternalDatabase.openDatabase( "ozonedb:remote://localhost:3333" );
db.reloadClasses();
System.out.println( "connected..." );
Bus bus = (Bus)db.createObject( BusImpl.class );
System.out.println( "bus:" + bus );
bus.print();
db.deleteObject( bus );
Auto auto = (Auto)db.objectForName( "auto" );
if (auto == null) {
auto = (Auto)db.createObject( AutoImpl.class,
OzoneInterface.Public,
"auto",
new Class[] {String.class, int.class},
new Object[] {"bla", new Integer(123)}
);
}
// doSomething() returns the database object itself. However, in the
// client we get a proper proxy object.
Auto auto2 = auto.doSomething( auto );
System.out.println( "auto:" + auto.getClass() + ", " + auto );
auto.setAge( new Integer( 3 ) );
System.out.println( "auto.setAge (3)" );
// auto and auto2 are proxies of the same object.
System.out.println( "auto2:" + auto2.getClass() + ", " + auto2 );
Auto copy = (Auto)db.copyObject( auto );
copy.setAge( new Integer( 100 ) );
System.out.println( "\nauto:" + auto );
System.out.println( "copy:" + copy );
db.deleteObject( copy );
db.close();
System.out.println( "deconnected..." );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -