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/communication/queries/CallRequest.java

    r84 r96  
    11package com.framsticks.communication.queries;
    22
    3 import com.framsticks.communication.Request;
     3import com.framsticks.util.Misc;
     4import com.framsticks.util.lang.Pair;
    45
     6import java.util.ArrayList;
     7import java.util.Collection;
    58import java.util.List;
    69
     
    1013public class CallRequest extends ApplicationRequest {
    1114
    12         protected String arguments;
    13         protected String method;
     15        protected final List<Object> arguments = new ArrayList<>();
     16        protected String procedure;
    1417
    15         public CallRequest setArguments(String arguments) {
    16                 this.arguments = arguments;
     18        public CallRequest addArguments(String arguments) {
     19                // this.arguments = arguments;
    1720                return this;
    1821        }
    1922
    20         public CallRequest setArguments(List<String> arguments) {
    21                 StringBuilder buffer = new StringBuilder();
    22                 for (String a : arguments) {
    23                         buffer.append(" ");
    24                         Request.quoteValue(buffer, a.trim());
    25                 }
    26                 return this.setArguments(buffer.toString());
     23        /**
     24         * @return the arguments
     25         */
     26        public List<Object> getArguments() {
     27                return arguments;
    2728        }
    2829
    29         public CallRequest setMethod(String method) {
    30                 this.method = method;
     30        /**
     31         * @return the procedure
     32         */
     33        public String getProcedure() {
     34                return procedure;
     35        }
     36
     37        /**
     38         * @param arguments the arguments to set
     39         */
     40        public CallRequest arguments(Collection<Object> arguments) {
     41                this.arguments.clear();
     42                this.arguments.addAll(arguments);
     43                return this;
     44        }
     45
     46        public CallRequest argument(Object argument) {
     47                arguments.add(argument);
     48                return this;
     49        }
     50
     51        public CallRequest procedure(String procedure) {
     52                this.procedure = procedure;
    3153                return this;
    3254        }
     
    3557        protected StringBuilder construct(StringBuilder buffer) {
    3658                super.construct(buffer);
    37                 if (method != null) {
    38                         buffer.append(" ").append(method);
    39                 }
    40                 if (arguments != null) {
    41                         buffer.append(arguments);
     59                Misc.throwIfNull(procedure);
     60                buffer.append(' ').append(procedure);
     61                for (Object arg : arguments) {
     62                        buffer.append(' ');
     63                        quoteArgumentIfNeeded(buffer, arg);
    4264                }
    4365                return buffer;
     
    4971        }
    5072
     73        @Override
     74        public CharSequence parseRest(CharSequence rest) {
     75                rest = super.parseRest(rest);
     76                Pair<CharSequence, CharSequence> p = Misc.throwIfNull(takeIdentifier(rest));
     77                this.procedure = p.first.toString();
     78                while ((p = takeString(p.second)) != null) {
     79                        arguments.add(p.first);
     80                }
     81                return null;
     82        }
     83
    5184}
Note: See TracChangeset for help on using the changeset viewer.