[
http://issues.ops4j.org/browse/QI-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13560#action_13560
]
Rickard Öberg commented on QI-249:
----------------------------------
All visitor interfaces and usages thereof have been changed to use the generic
ThrowableType pattern
> Visitor-pattern to work with throws -declaration
> ------------------------------------------------
>
> Key: QI-249
> URL: http://issues.ops4j.org/browse/QI-249
> Project: Qi4j
> Issue Type: Improvement
> Components: API, Core Runtime
> Affects Versions: 1.1
> Environment: Any environment capable of running Qi4j-application.
> Reporter: Stanislav Muhametsin
> Assignee: Rickard Öberg
> Fix For: 1.2
>
>
> Currently, for example the org.qi4j.api.property.StateHolder has method
> "public void visitProperties( StateVisitor visitor);" where StateVisitor has
> one method "public void visitProperty(...);". It is supposed to be used
> something like "holder.visitProperties(new StateVisitor() { [implementation
> of visitProperty] });". This works great as long as code implementing
> visitProperty doesn't invoke anything that has "throws XXXException" in its
> method declaration. If this happens, things start to get really awkward - one
> must catch exception, wrap it into something that extends RuntimeException
> (preferably class unique to this usecase), then catch it outside invokation
> of visitProperties(...), and possibly unwrap exception and throw it again.
> To easen up implementing this scenario, each interface which has visitXXX
> method working as visitor-pattern, could have additional method, like this:
> {{public <T> void visitXXXWithThrowable(XXXVisitorWithThrowable<T> visitor)
> throws T;}}
> where XXXVisitorWithThrowable could be something like this:
> {noformat}
> public interface XXXVisitorWithThrowable<T>
> {
> public void visitXXX(...) throws T;
> }
> {noformat}
> Client code may then invoke, for example,
> holder.visitPropertiesWithThrowable(new
> StateVisitorWithThrowable<SQLException> { [implementation of
> visitProperty(...) throw SQLException] } );
> Because the method has different name, and there are no changes (only
> additions) to any working interfaces and APIs, this improvement would be
> backwards-compatible too.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.ops4j.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev