1 22 package org.jboss.ejb3.test.service; 23 24 import javax.ejb.EJB ; 25 import javax.ejb.Remote ; 26 import javax.ejb.Local ; 27 28 import javax.persistence.EntityManager; 29 import javax.persistence.PersistenceContext; 30 31 import org.jboss.annotation.ejb.Management; 32 import org.jboss.annotation.ejb.Service; 33 import org.jboss.annotation.security.SecurityDomain; 34 35 39 @Service 40 @Remote (ServiceOneRemote.class) 41 @Local (ServiceOneLocal.class) 42 @Management(ServiceOneManagement.class) 43 @SecurityDomain("other") 44 public class ServiceOne implements ServiceOneLocal, ServiceOneRemote, ServiceOneManagement 45 { 46 @PersistenceContext(unitName = "test") 47 private EntityManager manager; 48 49 static int instances = 0; 50 int localMethodCalls; 51 int remoteMethodCalls; 52 int jmxAttribute; 53 int someJmxAttribute; 54 int otherJmxAttribute; 55 int readWriteOnlyAttribute; 56 57 @EJB StatelessRemote stateless; 58 59 public void testEjbInjection() 60 { 61 stateless.test(); 62 } 63 64 public ServiceOne() 65 { 66 instances++; 67 } 68 69 public int getInstances() 70 { 71 return instances; 72 } 73 74 public int getRemoteMethodCalls() 75 { 76 return remoteMethodCalls; 77 } 78 79 public void setRemoteMethodCalls(int i) 80 { 81 remoteMethodCalls = i; 82 } 83 84 public int getLocalMethodCalls() 85 { 86 return localMethodCalls; 87 } 88 89 public void setLocalMethodCalls(int i) 90 { 91 localMethodCalls = i; 92 } 93 94 public synchronized void localMethod(String s) 95 { 96 localMethodCalls++; 97 } 98 99 public synchronized void remoteMethod(String s) 100 { 101 remoteMethodCalls++; 102 } 103 104 public String jmxOperation(String s) 105 { 106 return "x" + s + "x"; 107 } 108 109 public String [] jmxOperation(String [] s) 110 { 111 for (int i = 0 ; i < s.length ; i++) 112 { 113 s[i] = jmxOperation(s[i]); 114 } 115 return s; 116 } 117 118 public int getAttribute() 119 { 120 return jmxAttribute; 121 } 122 123 public void setAttribute(int i) 124 { 125 jmxAttribute = i; 126 } 127 128 public int getSomeAttr() 129 { 130 return someJmxAttribute; 131 } 132 133 public void setSomeAttr(int i) 134 { 135 someJmxAttribute = i; 136 } 137 138 public int getOtherAttr() 139 { 140 return otherJmxAttribute; 141 } 142 143 public void setOtherAttr(int i) 144 { 145 otherJmxAttribute = i; 146 } 147 148 public void setWriteOnly(int i) 149 { 150 readWriteOnlyAttribute = i; 151 } 152 153 public int getReadOnly() 154 { 155 return readWriteOnlyAttribute; 156 } 157 158 159 public void create() throws Exception 160 { 161 System.out.println("ServiceOne - CREATE"); 162 Tester.creates.add("1"); 163 } 164 165 public void start() throws Exception 166 { 167 System.out.println("ServiceOne - START"); 168 Tester.starts.add("1"); 169 170 manager.toString(); 172 } 173 174 public void stop() 175 { 176 System.out.println("ServiceOne - STOP"); 177 } 178 179 public void destroy() 180 { 181 System.out.println("ServiceOne - DESTROY"); 182 } 183 184 } 185 | Popular Tags |