- Timestamp:
- 06/22/13 21:51:33 (11 years ago)
- Location:
- java/main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main
-
Property
svn:ignore
set to
target
-
Property
svn:ignore
set to
-
java/main/src/main/java/com/framsticks/hosting/ServerInstance.java
r78 r84 2 2 3 3 import com.framsticks.core.*; 4 import com.framsticks.params.CompositeParam; 4 5 import com.framsticks.params.FramsClass; 5 6 import com.framsticks.params.ParamBuilder; 6 import com.framsticks.params.types.CompositeParam;7 7 import com.framsticks.core.LocalInstance; 8 import com.framsticks.util.Future; 8 import com.framsticks.util.dispatching.Future; 9 10 import org.apache.commons.configuration.Configuration; 9 11 import org.apache.log4j.Logger; 10 12 … … 14 16 public class ServerInstance extends LocalInstance { 15 17 16 private final static Logger LOGGER= Logger.getLogger(ServerInstance.class.getName());18 private final static Logger log = Logger.getLogger(ServerInstance.class.getName()); 17 19 18 20 Entity hosted; 19 21 20 public ServerInstance(Parameters parameters) { 21 super(parameters); 22 } 22 public ServerInstance() { 23 } 23 24 24 25 26 27 28 29 25 @Override 26 protected void run() { 27 super.run(); 28 assert hosted != null; 29 hosted.start(); 30 } 30 31 31 32 protected void configure() throws Exception{33 super.configure();32 @Override 33 public void configure(Configuration config) { 34 super.configure(config); 34 35 35 Parameters p = new Parameters(config.subset("hosted.entity"), "hosted", this, null); 36 hosted = Program.configureEntity(p); 37 if (hosted == null) { 38 LOGGER.fatal("failed to create hosted entity"); 39 return; 40 } 41 hosted.configurePublic(); 42 root = new Node((CompositeParam)new ParamBuilder().setName("root").setId("root").setType("o" + hosted.getClass().getCanonicalName()).build(), hosted); 43 } 36 Configuration hostedConfig = config.subset("hosted.entity"); 37 hosted = Program.configureEntity(hostedConfig); 38 if (hosted == null) { 39 log.fatal("failed to create hosted entity"); 40 return; 41 } 42 hosted.setName("hosted"); 43 hosted.configure(hostedConfig); 44 root = new Node((CompositeParam)new ParamBuilder().setName("root").setId("root").setType("o" + hosted.getClass().getCanonicalName()).build(), hosted); 45 } 44 46 45 46 47 48 49 50 47 @Override 48 public FramsClass getInfoFromCache(String id) { 49 assert isActive(); 50 if (id == null) { 51 return null; 52 } 51 53 FramsClass cached = registry.getInfoFromCache(id); 52 54 if (cached != null) { 53 55 return cached; 54 55 56 ClassnativeClass = Class.forName(id);57 56 } 57 try { 58 Class<?> nativeClass = Class.forName(id); 59 FramsClass framsClass = new FramsClass.Constructor(nativeClass, id).getResult(); 58 60 59 60 61 62 63 61 registry.registerReflectedClass(null, id, nativeClass); 62 registry.putInfoIntoCache(framsClass); 63 return framsClass; 64 } catch (ClassNotFoundException ignored) { 65 } 64 66 65 66 67 return null; 68 } 67 69 68 69 70 70 @Override 71 protected void fetchInfo(Path path, Future<FramsClass> future) { 72 assert isActive(); 71 73 72 73 74 LOGGER.error("failed to create frams class for: " + path.getTop().getObject().getClass());75 76 77 78 74 FramsClass framsClass = getInfoFromCache(path.getTop().getObject().getClass().getCanonicalName()); 75 if (framsClass == null) { 76 log.error("failed to create frams class for: " + path.getTop().getObject().getClass()); 77 future.result(null, new Exception()); 78 return; 79 } 80 future.result(framsClass, null); 79 81 80 82 } 81 83 82 83 84 84 @Override 85 protected void tryRegisterOnChangeEvents(Path path) { 86 } 85 87 86 88 }
Note: See TracChangeset
for help on using the changeset viewer.