source: java/main/src/main/java/com/framsticks/observers/Endpoint.java @ 86

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

HIGHLIGHTS:

  • use java annotations to mark classes and fields to be used when:
    • using java classes with ReflectionAccess? to represent remote objects with FramsClass? description found by "info ..." requests
    • to build up FramsClass? representation of objects not present at remote server
  • allow using primitive types (instead of wraping counterparts) in reflected classes
  • rework FramsClass? creation process (add FramsClassBuilder?)
  • add more tests

CHANGELOG:
Prepare model.World class.

Minor change.

Use primitive types for Genotype and Creature classes.

Use primitive types in model.Neuro* classes.

Use primitive types in model.Joint* classes.

Use primitive types in model.Part* classes.

Fix primitive values.

Extract FramsClassBuilder?.

Add tests of Model classes.

More fixes.

Refactorize out ParamCandidate?.

Several fixes.

Fix all regressions after introducing annotations.

Use annotations throughout the project.

Add exception classes.

Improve creation of FramsClass?.

More changes.

Many changes regarding annotations.

Annotate classes in com.framsticks.model package.

Remove manual FramsClass? constructor.

Construct FramsClass? for Creature. Add test.

Add default values to the ParamAnnotation?.

Add ParamBuilderTest? and ParamAnnotation?.

Add FramsClassAnnotation?.

File size: 1.8 KB
Line 
1package com.framsticks.observers;
2
3import com.framsticks.core.Instance;
4import com.framsticks.core.InstanceListener;
5import com.framsticks.core.Path;
6import com.framsticks.params.annotations.FramsClassAnnotation;
7import com.framsticks.params.annotations.ParamAnnotation;
8import com.framsticks.core.ListChange;
9import com.framsticks.util.dispatching.Dispatcher;
10import org.apache.log4j.Logger;
11import com.framsticks.util.dispatching.RunAt;
12
13/**
14 * @author Piotr Sniegowski
15 */
16@FramsClassAnnotation
17public class Endpoint implements Dispatcher<Instance>, InstanceListener {
18        private final static Logger log = Logger.getLogger(Endpoint.class.getName());
19
20        @ParamAnnotation
21        protected Instance instance;
22        protected Observer observer;
23
24        @ParamAnnotation
25        protected String name;
26
27        public Endpoint() {
28        }
29
30        public final void configurePublic(Observer observer, Instance instance, String name) {
31                assert instance != null;
32                this.name = name;
33                this.observer = observer;
34                this.instance = instance;
35                instance.addListener(this);
36        }
37
38        public void start() {
39                instance.start();
40        }
41
42        @Override
43        public void onListChange(Path path, ListChange change) {
44                log.info("change " + change + " in " + path);
45        }
46
47        @Override
48        public void onRun(Exception e) {
49        }
50
51        @Override
52        public void onStop(Exception e) {
53        }
54
55        @Override
56        public void onFetch(Path path) {
57                log.trace("fetched " + path);
58        }
59
60        @Override
61        public String toString() {
62                return instance.toString();
63        }
64
65        public final Instance getInstance() {
66                return instance;
67        }
68
69        @Override
70        public final boolean isActive() {
71                return instance.isActive();
72        }
73
74        @Override
75        public final void invokeLater(RunAt<? extends Instance> runnable) {
76                instance.invokeLater(runnable);
77        }
78
79        public Observer getObserver() {
80                return observer;
81        }
82
83        public final String getName() {
84                return name;
85        }
86
87
88}
Note: See TracBrowser for help on using the repository browser.