Hi Michael and Daryoush.
After I sent the last email, I've been thinking how to retrieve
the result status of the annotation processing from APT and
Daryoush's suggestion which is "the process of validation and
building the Object model should be decoupled."
I think that the best way is to make a wrapper class of APT and
the wapper class returns a class which holds a result status,
an object model and warning or error messages if there are.
It's better to be applied to WsmReflectionAnnotationProcessor as well.
For example, the class returned from the wrapper class will be...
public class ProcessorResult{
public enum Status { SUCCESS, WARN, FAIL }
private Status status;
private ObjectModel serviceImplementObjectModel;
private ObjectModel endpointInterfaceObjectModel; // if there is.
private ObjectModel resultObjectModel;
private List errorMessages;
public void validate(){
....
try{
if(....){
setStatus(Status.FAIL)
errorMessages.add( "...." )
return;
}else if(....){
setStatus(Status.WARN)
errorMessages.add( "..." )
if(...){
setStatus(Status.WARN)
errorMessages.add( "..." )
}
}
setStatus( SUCESS )
}catch(...){
setStatus( FAIL )
}
}
setter/getter methods...
}
The caller does like ...
AptWrapperClass awc = new AptWrapperClass(...);
ProcessorResult processorResult = awc.getProcessorResult();
processorResult.validate();
if( processorResult.getStatus() == ProcessorResult.Status.SUCCESS ){
succeeded, so do something.
}else if ( processorResult.getStatus() == ProcessorResult.Statu.WARN ){
...
processorResult.getErrorMessages();
}else{
failed, so do something.
}
Disadvantage of this implementation is that all classes currently using
the processors ( WsmAnnotationProcessor, WsmReflectionAnnotationProcessor )
must be modified.
But this is much clean implementation.
any suggestions/opinions/recommendations or jokes ??
Thanks in advance.
Wolfgang.