-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/org/agilewiki/jactor/continuation/Continuation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2011 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.jactor.continuation; | ||
|
||
import org.agilewiki.jactor.Actor; | ||
import org.agilewiki.jactor.RP; | ||
import org.agilewiki.jactor.lpc.JLPCActor; | ||
import org.agilewiki.jactor.lpc.Request; | ||
import org.agilewiki.jactor.lpc.TargetActor; | ||
|
||
public class Continuation { | ||
private TargetActor targetActor; | ||
private RP _rp; | ||
|
||
public Continuation(TargetActor targetActor, RP _rp) { | ||
this.targetActor = targetActor; | ||
this._rp = _rp; | ||
} | ||
|
||
public void response(Object rsp) throws Exception { | ||
(new ContinuationRequest(_rp, rsp)).sendEvent(targetActor); | ||
} | ||
} | ||
|
||
class ContinuationRequest extends Request<Object, TargetActor> { | ||
private RP _rp; | ||
private Object rsp; | ||
|
||
ContinuationRequest(RP _rp, Object rsp) { | ||
this._rp = _rp; | ||
this.rsp = rsp; | ||
} | ||
|
||
@Override | ||
public boolean isTargetType(Actor targetActor) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void processRequest(JLPCActor targetActor, RP rp) throws Exception { | ||
_rp.processResponse(rsp); | ||
rp.processResponse(null); | ||
} | ||
} |