source: java/main/src/main/java/com/framsticks/hosting/ServerInstance.java @ 90

Last change on this file since 90 was 90, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

CHANGELOG:
Make ProcedureParam? hold only ValueParams?.

Use id instead of names when naming gui components internally.

Basic procedure calling in GUI.

The actual procedure call is currently only backed
by the ObjectInstance?.

Add UnimplementedException?.

Improve naming of various gui elements.

Allow easy navigating in FEST Swing testing.

Add optional explicit order attribute to FramsClassAnnotation?.

That's because java reflection does return declared members
in any specific order. That ordering is needed only for
classes that have no representation in framsticks and need
a deterministic ordering of params.

Add ControlOwner? interface.

Add test for procedure calling in Browser.

First version of ParamAnnotation? for procedures.

Development of ProcedureParam?.

Add draft version of ProcedureParam? implementation in ReflectionAccess?.

Allow viewing FramsClasses? in gui Browser.

Extract ResourceBuilder? from ModelBuilder?.

Remove internalId from Param.

It was currently completely not utilised. Whether it is still needed
after introduction of ParamAnnotation? is arguable.

Add remaining param attributes to ParamAnnotation?.

Change AutoBuilder? semantics.

AutoBuilder? returns list of objects that are to be appended
with methods @AutoAppendAnnotation?.

This allows to omit explicit addition of ModelPackage? to instance
if the instance uses ModelBuilder? (registration of ModelPackage? comes
from schema).

Fix params ordering problem in auto created FramsClasses?.

Improve ObjectInstance?.

Several fixes to ModelBuilder?.

Improve test for ObjectInstance? in Browser.

Make initialization of robot static.

With robot recreated for second browser test, the test hanged
deep in AWT.

Add base convenience base test for Browser tests.

More tests to ObjectInstance?.

Rename Dispatcher.invokeLater() to dispatch().

Add assertDispatch.

It allows assertions in other threads, than TestNGInvoker.
Assertions are gathered after each method invocation and rethrown.

Use timeOut annotation attribute for tests involving some waiting.

Remove firstTask method (merge with joinableStart).

Clean up leftovers.

Remove unused FavouritesXMLFactory (the reading part is already
completely done with generic XmlLoader?, and writing part will be done
based on the same approach if needed).
Move UserFavourite? to the com.framsticks.gui.configuration package.

Remove GenotypeBrowser? as to specific.

This functionality will be available in ObjectInstance?.

Add interface ParamsPackage?.

Package containing registration of Java classes meant to use with
ReflectionAccess? may be in Instance using configuration.

Minor changes.

Make Group immutable.

Add AutoBuilder? interface extending Builder - only those would
be used to automatically build from XML.

Fix groups in FramsClass?.

Minor naming cleanup in Registry.

Add ModelComponent? interface.

All class creating the Model are implementing that interface.

Extract Model.build into ModelBuilder?.

ModelBuilder? will be compatible with other builders
and allow using it from configuration.

Fix NeuroConnection?.

Add synchronous get operation for dispatchers.

Rename JoinableMonitor? to Monitor.

Add ObjectInstance?.

This class is mainly for demonstration
and testing purposes.

Improve FramsServer? runner.

  • improve ExternalProcess? runner,
  • runner can kill the server but also react properly, when the server exists on it's own,
  • set default path to search for framsticks server installation,
  • add LoggingOutputListener?.
File size: 2.9 KB
Line 
1package com.framsticks.hosting;
2
3import com.framsticks.core.*;
4import com.framsticks.params.ConstructionException;
5import com.framsticks.params.FramsClass;
6import com.framsticks.core.LocalInstance;
7import com.framsticks.util.dispatching.Dispatching;
8import com.framsticks.util.dispatching.Future;
9import com.framsticks.util.dispatching.Joinable;
10import com.framsticks.util.dispatching.JoinableParent;
11import com.framsticks.util.dispatching.JoinableState;
12
13import org.apache.log4j.Logger;
14
15/**
16 * @author Piotr Sniegowski
17 */
18public abstract class ServerInstance extends LocalInstance implements JoinableParent {
19
20        private final static Logger log = Logger.getLogger(ServerInstance.class.getName());
21
22        Entity hosted;
23
24        public ServerInstance() {
25        }
26
27        // @Override
28        // public void configure(Configuration config) {
29        //      super.configure(config);
30
31        //      Configuration hostedConfig = config.subset("hosted.entity");
32        //      hosted = Program.configureEntity(hostedConfig);
33        //      if (hosted == null) {
34        //              log.fatal("failed to create hosted entity");
35        //              return;
36        //      }
37        //      hosted.setName("hosted");
38        //      hosted.configure(hostedConfig);
39        //      root = new Node(Param.build().name("root").id("root").type("o" + hosted.getClass().getCanonicalName()), hosted);
40        // }
41
42        @Override
43        public FramsClass getInfoFromCache(String id) {
44                assert isActive();
45                if (id == null) {
46                        return null;
47                }
48                FramsClass cached = registry.getFramsClass(id);
49                if (cached != null) {
50                        return cached;
51                }
52                try {
53                        Class<?> nativeClass = Class.forName(id);
54                        FramsClass framsClass = FramsClass.build().forClass(nativeClass);
55
56                        if (!framsClass.getId().equals(id)) {
57                                log.error("no matching id");
58                                return null;
59                        }
60
61                        registry.registerReflectedClass(null, id, nativeClass);
62                        registry.putFramsClass(framsClass);
63                        return framsClass;
64                } catch (ClassNotFoundException ignored) {
65                } catch (ConstructionException e) {
66                        log.error("failed to use info from cache: " + e);
67                }
68
69                return null;
70        }
71
72        @Override
73        protected void fetchInfo(Path path, Future<FramsClass> future) {
74                assert isActive();
75
76                FramsClass framsClass = getInfoFromCache(path.getTop().getObject().getClass().getCanonicalName());
77                if (framsClass == null) {
78                        log.error("failed to create frams class for: " + path.getTop().getObject().getClass());
79                        future.result(null, new Exception());
80                        return;
81                }
82                future.result(framsClass, null);
83
84        }
85
86        @Override
87        protected void tryRegisterOnChangeEvents(Path path) {
88        }
89
90        @Override
91        public void childChangedState(Joinable joinable, JoinableState state) {
92                proceedToState(state);
93        }
94
95        @Override
96        protected void joinableStart() {
97                super.joinableStart();
98                assert hosted != null;
99                Dispatching.use(hosted, this);
100        }
101
102        @Override
103        protected void joinableInterrupt() {
104                super.joinableInterrupt();
105                Dispatching.drop(hosted, this);
106        }
107
108        @Override
109        protected void joinableJoin() throws InterruptedException {
110                Dispatching.join(hosted);
111                super.joinableJoin();
112        }
113
114}
Note: See TracBrowser for help on using the repository browser.