240 likes | 258 Views
Java Object-Relational Layer. Sharon Diskin GUS 3.0 Workshop June 18-21, 2002. Agenda. Motivation Overview of Design Overview of Implementation Status of Implementation Discussion of Future Plans. Motivation. Why another object layer?. Design of new Annotation Tool
E N D
Java Object-Relational Layer Sharon Diskin GUS 3.0 Workshop June 18-21, 2002
Agenda • Motivation • Overview of Design • Overview of Implementation • Status of Implementation • Discussion of Future Plans
Why another object layer? • Design of new Annotation Tool • prompted a review of the current method for interacting with the database from Java • current annotator interface queries with JDBC and writes XML which is parsed and processed using a Perl ga-plugin • avoid having to update class files on client machines • particularly since interacting with development database • avoid having SQL generated on client machines • Long term goal of being able to serve generic objects to the public (for example using BioJava)
Options Considered • SOAP • Java Objects and CORBA • Java Objects and Java RMI • Supports dynamic class loading • Automatic garbage collection • Decided to use • Port to use CORBA fairly straightforward, if desired
Overview of Design • Based on Perl Object-Relational Layer • Utility Classes • Objects mapped to tables in GUS 3.0 • Code Generator • Relationships modeled as parent/child • Accessible using Java RMI • Remote Interface for the GUS Server • Implementation of the remote GUS Server • Client uses remote GUS Server to obtain GUS objects (by value)
Overview of Design (continued) Erebus Zeus GUS Objects (Serializable) GUSdev (GUS3.0) Remote GUS Server … Clients
Overview of Implementation • Utility Classes cbil.gus.Objects.GUS30.util • Code Generator GUS30::GUS_utils::JavaGenerator.pm • Remote Interfaces RemoteGUSServer, RemoteGUSJDBCServer • Running remote GUSServer and Client access
cbil.gus.Objects.GUS30.util GUSTableAttribute GUSTable GUSRow Generated Subclasses of GUSRow for each table/view GUSTableRelation GUSJDBCServer GUSObjectCache SQLutils GUSServer
Implementation: RemoteGUSServer public String openConnection(String usr, String pswd) throws RemoteException,GUSException; • Verifies username/password • Creates a GUSConnection, including an instance of GUSJDBCServer (connection to GUSdev) • Saves off some information about the connection • Returns a session id (String) public GUSRow retrieveObject(GUSSession session, String owner, String tname, Integer pk) throws RemoteException, GUSException, SQLException; • Verifies valid session and password • Queries database to retrieve requested row • Returns an instance of owner.tablename (eg. Core.Workflow)
Implementation: RemoteGUSServer public GUSRow submitObject(GUSSession session, GUSRow obj) throws RemoteException, GUSException, SQLException; • Verifies session and password • Submits object to database • Submits children to database • Returns updated object public GUSRow createObject(GUSSession session, String pswd, String owner, String tname) throws RemoteException, GUSException; • Verifies username/password • Returns a new instance of the specified class (owner.tname)
Implementation: RemoteGUSServer public List getSessionHistory(GUSSession session) throws RemoteException, GUSException; • Verifies session and password • Returns a List of transactions in this session public void closeConnection(GUSSession session) throws RemoteException, GUSException; • Verifies session and password • Closes GUSConnection Etc. (getParent, getChildren, … )
Code Generation • Execute command file: • CreateAllJavaObjects.cmd • should be executed from directory where want objects created • Calls generateGusJavaObjects.pl • generateGusJavaObjects.pl --login GUSrw --database GUS30 --specialCases ./gus_special_cases • Same as generateGusPerlObjects.pl, but uses different code generation package
Code Generation (continued) • Uses JavaGenerator.pm • Creates java source files: • ./<namespace>/<tablename>.java • ./<namespace>/gen/<tablename>_gen.java • ./<namespace>/gen/<tablename>_tbl.java • Compiles all generated code • currently assumes java is in your path • hand_edited code not ported to Java yet
Starting Remote GUS Server // to generate stubs and skeletons rmic -d /home/diskins/java_dev/GUS/java/ GUSServer rmic -d /home/diskins/java_dev/GUS/java/ GUS_JDBC_Server // start the rmiregistry rmiregistry & // to start the remote GUSServer - without a codebase ... java \ -Djava.security.policy=/home/diskins/RMIServer/policy.txt \ -Djava.rmi.server.logCalls=true \ GUSServer \ >& GUSServer.log &
GUSServer registered with rmiregistry public static void main(String[] args) { try { GUSServer server = new GUSServer(); String name = System.getProperty("gusservername", "GUSServer_1") ; Naming.rebind(name, server); System.out.println(name + " is bound in RMIRegistry and ready to serve."); } catch ( Exception e ) { System.err.println(e); System.err.println("Usage: java [-Dgusservername=<name>] " + "GUSServer"); System.exit(1); //force exit cause may be hanging RMI threads. } }
Client access to remote GUSServer public static void main (String argv[]) { ... try { // Get a reference to the Remote GUS Server object... System.out.println("Looking for remote GUS Server..."); String name = "rmi:///GUSServer_1"; //here assumes local machine... RemoteGUSServer gi = (RemoteGUSServer)Naming.lookup(name); System.out.println("Obtained reference to remote GUS Server"); // Open a session with the remote GUS Server Object... String session = gi.openConnection(user, password); System.out.println("New Session is : " + session + "\n"); … }catch (Exception e) { System.err.println(e); e.printStackTrace(); } }
What “works” now • Code Generation (except hand edited) • RMI Server accepting connections • Create new objects (subclasses of GUSRow) • Set attribute values • Set / Get parent • Set / Get child (ren) • Simple submits: insert, update, delete • Deep submits not fully tested yet • Basic error checking • Username/password, valid attributes, etc.
What still needs to be done • More error checking/handling • Read/write permissions (config file initialization) • Port “Hand edited” classes to Java • Evidence and Similarity handling • Test, test, test
Discussion of Possible Plans • GUSApplication for Java • May help with submits • Could also just be handled by GUSServer • CBIL effort ? • BioJava Wrappers to GUS Java Objects • Would aid in java interface implementations • Could be served to the public • Sanger (or joint) effort ? • Sanger – BioJava expertise • CBIL – Schema and GUS Java object expertise • Perhaps start with educated estimate of resource requirements