JMS Conector demo (OC4J 10g R3)

Class Dealer

java.lang.Object
  extended byDealer

public class Dealer
extends java.lang.Object


Field Summary
(package private)  MyChannel chan
           
(package private) static int count
           
(package private) static int current_player
           
(package private) static boolean game_started
           
private  MessageDrivenContext m_ctx
           
(package private) static int NUM_PARTICIPANTS
           
(package private) static int NUM_PLAYERS
           
(package private) static java.lang.String[] player
           
(package private) static java.util.Random rand
           
(package private) static int[] score
           
 
Constructor Summary
Dealer()
           
 
Method Summary
private  boolean dealerIsAhead()
          Indicates if the dealer is winning.
 void ejbCreate()
          Called when the server wants to create a new instance of this MDB.
 void ejbRemove()
          Called when the server no longer wants to keep this MDB instance.
private  void notifyPlayer(GameEvent event)
          Let the players know whose turn it is.
 void onMessage(Message msg)
          This method is called whenever a message is sent to the queue associated with this MDB.
private  void processJoinRequest(GameEvent event)
          Process PLAYER_JOIN_REQUEST events.
private  void processTurn(GameEvent event)
          Process PLAYER_REDRAWS and PLAYER_PASSES events.
private  int randomValue()
          Return a random value between 1 and 100.
private  void sendValue(GameEvent event)
          Let all players know the current score of some player.
 void setMessageDrivenContext(MessageDrivenContext ctx)
          Remember the context for this MDB.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_ctx

private MessageDrivenContext m_ctx

chan

MyChannel chan

game_started

static boolean game_started

NUM_PLAYERS

static final int NUM_PLAYERS
See Also:
Constant Field Values

NUM_PARTICIPANTS

static final int NUM_PARTICIPANTS
See Also:
Constant Field Values

count

static int count

player

static java.lang.String[] player

score

static int[] score

current_player

static int current_player

rand

static java.util.Random rand
Constructor Detail

Dealer

public Dealer()
Method Detail

setMessageDrivenContext

public void setMessageDrivenContext(MessageDrivenContext ctx)
Remember the context for this MDB.

Parameters:
ctx - the context for this MDB

ejbCreate

public void ejbCreate()
Called when the server wants to create a new instance of this MDB. Creates a MyChannel object to use for outbound communication.


ejbRemove

public void ejbRemove()
Called when the server no longer wants to keep this MDB instance. Closes the MyChannel object created in ejbCreate.


randomValue

private int randomValue()
Return a random value between 1 and 100.

Returns:
random value

sendValue

private void sendValue(GameEvent event)
                throws java.lang.Exception
Let all players know the current score of some player. (Sends PLAYER_GOT_VALUE event.)

Parameters:
event - an event object for this method to use - its contents on method invocation are unimportant and on method return are undefined
Throws:
java.lang.Exception

notifyPlayer

private void notifyPlayer(GameEvent event)
                   throws java.lang.Exception
Let the players know whose turn it is. (Sends TURN_NOTIFICATION event.)

Parameters:
event - an event object for this method to use - its contents on method invocation are unimportant and on method return are undefined
Throws:
java.lang.Exception

processJoinRequest

private void processJoinRequest(GameEvent event)
                         throws java.lang.Exception
Process PLAYER_JOIN_REQUEST events.

Parameters:
event - the PLAYER_JOIN_REQUEST event
Throws:
java.lang.Exception

dealerIsAhead

private boolean dealerIsAhead()
Indicates if the dealer is winning.

Returns:
true iff the dealer is currently in the lead (and not tied for the lead)

processTurn

private void processTurn(GameEvent event)
                  throws java.lang.Exception
Process PLAYER_REDRAWS and PLAYER_PASSES events.

Parameters:
event - the PLAYER_REDRAWS or PLAYER_PASSES event
Throws:
java.lang.Exception

onMessage

public void onMessage(Message msg)
This method is called whenever a message is sent to the queue associated with this MDB. (See the DestinationName property in the orion-ejb-jar.xml file.)

Parameters:
msg - assumed to be a javax.jms.ObjectMessage containting a GameEvent object

JMS Conector demo (OC4J 10g R3)

Copyright © 2006, Oracle. All rights reserved.