client.evgen.stopWatching();
cwe.setHandler(null);
-// ask to the client to copy application data into the document
+ // ask to the client to copy application data into the document
client.evgen._raise(Events.DOCUMENT_FINALIZEAPPDATA, null, client,null);
-
- if ( this.isLastActiveClient(client))
- {
+ boolean closeSession=isLastActiveClient(client);
+ if (closeSession)
+ {
log.debug("Raising request-to-save event");
client.evgen._raise(Events.DOCUMENT_REQUESTTOCLOSE, null, client, null);
- //client.evgen._raise(Events.SESSION_SHUTDOWN, null, client.getSessionHandle(), null);
- log.debug("Last active client: closing session");
- log.info("Closing session");
- getSessionManager().removeSession(client.getSessionHandle());
- }
-
+ client.evgen._raise(Events.SESSION_SHUTDOWN, null, client.getSessionHandle(), null);
+ }
try
{
- log.debug("Releasing active client file");
+ log.debug("Attempting to release active client locks");
client.releaseActiveClientFile();
}
catch (IOException e)
{
log.error("error during active file client release");
}
- }
-
-
-
- /*clist.removeClient(client.getClientHandle(),null);
- if (this.clist.retrieveClientList() == null|| this.clist.retrieveClientList().length<1)
- {//assume it is the last client has been removed shutting down session
- slog.info("last client removed: removing session");
- log.debug("last client removed: removing session");
- this.getSessionManager().removeSession(client.getSessionHandle());
- }
- else
+ if (closeSession)
{
- int active=clist.retrieveClientList().length;
- log.debug("Still "+active+" active clients");
- slog.info("Still "+active+" active clients");
- }*/
-
+ log.debug("Last active client: closing session");
+ log.info("Closing session");
+ getSessionManager().removeSession(client.getSessionHandle());
+ }
+ }
}
private boolean isLastActiveClient(SimpleClient client)
{
log.debug("Testing if current client is the last one.");
+ log.debug("current client lockfile is '"+client.getClientlockFile()+"'");
boolean noOtherActiveClient = true;
//create, if need, subdirectory to contain client files
File clientlockFileDir = new File (this.sessionDir, clientFileDirectory);
{
File clientFile = clientFiles[i];
log.debug("testing file for lock: "+clientFile.getAbsolutePath());
- if(client.getClientlockFile().equals(clientFile))
+ if(client.getClientLock().isTargetLockFile(clientFile))
{
log.debug("current client file found");
continue;
}
log.debug("Stopping EventGenerator..");
+ // TODO: ensure ClientsFile lock is really released!! clist.unlockFile();
client.evgen.stopWatching();
}
watcher.setHandler(null);//Do not check if the client is the last client. watcher will shutdown anyway
// close document
client.evgen._raise(Events.DOCUMENT_REQUESTTOCLOSE, null, client,null);
log.debug("close document request done");
- this.closeSession(client.getSessionHandle());
+ closeSession(client.getSessionHandle());
}
/**