com.ibm.websphere.samples.activitysessionEJB
Class MasterMindGameBean

java.lang.Object
  extended by com.ibm.websphere.samples.activitysessionEJB.MasterMindGameBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class MasterMindGameBean
extends java.lang.Object
implements javax.ejb.SessionBean

This is the MasterMindBean Class, part of the ActivitySessions Samples. It is a Stateful Session Bean. The bean will be deployed with an activation policy of ActivitySession. It contains private instance data which is transient.

See Also:
Serialized Form

Field Summary
static int MAX_GUESSES
           
static int NUMBER_OF_COLORS
           
static int NUMBER_OF_ELEMENTS
           
 
Constructor Summary
MasterMindGameBean()
           
 
Method Summary
 boolean calculate(int[] guess)
          Calculates the results of the latest guess.
 void ejbActivate()
          This required callback method is user for lifecycle notification.
 void ejbCreate()
          This required callback method is user for lifecycle notification.
 void ejbPassivate()
          This required callback method is user for lifecycle notification.
 void ejbRemove()
          This required callback method is user for lifecycle notification.
 int[][] getGuessArray()
          Public accessor for the array of guesses
 int getGuessNumber()
          Public accessor for the number of guesses made.
 int[][] getResultsArray()
          Public accessor for the array of results.
 int[] getTarget()
          Public accessor for the target code.
 void newGame()
          This method resets the instance variables of the bean to default values and generates a new target code to be guessed.
 void setSessionContext(javax.ejb.SessionContext ctx)
          This required callback method sets the session context attribute for this SessionBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBER_OF_ELEMENTS

public static final int NUMBER_OF_ELEMENTS
See Also:
Constant Field Values

NUMBER_OF_COLORS

public static final int NUMBER_OF_COLORS
See Also:
Constant Field Values

MAX_GUESSES

public static final int MAX_GUESSES
See Also:
Constant Field Values
Constructor Detail

MasterMindGameBean

public MasterMindGameBean()
Method Detail

calculate

public boolean calculate(int[] guess)
Calculates the results of the latest guess.

Parameters:
guess - char [] Represents the most recent guess
Returns:
void

getGuessArray

public int[][] getGuessArray()
Public accessor for the array of guesses

Returns:
int[][]

getGuessNumber

public int getGuessNumber()
Public accessor for the number of guesses made.

Returns:
int The number of guesses made.

getResultsArray

public int[][] getResultsArray()
Public accessor for the array of results.

Returns:
int[][]

getTarget

public int[] getTarget()
Public accessor for the target code.

Returns:
int[] - an array of integers that represnts the target code

newGame

public void newGame()
This method resets the instance variables of the bean to default values and generates a new target code to be guessed.


ejbActivate

public void ejbActivate()
This required callback method is user for lifecycle notification. No actions need to be taken for the MasterMindBean.

Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbCreate

public void ejbCreate()
This required callback method is user for lifecycle notification. No actions need to be taken for the MasterMindBean.


ejbPassivate

public void ejbPassivate()
This required callback method is user for lifecycle notification. No actions need to be taken for the MasterMindBean.

Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
This required callback method is user for lifecycle notification. No actions need to be taken for the MasterMindBean.

Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
This required callback method sets the session context attribute for this SessionBean

Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
ctx - javax.ejb.SessionContext