• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

temporalio / sdk-java / #169

pending completion
#169

push

github-actions

web-flow
Remove use of deprecated API (#1758)

4 of 4 new or added lines in 1 file covered. (100.0%)

17345 of 21558 relevant lines covered (80.46%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.05
/temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowInboundCallsInterceptor.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.common.interceptors;
22

23
import io.temporal.common.Experimental;
24
import javax.annotation.Nonnull;
25
import javax.annotation.Nullable;
26

27
/**
28
 * Intercepts inbound calls to the workflow execution on the worker side.
29
 *
30
 * <p>An instance should be created in {@link
31
 * WorkerInterceptor#interceptWorkflow(WorkflowInboundCallsInterceptor)}.
32
 *
33
 * <p>The calls to this interceptor are executed under workflow context, all the rules and
34
 * restrictions on the workflow code apply. See {@link io.temporal.workflow}.
35
 *
36
 * <p>Prefer extending {@link WorkflowInboundCallsInterceptorBase} and overriding only the methods
37
 * you need instead of implementing this interface directly. {@link
38
 * WorkflowInboundCallsInterceptorBase} provides correct default implementations to all the methods
39
 * of this interface.
40
 *
41
 * <p>The implementation must forward all the calls to {@code next}, but it may change the input
42
 * parameters.
43
 *
44
 * @see WorkerInterceptor#interceptWorkflow(WorkflowInboundCallsInterceptor) for a definition of
45
 *     "next" {@link WorkflowInboundCallsInterceptor}
46
 */
47
@Experimental
48
public interface WorkflowInboundCallsInterceptor {
49

50
  final class WorkflowInput {
51
    private final Header header;
52
    private final Object[] arguments;
53

54
    public WorkflowInput(Header header, Object[] arguments) {
1✔
55
      this.header = header;
1✔
56
      this.arguments = arguments;
1✔
57
    }
1✔
58

59
    public Header getHeader() {
60
      return header;
1✔
61
    }
62

63
    public Object[] getArguments() {
64
      return arguments;
1✔
65
    }
66
  }
67

68
  final class WorkflowOutput {
69
    private final Object result;
70

71
    public WorkflowOutput(Object result) {
1✔
72
      this.result = result;
1✔
73
    }
1✔
74

75
    public Object getResult() {
76
      return result;
1✔
77
    }
78
  }
79

80
  final class SignalInput {
81
    private final String signalName;
82
    private final Object[] arguments;
83
    private final long EventId;
84

85
    public SignalInput(String signalName, Object[] arguments, long eventId) {
1✔
86
      this.signalName = signalName;
1✔
87
      this.arguments = arguments;
1✔
88
      EventId = eventId;
1✔
89
    }
1✔
90

91
    public String getSignalName() {
92
      return signalName;
1✔
93
    }
94

95
    public Object[] getArguments() {
96
      return arguments;
1✔
97
    }
98

99
    public long getEventId() {
100
      return EventId;
×
101
    }
102
  }
103

104
  final class QueryInput {
105
    private final String queryName;
106
    private final Object[] arguments;
107

108
    public QueryInput(String signalName, Object[] arguments) {
1✔
109
      this.queryName = signalName;
1✔
110
      this.arguments = arguments;
1✔
111
    }
1✔
112

113
    public String getQueryName() {
114
      return queryName;
1✔
115
    }
116

117
    public Object[] getArguments() {
118
      return arguments;
1✔
119
    }
120
  }
121

122
  final class QueryOutput {
123
    private final Object result;
124

125
    public QueryOutput(Object result) {
1✔
126
      this.result = result;
1✔
127
    }
1✔
128

129
    public Object getResult() {
130
      return result;
1✔
131
    }
132
  }
133

134
  @Experimental
135
  final class UpdateInput {
136
    private final String updateName;
137
    private final Object[] arguments;
138

139
    public UpdateInput(String updateName, Object[] arguments) {
×
140
      this.updateName = updateName;
×
141
      this.arguments = arguments;
×
142
    }
×
143

144
    public String getUpdateName() {
145
      return updateName;
×
146
    }
147

148
    public Object[] getArguments() {
149
      return arguments;
×
150
    }
151
  }
152

153
  @Experimental
154
  final class UpdateOutput {
155
    private final Object result;
156

157
    public UpdateOutput(Object result) {
×
158
      this.result = result;
×
159
    }
×
160

161
    public Object getResult() {
162
      return result;
×
163
    }
164
  }
165

166
  /**
167
   * Called when workflow class is instantiated. May create a {@link
168
   * WorkflowOutboundCallsInterceptor} instance. The instance must forward all the calls to {@code
169
   * outboundCalls}, but it may change the input parameters.
170
   *
171
   * <p>The instance should be passed into the {next.init(newWorkflowOutboundCallsInterceptor)}.
172
   *
173
   * @param outboundCalls an existing interceptor instance to be proxied by the interceptor created
174
   *     inside this method
175
   * @see WorkerInterceptor#interceptWorkflow for the definition of "next" {@link
176
   *     WorkflowInboundCallsInterceptor}
177
   */
178
  void init(WorkflowOutboundCallsInterceptor outboundCalls);
179

180
  /**
181
   * Called when workflow main method is called.
182
   *
183
   * @return result of the workflow execution.
184
   */
185
  WorkflowOutput execute(WorkflowInput input);
186

187
  /** Called when signal is delivered to a workflow execution. */
188
  void handleSignal(SignalInput input);
189

190
  /** Called when a workflow is queried. */
191
  QueryOutput handleQuery(QueryInput input);
192

193
  /**
194
   * Called when update workflow execution request is delivered to a workflow execution, before the
195
   * update is executed.
196
   */
197
  @Experimental
198
  void validateUpdate(UpdateInput input);
199

200
  /**
201
   * Called when update workflow execution request is delivered to a workflow execution, after
202
   * passing the validator.
203
   */
204
  @Experimental
205
  UpdateOutput executeUpdate(UpdateInput input);
206

207
  /**
208
   * Intercepts creation of the workflow main method thread
209
   *
210
   * @param runnable thread function to run
211
   * @param name name of the thread, optional
212
   * @return created workflow thread. Should be treated as a pass-through object that shouldn't be
213
   *     manipulated in any way by the interceptor code.
214
   */
215
  @Nonnull
216
  Object newWorkflowMethodThread(Runnable runnable, @Nullable String name);
217

218
  /**
219
   * Intercepts creation of a workflow callback thread
220
   *
221
   * @param runnable thread function to run
222
   * @param name name of the thread, optional
223
   * @return created workflow thread. Should be treated as a pass-through object that shouldn't be
224
   *     manipulated in any way by the interceptor code.
225
   */
226
  @Nonnull
227
  Object newCallbackThread(Runnable runnable, @Nullable String name);
228
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc