00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.openmobileis.synchro.client;
00026
00027 import java.util.Enumeration;
00028 import java.util.Hashtable;
00029
00030 import org.openmobileis.common.context.ApplicationContextManager;
00031 import org.openmobileis.common.util.exception.SynchroException;
00032 import org.openmobileis.common.util.log.LogManager;
00033 import org.openmobileis.synchro.security.auth.Credential;
00034
00042 public final class SynchroManager {
00043
00044 private static SynchroManager manager;
00045 private Hashtable procTable;
00046
00050 private SynchroManager() {
00051 super();
00052 procTable = new Hashtable(10);
00053 }
00054
00055 public static SynchroManager getManager() {
00056 if (manager == null) {
00057 synchronized (SynchroManager.class) {
00058 if (manager == null) {
00059 manager = new SynchroManager();
00060 ApplicationContextManager.getManager().addManager(manager);
00061 }
00062 }
00063 }
00064 return manager;
00065 }
00066
00067 public void registerSynchroProcessor(SynchroProcessor proc) {
00068 procTable.put(proc.getProcessorName(), proc);
00069 }
00070
00071 public SynchroProcessor getSynchroProcessor(String processorName) {
00072 return (SynchroProcessor) procTable.get(processorName);
00073 }
00074
00075 public void doSynchro(Credential cred, SynchroDescriptor descriptor) throws SynchroException {
00076
00077 descriptor.synchroConduit.openRAS();
00078 try {
00079 boolean error = false;
00080 Enumeration proclist = procTable.elements();
00081 while (proclist.hasMoreElements()) {
00082 try {
00083 SynchroProcessor proc = (SynchroProcessor) proclist.nextElement();
00084 proc.doSynchro(cred, descriptor);
00085 } catch (Throwable ex) {
00086 LogManager.traceError(0, ex);
00087 error = true;
00088 }
00089 }
00090 if (error) {
00091 throw new SynchroException("Error during SynchroManager doSynchro processing");
00092 }
00093 } finally {
00094 descriptor.synchroConduit.closeRAS();
00095 }
00096 }
00097
00098 }