xlawrence 2005/01/14 15:36:28 CET
Modified files:
calClient/src/java/org/jahia/suite/calendar/calServer
PersistentStore.java
SyncManager.java
SyncSession.java
WorkerThread.java
Revision Changes Path
1.2 +7 -6
uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/PersistentStore.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/PersistentStore.java.diff?r1=1.1&r2=1.2&f=h
1.7 +10 -5
uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/SyncManager.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/SyncManager.java.diff?r1=1.6&r2=1.7&f=h
1.2 +3 -3
uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/SyncSession.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/SyncSession.java.diff?r1=1.1&r2=1.2&f=h
1.3 +9 -5
uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/WorkerThread.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/WorkerThread.java.diff?r1=1.2&r2=1.3&f=h
Index: PersistentStore.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/PersistentStore.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PersistentStore.java 11 Jan 2005 09:50:06 -0000 1.1
+++ PersistentStore.java 14 Jan 2005 14:36:28 -0000 1.2
@@ -76,7 +76,7 @@
/**
*
*/
- public boolean isLocked(SyncEvent event) throws SyncException {
+ public synchronized boolean isLocked(SyncEvent event) throws
SyncException {
Transaction tx = null;
boolean result = false;
try {
@@ -115,7 +115,8 @@
/**
*
*/
- public boolean lock(SyncEvent event, String calendarID) throws
SyncException {
+ public synchronized boolean lock(SyncEvent event, String calendarID)
+ throws SyncException {
Transaction tx = null;
try {
tx = session.beginTransaction();
@@ -149,7 +150,7 @@
/**
*
*/
- public boolean unlockEvents(String calendarID) throws SyncException {
+ public synchronized boolean unlockEvents(String calendarID) throws
SyncException {
Transaction tx = null;
boolean result = false;
try {
@@ -189,7 +190,7 @@
/**
*
*/
- public boolean lockEvents(String calendarID, SyncEvent[] events)
+ public synchronized boolean lockEvents(String calendarID, SyncEvent[]
events)
throws SyncException {
try {
for (int i=0; i<events.length; i++) {
@@ -206,7 +207,7 @@
/**
*
*/
- public boolean unlock(SyncEvent event, String calendarID)
+ public synchronized boolean unlock(SyncEvent event, String calendarID)
throws SyncException {
Transaction tx = null;
try {
@@ -243,7 +244,7 @@
/**
*
*/
- public void close() throws SyncException {
+ public synchronized void close() throws SyncException {
try {
HibernateUtil.closeSession();
} catch (Throwable t) {
Index: SyncManager.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/SyncManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SyncManager.java 14 Jan 2005 11:05:47 -0000 1.6
+++ SyncManager.java 14 Jan 2005 14:36:28 -0000 1.7
@@ -240,9 +240,11 @@
throws SyncException{
UwCalConnector calServer = session.getCalServer(calendarID);
calServer.endTransaction(commit);
- if (commit) session.removeCalServer(calendarID);
- CleanUpTimer timer = (CleanUpTimer)sessionToTimer.get(calendarID);
- if (timer != null) timer.stop();
+ if (commit) {
+ session.removeCalServer(calendarID);
+ CleanUpTimer timer =
(CleanUpTimer)sessionToTimer.get(calendarID);
+ if (timer != null) timer.stop();
+ }
store.unlockEvents(calendarID);
}
@@ -286,13 +288,16 @@
/**
*
*/
- public synchronized void run() {
- log.warn("Time's up for session: "+calendarID);
+ public void run() {
+ log.debug("Time's up for session: "+calendarID);
try {
// Time is up and locks are still held. We assume we have
// a failure and release the locks.
store.unlockEvents(calendarID);
+ UwCalConnector calServer =
session.getCalServer(calendarID);
+ session.removeCalServer(calendarID);
+ if (calServer != null) calServer.endTransaction(false);
} catch (Exception e) {
log.error(e.getMessage());
Index: SyncSession.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/SyncSession.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SyncSession.java 12 Jan 2005 16:28:13 -0000 1.1
+++ SyncSession.java 14 Jan 2005 14:36:28 -0000 1.2
@@ -55,14 +55,14 @@
/**
*
*/
- public UwCalConnector getCalServer(String calendarID) {
+ public synchronized UwCalConnector getCalServer(String calendarID) {
return (UwCalConnector)calendarToUwCalConnectors.get(calendarID);
}
/**
*
*/
- public void addCalServer(String calendarID, UwCalConnector calServer)
+ public synchronized void addCalServer(String calendarID, UwCalConnector
calServer)
throws SyncException {
if (calendarToUwCalConnectors.containsKey(calendarID)) {
throw new SyncException("Session allready created for:
"+calendarID);
@@ -73,7 +73,7 @@
/**
*
*/
- public void removeCalServer(String calendarID) {
+ public synchronized void removeCalServer(String calendarID) {
calendarToUwCalConnectors.remove(calendarID);
}
}
Index: WorkerThread.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/calClient/src/java/org/jahia/suite/calendar/calServer/WorkerThread.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WorkerThread.java 14 Jan 2005 10:59:47 -0000 1.2
+++ WorkerThread.java 14 Jan 2005 14:36:28 -0000 1.3
@@ -63,7 +63,7 @@
/**
* Worker Thread class that processes a received message (Request) and sends
a
* corresponding response message (Response).
- *
+ *
* @author Xavier Lawrence
*/
public class WorkerThread extends Thread {
@@ -97,7 +97,7 @@
log.debug("WorkerThread started");
- // The Sync Server is requesting the data of a user's calendar
+ // The Sync Server is requesting the data of a user's calendar
if (msg instanceof GetCalendarRequest) {
GetCalendarRequest req = (GetCalendarRequest)msg;
@@ -121,15 +121,20 @@
req.makeResponse(newID(), "Error getting the calendar: "+
e.getMessage(), null);
sendResponse(resp, req);
- syncManager.endSynch(calendarID, false);
+ if (e.getMessage() != null &&
+ e.getMessage().startsWith("Session allready"))
+ syncManager.endSynch(calendarID, false);
+ else
+ syncManager.endSynch(calendarID, true);
+ log.debug("Releasing the fucking locks that are driving
me nuts !!!");
}
// The Sync Server is requesting changes on the data of a
calendar
} else if (msg instanceof UpdateCalendarRequest) {
UpdateCalendarRequest req = (UpdateCalendarRequest)msg;
Response resp;
- final String calendarID = req.getCalendarID();
+ final String calendarID = req.getCalendarID();
try {
log.debug(req);
SyncOperation[] ops = req.getOperations();
@@ -177,7 +182,6 @@
} else {
throw new SyncException("Not a known request: "+msg);
}
-
log.debug("WorkerThread dying");
}