- Timestamp:
- 07/14/13 23:20:04 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/hosting/Server.java
r100 r101 6 6 7 7 import com.framsticks.core.Tree; 8 import com.framsticks.params.ParamFlags; 8 9 import com.framsticks.params.annotations.AutoAppendAnnotation; 9 10 import com.framsticks.params.annotations.FramsClassAnnotation; … … 17 18 import com.framsticks.util.dispatching.JoinableState; 18 19 import com.framsticks.util.dispatching.RunAt; 19 import com.framsticks.util.dispatching.Task;20 20 import com.framsticks.util.dispatching.ThrowExceptionHandler; 21 21 … … 24 24 import java.net.ServerSocket; 25 25 import java.net.Socket; 26 import java.util.TimerTask; 27 26 28 import com.framsticks.util.dispatching.Thread; 27 29 … … 61 63 * @param port the port to set 62 64 */ 63 @ParamAnnotation 65 @ParamAnnotation(flags = ParamFlags.USERREADONLY) 64 66 public void setPort(int port) { 65 67 this.port = port; … … 76 78 log.debug("exception caught during socket closing: ", e); 77 79 } 78 finish ();80 finishJoinable(); 79 81 } 80 82 … … 150 152 151 153 protected void tryBind(int when) { 152 acceptThread.dispatch(new Task<Accept>(ThrowExceptionHandler.getInstance(), when) { 154 Dispatching.getTimer().schedule(new TimerTask() { 155 153 156 @Override 154 protected void runAt() { 155 try { 156 acceptSocket.bind(new InetSocketAddress(port)); 157 log.debug("started accepting on port {}", port); 158 acceptNext(); 159 return; 160 } catch (IOException e) { 161 log.warn("failed to accept on port {} (repeating): ", port, e); 162 } 163 tryBind(1000); 157 public void run() { 158 acceptThread.dispatch(new RunAt<Accept>(ThrowExceptionHandler.getInstance()) { 159 @Override 160 protected void runAt() { 161 try { 162 acceptSocket.bind(new InetSocketAddress(port)); 163 log.debug("started accepting on port {}", port); 164 acceptNext(); 165 return; 166 } catch (IOException e) { 167 log.warn("failed to accept on port {} (repeating): ", port, e); 168 } 169 tryBind(1000); 170 } 171 }); 164 172 } 165 }); 173 174 }, when); 166 175 } 167 176 … … 178 187 } 179 188 180 // @Override181 // public FramsClass getInfoFromCache(String id) {182 // assert isActive();183 // if (id == null) {184 // return null;185 // }186 // FramsClass cached = registry.getFramsClass(id);187 // if (cached != null) {188 // return cached;189 // }190 // try {191 // Class<?> nativeClass = Class.forName(id);192 // FramsClass framsClass = FramsClass.build().forClass(nativeClass);193 194 // if (!framsClass.getId().equals(id)) {195 // log.error("no matching id");196 // return null;197 // }198 199 // registry.registerReflectedClass(null, id, nativeClass);200 // registry.putFramsClass(framsClass);201 // return framsClass;202 // } catch (ClassNotFoundException ignored) {203 // } catch (ConstructionException e) {204 // log.error("failed to use info from cache: {}", e);205 // }206 207 // return null;208 // }209 210 // @Override211 // protected void fetchInfo(Path path, Future<FramsClass> future) {212 // assert isActive();213 214 // FramsClass framsClass = getInfoFromCache(path.getTop().getObject().getClass().getCanonicalName());215 // if (framsClass == null) {216 // log.error("failed to create frams class for: {}", path.getTop().getObject().getClass());217 // future.result(null, new Exception());218 // return;219 // }220 // future.result(framsClass, null);221 // }222 189 }
Note: See TracChangeset
for help on using the changeset viewer.