KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > jacc > StatelessBean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22
23 package org.jboss.ejb3.test.jacc;
24
25 import javax.annotation.security.RolesAllowed;
26 import javax.annotation.security.PermitAll;
27 import javax.ejb.Remote JavaDoc;
28 import javax.persistence.EntityManager;
29 import javax.persistence.PersistenceContext;
30
31 import org.jboss.annotation.security.SecurityDomain;
32 import org.jboss.annotation.ejb.AspectDomain;
33
34 /**
35  *
36  * @author <a HREF="mailto:kabir.khan@jboss.org">Kabir Khan</a>
37  * @version $Revision: 55958 $
38  */

39 @javax.ejb.Stateless JavaDoc
40 @Remote JavaDoc (Stateless.class)
41 @SecurityDomain ("other")
42 //@AspectDomain("JACC Stateless Bean")
43
public class StatelessBean implements Stateless
44 {
45    //TODO: put this in again once we update the hibernate jars (changes already made to hibernate)
46
//@PersistenceContext(unitName="jacc-test")
47
@PersistenceContext
48    EntityManager em;
49
50    @PermitAll
51    public int unchecked(int i)
52    {
53       System.out.println("stateless unchecked");
54       return i;
55    }
56
57    @RolesAllowed ("allowed")
58    public int checked(int i)
59    {
60       System.out.println("stateless checked");
61       return i;
62    }
63
64    @PermitAll
65    public AllEntity insertAllEntity()
66    {
67       AllEntity e = new AllEntity();
68       e.val = "x";
69       em.persist(e);
70       return e;
71    }
72
73    @PermitAll
74    public AllEntity readAllEntity(int key)
75    {
76       AllEntity e = em.find(AllEntity.class, key);
77       return e;
78    }
79
80    @PermitAll
81    public void updateAllEntity(AllEntity e)
82    {
83       em.merge(e);
84    }
85
86    @PermitAll
87    public void deleteAllEntity(AllEntity e)
88    {
89       em.remove(e);
90    }
91
92    @PermitAll
93    public StarEntity insertStarEntity()
94    {
95       StarEntity e = new StarEntity();
96       e.val = "x";
97       em.persist(e);
98       return e;
99    }
100
101    @PermitAll
102    public StarEntity readStarEntity(int key)
103    {
104       StarEntity e = em.find(StarEntity.class, key);
105       return e;
106    }
107
108    @PermitAll
109    public void updateStarEntity(StarEntity e)
110    {
111       em.merge(e);
112    }
113
114    @PermitAll
115    public void deleteStarEntity(StarEntity e)
116    {
117       em.remove(e);
118    }
119
120
121    @PermitAll
122    public SomeEntity insertSomeEntity()
123    {
124       SomeEntity e = new SomeEntity();
125       e.val = "x";
126       em.persist(e);
127       return e;
128    }
129
130    @PermitAll
131    public SomeEntity readSomeEntity(int key)
132    {
133       SomeEntity e = em.find(SomeEntity.class, key);
134       return e;
135    }
136
137    @PermitAll
138    public void updateSomeEntity(SomeEntity e)
139    {
140       em.merge(e);
141    }
142
143    @PermitAll
144    public void deleteSomeEntity(SomeEntity e)
145    {
146       em.remove(e);
147    }
148 }
149
Popular Tags