Ignore:
Timestamp:
07/10/13 22:41:02 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGTS:

  • complete events implementation
  • add CLI in Java Framsticks server
  • add automatic registration for events in GUI
  • improve objects fetching (object are never overwritten with new instances)
  • properly react for ListChange? events
  • add ListPanel? with table view
    • columns to be shown may be statically specified in configuration
    • currently modyfying data through tables is not available
  • improve maven configuration
    • configuration file may be specified without touching pom.xml

CHANGELOG:
Extract constants from Flags into ParamFlags? and SetStateFlags?.

Extract flags I/O to FlagsUtils? class.

Configured maven to exec given resource configuration.

For example:
mvn exec:exec -Dframsticks.config=/configs/managed-console.xml

Cleanup pom.xml

Rename ObjectTree? to LocalTree? (also make LocalTree? and RemoteTree? final).

Minor change.

Add maximum number of columns in ListPanelProvider?.

Improve ColumnsConfig? interpretation.

Automatically fill FramsClass?.name if trying to construct empty.

Improve identitifer case mangling in XmlLoader?.

Introduce configurable ColumnsConfig?.

Draft working version of ListPanel?.

Table is being shown (although empty).

More improvements to table building.

Move some functionality from Frame to TreeModel?.

Move tree classes in gui to separate package.

Remove old table related classes.

Add draft implementation of TableModel?.

Redirect ParamBuilder?.forAccess to AccessInterface?.

Optimize ParamBuilder?.forAccess()

Do not clear list when loading.

Do not load fetched values directly.

Implement different AccessInterface? copying policy.

Optimize fetching values routine.

Remove Mode enum (work out get semantics).

Some improvements to ListChange? handling.

Improve UniqueListAccess?.

Add reaction for ListChanges? in the TreeNode?.

EventListeners? are being added in the TreeNode?.

Listeners for ListParams? are now very naive (they download
whole list).

Automatially register on events in GUI.

Events are working in RemoteTree? and Server.

Move listeners to the ClientSideManagedConnection?.

Remove old classes responsible for event subscriptions.

Improve event reading.

Improve events handling at server side.

Add register attribute in FramsClassAnnotation?
to automatically also register other classes.

Registering events works.

Setup for remote listeners registration.

More improvements.

Minor changes.

Add rootTree to the ClientAtServer?.

Moving CLI to the ClientAtServer?.

Fix bug: use Void.TYPE instead of Void.class

More development around CLI.

  • Improve Path resolving.

Add synthetic root to ObjectTree?.

It is needed to allow sybling for the original root
that would containg CLI.

Some work with registering events in RemoteTree?.

Draft implementation of listener registering in RemoteTree?.

Support events registration in the ObjectTree?.

Add events support to ReflectionAccess?.

EventParam? is recognized by ParamCandidate?.

Prepare interface for Events across project.

Add EventListener? and API for listeners in Tree.

File:
1 edited

