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/core/ObjectInstance.java

    r90 r96  
    55import com.framsticks.params.AccessInterface;
    66import com.framsticks.params.CompositeParam;
     7import com.framsticks.params.FramsClass;
    78import com.framsticks.params.Param;
     9import com.framsticks.params.ValueParam;
    810import com.framsticks.params.annotations.AutoAppendAnnotation;
    911import com.framsticks.params.annotations.FramsClassAnnotation;
     12import com.framsticks.util.UnsupportedOperationException;
    1013import com.framsticks.params.types.ProcedureParam;
    1114import com.framsticks.util.FramsticksException;
    1215import com.framsticks.util.StateFunctor;
     16import com.framsticks.util.dispatching.Future;
     17// import static com.framsticks.core.InstanceUtils.*;
    1318
    1419@FramsClassAnnotation
    15 public class ObjectInstance extends Instance {
     20public class ObjectInstance extends AbstractInstance {
    1621        private static final Logger log = Logger.getLogger(ObjectInstance.class);
    1722
     
    2025                registry.registerAndBuild(object.getClass());
    2126                AccessInterface access = registry.createAccess(object.getClass());
    22                 setRoot(Param.build().forAccess(access).id(getName()).finish(CompositeParam.class), object);
     27                setRoot(new Node(Param.build().forAccess(access).id(getName()).finish(CompositeParam.class), object));
    2328        }
    2429
     
    4348                log.debug("requesting: " + path);
    4449                fireFetch(path);
    45                 stateFunctor.call(null);
     50                stateFunctor.call();
    4651        }
    4752
    4853        @Override
    49         public void fetchValue(Path path, Param param, StateFunctor stateFunctor) {
     54        public void fetchValue(Path path, ValueParam param, StateFunctor stateFunctor) {
    5055                assert isActive();
    5156                fireFetch(path);
    52                 stateFunctor.call(null);
     57                stateFunctor.call();
    5358        }
    5459
    5560        @Override
    56         public void call(Path path, ProcedureParam param, Object[] arguments, StateFunctor stateFunctor) {
     61        public void call(Path path, ProcedureParam param, Object[] arguments, Future<Object> future) {
    5762                assert isActive();
    5863                try {
    59                         bindAccess(path).call(param, arguments);
    60                         stateFunctor.call(null);
     64                        future.pass(InstanceUtils.bindAccess(path).call(param, arguments));
    6165                } catch (FramsticksException e) {
    62                         stateFunctor.call(e);
     66                        future.handle(e);
    6367                }
    6468        }
     69
     70        @Override
     71        public void fetchInfo(Path path, Future<FramsClass> future) {
     72                assert isActive();
     73                Path p = path.tryResolveIfNeeded();
     74                Class<?> javaClass = p.getTopObject().getClass();
     75                FramsClass framsClass = registry.registerReflectedIfNeeded(javaClass);
     76                if (framsClass != null) {
     77                        future.pass(framsClass);
     78                } else {
     79                        future.handle(new FramsticksException().msg("failed to find info for class").arg("java class", javaClass));
     80                }
     81        }
     82
     83        @Override
     84        public void resolve(Path path, Future<Path> future) {
     85                assert isActive();
     86                assert path.isOwner(this);
     87                if (path.getTop().getObject() != null) {
     88                        future.pass(path);
     89                        return;
     90                }
     91                AccessInterface access = InstanceUtils.bindAccess(this, path.getUnder());
     92                Object object = access.get(path.getTop().getParam(), Object.class);
     93                if (object == null) {
     94                        future.pass(path);
     95                        return;
     96                }
     97                future.pass(path.appendResolution(object));
     98        }
     99
     100        @Override
     101        public void storeValue(Path path, ValueParam param, Object value, final StateFunctor stateFunctor) {
     102                assert isActive();
     103                stateFunctor.handle(new UnsupportedOperationException());
     104        }
     105
     106        @Override
     107        public Path create(Path path) {
     108                assert isActive();
     109                assert !path.isResolved();
     110                throw new UnsupportedOperationException();
     111        }
     112
    65113}
Note: See TracChangeset for help on using the changeset viewer.