1 18 package sync4j.transport.http.server; 19 20 import java.io.File ; 21 import java.net.URL ; 22 import java.util.Map ; 23 import java.util.logging.Logger ; 24 import java.util.logging.Level ; 25 26 import sync4j.framework.transport.http.SyncHolder; 27 import sync4j.framework.server.SyncResponse; 28 import sync4j.framework.core.Sync4jException; 29 import sync4j.framework.config.ConfigClassLoader; 30 import sync4j.framework.config.ConfigurationException; 31 import sync4j.framework.logging.Sync4jLogger; 32 import sync4j.framework.logging.Sync4jLoggerName; 33 import sync4j.framework.server.error.ServerException; 34 import sync4j.framework.server.error.ServerFailureException; 35 import sync4j.framework.server.error.NotImplementedException; 36 import sync4j.framework.protocol.ProtocolException; 37 38 import sync4j.server.config.Configuration; 39 import sync4j.server.engine.SyncAdapter; 40 41 48 public class LocalSyncHolder implements SyncHolder { 49 50 52 54 private transient Logger log = Sync4jLogger.getLogger(Sync4jLoggerName.HANDLER); 55 56 private SyncAdapter syncAdapter = null; 57 private long creationTimestamp ; 58 private String sessionId ; 59 60 public LocalSyncHolder() throws ServerException { 62 try { 63 syncAdapter = new SyncAdapter(loadConfiguration()); 64 } catch (ConfigurationException e) { 65 66 } 67 creationTimestamp = System.currentTimeMillis(); 68 } 69 70 72 83 public SyncResponse processXMLMessage(final byte[] requestData, 84 final Map parameters , 85 final Map headers ) 86 throws ServerException { 87 return syncAdapter.processXMLMessage(requestData, parameters, headers); 88 } 89 90 101 public SyncResponse processWBXMLMessage(final byte[] requestData, 102 final Map parameters , 103 final Map headers ) 104 105 throws ServerException { 106 return syncAdapter.processWBXMLMessage(requestData, parameters, headers); 107 } 108 109 public void setSessionId(String sessionId) throws Sync4jException { 110 this.sessionId = sessionId; 111 syncAdapter.beginSync(sessionId); 112 } 113 114 public String getSessionId() { 115 return this.sessionId; 116 } 117 118 125 public void close() throws Exception { 126 syncAdapter.endSync(); 127 } 128 129 135 public long getCreationTimestamp() { 136 return creationTimestamp; 137 } 138 139 144 private Configuration loadConfiguration() 145 throws ConfigurationException { 146 147 Configuration config = Configuration.getConfiguration(); 148 149 if (config == null) { 154 throw new ConfigurationException("Error loading configuration (see the log for details)!"); 155 } 156 157 return config; 158 } 159 } 160 | Popular Tags |