java - JavaFX Clients and JDBC Servers: Are JavaFX Bean-style objects required on the server side? -
i have jdbc application built around single-server database (the rdbms hsqldb -- love far). in first draft of application, have used following tiered approach:
+-------------------------------+ | data store (appx 20 tables) | hsqldb; highly normalized tables +-------------------------------+ | v +-------------------------------+ | domain object layer (1:1) | java class each table in db +-------------------------------+ | v +-------------------------------+ abstraction objects app | client object layer / dao's | logic uses (denormalized) +-------------------------------+ | v +-------------------------------+ adapts observablearraylist() instances | presentation layer (javafx) | of objects gui +-------------------------------+
in domain object layer presently jdbc queries generic static method:
static <e> observablelist<e> dogenericquery(sqlparameterslist pars, string sql, callback<rowset,e> factory) { // factory function object. use callback<p,r> // "strategy" ... p rowset, r object return type. factory // invokes constructor desired return object type. rowset jrs = null; observablelist<e> querylist = fxcollections.<e>observablearraylist(); try { jrs = sqlconnection.getrowsetinstance(); if (jrs == null) { system.err.println(census.msg_err_jdbcfail); return querylist; } jrs.setcommand(sql); for(int i=0; < pars.size(); i++) { // datum().col() method returns enum representing // database column; setjdbcparambytype enum // constant-specific method invokes correct // setxxx method on preparedstatement pars.datum(i).col().setjdbcparambytype(jrs, pars.datum(i))); } jrs.execute(); while (jrs.next()) { querylist.add(factory.<rowset,e>call(jrs)); } } catch (sqlexception e) { logger.getlogger(db.class.getname()).log(level.severe, null, e); } { if (jrs != null) try { jrs.close(); } catch (sqlexception e) { } } return querylist; }
what use method in data access abstraction whole application, i'm wondering if can. written, method returns observablelist because used javafx application. observablelist holds instances of simplexxxproperty objects (javafx bean-style, i.e. mutable, objects). don't think can use code presently written because don't want take javafx bean-style objects server-side.
eventually, data access layers going executed in server-side environment , presentation-layer stuff going happen on client.
i don't want have server-side code using javafx bean-style objects. ideally, want queries form list of immutable objects , think accomplish except necessity deal javafx seems mandate make public , mutable.
the solution thinking of have server code create immutable objects query result wrapped in unmodifiablelist gets transmitted client. client has transmogrify read-only list observablelist of javafx bean-style objects may used in gui. .. approach requires write different version of domain object layer (client , server).
am on right track here? (i hate sound i'm in on head, here .. may in on head right now).
as i've thought more i'd do, i've understood approach far simplistic. think i'm talking flow information data store client looks closer this:
+-------------------------------+ | data store (appx 20 tables) | hsqldb; highly normalized tables +-------------------------------+ | v +-------------------------------+ receives query result | server/servlet req processor | transmits cachedrowset +-------------------------------+ | (serialization) | v +-------------------------------+ | client interface layer | deserializes query results +-------------------------------+ | v +-------------------------------+ | domain object layer (1:1) | java class each table in db +-------------------------------+ generates data model objects results | v +-------------------------------+ abstraction objects app | client object layer / dao's | logic uses (denormalized) +-------------------------------+ | v +-------------------------------+ adapts observablearraylist() instances | presentation layer (javafx) | of objects gui +-------------------------------+
of course, looking rather more internet-based client-server app frameworks exist, eg. javaee. going simple, single-machine jdbc database app distributed client-server app appears involve quantum leap in complexity.
but, not believe need use javafx bean-style objects anywhere in process @ all, except on client.
Comments
Post a Comment