Ignore:
Timestamp:
07/04/13 20:29:50 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • cleanup Instance management
    • extract Instance interface
    • extract Instance common algorithms to InstanceUtils?
  • fix closing issues: Ctrl+C or window close button

properly shutdown whole program

by Java Framsticks framework

  • fix parsing and printing of all request types
  • hide exception passing in special handle method of closures
    • substantially improve readability of closures
    • basically enable use of exception in asynchronous closures

(thrown exception is transported back to the caller)

  • implement call request on both sides

CHANGELOG:
Further improve calling.

Improve instance calling.

Calling is working on both sides.

Improve exception handling in testing.

Waiters do not supercede other apllication exception being thrown.

Finished parsing and printing of all request types (with tests).

Move implementation and tests of request parsing to Request.

Add tests for Requests.

Improve waits in asynchronours tests.

Extract more algorithms to InstanceUtils?.

Extract Instance.resolve to InstanceUtils?.

Improve naming.

Improve passing exception in InstanceClient?.

Hide calling of passed functor in StateCallback?.

Hide Exception passing in asynchronous closures.

Hide exception passing in Future.

Make ResponseCallback? an abstract class.

Make Future an abstract class.

Minor change.

Move getPath to Path.to()

Move bindAccess to InstanceUtils?.

Extract common things to InstanceUtils?.

Fix synchronization bug in Connection.

Move resolve to InstanceUtils?.

Allow names of Joinable to be dynamic.

Add support for set request server side.

More fixes in communication.

Fix issues with parsing in connection.

Cut new line characters when reading.

More improvements.

Migrate closures to FramsticksException?.

Several changes.

Extract resolveAndFetch to InstanceUtils? algorithms.

Test resolving and fetching.

More fixes with function signature deduction.

Do not print default values in SimpleAbstractAccess?.

Add test of FramsClass? printing.

Improve FramsticksException? messages.

Add explicit dispatcher synchronization feature.

Rework assertions in tests.

Previous solution was not generic enough.

Allow addition of joinables to collection after start.

Extract SimulatorInstance? from RemoteInstance?.

Remove PrivateJoinableCollection?.

Improve connections.

Move shutdown hook to inside the Monitor.

It should work in TestNG tests, but it seems that
hooks are not called.

In ServerTest? client connects to testing server.

Move socket initialization to receiver thread.

Add proper closing on Ctrl+C (don't use signals).

Fix bugs with server accepting connections.

Merge Entity into Joinable.

Reworking ServerInstance?.

Extract more algorithm to InstanceUtils?.

Extract some common functionality from AbstractInstance?.

Functions were placed in InstanceUtils?.

Hide registry of Instance.

Use ValueParam? in Instance interface.

Minor change.

Extract Instance interface.

Old Instance is now AbstractInstance?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/util/dispatching/JoinableCollection.java

    r88 r96  
    22
    33import java.util.Collections;
    4 import java.util.HashMap;
    54import java.util.HashSet;
    65import java.util.Iterator;
    7 import java.util.Map;
    86import java.util.Set;
    97
    10 import com.framsticks.core.Entity;
    118import com.framsticks.params.annotations.AutoAppendAnnotation;
    129import com.framsticks.params.annotations.FramsClassAnnotation;
     
    1916
    2017        protected final Set<T> joinables = new HashSet<T>();
    21         protected final Map<String, T> namedJoinables = new HashMap<>();
    2218
    2319        protected boolean finishIfOne;
     
    3430
    3531        @AutoAppendAnnotation
    36         public void add(T joinable) {
    37                 assert isInState(JoinableState.INITILIAZED);
     32        public synchronized void add(T joinable) {
     33                if (this.state.ordinal() > JoinableState.RUNNING.ordinal()) {
     34                        throw new FramsticksException().msg("failed to add joinable - collection is passed running state").arg("joinable", joinable).arg("collection", this);
     35                }
    3836
    3937                if (joinables.contains(joinable)) {
    4038                        throw new FramsticksException().msg("joinable is already observed").arg("joinable", joinable).arg("in", this);
    4139                }
    42                 // if (observables.containsKey(observable.getName())) {
    43                 //      throw new FramsticksException().msg("observable with given name already exists").arg("name", observable.getName()).arg("in", this);
    44                 // }
     40                joinables.add(joinable);
    4541
    46                 if (joinable instanceof Entity) {
    47                         Entity e = (Entity) joinable;
    48                         if (!namedJoinables.containsKey(e.getName())) {
    49                                 namedJoinables.put(e.getName(), joinable);
    50                         }
     42                if (this.state.equals(JoinableState.RUNNING)) {
     43                        Dispatching.use(joinable, this);
    5144                }
    52 
    53                 joinables.add(joinable);
    5445        }
    5546
     
    10798        public void childChangedState(Joinable joinable, JoinableState state) {
    10899                proceedToState(getNextState());
    109 
    110100        }
    111101
     
    129119
    130120        public T get(String name) {
    131                 return namedJoinables.get(name);
     121                for (T j : joinables) {
     122                        if (j.getName().equals(name)) {
     123                                return j;
     124                        }
     125                }
     126                return null;
    132127        }
    133128
     129        public int size() {
     130                return joinables.size();
     131        }
    134132
    135         public Map<String, T> getObservables() {
    136                 return Collections.unmodifiableMap(namedJoinables);
     133        public boolean contains(T joinable) {
     134                return joinables.contains(joinable);
     135        }
     136
     137        @Override
     138        public String getName() {
     139                return observableName;
    137140        }
    138141
Note: See TracChangeset for help on using the changeset viewer.