diff options
author | Matthew Newhook <matthew@zeroc.com> | 2008-08-22 12:07:39 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2008-08-22 12:07:39 -0230 |
commit | ba630ccacc8ee0b1735e263569107a5f309a3a2d (patch) | |
tree | adbf1c264aae37bef60eb42350b203391ad3e2e1 /java/demo/Database/library/LibraryI.java | |
parent | Moved to using a dispatch interceptor model. (diff) | |
download | ice-ba630ccacc8ee0b1735e263569107a5f309a3a2d.tar.bz2 ice-ba630ccacc8ee0b1735e263569107a5f309a3a2d.tar.xz ice-ba630ccacc8ee0b1735e263569107a5f309a3a2d.zip |
use a library per session.
Diffstat (limited to 'java/demo/Database/library/LibraryI.java')
-rw-r--r-- | java/demo/Database/library/LibraryI.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/java/demo/Database/library/LibraryI.java b/java/demo/Database/library/LibraryI.java index ac160b629cc..e1c52f69487 100644 --- a/java/demo/Database/library/LibraryI.java +++ b/java/demo/Database/library/LibraryI.java @@ -10,9 +10,7 @@ import Demo.*; // -// This servant is a default servant. The book identity is retrieved -// from the Ice.Current object. The session object associated with the -// library is also retrieved using the Library's identity. +// This is a per-session library object. // class LibraryI extends _LibraryDisp { @@ -20,10 +18,10 @@ class LibraryI extends _LibraryDisp queryByIsbn(String isbn, BookDescriptionHolder first, BookQueryResultPrxHolder result, Ice.Current current) throws NoResultsException { - SessionSQLRequestContext context = (SessionSQLRequestContext)SQLRequestContext.getCurrentContext(); + SQLRequestContext context = SQLRequestContext.getCurrentContext(); assert context != null; - context.getSession().reapQueries(); + _session.reapQueries(); try { @@ -43,7 +41,7 @@ class LibraryI extends _LibraryDisp context.obtain(); BookQueryResultI impl = new BookQueryResultI(context, rs); result.value = BookQueryResultPrxHelper.uncheckedCast(current.adapter.addWithUUID(impl)); - context.getSession().add(result.value, impl); + _session.add(result.value, impl); } } catch(java.sql.SQLException e) @@ -58,10 +56,10 @@ class LibraryI extends _LibraryDisp queryByAuthor(String author, BookDescriptionHolder first, BookQueryResultPrxHolder result, Ice.Current current) throws NoResultsException { - SessionSQLRequestContext context = (SessionSQLRequestContext)SQLRequestContext.getCurrentContext(); + SQLRequestContext context = SQLRequestContext.getCurrentContext(); assert context != null; - context.getSession().reapQueries(); + _session.reapQueries(); try { @@ -106,7 +104,7 @@ class LibraryI extends _LibraryDisp context.obtain(); BookQueryResultI impl = new BookQueryResultI(context, rs); result.value = BookQueryResultPrxHelper.uncheckedCast(current.adapter.addWithUUID(impl)); - context.getSession().add(result.value, impl); + _session.add(result.value, impl); } } catch(java.sql.SQLException e) @@ -121,7 +119,7 @@ class LibraryI extends _LibraryDisp createBook(String isbn, String title, java.util.List<String> authors, Ice.Current current) throws BookExistsException { - SessionSQLRequestContext context = (SessionSQLRequestContext)SQLRequestContext.getCurrentContext(); + SQLRequestContext context = SQLRequestContext.getCurrentContext(); assert context != null; try { @@ -205,7 +203,10 @@ class LibraryI extends _LibraryDisp } } - LibraryI() + LibraryI(SessionI session) { + _session = session; } + + private SessionI _session; } |