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
|
/*
* 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.databinding;
import java.util.Map;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Operation;
/**
* This interface will be used as a Tuscany system service to perform data mediations
*
* Mediate the data from one type to the other one
*
* @version $Rev$ $Date$
*/
public interface Mediator {
/**
* Mediate the data from the source type to the target type
* @param source The data to be mediated
* @param sourceDataType Data type for the source data
* @param targetDataType Data type for the target data
* @param context
* @return
*/
Object mediate(Object source, DataType sourceDataType, DataType targetDataType, Map<String, Object> context);
/**
* Mediate the source data into the target which is a sink to receive the data
* @param source The data to be mediated
* @param target The sink to receive data
* @param sourceDataType Data type for the source data
* @param targetDataType Data type for the target data
*/
void mediate(Object source,
Object target,
DataType sourceDataType,
DataType targetDataType,
Map<String, Object> context);
/**
* Transform the input parameters for the source operation to the expected parameters for
* the target operation
* @param input The input data, typically an array of parameters
* @param sourceOperation The source operation
* @param targetOperation The target operation
* @param metadata Additional metadata
* @return The transformed input data for the target operation
*/
Object mediateInput(Object input, Operation sourceOperation, Operation targetOperation, Map<String, Object> metadata);
/**
* Transform the return value for the target operation to the expected return value for
* the source operation
* @param output The output data, typically the return value
* @param sourceOperation The source operation
* @param targetOperation The target operation
* @param metadata Additional metadata
* @return The transformed output data for the source operation
*/
Object mediateOutput(Object output,
Operation sourceOperation,
Operation targetOperation,
Map<String, Object> metadata);
/**
* Transform the fault data for the target operation to the expected fault data for
* the source operation
* @param fault The fault data, such as Java exception or fault message
* @param sourceOperation The source operation
* @param targetOperation The target operation
* @param metadata Additional metadata
* @return The transformed fault data for the source operation
*/
Object mediateFault(Object fault, Operation sourceOperation, Operation targetOperation, Map<String, Object> metadata);
/**
* Copy the data
* @param data The orginal data
* @param dataType The data type
* @return The copy
*/
Object copy(Object data, DataType dataType);
/**
* Copy the data
* @param data The orginal data
* @param dataType The data type
* @param targetDataType The target data type
* @return The copy
*/
Object copy(Object data, DataType dataType, DataType targetDataType);
/**
* Copy an array of data objects passed to an operation
* @param data array of objects to copy
* @return the copy
*/
public Object copyInput(Object input, Operation operation);
/**
* Copy an array of data objects passed to an operation
* @param data array of objects to copy
* @return the copy
*/
public Object copyInput(Object input, Operation operation, Operation targetOperation);
/**
* Copy the output data
* @param data The orginal output
* @param operation The operation
* @return The copy
*/
Object copyOutput(Object data, Operation operation);
/**
* Copy the output data
* @param data The orginal output
* @param operation The operation
* @param targetOperation The target operation
* @return The copy
*/
Object copyOutput(Object data, Operation operation, Operation targetOperation);
/**
* Copy the fault data
* @param fault The orginal fault data
* @param operation The operation
* @return The copy
*/
Object copyFault(Object fault, Operation operation);
/**
* Copy the fault data
* @param fault The orginal fault data
* @param operation The operation
* @param targetOperation The target operation
* @return The copy
*/
Object copyFault(Object fault, Operation operation, Operation targetOperation);
/**
* Get the DataBindings used by this mediator.
* @return
*/
DataBindingExtensionPoint getDataBindings();
/**
* Get the Transformers used by this mediator.
* @return
*/
TransformerExtensionPoint getTransformers();
/**
* Create an instance of TransformationContext
* @return
*/
TransformationContext createTransformationContext();
/**
* Create an instance of TransformationContext
* @param sourceDataType
* @param targetDataType
* @param metadata
* @return
*/
TransformationContext createTransformationContext(DataType sourceDataType,
DataType targetDataType,
Map<String, Object> metadata);
}
|