1 45 package org.openejb.test.entity.cmp; 46 47 import java.rmi.RemoteException ; 48 import java.util.StringTokenizer ; 49 50 import javax.ejb.EJBException ; 51 import javax.ejb.EJBHome ; 52 import javax.ejb.EJBMetaData ; 53 import javax.ejb.EJBObject ; 54 import javax.ejb.EntityContext ; 55 import javax.ejb.Handle ; 56 import javax.ejb.RemoveException ; 57 import javax.naming.InitialContext ; 58 59 import org.openejb.test.object.ObjectGraph; 60 61 66 public class RmiIiopCmpBean implements javax.ejb.EntityBean { 67 68 public static int key = 20; 69 70 public int primaryKey; 71 public String firstName; 72 public String lastName; 73 public EntityContext ejbContext; 74 75 79 87 public Integer ejbCreate(String name) 88 throws javax.ejb.CreateException { 89 StringTokenizer st = new StringTokenizer (name, " "); 90 firstName = st.nextToken(); 91 lastName = st.nextToken(); 92 this.primaryKey = key++; 93 return null; 94 } 95 96 public void ejbPostCreate(String name) 97 throws javax.ejb.CreateException { 98 } 99 100 101 105 106 110 111 112 113 public String returnStringObject(String data) { 114 return data; 115 } 116 117 public String [] returnStringObjectArray(String [] data) { 118 return data; 119 } 120 121 122 123 124 125 public Character returnCharacterObject(Character data) { 126 return data; 127 } 128 129 public char returnCharacterPrimitive(char data) { 130 return data; 131 } 132 133 public Character [] returnCharacterObjectArray(Character [] data) { 134 return data; 135 } 136 137 public char[] returnCharacterPrimitiveArray(char[] data) { 138 return data; 139 } 140 141 142 143 144 145 public Boolean returnBooleanObject(Boolean data) { 146 return data; 147 } 148 149 public boolean returnBooleanPrimitive(boolean data) { 150 return data; 151 } 152 153 public Boolean [] returnBooleanObjectArray(Boolean [] data) { 154 return data; 155 } 156 157 public boolean[] returnBooleanPrimitiveArray(boolean[] data) { 158 return data; 159 } 160 161 162 163 164 165 public Byte returnByteObject(Byte data) { 166 return data; 167 } 168 169 public byte returnBytePrimitive(byte data) { 170 return data; 171 } 172 173 public Byte [] returnByteObjectArray(Byte [] data) { 174 return data; 175 } 176 177 public byte[] returnBytePrimitiveArray(byte[] data) { 178 return data; 179 } 180 181 182 183 184 185 public Short returnShortObject(Short data) { 186 return data; 187 } 188 189 public short returnShortPrimitive(short data) { 190 return data; 191 } 192 193 public Short [] returnShortObjectArray(Short [] data) { 194 return data; 195 } 196 197 public short[] returnShortPrimitiveArray(short[] data) { 198 return data; 199 } 200 201 202 203 204 205 public Integer returnIntegerObject(Integer data) { 206 return data; 207 } 208 209 public int returnIntegerPrimitive(int data) { 210 return data; 211 } 212 213 public Integer [] returnIntegerObjectArray(Integer [] data) { 214 return data; 215 } 216 217 public int[] returnIntegerPrimitiveArray(int[] data) { 218 return data; 219 } 220 221 222 223 224 225 public Long returnLongObject(Long data) { 226 return data; 227 } 228 229 public long returnLongPrimitive(long data) { 230 return data; 231 } 232 233 public Long [] returnLongObjectArray(Long [] data) { 234 return data; 235 } 236 237 public long[] returnLongPrimitiveArray(long[] data) { 238 return data; 239 } 240 241 242 243 244 245 public Float returnFloatObject(Float data) { 246 return data; 247 } 248 249 public float returnFloatPrimitive(float data) { 250 return data; 251 } 252 253 public Float [] returnFloatObjectArray(Float [] data) { 254 return data; 255 } 256 257 public float[] returnFloatPrimitiveArray(float[] data) { 258 return data; 259 } 260 261 262 263 264 265 public Double returnDoubleObject(Double data) { 266 return data; 267 } 268 269 public double returnDoublePrimitive(double data) { 270 return data; 271 } 272 273 public Double [] returnDoubleObjectArray(Double [] data) { 274 return data; 275 } 276 277 public double[] returnDoublePrimitiveArray(double[] data) { 278 return data; 279 } 280 281 282 283 284 285 286 public EJBHome returnEJBHome(EJBHome data) { 287 return data; 288 } 289 290 public EJBHome returnEJBHome() throws javax.ejb.EJBException { 291 EJBHome data = null; 292 293 try{ 294 InitialContext ctx = new InitialContext (); 295 296 data = (EJBHome )ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 297 298 } catch (Exception e){ 299 e.printStackTrace(); 300 throw new javax.ejb.EJBException (e); 301 } 302 return data; 303 } 304 305 public ObjectGraph returnNestedEJBHome() throws javax.ejb.EJBException { 306 ObjectGraph data = null; 307 308 try{ 309 InitialContext ctx = new InitialContext (); 310 311 Object object = ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 312 data = new ObjectGraph(object); 313 314 } catch (Exception e){ 315 throw new javax.ejb.EJBException (e); 316 } 317 return data; 318 } 319 320 public EJBHome [] returnEJBHomeArray(EJBHome [] data) { 321 return data; 322 } 323 324 325 326 327 328 public EJBObject returnEJBObject(EJBObject data) { 329 return data; 330 } 331 332 public EJBObject returnEJBObject() throws javax.ejb.EJBException { 333 EncCmpObject data = null; 334 335 try{ 336 InitialContext ctx = new InitialContext (); 337 338 EncCmpHome home = (EncCmpHome)ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 339 data = home.create("Test01 CmpBean"); 340 341 } catch (Exception e){ 342 throw new javax.ejb.EJBException (e); 343 } 344 return data; 345 } 346 347 public ObjectGraph returnNestedEJBObject() throws javax.ejb.EJBException { 348 ObjectGraph data = null; 349 350 try{ 351 InitialContext ctx = new InitialContext (); 352 353 EncCmpHome home = (EncCmpHome)ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 354 EncCmpObject object = home.create("Test02 CmpBean"); 355 data = new ObjectGraph(object); 356 357 } catch (Exception e){ 358 throw new javax.ejb.EJBException (e); 359 } 360 return data; 361 } 362 363 public EJBObject [] returnEJBObjectArray(EJBObject [] data) { 364 return data; 365 } 366 367 368 369 370 371 public EJBMetaData returnEJBMetaData(EJBMetaData data) { 372 return data; 373 } 374 375 public EJBMetaData returnEJBMetaData() throws javax.ejb.EJBException { 376 EJBMetaData data = null; 377 378 try{ 379 InitialContext ctx = new InitialContext (); 380 381 EncCmpHome home = (EncCmpHome)ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 382 data = home.getEJBMetaData(); 383 384 } catch (Exception e){ 385 throw new javax.ejb.EJBException (e); 386 } 387 return data; 388 } 389 390 public ObjectGraph returnNestedEJBMetaData() throws javax.ejb.EJBException { 391 ObjectGraph data = null; 392 393 try{ 394 InitialContext ctx = new InitialContext (); 395 396 EncCmpHome home = (EncCmpHome)ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 397 EJBMetaData object = home.getEJBMetaData(); 398 data = new ObjectGraph(object); 399 400 } catch (Exception e){ 401 throw new javax.ejb.EJBException (e); 402 } 403 return data; 404 } 405 406 public EJBMetaData [] returnEJBMetaDataArray(EJBMetaData [] data) { 407 return data; 408 } 409 410 411 412 413 414 public Handle returnHandle(Handle data) { 415 return data; 416 } 417 418 public Handle returnHandle() throws javax.ejb.EJBException { 419 Handle data = null; 420 421 try{ 422 InitialContext ctx = new InitialContext (); 423 424 EncCmpHome home = (EncCmpHome)ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 425 EncCmpObject object = home.create("Test03 CmpBean"); 426 data = object.getHandle(); 427 428 } catch (Exception e){ 429 throw new javax.ejb.EJBException (e); 430 } 431 return data; 432 } 433 434 public ObjectGraph returnNestedHandle() throws javax.ejb.EJBException { 435 ObjectGraph data = null; 436 437 try{ 438 InitialContext ctx = new InitialContext (); 439 440 EncCmpHome home = (EncCmpHome)ctx.lookup("java:comp/env/cmp/rmi-iiop/home"); 441 EncCmpObject object = home.create("Test04 CmpBean"); 442 data = new ObjectGraph(object.getHandle()); 443 444 } catch (Exception e){ 445 throw new javax.ejb.EJBException (e); 446 } 447 return data; 448 } 449 450 public Handle [] returnHandleArray(Handle [] data) { 451 return data; 452 } 453 454 455 456 457 458 public ObjectGraph returnObjectGraph(ObjectGraph data) { 459 return data; 460 } 461 462 public ObjectGraph[] returnObjectGraphArray(ObjectGraph[] data) { 463 return data; 464 } 465 469 470 474 479 public void ejbLoad() throws EJBException ,RemoteException { 480 } 481 482 486 public void setEntityContext(EntityContext ctx) throws EJBException ,RemoteException { 487 ejbContext = ctx; 488 } 489 490 494 public void unsetEntityContext() throws EJBException ,RemoteException { 495 } 496 497 502 public void ejbStore() throws EJBException ,RemoteException { 503 } 504 505 513 public void ejbRemove() throws RemoveException ,EJBException ,RemoteException { 514 } 515 516 522 public void ejbActivate() throws EJBException ,RemoteException { 523 } 524 525 531 public void ejbPassivate() throws EJBException ,RemoteException { 532 } 533 534 } 538 | Popular Tags |