1 22 package org.jboss.ejb3.test.service; 23 24 import javax.ejb.Remote ; 25 import javax.ejb.Local ; 26 import javax.naming.Context ; 27 import javax.naming.InitialContext ; 28 import javax.naming.NamingException ; 29 import javax.sql.DataSource ; 30 31 import org.jboss.annotation.ejb.Service; 32 import org.jboss.ejb3.Container; 33 34 38 public class ServiceSix implements ServiceSixLocal, ServiceSixRemote, ServiceSixManagement 39 { 40 boolean called; 41 42 int localMethodCalls; 43 int remoteMethodCalls; 44 int jmxAttribute; 45 int someJmxAttribute; 46 int otherJmxAttribute; 47 int readWriteOnlyAttribute; 48 49 StatelessRemote stateless; 50 StatelessLocal statelessLocal; 51 DataSource testDatasource; 52 53 public void setStatelessLocal(StatelessLocal statelessLocal) 54 { 55 this.statelessLocal = statelessLocal; 56 } 57 58 public void testInjection() throws Exception 59 { 60 try 61 { 62 stateless.test(); 63 statelessLocal.testLocal(); 64 testDatasource.getConnection(); 65 66 Context initCtx = new InitialContext (); 67 Context myEnv = (Context ) initCtx.lookup(Container.ENC_CTX_NAME + "/env"); 68 Object obj = myEnv.lookup("res/aQueue"); 69 if ((obj instanceof javax.jms.Queue ) == false) 70 throw new NamingException ("res/aQueue is not a javax.jms.Queue"); 71 } 72 catch (Exception e) 73 { 74 e.printStackTrace(); 75 throw e; 76 } 77 } 78 79 public boolean getCalled() 80 { 81 return called; 82 } 83 84 public void setCalled(boolean called) 85 { 86 this.called = called; 87 } 88 89 public void localMethod() 90 { 91 called = true; 92 } 93 94 public void remoteMethod() 95 { 96 called = true; 97 } 98 99 public String jmxOperation(String s) 100 { 101 return "x" + s + "x"; 102 } 103 104 public String [] jmxOperation(String [] s) 105 { 106 for (int i = 0 ; i < s.length ; i++) 107 { 108 s[i] = jmxOperation(s[i]); 109 } 110 return s; 111 } 112 113 public int getAttribute() 114 { 115 return jmxAttribute; 116 } 117 118 public void setAttribute(int i) 119 { 120 jmxAttribute = i; 121 } 122 123 public int getSomeAttr() 124 { 125 return someJmxAttribute; 126 } 127 128 public void setSomeAttr(int i) 129 { 130 someJmxAttribute = i; 131 } 132 133 public int getOtherAttr() 134 { 135 return otherJmxAttribute; 136 } 137 138 public void setOtherAttr(int i) 139 { 140 otherJmxAttribute = i; 141 } 142 143 public void setWriteOnly(int i) 144 { 145 readWriteOnlyAttribute = i; 146 } 147 148 public int getReadOnly() 149 { 150 return readWriteOnlyAttribute; 151 } 152 153 154 public void create() throws Exception 155 { 156 157 } 158 159 public void start() throws Exception 160 { 161 162 } 163 164 public void stop() 165 { 166 167 } 168 169 public void destroy() 170 { 171 172 } 173 174 } 175 | Popular Tags |