KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > management > service > mock > MockRegistry


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: MockRegistry.java 16:29:05 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.management.service.mock;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import javax.jbi.servicedesc.ServiceEndpoint;
28 import javax.naming.Context JavaDoc;
29 import javax.xml.namespace.QName JavaDoc;
30
31 import org.objectweb.petals.jbi.registry.AbstractEndpoint;
32 import org.objectweb.petals.jbi.registry.ConsumerEndpoint;
33 import org.objectweb.petals.jbi.registry.InternalEndpoint;
34 import org.objectweb.petals.jbi.registry.LinkedEndpoint;
35 import org.objectweb.petals.jbi.registry.Registry;
36 import org.objectweb.petals.jbi.registry.RegistryException;
37
38 /**
39  * Mock object of the Registry
40  *
41  * @author ddesjardins - eBMWebsourcing
42  */

43 public class MockRegistry implements Registry {
44
45     private boolean deregisterConnection;
46
47     private boolean deregisterExternalEndpoint;
48
49     private boolean deregisterInternalEndpoint;
50
51     private boolean getExternalEndpoint;
52
53     private boolean getExternalEndpointsForInterface;
54
55     private boolean getExternalEndpointsForService;
56
57     private boolean getInternalEndpoint;
58
59     private boolean getInternalEndpointsForInterface;
60
61     private boolean getInternalEndpointsForService;
62
63     private boolean registerConnection;
64
65     private boolean registerExternalEndpoint;
66
67     private boolean registerInternalEndpoint;
68
69     private boolean retrieveNewEndpoints;
70
71     private boolean validateEndpoint;
72
73     public void deregisterConnection(LinkedEndpoint connection)
74         throws RegistryException {
75         deregisterConnection = true;
76     }
77
78     public void deregisterExternalEndpoint(ServiceEndpoint externalEndpoint)
79         throws RegistryException {
80         deregisterExternalEndpoint = true;
81     }
82
83     public void deregisterInternalEndpoint(AbstractEndpoint endpoint)
84         throws RegistryException {
85         deregisterInternalEndpoint = true;
86     }
87
88     public AbstractEndpoint getExternalEndpoint(QName JavaDoc service, String JavaDoc name)
89         throws RegistryException {
90         getExternalEndpoint = true;
91         return null;
92     }
93
94     public AbstractEndpoint[] getExternalEndpointsForInterface(
95         QName JavaDoc interfaceName) throws RegistryException {
96         getExternalEndpointsForInterface = true;
97         return new AbstractEndpoint[] {new ConsumerEndpoint("compo", "0")};
98     }
99
100     public AbstractEndpoint[] getExternalEndpointsForService(QName JavaDoc serviceName) {
101         getExternalEndpointsForService = true;
102         return new AbstractEndpoint[] {new ConsumerEndpoint("compo", "0")};
103     }
104
105     public AbstractEndpoint getInternalEndpoint(QName JavaDoc service, String JavaDoc name)
106         throws RegistryException {
107         getInternalEndpoint = true;
108         InternalEndpoint internalEndpoint = new InternalEndpoint(new QName JavaDoc(
109             "service"), "endpoint", "compo", "0", null);
110         if (service.equals(new QName JavaDoc(
111             "http://127.0.0.1:8080/axis/Helloworld.jws", "HelloworldService"))) {
112             internalEndpoint.setInterfaces(new QName JavaDoc[] {new QName JavaDoc("test")});
113         }
114         return internalEndpoint;
115     }
116
117     public AbstractEndpoint[] getInternalEndpointsForInterface(
118         QName JavaDoc interfaceName) throws RegistryException {
119         getInternalEndpointsForInterface = true;
120         AbstractEndpoint[] endpoints = new AbstractEndpoint[0];
121         if (interfaceName.equals(new QName JavaDoc("inter"))) {
122             endpoints = new AbstractEndpoint[] {new InternalEndpoint(new QName JavaDoc(
123                 "serv"), "endpoiny", "compo", "0", null)};
124         }
125         return endpoints;
126     }
127
128     public AbstractEndpoint[] getInternalEndpointsForService(QName JavaDoc serviceName) {
129         getInternalEndpointsForService = true;
130         AbstractEndpoint[] endpoints = new AbstractEndpoint[0];
131         if (serviceName.equals(new QName JavaDoc("serv"))) {
132             endpoints = new AbstractEndpoint[] {new InternalEndpoint(
133                 serviceName, "endpoint", "compo", "0", null)};
134         }
135         return endpoints;
136     }
137
138     public boolean isDeregisterConnection() {
139         return deregisterConnection;
140     }
141
142     public boolean isDeregisterExternalEndpoint() throws RegistryException {
143         return deregisterExternalEndpoint;
144     }
145
146     public boolean isDeregisterInternalEndpoint() throws RegistryException {
147         return deregisterInternalEndpoint;
148     }
149
150     public boolean isGetExternalEndpoint() {
151         return getExternalEndpoint;
152     }
153
154     public boolean isGetExternalEndpointsForInterface()
155         throws RegistryException {
156         return getExternalEndpointsForInterface;
157     }
158
159     public boolean isGetExternalEndpointsForService() throws RegistryException {
160         return getExternalEndpointsForService;
161     }
162
163     public boolean isGetInternalEndpoint() throws RegistryException {
164         return getInternalEndpoint;
165     }
166
167     public boolean isGetInternalEndpointsForInterface() {
168         return getInternalEndpointsForInterface;
169     }
170
171     public boolean isGetInternalEndpointsForService() {
172         return getInternalEndpointsForService;
173     }
174
175     public boolean isRegisterConnection() {
176         return registerConnection;
177     }
178
179     public boolean isRegisterExternalEndpoint() throws RegistryException {
180         return registerExternalEndpoint;
181     }
182
183     public boolean isRegisterInternalEndpoint() throws RegistryException {
184         return registerInternalEndpoint;
185     }
186
187     public boolean isRetrieveNewEndpoints() throws RegistryException {
188         return retrieveNewEndpoints;
189     }
190
191     public boolean isValidateEndpoint() {
192         return validateEndpoint;
193     }
194
195     public void registerConnection(LinkedEndpoint linkedEndpoint)
196         throws RegistryException {
197         registerConnection = true;
198     }
199
200     public void registerExternalEndpoint(ServiceEndpoint externalEndpoint)
201         throws RegistryException {
202         registerExternalEndpoint = true;
203     }
204
205     public void registerInternalEndpoint(AbstractEndpoint endpoint)
206         throws RegistryException {
207         registerInternalEndpoint = true;
208     }
209
210     public List JavaDoc<AbstractEndpoint> retrieveNewEndpoints()
211         throws RegistryException {
212         retrieveNewEndpoints = true;
213         List JavaDoc<AbstractEndpoint> absList = new ArrayList JavaDoc<AbstractEndpoint>();
214         absList.add(new InternalEndpoint(new QName JavaDoc(
215             "http://127.0.0.1:8080/axis/Helloworld.jws", "HelloworldService"),
216             "endpoint", "compo", "0", null));
217         return absList;
218     }
219
220     public void setDeregisterConnection(boolean deregisterConnection) {
221         this.deregisterConnection = deregisterConnection;
222     }
223
224     public void setDeregisterExternalEndpoint(boolean deregisterExternalEndpoint) {
225         this.deregisterExternalEndpoint = deregisterExternalEndpoint;
226     }
227
228     public void setDeregisterInternalEndpoint(boolean deregisterInternalEndpoint) {
229         this.deregisterInternalEndpoint = deregisterInternalEndpoint;
230     }
231
232     public void setGetExternalEndpoint(boolean getExternalEndpoint) {
233         this.getExternalEndpoint = getExternalEndpoint;
234     }
235
236     public void setGetExternalEndpointsForInterface(
237         boolean getExternalEndpointsForInterface) {
238         this.getExternalEndpointsForInterface = getExternalEndpointsForInterface;
239     }
240
241     public void setGetExternalEndpointsForService(
242         boolean getExternalEndpointsForService) {
243         this.getExternalEndpointsForService = getExternalEndpointsForService;
244     }
245
246     public void setGetInternalEndpoint(boolean getInternalEndpoint) {
247         this.getInternalEndpoint = getInternalEndpoint;
248     }
249
250     public void setGetInternalEndpointsForInterface(
251         boolean getInternalEndpointsForInterface) {
252         this.getInternalEndpointsForInterface = getInternalEndpointsForInterface;
253     }
254
255     public void setGetInternalEndpointsForService(
256         boolean getInternalEndpointsForService) {
257         this.getInternalEndpointsForService = getInternalEndpointsForService;
258     }
259
260     public void setRegisterConnection(boolean registerConnection) {
261         this.registerConnection = registerConnection;
262     }
263
264     public void setRegisterExternalEndpoint(boolean registerExternalEndpoint) {
265         this.registerExternalEndpoint = registerExternalEndpoint;
266     }
267
268     public void setRegisterInternalEndpoint(boolean registerInternalEndpoint) {
269         this.registerInternalEndpoint = registerInternalEndpoint;
270     }
271
272     public void setRetrieveNewEndpoints(boolean retrieveNewEndpoints) {
273         this.retrieveNewEndpoints = retrieveNewEndpoints;
274     }
275
276     public void setValidateEndpoint(boolean validateEndpoint) {
277         this.validateEndpoint = validateEndpoint;
278     }
279
280     public void validateEndpoint(AbstractEndpoint endpoint)
281         throws RegistryException {
282         validateEndpoint = true;
283     }
284
285     public void cleanNewEndpoints() throws RegistryException {
286     }
287
288     public AbstractEndpoint getInternalEndpoint(QName JavaDoc service, String JavaDoc name, boolean resolveLink) throws RegistryException {
289         getInternalEndpoint = true;
290         InternalEndpoint internalEndpoint = new InternalEndpoint(new QName JavaDoc(
291             "service"), "endpoint", "compo", "0", null);
292         if (service.equals(new QName JavaDoc(
293             "http://127.0.0.1:8080/axis/Helloworld.jws", "HelloworldService"))) {
294             internalEndpoint.setInterfaces(new QName JavaDoc[] {new QName JavaDoc("test")});
295         }
296         return internalEndpoint;
297
298     }
299
300     public Context JavaDoc getUsersContext() {
301         return null;
302     }
303
304 }
305
Popular Tags