Java Reference
In-Depth Information
public void ejbRemove()
{
System.out.println("EJBCreate::Removing New UserInfo Bean");
}
public String ejbFindByPrimaryKey( String userName )
throws FinderException,RemoteException
{
System.out.println("find::Current Count:" + count++);
this.userName=userName;
return userName;
}
public void setEntityContext( EntityContext ctx )
{
this.ctx = ctx;
}
public void unsetEntityContext()
{
this.ctx = null;
}
public void ejbActivate()
{
System.out.println( "Activate called:"+userName );
}
public void ejbPassivate()
{
System.out.println( "Passivate called" );
}
}
You can see from the listing that the entity bean saves the number of logins for a
particular user. It also contains the permissions to log in (in this case, a
boolean
).
The
login()
method checks to see if the user has login permission and returns
that status to the calling program. It also increments the number of logins the
user has completed.
As stated earlier, the
setLoginAllowed()
method enables or disables a user's
account, based on the value of the
boolean
input parameter.
The methods that appear after the
setLoginAllowed()
method are required
by the
EJB
specification, but you don't need to provide an implementation for
this example. All in all, the code for the entity bean is quite simpleāit just con-
tains some information and behavior about the login process for an application.
That concludes the construction of the
EJB
. Now it is time to move on to the
construction of the MBean you will use to interact with the
UserInfo
EJB
.