Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Howto: Register Annotation Routers

< To: Tigerstripe_APIs
Annotation Framework provide configuration to setting where annotations can be saved. This configuration named Annotation Routers. Annotation Routers map annotation object to corresponding storage. If there is no one router specify for the annotation it will be saved in the default annotations location (located in the plug-in metadata). Annotation Router can be registered with the org.eclipse.tigerstripe.annotation.core.router extension point:


ResourceRouter show how we can use router to save resource annotation to the project specific path:

 public class ResourceRouter implements EObjectRouter {
     private static final String ANNOTATIONS_FILE_NAME = ".ann";
     protected URI getUri(IResource res) {
         IPath path = res.getProject().getFullPath();
         if (path != null) {
             path = path.append(ANNOTATIONS_FILE_NAME);
             return URI.createPlatformResourceURI(path.toString(), false);
         return null;
     public URI route(EObject object) {
         if (object instanceof Annotation) {
             Annotation annotation = (Annotation)object;
             Object annotable =  AnnotationPlugin.getManager().getAnnotatedObject(annotation);
             if (annotable instanceof IResource) {
                 IResource resource = (IResource)annotable;
                 return getUri(resource);
         return null;

With the route(EObject) method we map object to some URI. If this object can not be routed (annotable object is not a resource), this method return null and will be saved to the default location or location specified with an another router. This URI will be used to get resource with ResourceSet.createResource(URI) and ResourceSet.getResource(URI, boolean) methods

Back to the top