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?.

Location:
java/main/src/main/java/com/framsticks/communication
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/communication/ClientSideManagedConnection.java

    r103 r105  
    99import com.framsticks.communication.queries.UseRequest;
    1010import com.framsticks.communication.queries.VersionRequest;
    11 import com.framsticks.core.Path;
    1211import com.framsticks.params.ListSource;
     12import com.framsticks.structure.Path;
    1313import com.framsticks.util.*;
    1414import com.framsticks.util.dispatching.AtOnceDispatcher;
    1515import com.framsticks.util.dispatching.Dispatcher;
    1616import com.framsticks.util.dispatching.Dispatching;
    17 import com.framsticks.util.dispatching.ExceptionResultHandler;
     17import com.framsticks.util.dispatching.FutureHandler;
    1818import com.framsticks.util.dispatching.Future;
    19 import com.framsticks.util.dispatching.FutureHandler;
    2019import com.framsticks.util.dispatching.JoinableState;
    2120import com.framsticks.util.lang.Casting;
     
    195194        }
    196195
    197         private void sendNextUseRequest(final Iterator<String> featuresIterator, final Future<Void> future) {
     196        private void sendNextUseRequest(final Iterator<String> featuresIterator, final FutureHandler<Void> future) {
    198197                if (!featuresIterator.hasNext()) {
    199198                        future.pass(null);
     
    214213        }
    215214
    216         private void sendQueryVersion(final int version, final Future<Void> future) {
     215        private void sendQueryVersion(final int version, final FutureHandler<Void> future) {
    217216                send(new VersionRequest().version(version), new ClientSideResponseFuture(future) {
    218217                        @Override
     
    335334                }
    336335
    337                 final Future<File> future = new Future<File>() {
     336                final FutureHandler<File> future = new FutureHandler<File>() {
    338337
    339338                        protected void send(final File result) {
     
    415414        }
    416415
    417         protected final ExceptionResultHandler closeOnFailure = new ExceptionResultHandler() {
     416        protected final ExceptionHandler closeOnFailure = new ExceptionHandler() {
    418417
    419418                @Override
     
    428427                startClientConnection(this);
    429428
    430                 sendQueryVersion(1, new FutureHandler<Void>(closeOnFailure) {
     429                sendQueryVersion(1, new Future<Void>(closeOnFailure) {
    431430
    432431                        @Override
     
    451450        protected final Map<String, EventListener<File>> registeredListeners = new HashMap<>();
    452451
    453         public <C> void addListener(String path, final EventListener<File> listener, final Dispatcher<C> dispatcher, final Future<Void> future) {
     452        public <C> void addListener(String path, final EventListener<File> listener, final Dispatcher<C> dispatcher, final FutureHandler<Void> future) {
    454453                send(new RegisterRequest().path(path), dispatcher, new ClientSideResponseFuture(future) {
    455454                        @Override
     
    463462        }
    464463
    465         public <C> void removeListener(EventListener<File> listener, final Dispatcher<C> dispatcher, final Future<Void> future) {
     464        public <C> void removeListener(EventListener<File> listener, final Dispatcher<C> dispatcher, final FutureHandler<Void> future) {
    466465                String eventPath = null;
    467466                synchronized (registeredListeners) {
  • java/main/src/main/java/com/framsticks/communication/ClientSideRawConnection.java

    r97 r105  
    22
    33import com.framsticks.params.annotations.FramsClassAnnotation;
    4 import com.framsticks.util.dispatching.ExceptionResultHandler;
     4import com.framsticks.util.ExceptionHandler;
    55import com.framsticks.util.dispatching.RunAt;
    66
     
    2323        }
    2424
    25         public void send(final String line, ExceptionResultHandler handler) {
     25        public void send(final String line, ExceptionHandler handler) {
    2626
    2727                senderThread.dispatch(new RunAt<ClientSideRawConnection>(handler) {
  • java/main/src/main/java/com/framsticks/communication/ClientSideResponseFuture.java

    r98 r105  
    11package com.framsticks.communication;
    22
     3import com.framsticks.util.ExceptionHandler;
    34import com.framsticks.util.FramsticksException;
    4 import com.framsticks.util.dispatching.ExceptionResultHandler;
    5 import com.framsticks.util.dispatching.FutureHandler;
     5import com.framsticks.util.dispatching.Future;
    66
    7 public abstract class ClientSideResponseFuture extends FutureHandler<Response> {
     7public abstract class ClientSideResponseFuture extends Future<Response> {
    88
    9         public ClientSideResponseFuture(ExceptionResultHandler handler) {
     9        public ClientSideResponseFuture(ExceptionHandler handler) {
    1010                super(handler);
    1111        }
  • java/main/src/main/java/com/framsticks/communication/Connection.java

    r102 r105  
    55import com.framsticks.params.annotations.FramsClassAnnotation;
    66import com.framsticks.params.annotations.ParamAnnotation;
     7import com.framsticks.util.ExceptionHandler;
    78import com.framsticks.util.FramsticksException;
    89import com.framsticks.util.io.Encoding;
     
    2526import com.framsticks.util.dispatching.Dispatcher;
    2627import com.framsticks.util.dispatching.Dispatching;
    27 import com.framsticks.util.dispatching.ExceptionResultHandler;
    2828import com.framsticks.util.dispatching.Joinable;
    2929import com.framsticks.util.dispatching.JoinableCollection;
     
    3535
    3636@FramsClassAnnotation
    37 public abstract class Connection extends AbstractJoinable implements JoinableParent, ExceptionResultHandler {
     37public abstract class Connection extends AbstractJoinable implements JoinableParent, ExceptionHandler {
    3838
    3939        protected final static Logger log = LogManager.getLogger(Connection.class);
     
    5252        protected final Set<ConnectionListener> listeners = new HashSet<>();
    5353
    54         protected ExceptionResultHandler exceptionHandler = ThrowExceptionHandler.getInstance();
     54        protected ExceptionHandler exceptionHandler = ThrowExceptionHandler.getInstance();
    5555
    5656        /**
     
    301301         * @return the handler
    302302         */
    303         public ExceptionResultHandler getExceptionHandler() {
     303        public ExceptionHandler getExceptionHandler() {
    304304                return exceptionHandler;
    305305        }
     
    308308         * @param handler the handler to set
    309309         */
    310         public void setExceptionHandler(ExceptionResultHandler handler) {
     310        public void setExceptionHandler(ExceptionHandler handler) {
    311311                this.exceptionHandler = handler;
    312312        }
     
    346346        }
    347347
    348         public final void sendFile(final String header, final File file, final Integer id, ExceptionResultHandler handler) {
     348        public final void sendFile(final String header, final File file, final Integer id, ExceptionHandler handler) {
    349349                senderThread.dispatch(new RunAt<Connection>(handler) {
    350350                        @Override
  • java/main/src/main/java/com/framsticks/communication/File.java

    r101 r105  
    11package com.framsticks.communication;
    22
    3 import java.util.ArrayList;
    4 import java.util.List;
    53
    64import javax.annotation.Nonnull;
     
    3129        }
    3230
    33         public static List<File> single(File file) {
    34                 List<File> result = new ArrayList<File>();
    35                 result.add(file);
    36                 return result;
    37         }
    38 
    3931        @Override
    4032        public String toString() {
  • java/main/src/main/java/com/framsticks/communication/RequestHandler.java

    r98 r105  
    22
    33import com.framsticks.communication.queries.ApplicationRequest;
    4 import com.framsticks.util.dispatching.ExceptionResultHandler;
     4import com.framsticks.util.ExceptionHandler;
    55
    66/**
    77 * @author Piotr Sniegowski
    88 */
    9 public interface RequestHandler extends ExceptionResultHandler {
     9public interface RequestHandler extends ExceptionHandler {
    1010        public void handle(ApplicationRequest request, ServerSideResponseFuture responseCallback);
    1111}
  • java/main/src/main/java/com/framsticks/communication/Response.java

    r96 r105  
    11package com.framsticks.communication;
    22
     3import java.util.Arrays;
    34import java.util.List;
    45
     
    1011        protected final String comment;
    1112        protected final List<File> files;
     13
     14        public Response(boolean ok, String comment, File... files) {
     15                this(ok, comment, (files.length == 0 ? null : Arrays.asList(files)));
     16        }
    1217
    1318        public Response(boolean ok, String comment, List<File> files) {
  • java/main/src/main/java/com/framsticks/communication/ServerSideManagedConnection.java

    r103 r105  
    4646                if (request instanceof ProtocolRequest) {
    4747                        if (request instanceof VersionRequest) {
    48                                 responseCallback.pass(new Response(true, null, null));
     48                                responseCallback.pass(new Response(true, null));
    4949                                return;
    5050                        }
     
    5353                                if (feature.equals("request_id")) {
    5454                                        requestIdEnabled = true;
    55                                         responseCallback.pass(new Response(true, null, null));
     55                                        responseCallback.pass(new Response(true, null));
    5656                                        return;
    5757                                }
    5858                                if (feature.equals("call_empty_result")) {
    59                                         responseCallback.pass(new Response(true, null, null));
     59                                        responseCallback.pass(new Response(true, null));
    6060                                        return;
    6161                                }
    6262                                if (feature.equals("needfile_id")) {
    63                                         responseCallback.pass(new Response(true, null, null));
     63                                        responseCallback.pass(new Response(true, null));
    6464                                        return;
    6565                                }
    66                                 responseCallback.pass(new Response(false, "unknown feature: " + feature, null));
     66                                responseCallback.pass(new Response(false, "unknown feature: " + feature));
    6767                                return;
    6868                        }
     
    7070                }
    7171                log.error("unhandled request: {}", request);
    72                 responseCallback.pass(new Response(false, "unhandled", null));
     72                responseCallback.pass(new Response(false, "unhandled"));
    7373        }
    7474
     
    120120                        e.arg("id", id.get()).arg("line", line);
    121121                        log.error("error: ", e);
    122                         respond(new Response(false, "invalid input: " + e.getMsg(), null), id.get());
     122                        respond(new Response(false, "invalid input: " + e.getMsg()), id.get());
    123123                        return;
    124124                }
  • java/main/src/main/java/com/framsticks/communication/ServerSideResponseFuture.java

    r99 r105  
    22
    33import com.framsticks.util.FramsticksException;
    4 import com.framsticks.util.dispatching.Future;
     4import com.framsticks.util.dispatching.FutureHandler;
    55
    66/**
    77 * @author Piotr Sniegowski
    88 */
    9 public abstract class ServerSideResponseFuture extends Future<Response> {
     9public abstract class ServerSideResponseFuture extends FutureHandler<Response> {
    1010
    1111        @Override
    1212        public final void handle(FramsticksException e) {
    13                 result(new Response(false, e.getClass().getCanonicalName() + ": " + e.getMessage(), null));
     13                result(new Response(false, e.getClass().getCanonicalName() + ": " + e.getMessage()));
    1414        }
    1515
  • java/main/src/main/java/com/framsticks/communication/queries/NeedFile.java

    r101 r105  
    22
    33import com.framsticks.communication.File;
    4 import com.framsticks.util.dispatching.Future;
     4import com.framsticks.util.dispatching.FutureHandler;
    55import com.framsticks.util.lang.Strings;
    66
     
    99        protected final String suggestedName;
    1010        protected final String description;
    11         protected final Future<File> future;
     11        protected final FutureHandler<File> future;
    1212
    1313        /**
     
    1616         * @param future
    1717         */
    18         public NeedFile(String suggestedName, String description, Future<File> future) {
     18        public NeedFile(String suggestedName, String description, FutureHandler<File> future) {
    1919                this.suggestedName = suggestedName;
    2020                this.description = description;
     
    3939         * @return the future
    4040         */
    41         public Future<File> getFuture() {
     41        public FutureHandler<File> getFuture() {
    4242                return future;
    4343        }
  • java/main/src/main/java/com/framsticks/communication/queries/RegisterRequest.java

    r99 r105  
    11package com.framsticks.communication.queries;
    22
    3 import com.framsticks.core.Path;
     3import com.framsticks.structure.Path;
    44import com.framsticks.util.lang.Pair;
    55
Note: See TracChangeset for help on using the changeset viewer.