Ignore:
Timestamp:
09/10/13 21:11:41 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • import refactorization: move Tree, Path, etc.

from core to structure package

  • initial serialization implementation
  • improve PrimeExperiment? test
  • many organizational changes and convenience improvements

CHANGELOG:
Make registry in AbstractTree? final.

Move most classes from core to structure package.

Minor changes.

Switch names of Future and FutureHandler?.

Rename ExceptionResultHandler? to ExceptionHandler?.

Rename ExceptionHandler? to ExceptionDispatcherHandler?.

Fix bug in ParamCandidate? cache.

Add missing synchronization to the BufferedDispatcher?.

Develop @Serialized support.

Rework serialization further.

Add serialization/deserialization interface to ValueParam?.

Move getStorageType and isNumeric from Param down to params hierarchy.

Minor changes.

Improve param type induction.

Add TestSerializedClass? for testing new serialization.

Add info files gor GenePool? and Population.

Add standard.expt exemplary netfile.

Add type name field to PropertiesObject?.

Use PropertiesObject? for PropertiesAccess? instead of ordinary map.

Hide getFramsClass is several more places.

More unification accross FramsClass?, Access and Path.

Add ParamCollection?.

Simplify interface for getting params from FramsClass?, Access
or Path.

Make Access.call() interface variadic.

Add arguments(args) convenience wrapper around new Object[] {args}.

Upgrade to apache.commons.lang version 3.1

Minor improvement with Response constructors.

Develop proper result printing in ClientAtServer?.

