summaryrefslogtreecommitdiff
path: root/java/demo/Database/library/SessionI.java
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2008-08-15 14:47:14 -0230
committerMatthew Newhook <matthew@zeroc.com>2008-08-15 14:47:14 -0230
commit7b735386b10c464a39d4e0298c99a33f6ae038fe (patch)
tree7f2e9ee218038b3b3883e3827b82ec70533aff8f /java/demo/Database/library/SessionI.java
parentFix more conflicts. (diff)
downloadice-7b735386b10c464a39d4e0298c99a33f6ae038fe.tar.bz2
ice-7b735386b10c464a39d4e0298c99a33f6ae038fe.tar.xz
ice-7b735386b10c464a39d4e0298c99a33f6ae038fe.zip
added first cut at JDBC demo.
Diffstat (limited to 'java/demo/Database/library/SessionI.java')
-rw-r--r--java/demo/Database/library/SessionI.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/java/demo/Database/library/SessionI.java b/java/demo/Database/library/SessionI.java
new file mode 100644
index 00000000000..610cb8e4201
--- /dev/null
+++ b/java/demo/Database/library/SessionI.java
@@ -0,0 +1,97 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+class SessionI extends _SessionDisp
+{
+ public
+ SessionI(ConnectionPool pool, Ice.Logger logger, Ice.ObjectAdapter adapter)
+ {
+ _pool = pool;
+ _logger = logger;
+ _timestamp = System.currentTimeMillis();
+ _libraryImpl = new LibraryI(_logger, _pool);
+ _library = LibraryPrxHelper.uncheckedCast(adapter.addWithUUID(_libraryImpl));
+ }
+
+ synchronized public LibraryPrx
+ getLibrary(Ice.Current c)
+ {
+ if(_destroyed)
+ {
+ throw new Ice.ObjectNotExistException();
+ }
+ return _library;
+ }
+
+ synchronized public void
+ refresh(Ice.Current c)
+ {
+ if(_destroyed)
+ {
+ throw new Ice.ObjectNotExistException();
+ }
+ _timestamp = System.currentTimeMillis();
+ }
+
+ synchronized public void
+ destroy(Ice.Current c)
+ {
+ if(_destroyed)
+ {
+ throw new Ice.ObjectNotExistException();
+ }
+
+ _destroyed = true;
+ _logger.trace("Session", "The session " + c.id + " is now destroyed.");
+ _libraryImpl.destroy();
+ try
+ {
+ if(c != null)
+ {
+ c.adapter.remove(c.id);
+ c.adapter.remove(_library.ice_getIdentity());
+ }
+ }
+ catch(Ice.ObjectAdapterDeactivatedException e)
+ {
+ // This method is called on shutdown of the server, in
+ // which case this exception is expected.
+ }
+ }
+
+ // Called on application shutdown.
+ synchronized public void
+ shutdown()
+ {
+ if(!_destroyed)
+ {
+ _destroyed = true;
+ _libraryImpl.shutdown();
+ }
+ }
+
+ synchronized public long
+ timestamp()
+ {
+ if(_destroyed)
+ {
+ throw new Ice.ObjectNotExistException();
+ }
+ return _timestamp;
+ }
+
+ private Ice.Logger _logger;
+ private ConnectionPool _pool;
+ private boolean _destroyed = false; // true if destroy() was called, false otherwise.
+ private long _timestamp; // The last time the session was refreshed.
+ private LibraryPrx _library;
+ private LibraryI _libraryImpl;
+}