Legend:

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

    r98 r99  
    88import com.framsticks.communication.queries.GetRequest;
    99import com.framsticks.communication.queries.InfoRequest;
     10import com.framsticks.communication.queries.RegisterRequest;
    1011import com.framsticks.communication.queries.SetRequest;
     12import com.framsticks.core.LocalTree;
    1113import com.framsticks.core.Tree;
    1214import com.framsticks.core.Path;
    1315import com.framsticks.params.*;
     16import com.framsticks.params.types.EventParam;
    1417import com.framsticks.params.types.ProcedureParam;
    1518import com.framsticks.parsers.Savers;
    1619import com.framsticks.util.FramsticksException;
     20import com.framsticks.util.Misc;
    1721import com.framsticks.util.dispatching.AbstractJoinable;
    1822import com.framsticks.util.dispatching.Dispatching;
     
    2226import com.framsticks.util.dispatching.JoinableParent;
    2327import com.framsticks.util.dispatching.JoinableState;
     28import com.framsticks.util.lang.FlagsUtil;
     29import com.framsticks.util.lang.Strings;
     30
    2431import static com.framsticks.core.TreeOperations.*;
    2532
    2633import java.net.Socket;
    27 import java.util.LinkedList;
    28 import java.util.List;
    2934
    3035/**
     
    3439
    3540        protected final Server server;
    36         protected final Tree tree;
     41        protected final Tree contentTree;
     42        protected final Object treeRootObject;
    3743        protected final ServerSideManagedConnection connection;
     44
     45        protected final Cli cliObject;
     46        protected final LocalTree rootTree;
     47
     48
     49        protected final FramsClass rootFramsClass;
     50        protected final Object root;
     51        protected final String contentPrefix;
    3852
    3953        public ClientAtServer(Server server, Socket socket) {
    4054                this.server = server;
    41                 this.tree = server.hosted;
     55                this.contentTree = server.hosted;
    4256                this.connection = new ServerSideManagedConnection(socket, this);
     57
     58                treeRootObject = contentTree.getAssignedRoot().getObject();
     59                Misc.throwIfNull(treeRootObject);
     60
     61                cliObject = new Cli(this);
     62                rootTree = new LocalTree();
     63                // rootTree.setDispatcher(new AtOnceDispatcher<Tree>());
     64                rootTree.setDispatcher(server.getHosted().getDispatcher());
     65                assert rootTree.getDispatcher() != null;
     66
     67                final FramsClass framsClass = bindAccess(contentTree.getAssignedRoot()).getFramsClass();
     68                final String id = Strings.uncapitalize(framsClass.getName());
     69                contentPrefix = "/" + id;
     70                final String rootFramsClassId = id + "Root";
     71
     72                rootFramsClass = FramsClass.build()
     73                        .idAndName(rootFramsClassId)
     74                        .param(Param.build().id(id).name(framsClass.getName()).type("o " + framsClass.getId()))
     75                        .param(Param.build().id("cli").name("CLI").type("o Cli"))
     76                        .finish();
     77
     78                // rootTree.putInfoIntoCache(rootFramsClass);
     79                rootTree.getRegistry().putFramsClass(rootFramsClass);
     80                rootTree.getRegistry().registerAndBuild(Cli.class);
     81                rootTree.getRegistry().registerAndBuild(CliEvent.class);
     82
     83                AccessInterface access = new PropertiesAccess(rootFramsClass);
     84
     85                root = access.createAccessee();
     86                access.select(root);
     87                access.set(id, treeRootObject);
     88                access.set("cli", cliObject);
     89
     90                rootTree.assignRootParam(access.buildParam(new ParamBuilder()).name(rootFramsClassId).finish(CompositeParam.class));
     91                rootTree.assignRootObject(root);
     92
    4393        }
    4494
     
    52102                assureNotEmpty(request.getPath());
    53103
    54                 tryGet(tree, request.getPath(), new FutureHandler<Path>(responseCallback) {
     104                if (request.getPath().startsWith(contentPrefix)) {
     105                        String p = request.getPath().substring(contentPrefix.length());
     106                        request.path(p.equals("") ? "/" : p);
     107                        handleInTree(contentTree, request, responseCallback, contentPrefix);
     108                        return;
     109                }
     110
     111                handleInTree(rootTree, request, responseCallback, "");
     112        }
     113
     114        public static File printToFile(String path, AccessInterface access) {
     115                ListSink sink = new ListSink();
     116                access.save(sink);
     117                return new File(path, new ListSource(sink.getOut()));
     118        }
     119
     120        protected void handleInTree(final Tree tree, final ApplicationRequest request, final ServerSideResponseFuture responseCallback, final String usedPrefix) {
     121
     122                tryGet(tree, request.getActualPath(), new FutureHandler<Path>(responseCallback) {
    55123                        @Override
    56124                        protected void result(final Path path) {
    57125
    58                                 if (!path.getTextual().equals(request.getPath())) {
    59                                         throw new FramsticksException().msg("invalid path").arg("path", request.getPath());
     126                                if (!path.getTextual().equals(request.getActualPath())) {
     127                                        throw new FramsticksException().msg("invalid path").arg("path", request.getActualPath());
    60128                                }
    61129
    62130                                // final AccessInterface access = tree.prepareAccess(path);
    63131                                final AccessInterface access = bindAccess(path);
     132
     133                                if (request instanceof GetRequest) {
     134                                        Object result = path.getTopObject();
     135                                        if (result != access.getSelected()) {
     136                                                throw new FramsticksException().msg("mismatch objects during fetch").arg("path", path);
     137                                        }
     138                                        responseCallback.pass(new Response(true, "", File.single(printToFile(path.getTextual(), access))));
     139
     140                                        return;
     141                                }
    64142
    65143                                if (request instanceof SetRequest) {
     
    69147                                                @Override
    70148                                                protected void result(Integer flag) {
    71                                                         responseCallback.pass(new Response(true, Flags.write(flag, null), null));
     149                                                        responseCallback.pass(new Response(true, FlagsUtil.write(SetStateFlags.class, flag, null), null));
    72150
    73151                                                }
     
    76154                                }
    77155
    78                                 if (request instanceof GetRequest) {
    79                                         Object result = path.getTopObject();
    80                                         if (result != access.getSelected()) {
    81                                                 throw new FramsticksException().msg("mismatch objects during fetch").arg("path", path);
    82                                         }
    83                                         List<File> files = new LinkedList<File>();
    84                                         ListSink sink = new ListSink();
    85                                         access.save(sink);
    86                                         files.add(new File(path.getTextual(), new ListSource(sink.getOut())));
    87                                         responseCallback.pass(new Response(true, "", files));
    88 
    89                                         return;
    90                                 }
    91156                                if (request instanceof CallRequest) {
    92157                                        final CallRequest callRequest = (CallRequest) request;
     
    107172                                        return;
    108173                                }
     174
    109175                                if (request instanceof InfoRequest) {
    110176                                        FramsClass framsClass = getInfo(path);
     
    116182                                }
    117183
     184                                if (request instanceof RegisterRequest) {
     185                                        RegisterRequest register = (RegisterRequest) request;
     186
     187                                        cliObject.addListener(path, access.getFramsClass().getParamEntry(register.getEventName(), EventParam.class), usedPrefix, responseCallback);
     188                                        return;
     189                                }
     190
    118191                                throw new FramsticksException().msg("invalid request type: " + request.getCommand());
    119192                        }
     
    148221        @Override
    149222        public void handle(FramsticksException exception) {
    150                 tree.handle(exception);
     223                contentTree.handle(exception);
     224        }
     225
     226        /**
     227         * @return the tree
     228         */
     229        public Tree getTree() {
     230                return contentTree;
    151231        }
    152232
Note: See TracChangeset for help on using the changeset viewer.