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

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

HIGHLIGHTS:

  • upgrade to Java 7
    • use try-multi-catch clauses
    • use try-with-resources were appropriate
  • configure FindBugs? (use mvn site and then navigate in browser to the report)
    • remove most bugs found
  • parametrize Dispatching environment (Dispatcher, RunAt?) to enforce more control on the place of closures actual call

CHANGELOG:
Rework FavouritesXMLFactory.

FindBugs?. Thread start.

FindBugs?. Minor change.

FindBugs?. Iterate over entrySet.

FindBugs?. Various.

FindBug?.

FindBug?. Encoding.

FindBug?. Final fields.

FindBug?.

Remove synchronization bug in ClientConnection?.

Experiments with findbugs.

Finish parametrization.

Make RunAt? an abstract class.

More changes in parametrization.

More changes in parametrizing dispatching.

Several changes to parametrize tasks.

Rename Runnable to RunAt?.

Add specific framsticks Runnable.

Add JSR305 (annotations).

Add findbugs reporting.

More improvements to ParamBuilder? wording.

Make FramsClass? accept also ParamBuilder?.

Change wording of ParamBuilder?.

Change wording of Request creation.

Use Java 7 exception catch syntax.

Add ScopeEnd? class.

Upgrade to Java 7.

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