Skip to content

Commit

Permalink
updated the optional/not-optional semantics of cleanup, prepare, and …
Browse files Browse the repository at this point in the history
…start. updated javadoc
  • Loading branch information
cwensel committed Jul 31, 2010
1 parent c991f9b commit 5d9523b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/java/riffle/process/ProcessStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
* The ProcessStart method is called after the {@link ProcessPrepare} method. It may be called by the
* {@link ProcessComplete} method (but will block till the process is finished).
* <p/>
* This annotation is not optional.
* This annotation is optional. Calling methods should test for its existence with the
* {@link riffle.process.scheduler.ProcessWrapper#hasStart} method and should call the corresponding
* ProcessComplete annotated method.
*
* @see ProcessPrepare
* @see ProcessComplete
Expand Down
61 changes: 56 additions & 5 deletions src/java/riffle/process/scheduler/ProcessWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
*
* @see ProcessChain
* @see riffle.process.Process
* @see riffle.process.ProcessPrepare
* @see riffle.process.ProcessStart
* @see ProcessPrepare
* @see ProcessStart
* @see riffle.process.ProcessStop
* @see riffle.process.ProcessComplete
* @see riffle.process.ProcessCleanup
* @see ProcessCleanup
* @see riffle.process.DependencyOutgoing
* @see riffle.process.DependencyIncoming
*/
Expand All @@ -61,7 +61,6 @@ private void verifyObjectIsProcess( Object process )

findMethodWith( DependencyOutgoing.class, false );
findMethodWith( DependencyIncoming.class, false );
findMethodWith( ProcessStart.class, false );
findMethodWith( ProcessComplete.class, false );
findMethodWith( ProcessStop.class, false );
}
Expand All @@ -76,19 +75,71 @@ public Object getDependencyIncoming() throws ProcessException
return findInvoke( DependencyIncoming.class, false );
}

/**
* Method hasPrepare returns true if the annotated child Process object implements the {@link ProcessPrepare} method.
*
* @return boolean
*/
public boolean hasPrepare()
{
return findMethodWith( ProcessPrepare.class, true ) != null;
}

/**
* Method prepare calls the annotated child Process object {@link ProcessPrepare} method.
* <p/>
* This method will not fail if the prepare method is not implemented.
*
* @throws ProcessException when
*/
public void prepare() throws ProcessException
{
findInvoke( ProcessPrepare.class, true );
}

/**
* Method hasCleanup returns true if the annotated child Process object implements the {@link ProcessCleanup} method.
*
* @return boolean
*/
public boolean hasCleanup()
{
return findMethodWith( ProcessCleanup.class, true ) != null;
}

/**
* Method cleanup calls the annotated child Process object {@link ProcessCleanup} method.
* <p/>
* This method will not fail if the cleanup method is not implemented.
*
* @throws ProcessException when
*/
public void cleanup() throws ProcessException
{
findInvoke( ProcessCleanup.class, true );
}

/**
* Method hasStart returns true if the annotated child Process object implements the {@link ProcessStart} method.
*
* @return boolean
*/
public boolean hasStart()
{
return findMethodWith( ProcessStart.class, true ) != null;
}

/**
* Method start calls the annotated child Process object {@link ProcessStart} method.
* <p/>
* This method will throw an exception if the start method is not implemented. Call {@link #hasStart()}
* to verify before calling.
*
* @throws ProcessException when there is a failure
*/
public void start() throws ProcessException
{
findInvoke( ProcessStart.class, false );
findInvoke( ProcessStart.class, true );
}

public void complete() throws ProcessException
Expand Down

0 comments on commit 5d9523b

Please sign in to comment.