Skip to content

Commit a1af9a8

Browse files
committed
Preparation for publishing to Maven repo -- modifying parent POM, fixing JavaDocs
1 parent f1e1d51 commit a1af9a8

File tree

14 files changed

+193
-50
lines changed

14 files changed

+193
-50
lines changed

HEADER.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Copyright � 2013-2016 Valery Silaev ([email protected])
2+
3+
This project is based on the code licensed to the Apache Software
4+
Foundation (ASF) under one or more contributor license agreements.
5+
See the NOTICE file distributed with this work for additional information
6+
regarding copyright ownership.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file 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.

NOTICE.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Apache Commons Javaflow
2+
Copyright 1999-2004 The Apache Software Foundation
3+
4+
This product includes software developed by
5+
The Apache Software Foundation (http://www.apache.org/).

net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/api/ContinuableAnnotation.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@
66
import java.lang.annotation.RetentionPolicy;
77
import java.lang.annotation.Target;
88

9+
/**
10+
*
11+
* Meta-annotation that is used to annotate other continuation-related annotations.
12+
* It provides an option to declare and use own annotations instead of supplied
13+
* {@link continuable} and {@link ccs} annotations, for ex:
14+
*
15+
* <pre><code>
16+
* import java.lang.annotation.Documented;
17+
* import java.lang.annotation.ElementType;
18+
* import java.lang.annotation.Retention;
19+
* import java.lang.annotation.RetentionPolicy;
20+
* import java.lang.annotation.Target;
21+
*
22+
* {@literal @}Documented
23+
* {@literal @}Retention(RetentionPolicy.CLASS)
24+
* {@literal @}Target({ElementType.METHOD})
25+
* <b>{@literal @}ContinuableAnnotation</b>
26+
* public {@literal @}interface ContinuableMethod {
27+
* // The annotation to mark continuable methods
28+
* }
29+
*
30+
* </code></pre>
31+
*
32+
* @author Valery Silaev
33+
*
34+
*/
935
@Documented
1036
@Retention(RetentionPolicy.CLASS)
1137
@Target(ElementType.ANNOTATION_TYPE)

net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/api/Continuation.java

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,19 @@ public static Object getContext() {
8686
* <p>
8787
* Unlike the {@link #startWith(Runnable)} method, this method doesn't actually
8888
* execute the <tt>Runnable</tt> object. It will be executed when
89-
* it's {@link #resume() continued}.
89+
* it's {@link #resume() resumed}.</p>
90+
*
91+
* @param target
92+
* The object whose <tt>run</tt> method will be executed.
9093
*
9194
* @return
9295
* always return a non-null valid object.
9396
*/
94-
public static Continuation startSuspendedWith( final Runnable pTarget ) {
95-
if(pTarget == null) {
97+
public static Continuation startSuspendedWith( final Runnable target ) {
98+
if(target == null) {
9699
throw new IllegalArgumentException("target is null");
97100
}
98-
return new Continuation( new StackRecorder(pTarget), null );
101+
return new Continuation( new StackRecorder(target), null );
99102
}
100103

101104
/**
@@ -104,11 +107,15 @@ public static Continuation startSuspendedWith( final Runnable pTarget ) {
104107
*
105108
* <p>
106109
* This is a short hand for <tt>startWith(target,null)</tt>.
107-
*
110+
*
111+
* @param target
112+
* The object whose <tt>run</tt> method will be executed.
113+
* @return
114+
* Continuation object if runnable supplied is supended, otherwise <code>null</code>
108115
* @see #startWith(Runnable, Object)
109116
*/
110-
public static Continuation startWith( final Runnable pTarget ) {
111-
return startWith(pTarget, null);
117+
public static Continuation startWith( final Runnable target ) {
118+
return startWith(target, null);
112119
}
113120

114121
/**
@@ -117,7 +124,7 @@ public static Continuation startWith( final Runnable pTarget ) {
117124
*
118125
* This method blocks until the continuation suspends or completes.
119126
*
120-
* @param pTarget
127+
* @param target
121128
* The object whose <tt>run</tt> method will be executed.
122129
* @param pContext
123130
* This value can be obtained from {@link #getContext()} until this method returns.
@@ -128,12 +135,12 @@ public static Continuation startWith( final Runnable pTarget ) {
128135
* a new non-null continuation is returned.
129136
* @see #getContext()
130137
*/
131-
public static Continuation startWith( final Runnable pTarget, final Object pContext ) {
138+
public static Continuation startWith( final Runnable target, final Object pContext ) {
132139
if (log.isDebugEnabled()) {
133-
log.debug("starting new flow from " + ReflectionUtils.getClassName(pTarget) + "/" + ReflectionUtils.getClassLoaderName(pTarget));
140+
log.debug("starting new flow from " + ReflectionUtils.getClassName(target) + "/" + ReflectionUtils.getClassLoaderName(target));
134141
}
135142

136-
return startSuspendedWith(pTarget).resume(pContext);
143+
return startSuspendedWith(target).resume(pContext);
137144
}
138145

139146
/**
@@ -143,13 +150,21 @@ public static Continuation startWith( final Runnable pTarget, final Object pCont
143150
*
144151
* <p>
145152
* This is a short hand for <tt>continueWith(resumed,null)</tt>.
153+
*
154+
* @param continuation
155+
* The suspended continuation to be resumed. Must not be null.
156+
*
157+
* @return
158+
* If the execution completes and there's nothing more to continue, return null.
159+
* Otherwise, the execution has been {@link #suspend() suspended}, in which case
160+
* a new non-null continuation is returned.
146161
*
147162
* @see #continueWith(Continuation, Object)
148163
*
149164
* @deprecated
150165
*/
151-
public static Continuation continueWith(final Continuation pOldContinuation) {
152-
return continueWith(pOldContinuation, (Object)null);
166+
public static Continuation continueWith(final Continuation continuation) {
167+
return continueWith(continuation, (Object)null);
153168
}
154169

155170
/**
@@ -160,32 +175,39 @@ public static Continuation continueWith(final Continuation pOldContinuation) {
160175
*
161176
* This method blocks until the continuation suspends or completes.
162177
*
163-
* @param pOldContinuation
164-
* The resumed continuation to be executed. Must not be null.
165-
* @param pContext
166-
* This value can be obtained from {@link #getContext()} until this method returns.
167-
* Can be null.
178+
* @param continuation
179+
* The suspended continuation to be resumed. Must not be null.
180+
*
181+
* @param value
182+
* The value to be returned as a result form {@link #suspend() Continuation.suspend()} call or
183+
* from {@link #getContext()} until this method returns. Can be null.
168184
* @return
169185
* If the execution completes and there's nothing more to continue, return null.
170186
* Otherwise, the execution has been {@link #suspend() suspended}, in which case
171187
* a new non-null continuation is returned.
172-
* @see #resume(Object) #getContext()
188+
* @see #getContext()
189+
* @see #suspend()
173190
*
174191
* @deprecated
175192
*/
176-
public static Continuation continueWith(final Continuation pOldContinuation, final Object pContext) {
177-
if (pOldContinuation == null) {
193+
public static Continuation continueWith(final Continuation continuation, final Object value) {
194+
if (continuation == null) {
178195
throw new IllegalArgumentException("continuation parameter must not be null.");
179196
}
180197

181-
return pOldContinuation.resume(pContext);
198+
return continuation.resume(value);
182199
}
183200

184201
/**
185202
* Resumes the execution of the specified continuation from where it's left off.
186203
*
187204
* <p>
188205
* This is a short hand for <tt>resume(null)</tt>.
206+
*
207+
* @return
208+
* If the execution completes and there's nothing more to continue, return null.
209+
* Otherwise, the execution has been {@link #suspend() suspended}, in which case
210+
* a new non-null continuation is returned.
189211
*
190212
* @see #resume(Object)
191213
*
@@ -202,20 +224,26 @@ public Continuation resume() {
202224
* This method blocks until the continuation suspends or completes.
203225
*
204226
* @param value
205-
* This value can be obtained from {@link #getContext()} until this method returns.
206-
* Can be null.
227+
* The value to be returned as a result form {@link #suspend() Continuation.suspend()} call or
228+
* from {@link #getContext()} until this method returns. Can be null.
207229
* @return
208230
* If the execution completes and there's nothing more to continue, return null.
209231
* Otherwise, the execution has been {@link #suspend() suspended}, in which case
210232
* a new non-null continuation is returned.
211233
* @see #getContext()
234+
* @see #suspend()
212235
*
213236
*/
214237
public Continuation resume(final Object value) {
215238
return resumeWith(ResumeParameter.value(value));
216239
}
217240

218-
public void destroy() {
241+
/**
242+
* Abnormally terminates the suspended call chain represented by this continuation.
243+
* <p>Use this method to execute any clean-up code of suspended methods (<code>finally</code> blocks)
244+
* when there is no need to {@link #resume()} the continuation.</p>
245+
*/
246+
public void terminate() {
219247
resumeWith(ResumeParameter.exit());
220248
}
221249

@@ -242,6 +270,11 @@ protected Continuation resumeWith(final ResumeParameter param) {
242270
}
243271
}
244272

273+
/**
274+
* Check if captured continuation is serializable
275+
* @return
276+
* true if all variables on captured stack and runnable supplied are serializeble, false otherwise.
277+
*/
245278
public boolean isSerializable() {
246279
return stackRecorder.isSerializable();
247280
}
@@ -283,11 +316,11 @@ public static Object suspend() {
283316
* <p>
284317
* This method can be only called inside {@link #continueWith} or {@link #startWith} methods.
285318
* When called, the thread returns from the above methods with a new {@link Continuation}
286-
* object that captures the thread state and with {@link #result} equals to parameter passed.
319+
* object that captures the thread state and with {@link #value()} equals to parameter passed.
287320
*
288321
* @param value
289322
* The intermediate result yielded by suspended continuations
290-
* The value may be accessed via {@link #result} method of continuation returned
323+
* The value may be accessed via {@link #value()} method of continuation returned
291324
*
292325
* @return
293326
* The value to be returned to suspended code after continuation is resumed.

net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/ContinuationDeath.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* a control flow change that needs
66
* the cooperation inside {@link StackRecorder}.
77
*
8-
* <p>
9-
* This class is only for javaflow internal code.
8+
* <p>This class is only for javaflow internal code.</p>
109
*
1110
* @author Kohsuke Kawaguchi
1211
*/

net.tascalate.javaflow.api/src/main/java/org/apache/commons/javaflow/core/StackRecorder.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,21 @@ public final class StackRecorder extends Stack {
5858

5959
/**
6060
* Creates a new empty {@link StackRecorder} that runs the given target.
61+
* @param target
62+
* a target to run
6163
*/
62-
public StackRecorder( final Runnable pTarget ) {
63-
super(pTarget);
64+
public StackRecorder( final Runnable target ) {
65+
super(target);
6466
}
6567

6668
/**
6769
* Creates a clone of the given {@link StackRecorder}.
70+
* @param parent
71+
* a StackRecorder to clone
72+
*
6873
*/
69-
public StackRecorder(final Stack pParent) {
70-
super(pParent);
74+
public StackRecorder(final Stack parent) {
75+
super(parent);
7176
}
7277

7378
public static Object suspend(final SuspendResult value) {
@@ -162,6 +167,12 @@ public static void exit() {
162167
throw ContinuationDeath.INSTANCE;
163168
}
164169

170+
/**
171+
* Access value supplied to resumed method
172+
*
173+
* @return value passed to the resumed method (may be <code>null</code>)
174+
*
175+
*/
165176
public Object getContext() {
166177
return null == parameter ? null : parameter.value();
167178
}
@@ -184,6 +195,8 @@ private void deregisterThread(final StackRecorder old) {
184195

185196
/**
186197
* Return the continuation, which is associated to the current thread.
198+
* @return currently associated continuation stack, or <code>null</code> if invoked outside
199+
* of continuation context
187200
*/
188201
public static StackRecorder get() {
189202
return threadMap.get();

net.tascalate.javaflow.examples/src/main/java/org/apache/commons/javaflow/examples/cancel/CancelExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void main(final String[] argv) throws Exception {
1414
System.out.println("In main after #" + i + " suspend (cc.value = " + cc.value() + ") ");
1515
}
1616
// This will gracefully complete continuation -- finally blocks will be executed
17-
cc.destroy();
17+
cc.terminate();
1818
System.out.println("In main after destroy");
1919
System.out.println("===");
2020
}

net.tascalate.javaflow.spi/src/main/java/org/apache/commons/javaflow/spi/ResourceTransformer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
* Byte-code transformer that enhances the class files for javaflow.
2121
*
2222
* <p>
23-
* When {@link Continuation#suspend()} is called, all the methods
23+
* When Continuation.suspend is called, all the methods
2424
* in the stack frame needs to be enhanced.
2525
*
2626
* @author tcurdt
27-
* @see BcelClassTransformer
28-
* @see AsmClassTransformer
2927
*/
3028
public interface ResourceTransformer {
3129
abstract public byte[] transform( byte[] original );

net.tascalate.javaflow.tools.ant/src/main/java/org/apache/commons/javaflow/ant/AntRewriteTask.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,19 @@ public class AntRewriteTask extends MatchingTask {
3737
/**
3838
* Directory to which the transformed files will be written.
3939
* This can be the same as the source directory.
40+
*
41+
* @param pFile destination directory
4042
*/
4143
public void setDestdir(final File pFile) {
4244
dstDir = pFile;
4345
}
4446

4547
/**
4648
* Directory from which the input files are read.
47-
* This and the inherited {@link MatchingTask} forms an implicit
48-
* {@link FileSet}.
49+
* This and the inherited MatchingTask forms an implicit
50+
* FileSet.
51+
*
52+
* @param pFile source directory
4953
*/
5054
public void setSrcDir(final File pFile) {
5155
srcDir = pFile;

net.tascalate.javaflow.tools.cdi-javaagent/src/main/java/org/apache/commons/javaflow/instrumentation/cdi/CdiProxyInstrumentationAgent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class CdiProxyInstrumentationAgent {
1111
* will be called. Then the real application main method will be called.
1212
*
1313
* @param args
14-
* @param inst
14+
* @param instrumentation
1515
* @throws Exception
1616
*/
1717
public static void premain(String args, Instrumentation instrumentation) throws Exception {
@@ -25,7 +25,7 @@ public static void premain(String args, Instrumentation instrumentation) throws
2525
* started after VM startup.
2626
*
2727
* @param args
28-
* @param inst
28+
* @param instrumentation
2929
* @throws Exception
3030
*/
3131
public static void agentmain(String args, Instrumentation instrumentation) throws Exception {

0 commit comments

Comments
 (0)