Rahul:
I checked the error log. Actually, I got the error:
15:58:50,555 ERROR (com.mgt.lottery.poker.domain.Game.java:298) [logError] -
Class org.apache.commons.scxml.env.AbstractStateMachine can not access a member
of class com.mgt.lottery.poker.domain.Game with modifiers "private"
java.lang.IllegalAccessException: Class
org.apache.commons.scxml.env.AbstractStateMachine can not access a member of
class com.mgt.lottery.poker.domain.Game with modifiers "private"
I have:
Game game = new Game("myTable");
In game constructor:
super(Game.class.getClassLoader().getResource("com/game.xml"));
The above line throws the exception.
What might have gone wrong?
QD
----- Original Message ----
From: Rahul Akolkar <[email protected]>
To: Commons Users List <[email protected]>
Sent: Mon, July 12, 2010 2:56:28 PM
Subject: Re: [scxml] passing data to the state
On Mon, Jul 12, 2010 at 3:18 PM, qin ding <[email protected]> wrote:
> Thank you, Rahaul, for your quick response.
>
> If I do the following:
>
> Player p = ... // POJO from game client
> getEngine().getRootContext().set("player", p);
>
> then in the states, I should do this to get it out, right?
> Player p = (Player) getEngine().getRootContext().get("player");
>
> Somehow, when I do this, I get null out of the RootContext(). Any idea?
>
<snip/>
You should certainly get back what you've last set it to. I assume its
not null before the set, in which case its being modified elsewhere,
so we'll need more details.
-Rahul
> I will study the link you sent to me.
>
>
>
> ----- Original Message ----
> From: Rahul Akolkar <[email protected]>
> To: Commons Users List <[email protected]>
> Sent: Mon, July 12, 2010 1:02:04 PM
> Subject: Re: [scxml] passing data to the state
>
> On Mon, Jul 12, 2010 at 12:49 PM, qin ding <[email protected]> wrote:
>> I am learning commons scxml. I am experimenting writing a poker game using
>> activemq and scxml.
>>
>>
>> So, I have my config xml defined as follows:
>>
>> <?xml version="1.0"?>
>> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>> version="1.0"
>> initialstate="waitingRound">
>> <datamodel>
>> <data name="inputPlayer">
>> <!-- Note namespace declaration in line below -->
>> <player xmlns="com.mgt.lottery.poker.domain">
>> <id/>
>> <name/>
>> <chips/>
>> <sitin/>
>> <winner/>
>> <betOption/>
>> <gainedChips/>
>> <popocketCards/>
>> <description/>
>> <bestHand/>
>> </player>
>> </data>
>> </datamodel>
>> <state id="waitingRound">
>> <!-- shuffle deck and check players and empty pot -->
>> <transition event="game.start" target="preflopRound"/>
>> </state>
>> <state id="preflopRound">
>> <!-- place small/big blinds in pot and deal each player two hole
cards
>> -->
>> <transition target="firstBettingRound"/>
>> </state>
>> <state id="firstBettingRound">
>> <transition event="game.flop" target="flopRound"/>
>> <transition event="game.showdown" target="showdownRound"/>
>> </state>
>> <state id="flopRound">
>> <!-- deal three cards in the community -->
>> <transition target="secondBettingRound"/>
>> </state>
>> <state id="secondBettingRound">
>> <onentry>
>> <var name="inputPlayer" expr="#{request$player}" />
>> </onentry>
>> <transition event="game.turn" target="turnRound"/>
>> <transition event="game.showdown" target="showdownRound"/>
>> </state>
>> <state id="turnRound">
>> <!-- deal a 4th card in the community -->
>> <transition target="thirdBettingRound"/>
>> </state>
>> <state id="thirdBettingRound">
>> <!-- deal a 4th card in the community -->
>> <onentry>
>> <var name="inputPlayer" expr="#{request$player}" />
>> </onentry>
>> <transition event="game.final" target="finalRound"/>
>> <transition event="game.showdown" target="showdownRound"/>
>> </state>
>> <state id="finalRound">
>> <!-- deal a 5th card in the community -->
>> <transition target="finalBettingRound"/>
>> </state>
>> <state id="finalBettingRound">
>> <!-- bet, check, call, raise, or fold -->
>> <onentry>
>> <var name="inputPlayer" expr="#{request$player}" />
>> </onentry>
>> <transition event="game.showdown" target="showdownRound"/>
>> </state>
>> <state id="showdownRound">
>> <transition event="game.reset" target="waitingRound"/>
>> </state>
>> </scxml>
>>
>> My questions:
>> How can I pass my pojo "Player" to the firstBettingRound, secondBettingRound
>>and
>> etc? This player object is coming from game client with betting information.
>>
> <snip/>
>
> Data (including POJOs) can be passed into an executor either via an
> external event's payload or via procedural injection to the executor's
> root context.
>
> So, as an example of the latter, the following will create a variable
> "player" in the executor's root context and bind the POJO to it:
>
> Player p = ... // POJO from game client
> getEngine().getRootContext().set("player", p);
>
> Subsequently, the variable "player" may be used in expressions in the
> state machine.
>
> In the above state machine, the variable "inputPlayer" doesn't seem to
> be accessed anywhere, so unless the player information is needed for
> the state machine logic, it can perhaps stay out of the state
> machine's root context altogether (given the pattern of use you
> mention below).
>
>
>> After the activemq delivers it to the server end, how can I know which
method
>> to call? I think scxml handles the the state of game, so I have to say
>>
>>
>> Set states = getEngine().getCurrentStatus().getStates();
>> return ((org.apache.commons.scxml.model.State) states.iterator().
>> next()).getId();
>>
>> if the current state is firstBettingRound, I do
>> game.firstBettingRound(player); Is it correct
>>
> <snap/>
>
> If you wanted to map states to activities that way. There are a few
> patterns that are commonly used, see:
>
> http://commons.apache.org/scxml/guide/using-commons-scxml.html
>
> -Rahul
>
>
>> I seem unable to find the example to show me how to pass pojo to the state
>> correcponded method. If I am completely wrong with my approach, Please
> advise.
>> Thank you very much.
>>
>> QD
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]