1 18 package org.objectweb.jorm.lib; 19 20 import org.objectweb.jorm.api.PAccessor; 21 import org.objectweb.jorm.api.PBinding; 22 import org.objectweb.jorm.api.PBindingCtrl; 23 import org.objectweb.jorm.api.PClassMapping; 24 import org.objectweb.jorm.api.PException; 25 import org.objectweb.jorm.api.PExceptionProtocol; 26 import org.objectweb.jorm.naming.api.PName; 27 28 32 public class PBindingImpl implements PBinding, PBindingCtrl { 33 34 transient protected byte status; 35 36 transient public PClassMapping pClassMapping; 37 38 transient protected PName pname; 39 40 41 public PBindingImpl() { 42 } 43 44 public PBindingImpl(PClassMapping pcm) { 45 this.pClassMapping = pcm; 46 status = PBinding.LIFECYCLE_NOTBOUND; 47 } 48 49 public void bind(PName pn) throws PException { 50 if (pname!=null) { 51 pClassMapping.getPBinder().unbind(this); 54 } 55 pClassMapping.getPBinder().bind(pn, this); 56 } 57 58 public boolean exist(Object conn) throws PException { 59 return pClassMapping.exist(this, conn); 60 } 61 62 public PName export(Object conn) throws PException { 63 return pClassMapping.getPBinder().export(conn, this); 64 } 65 66 public PName export(Object conn, Object hints) throws PException { 67 return pClassMapping.getPBinder().export(conn, this, hints); 68 } 69 70 public PClassMapping getPClassMapping() { 71 return pClassMapping; 72 } 73 74 public PName getPName() { 75 return pname; 76 } 77 78 public byte getStatus() { 79 return status; 80 } 81 82 public void setPName(PName pn) { 83 this.pname = pn; 84 } 85 86 public void setStatus(byte s) { 87 this.status = s; 88 } 89 90 public void init(PClassMapping pcm) throws PException { 91 this.pClassMapping = pcm; 92 this.status = PBinding.LIFECYCLE_NOTBOUND; 93 } 94 95 public void read(Object conn, PAccessor pa) throws PException { 96 if (pClassMapping == null) { 97 throw new PExceptionProtocol("PBinding is not initialized"); 98 } 99 pClassMapping.read(this, conn, pa); 100 } 101 102 public void read(Object conn, PAccessor pa, Object txctx) throws PException { 103 if (pClassMapping == null) { 104 throw new PExceptionProtocol("PBinding is not initialized"); 105 } 106 pClassMapping.read(this, conn, pa, txctx); 107 } 108 109 public void unbind() throws PException { 110 if (pClassMapping == null) { 111 throw new PExceptionProtocol("PBinding is not initialized"); 112 } 113 pClassMapping.getPBinder().unbind(this); 114 } 115 116 public void unexport(Object conn) throws PException { 117 if (pClassMapping == null) { 118 throw new PExceptionProtocol("PBinding is not initialized"); 119 } 120 pClassMapping.getPBinder().unexport(conn, pname, this); 121 } 122 123 public void write(Object conn, PAccessor pa) throws PException { 124 if (pClassMapping == null) { 125 throw new PExceptionProtocol("PBinding is not initialized"); 126 } 127 pClassMapping.write(this, conn, pa); 128 } 129 130 } 131 | Popular Tags |