KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > lib > PBindingImpl


1 /**
2  * Copyright (C) 2004 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

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 /**
29  *
30  * @author S.Chassande-Barrioz
31  */

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             // The Pbinding must be unbinded only if the PName has been already
52
// defined
53
pClassMapping.getPBinder().unbind(this);
54         }
55         pClassMapping.getPBinder().bind(pn, this);
56     }
57
58     public boolean exist(Object JavaDoc conn) throws PException {
59         return pClassMapping.exist(this, conn);
60     }
61
62     public PName export(Object JavaDoc conn) throws PException {
63         return pClassMapping.getPBinder().export(conn, this);
64     }
65
66     public PName export(Object JavaDoc conn, Object JavaDoc 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 JavaDoc 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 JavaDoc conn, PAccessor pa, Object JavaDoc 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 JavaDoc 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 JavaDoc 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