KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > kernel > registry > jndi > mock > MockJNDIConnection


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
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  * -------------------------------------------------------------------------
19  * $Id: MockJNDIConnection.java 11:12:31 AM ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.kernel.registry.jndi.mock;
23
24 import javax.naming.Binding JavaDoc;
25 import javax.naming.NameClassPair JavaDoc;
26
27 import org.objectweb.petals.kernel.registry.jndi.JNDIConnection;
28 import org.objectweb.petals.kernel.registry.msg.request.RegistryRequest;
29 import org.objectweb.petals.kernel.registry.msg.request.RegistryRequest.RequestType;
30
31 /**
32  * Mock of the JNDIConnection
33  *
34  * @author ddesjardins - eBMWebsourcing
35  */

36 public class MockJNDIConnection extends JNDIConnection {
37
38     public MockJNDIConnection(int port, String JavaDoc host) {
39         super(port, host);
40     }
41
42     /**
43      *
44      */

45     private static final long serialVersionUID = 1L;
46
47     protected boolean isBind;
48
49     protected boolean isCreateSubcontext;
50
51     protected boolean isDestroySubcontext;
52
53     protected boolean isList;
54
55     protected boolean isListBindings;
56
57     protected boolean isLookup;
58
59     protected boolean isLookupLink;
60
61     protected boolean isRebind;
62
63     protected boolean isRename;
64
65     protected boolean isUnbind;
66
67     public boolean isUnbind() {
68         return isUnbind;
69     }
70
71     public void setUnbind(boolean isUnbind) {
72         this.isUnbind = isUnbind;
73     }
74
75     public boolean isDestroySubcontext() {
76         return isDestroySubcontext;
77     }
78
79     public void setDestroySubcontext(boolean isDestroySubcontext) {
80         this.isDestroySubcontext = isDestroySubcontext;
81     }
82
83     public Object JavaDoc send(RegistryRequest registryRequest) {
84         Object JavaDoc out = null;
85         if (registryRequest.getType().equals(RequestType.bind)) {
86             isBind = true;
87         } else if (registryRequest.getType().equals(
88             RequestType.createSubcontext)) {
89             isCreateSubcontext = true;
90         } else if (registryRequest.getType().equals(
91             RequestType.destroySubcontext)) {
92             isDestroySubcontext = true;
93         } else if (registryRequest.getType().equals(RequestType.list)) {
94             isList = true;
95             out = new NameClassPair JavaDoc[0];
96         } else if (registryRequest.getType().equals(RequestType.listBindings)) {
97             isListBindings = true;
98             out = new Binding JavaDoc[0];
99         } else if (registryRequest.getType().equals(RequestType.lookup)) {
100             isLookup = true;
101         } else if (registryRequest.getType().equals(RequestType.lookupLink)) {
102             isLookupLink = true;
103         } else if (registryRequest.getType().equals(RequestType.rebind)) {
104             isRebind = true;
105         } else if (registryRequest.getType().equals(RequestType.rename)) {
106             isRename = true;
107         } else if (registryRequest.getType().equals(RequestType.unbind)) {
108             isUnbind = true;
109         }
110         return out;
111     }
112
113     public boolean isBind() {
114         return isBind;
115     }
116
117     public void setBind(boolean isBind) {
118         this.isBind = isBind;
119     }
120
121     public boolean isCreateSubcontext() {
122         return isCreateSubcontext;
123     }
124
125     public void setCreateSubcontext(boolean isCreateSubcontext) {
126         this.isCreateSubcontext = isCreateSubcontext;
127     }
128
129     public boolean isList() {
130         return isList;
131     }
132
133     public void setList(boolean isList) {
134         this.isList = isList;
135     }
136
137     public boolean isListBindings() {
138         return isListBindings;
139     }
140
141     public void setListBindings(boolean isListBindings) {
142         this.isListBindings = isListBindings;
143     }
144
145     public boolean isLookup() {
146         return isLookup;
147     }
148
149     public void setLookup(boolean isLookup) {
150         this.isLookup = isLookup;
151     }
152
153     public boolean isLookupLink() {
154         return isLookupLink;
155     }
156
157     public void setLookupLink(boolean isLookupLink) {
158         this.isLookupLink = isLookupLink;
159     }
160
161     public boolean isRebind() {
162         return isRebind;
163     }
164
165     public void setRebind(boolean isRebind) {
166         this.isRebind = isRebind;
167     }
168
169     public boolean isRename() {
170         return isRename;
171     }
172
173     public void setRename(boolean isRename) {
174         this.isRename = isRename;
175     }
176
177 }
178
Popular Tags