Java Reference
In-Depth Information
Figure 14.9
Output from the
MBean query for
the login count
When we tested this example, we ran several sample logins. We logged in using the
name “mark” and then logged in using the name “ben”. Finally, we logged in a
second time using the name “mark”. We assumed that if all went well, the login
count for Ben would be 1 and the login count for Mark would be 2.
Figure 14.9 shows the output from the JMX console when querying the
MBean for the login count for user mark. You can see that Mark has logged in
successfully twice.
You can see that the number of logins for user Mark is as expected. Now that
you have seen that you can track the number of logins per user, you will turn off
the login capabilities of user Ben.
14.4.4
Removing login privileges
Let's assume that Ben has exceeded his allowed logins for the week, and you
wish to turn off his account for a while. Using the JMX management console, you
can deactivate his account by invoking the allowLogin() method and passing in
a boolean value of false . Figure 14.10 illustrates this process.
When you click the allowLogins button, you should see a success status page.
Now you can try to log in using the user name “ben”, and you should be denied.
Run the command to log in for Ben, and you will see that the status returned is
false . Also, if you look at the count of logins for Ben, you will see that it
remains at 1.
14.5 Example: managing EJBs
In the previous example, we showed you how to create an MBean to contact a
specific EJB to perform a specific task. To complete the example, you had to take
specific steps to create and register the MBean in a JMX agent. Now consider an
EJB that, when created, registers an MBean with a local MBean server contained
in the application server hosting the EJB container. The MBean would be specif-
Search WWH ::




Custom Search