xlawrence 2005/02/11 14:44:24 CET
Modified files:
syncServer/src/java/org/jahia/suite/calendar/sync4jModule
CalendarSyncSource.java
syncServer/src/java/org/jahia/suite/calendar/syncServer
CalendarManager.java
Log:
Use of the Factory classes to get Class instances
Revision Changes Path
1.8 +8 -6
uwcal_JSR168/syncServer/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSource.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/syncServer/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSource.java.diff?r1=1.7&r2=1.8&f=h
1.7 +42 -15
uwcal_JSR168/syncServer/src/java/org/jahia/suite/calendar/syncServer/CalendarManager.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/syncServer/src/java/org/jahia/suite/calendar/syncServer/CalendarManager.java.diff?r1=1.6&r2=1.7&f=h
Index: CalendarSyncSource.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/syncServer/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSource.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CalendarSyncSource.java 3 Feb 2005 10:52:36 -0000 1.7
+++ CalendarSyncSource.java 11 Feb 2005 13:44:23 -0000 1.8
@@ -63,7 +63,8 @@
import org.apache.log4j.Logger;
-import org.jahia.suite.calendar.syncServer.CalendarManager;
+import org.jahia.suite.calendar.framework.CalendarManageable;
+import org.jahia.suite.calendar.syncServer.CalendarManageableFactory;
import org.jahia.suite.calendar.util.StateValueConverter;
/**
@@ -82,7 +83,7 @@
static Logger log = Logger.getLogger(CalendarSyncSource.class);
- private CalendarManager cm;
+ private CalendarManageable cm;
private boolean loaded;
private int syncMode;
@@ -105,7 +106,8 @@
public void beginSync(java.security.Principal principal, int syncMode)
throws SyncSourceException {
log.info("beginSync: "+principal+": "+syncMode);
- cm = new CalendarManager(this);
+ cm = new CalendarManageableFactory().
+ createCalendarManageable(CalendarManageableFactory.SYNC4J,
this);
this.syncMode = syncMode;
}
@@ -126,7 +128,7 @@
throws SyncSourceException {
log.debug("getAllSyncItems(" + principal + ")");
getCalendarFromServer(principal, null);
- Vector temp = cm.getAllItems();
+ Vector temp = (Vector)cm.getAllItems();
return (SyncItem[])temp.toArray(new SyncItem[] {});
}
@@ -179,7 +181,7 @@
throws SyncSourceException {
log.debug("getSyncItemFromId(" + principal + " , " +
syncItemKey.getKeyAsString() + ")");
- return cm.getItem(syncItemKey);
+ return (SyncItem)cm.getItem(syncItemKey);
}
/**
@@ -189,7 +191,7 @@
SyncItemKey[] syncItemKeys) throws SyncSourceException {
log.debug("getSyncItemsFromIds(" + principal + " , " +
syncItemKeys.length + ")");
- return cm.getItems(syncItemKeys);
+ return (SyncItem[])cm.getItems(syncItemKeys);
}
/**
Index: CalendarManager.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/syncServer/src/java/org/jahia/suite/calendar/syncServer/CalendarManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CalendarManager.java 3 Feb 2005 10:52:36 -0000 1.6
+++ CalendarManager.java 11 Feb 2005 13:44:24 -0000 1.7
@@ -64,6 +64,7 @@
import org.apache.log4j.Logger;
import java.util.Vector;
+import java.util.Collection;
import java.util.Iterator;
import java.util.Timer;
import java.util.TimerTask;
@@ -111,8 +112,23 @@
* CalendarManager
*/
public CalendarManager(SyncSource source) {
- JMSAgent tAgent = new JMSAgent(JMSAgent.CAL_SERVER_QUEUE,
"syncServer",
- "syncServer");
+ setSyncSource(source);
+ init();
+ }
+
+ /**
+ * Creates a new instance of CalendarManager
+ */
+ public CalendarManager() {
+ init();
+ }
+
+ /**
+ * init method
+ */
+ private void init() {
+ TransportSender tAgent = new TransportSenderFactory().
+ createTransportSender(TransportSenderFactory.JMS);
try {
tAgent.start();
} catch (Exception e){
@@ -120,7 +136,6 @@
throw new SyncException(e.getMessage(), e);
}
this.transportSender = tAgent;
- this.source = source;
reqID = 0;
newItems = new Vector(0);
modifyItems = new Vector(0);
@@ -129,10 +144,17 @@
}
/**
+ *
+ */
+ public void setSyncSource(SyncSource source) {
+ this.source = source;
+ }
+
+ /**
* Getter for property allItems.
* @return Value of property allItems.
*/
- public Vector getAllItems() {
+ public Collection getAllItems() throws SyncException {
return allItems;
}
@@ -140,7 +162,7 @@
* Getter for property deleteItems.
* @return Value of property deleteItems.
*/
- public Vector getDeleteItems() {
+ public Collection getDeleteItems() throws SyncException {
return deleteItems;
}
@@ -148,7 +170,7 @@
* Getter for property modifyItems.
* @return Value of property modifyItems.
*/
- public Vector getModifyItems() {
+ public Collection getModifyItems() throws SyncException {
return modifyItems;
}
@@ -156,7 +178,7 @@
* Getter for property newItems.
* @return Value of property newItems.
*/
- public Vector getNewItems() {
+ public Collection getNewItems() throws SyncException {
return newItems;
}
@@ -165,11 +187,12 @@
* @param item The SyncItem to look for
* @return True if the item is found
*/
- public boolean itemExists(SyncItem item) {
+ public boolean itemExists(Object item) {
+ SyncItem sItem = (SyncItem)item;
Iterator ite = allItems.iterator();
while (ite.hasNext()) {
SyncItem temp = (SyncItem)ite.next();
- if ((temp.getKey()).equals(item.getKey())) {
+ if ((temp.getKey()).equals(sItem.getKey())) {
return true;
}
}
@@ -181,7 +204,10 @@
* @param syncItemKey The key of the SyncItem
* @return The corresponding SyncItem or NULL if not found
*/
- public SyncItem getItem(SyncItemKey syncItemKey) {
+ public Object getItem(Object key) {
+
+ SyncItemKey syncItemKey = (SyncItemKey)key;
+
Iterator ite = allItems.iterator();
while (ite.hasNext()) {
SyncItem temp = (SyncItem)ite.next();
@@ -197,7 +223,8 @@
* @param syncItemKeys The array of SyncItemKey
* @return An array of SyncItem
*/
- public SyncItem[] getItems(SyncItemKey syncItemKeys[]) {
+ public Object[] getItems(Object[] keys) {
+ SyncItemKey syncItemKeys[] = (SyncItemKey[])keys;
Iterator ite = allItems.iterator();
Vector res = new Vector(0);
@@ -205,7 +232,7 @@
res.addElement(getItem(syncItemKeys[i]));
}
- return (SyncItem[])res.toArray(new SyncItem[] {});
+ return res.toArray(new SyncItem[] {});
}
/**
@@ -313,7 +340,7 @@
* deleted on the calendar server
* @param item The item to delete
*/
- public void addDeletedItem(SyncItem item) {
+ public void addDeletedItem(Object item) throws SyncException {
deleteItems.addElement(item);
}
@@ -322,7 +349,7 @@
* updated on the calendar server
* @param item The item to update
*/
- public void addModifiedItem(SyncItem item) {
+ public void addModifiedItem(Object item) throws SyncException {
modifyItems.addElement(item);
}
@@ -331,7 +358,7 @@
* added to the calendar server
* @param item The item to add
*/
- public void addNewItem(SyncItem item) {
+ public void addNewItem(Object item) throws SyncException {
newItems.addElement(item);
}