Add experimentNetsave to PrimeExperiment?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/hosting/ClientAtServer.java

    r103 r105  
    11package com.framsticks.hosting;
    22
     3import static com.framsticks.structure.TreeOperations.*;
    34import static com.framsticks.util.lang.Strings.assureNotEmpty;
    45
     
    1011import com.framsticks.communication.queries.RegisterRequest;
    1112import com.framsticks.communication.queries.SetRequest;
    12 import com.framsticks.core.LocalTree;
    13 import com.framsticks.core.Tree;
    14 import com.framsticks.core.Path;
    1513import com.framsticks.params.*;
    1614import com.framsticks.params.types.EventParam;
    1715import com.framsticks.params.types.ProcedureParam;
    1816import com.framsticks.parsers.Savers;
     17import com.framsticks.structure.LocalTree;
     18import com.framsticks.structure.Path;
     19import com.framsticks.structure.Tree;
     20import com.framsticks.util.ExceptionHandler;
    1921import com.framsticks.util.FramsticksException;
    2022import com.framsticks.util.Misc;
    2123import com.framsticks.util.dispatching.AbstractJoinable;
    2224import com.framsticks.util.dispatching.Dispatching;
    23 import com.framsticks.util.dispatching.ExceptionResultHandler;
    24 import com.framsticks.util.dispatching.FutureHandler;
     25import com.framsticks.util.dispatching.Future;
    2526import com.framsticks.util.dispatching.Joinable;
    2627import com.framsticks.util.dispatching.JoinableParent;
     
    2930import com.framsticks.util.lang.Strings;
    3031
    31 import static com.framsticks.core.TreeOperations.*;
    3232import static com.framsticks.params.AccessOperations.*;
     33import static com.framsticks.params.ParamsUtil.getParam;
    3334
    3435import java.net.Socket;
     
    3738 * @author Piotr Sniegowski
    3839 */
    39 public class ClientAtServer extends AbstractJoinable implements RequestHandler, JoinableParent, ExceptionResultHandler {
     40public class ClientAtServer extends AbstractJoinable implements RequestHandler, JoinableParent, ExceptionHandler {
    4041
    4142        protected final Server server;
     
    126127        protected void handleInTree(final Tree tree, final ApplicationRequest request, final ServerSideResponseFuture responseCallback, final String usedPrefix) {
    127128
    128                 tryGet(tree, request.getActualPath(), new FutureHandler<Path>(responseCallback) {
     129                tryGet(tree, request.getActualPath(), new Future<Path>(responseCallback) {
    129130                        @Override
    130131                        protected void result(final Path path) {
     
    142143                                                throw new FramsticksException().msg("mismatch objects during fetch").arg("path", path);
    143144                                        }
    144                                         responseCallback.pass(new Response(true, "", File.single(printToFile(path.getTextual(), access))));
     145                                        responseCallback.pass(new Response(true, "", printToFile(path.getTextual(), access)));
    145146
    146147                                        return;
     
    149150                                if (request instanceof SetRequest) {
    150151                                        SetRequest setRequest = (SetRequest) request;
    151                                         tree.set(path, access.getFramsClass().getParamEntry(setRequest.getField(), PrimitiveParam.class), setRequest.getValue(), new FutureHandler<Integer>(responseCallback) {
     152                                        tree.set(path, getParam(access, setRequest.getField(), PrimitiveParam.class), setRequest.getValue(), new Future<Integer>(responseCallback) {
    152153                                                @Override
    153154                                                protected void result(Integer flag) {
    154                                                         responseCallback.pass(new Response(true, FlagsUtil.write(SetStateFlags.class, flag, null), null));
    155 
     155                                                        responseCallback.pass(new Response(true, FlagsUtil.write(SetStateFlags.class, flag, null)));
    156156                                                }
    157157                                        });
     
    161161                                if (request instanceof CallRequest) {
    162162                                        final CallRequest callRequest = (CallRequest) request;
    163                                         tree.call(path, access.getFramsClass().getParamEntry(callRequest.getProcedure(), ProcedureParam.class), callRequest.getArguments().toArray(), Object.class, new FutureHandler<Object>(responseCallback) {
     163                                        tree.call(path, getParam(access, callRequest.getProcedure(), ProcedureParam.class), callRequest.getArguments().toArray(), Object.class, new Future<Object>(responseCallback) {
    164164                                                @Override
    165                                                 protected void result(Object result) {
    166                                                         ListSink sink = new ListSink();
    167                                                         sink.print("Result:").breakLine();
    168                                                         sink.print("value:");
    169                                                         sink.print("[");
    170                                                         if (result != null) {
    171                                                                 sink.print(result);
     165                                                protected void result(final Object result) {
     166                                                        if (result == null) {
     167                                                                responseCallback.pass(new Response(true, ""));
     168                                                                return;
    172169                                                        }
    173                                                         sink.print("]");
    174 
    175                                                         responseCallback.pass(new Response(true, "", File.single(new File("", new ListSource(sink.getOut())))));
     170                                                        final Object wrapped = AccessOperations.wrapValueInResultIfPrimitive(result);
     171                                                        final File file = AccessOperations.convert(File.class, wrapped, tree.getRegistry());
     172                                                        responseCallback.pass(new Response(true, "", file));
     173
    176174                                                }
    177175                                        });
     
    184182                                                throw new FramsticksException().msg("info should be available");
    185183                                        }
    186                                         responseCallback.pass(new Response(true, null, File.single(new File(path.getTextual(), new ListSource(Savers.saveFramsClass(new ListSink(), framsClass).getOut())))));
     184                                        responseCallback.pass(new Response(true, null, new File(path.getTextual(), new ListSource(Savers.saveFramsClass(new ListSink(), framsClass).getOut()))));
    187185                                        return;
    188186                                }
     
    191189                                        RegisterRequest register = (RegisterRequest) request;
    192190
    193                                         cliObject.addListener(path, access.getFramsClass().getParamEntry(register.getEventName(), EventParam.class), usedPrefix, responseCallback);
     191                                        cliObject.addListener(path, getParam(access, register.getEventName(), EventParam.class), usedPrefix, responseCallback);
    194192                                        return;
    195193                                }
Note: See TracChangeset for help on using the changeset viewer.