Permalink
Browse files

new transaction deserializer

  • Loading branch information...
1 parent f77a633 commit 4ec7c80169bca9b81261ec91a3817d2666d17a7d @laforge49 committed May 16, 2012
Showing with 72 additions and 0 deletions.
  1. +72 −0 src/main/java/org/agilewiki/jfile/transactions/Deserializer.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2012 Bill La Forge
+ *
+ * This file is part of AgileWiki and is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License (LGPL) as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * or navigate to the following url http://www.gnu.org/licenses/lgpl-2.1.txt
+ *
+ * Note however that only Scala, Java and JavaScript files are being covered by LGPL.
+ * All other files are covered by the Common Public License (CPL).
+ * A copy of this license is also included and can be
+ * found as well at http://www.opensource.org/licenses/cpl1.0.txt
+ */
+package org.agilewiki.jfile.transactions;
+
+import org.agilewiki.jactor.Mailbox;
+import org.agilewiki.jactor.RP;
+import org.agilewiki.jid.scalar.vlens.actor.ActorJid;
+import org.agilewiki.jid.scalar.vlens.actor.RootJid;
+
+/**
+ * Partially deserializes the transactions in a block.
+ */
+public class Deserializer extends BlockSource implements BlockProcessor {
+
+ /**
+ * Create a LiteActor
+ *
+ * @param mailbox A mailbox which may be shared with other actors.
+ */
+ public Deserializer(Mailbox mailbox) {
+ super(mailbox);
+ }
+
+ /**
+ * The application method for processing requests sent to the actor.
+ *
+ * @param request A request.
+ * @param rp The response processor.
+ * @throws Exception Any uncaught exceptions raised while processing the request.
+ */
+ @Override
+ protected void processRequest(Object request, RP rp) throws Exception {
+ Class reqClass = request.getClass();
+
+ if (reqClass == ProcessBlock.class) {
+ ProcessBlock req = (ProcessBlock) request;
+ RootJid rootJid = req.block.getRootJid(getMailbox(), getParent());
+ TransactionListJid transactionListJid = (TransactionListJid) rootJid.getValue();
+ int i = 0;
+ while (i < transactionListJid.size()) {
+ ActorJid actorJid = (ActorJid) transactionListJid.iGet(i);
+ actorJid.getValue();
+ i += 1;
+ }
+ req.send(this, blockFlowBuffer, rp);
+ return;
+ }
+
+ throw new UnsupportedOperationException(reqClass.getName());
+ }
+}

0 comments on commit 4ec7c80

Please sign in to comment.