KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > security > bean > CalculatorBean


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.security.bean;
8
9 import javax.annotation.security.RolesAllowed;
10 import javax.ejb.Stateless JavaDoc;
11 import javax.ejb.TransactionAttribute JavaDoc;
12 import javax.ejb.TransactionAttributeType JavaDoc;
13 import javax.annotation.security.PermitAll;
14 import javax.annotation.security.RolesAllowed;
15 import javax.ejb.Remote JavaDoc;
16 import org.jboss.annotation.security.SecurityDomain;
17 import org.jboss.annotation.security.SecurityDomain;
18
19 @Stateless JavaDoc
20 @SecurityDomain("other")
21 @Remote JavaDoc(Calculator.class)
22 public class CalculatorBean implements Calculator
23 {
24    @PermitAll
25    @TransactionAttribute JavaDoc(TransactionAttributeType.REQUIRES_NEW)
26    public int add(int x, int y)
27    {
28       return x + y;
29    }
30
31    @RolesAllowed({"student"})
32    public int subtract(int x, int y)
33    {
34       return x - y;
35    }
36
37    @RolesAllowed({"teacher"})
38    public int divide(int x, int y)
39    {
40       return x / y;
41    }
42 }
43
Popular Tags