summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
blob: 39a13dcef547f0776a9d1cc517eeeec2907f7cae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.    
 */

package org.apache.tuscany.sca.binding.corba.testing.service.mocks;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.context.CompositeContext;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.runtime.DomainRegistry;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;

/**
 * Mock RuntimeWire implementation. Only few methods needs to be implemented.
 */
public class TestRuntimeWire implements RuntimeEndpoint {
    private Object invocationTarget;
    private InterfaceContract interfaceContract;

    public TestRuntimeWire(InterfaceContract interfaceContract, Object invocationTarget) {
        this.interfaceContract = interfaceContract;
        this.invocationTarget = invocationTarget;
    }


    public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
        Class<?>[] types = new Class<?>[args.length];
        for (int i = 0; i < args.length; i++) {
            types[i] = args[i].getClass();
        }
        Object result = null;
        try {
            Method[] methods = invocationTarget.getClass().getMethods();
            for (int i = 0; i < methods.length; i++) {
                if (methods[i].getName().equals(operation.getName())) {
                    result = methods[i].invoke(invocationTarget, args);
                    break;
                }
            }
        } catch (InvocationTargetException e) {
            throw e;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        return result;
    }


    @Override
    public Object clone() throws CloneNotSupportedException {
        // TODO Auto-generated method stub
        return super.clone();
    }


    public InterfaceContract getBindingInterfaceContract() {
        // TODO Auto-generated method stub
        return interfaceContract;
    }


    public ServiceBindingProvider getBindingProvider() {
        // TODO Auto-generated method stub
        return null;
    }


    public InterfaceContract getComponentTypeServiceInterfaceContract() {
        // TODO Auto-generated method stub
        return interfaceContract;
    }


    public void setBindingProvider(ServiceBindingProvider provider) {
        // TODO Auto-generated method stub
        
    }


    public boolean isUnresolved() {
        // TODO Auto-generated method stub
        return false;
    }


    public void setUnresolved(boolean unresolved) {
        // TODO Auto-generated method stub
        
    }


    public ExtensionType getExtensionType() {
        // TODO Auto-generated method stub
        return null;
    }


    public List<PolicySet> getPolicySets() {
        // TODO Auto-generated method stub
        return null;
    }


    public List<Intent> getRequiredIntents() {
        // TODO Auto-generated method stub
        return null;
    }


    public void setExtensionType(ExtensionType type) {
        // TODO Auto-generated method stub
        
    }


    public void bind(CompositeContext context) {
        // TODO Auto-generated method stub
        
    }


    public void bind(ExtensionPointRegistry registry, DomainRegistry domainRegistry) {
        // TODO Auto-generated method stub
        
    }


    public InvocationChain getBindingInvocationChain() {
        // TODO Auto-generated method stub
        return null;
    }


    public CompositeContext getCompositeContext() {
        // TODO Auto-generated method stub
        return null;
    }


    public Contract getContract() {
        // TODO Auto-generated method stub
        return null;
    }


    public InvocationChain getInvocationChain(Operation operation) {
        // TODO Auto-generated method stub
        return null;
    }


    public List<InvocationChain> getInvocationChains() {
        // TODO Auto-generated method stub
        return null;
    }


    public List<PolicyProvider> getPolicyProviders() {
        // TODO Auto-generated method stub
        return null;
    }


    public Message invoke(Message msg) {
        // TODO Auto-generated method stub
        return null;
    }


    public Message invoke(Operation operation, Message msg) {
        // TODO Auto-generated method stub
        return null;
    }
    
    public void invokeAsync(Operation operation, Message msg) {
    }
    
    public void invokeAsyncResponse(Message msg) {
    }

    public void unbind() {
        // TODO Auto-generated method stub
        
    }


    public Binding getBinding() {
        // TODO Auto-generated method stub
        return null;
    }


    public List<EndpointReference> getCallbackEndpointReferences() {
        // TODO Auto-generated method stub
        return null;
    }


    public Component getComponent() {
        // TODO Auto-generated method stub
        return null;
    }


    public InterfaceContract getComponentServiceInterfaceContract() {
        // TODO Auto-generated method stub
        return interfaceContract;
    }


    public ComponentService getService() {
        // TODO Auto-generated method stub
        return null;
    }


    public String getURI() {
        // TODO Auto-generated method stub
        return null;
    }


    public boolean isRemote() {
        // TODO Auto-generated method stub
        return false;
    }


    public boolean matches(String serviceURI) {
        // TODO Auto-generated method stub
        return false;
    }


    public void setBinding(Binding binding) {
        // TODO Auto-generated method stub
        
    }


    public void setComponent(Component component) {
        // TODO Auto-generated method stub
        
    }


    public void setRemote(boolean remote) {
        // TODO Auto-generated method stub
        
    }


    public void setService(ComponentService service) {
        // TODO Auto-generated method stub
        
    }


    public void setURI(String uri) {
        // TODO Auto-generated method stub
        
    }
    
    public void setGeneratedWSDLContract(InterfaceContract wsdlContract){
        
    }
    
    public InterfaceContract getGeneratedWSDLContract(){
        return null;
    }
    
    public void validateServiceInterfaceCompatibility() {
        // TODO Auto-generated method stub
        
    }
    
    public InterfaceContract getGeneratedWSDLContract(
            InterfaceContract interfaceContract) {
        // TODO Auto-generated method stub
        return null;
    }

    public boolean isAsyncInvocation() {
        // TODO Auto-generated method stub
        return false;
    }


	@Override
	public void invokeAsync(Message msg) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void createAsyncServerCallback() {
		// TODO Auto-generated method stub
		
	}


	@Override
	public RuntimeEndpointReference getAsyncServerCallback() {
		// TODO Auto-generated method stub
		return null;
	}


    @Override
    public String getDeployedURI() {
        // TODO Auto-generated method stub
        return null;
    }


    @Override
    public void setDeployedURI(String deployedURI) {
        // TODO Auto-generated method stub
        
    }
    
    @Override
    public RuntimeEndpoint getDelegateEndpoint() {
        // TODO Auto-generated method stub
        return null;
    }
    
    @Override
    public void setDelegateEndpoint(RuntimeEndpoint delegateEndpoint) {
        // TODO Auto-generated method stub
        
    }
    
    @Override
    public String getSpecVersion() {
        // TODO Auto-generated method stub
        return null;
    }
    
    @Override
    public void setSpecVersion(String specVersion) {
        // TODO Auto-generated method stub
        
    }
}