Documentation
The AnnotationService is available to Pod beans just like the AgentService and SesssionService are.
The AnnotationService currently provides annotations on Pods or Rims, it might be extended to support Offerings and Curnits, and possibly Socks and SockEntries.
The interface currently looks like:
public interface AnnotationService { /** * Return the list of annotations associated with this entity and * agent. * * @param sailEntity currently this has to be a Pod or Rim * @param agent this is typically a workgroup * @return */ public IAnnotation [] getAnnotations(Object sailEntity, IAgent agent); /** * Returns the first annotation associated with this entity and * agent which has the requested source. * * @param sailEntity * @param agent * @param source * @return */ public IAnnotation getAnnotation(Object sailEntity, IAgent agent, String source); }
The IAnnotation interface looks like:
public interface IAnnotation { /** * This is a URI identifying the type of this annotation. * * The name source came from the EAnnotation object used by EMF. * The use of a URI to identify a type is used by: * xml namespaces and RDF * * @return */ public String getSource(); public void setSource(String source); /** * The mime type for the content of the Annotation. Unlike EMF these * annotations can only store strings. So a content type is useful * to help parse string, * * @return */ public String getContentType(); public void setContentType(String contentType); /** * The actual content of the annotation. * * @return */ public String getContents(); public void setContents(String contents); /** * Return the entity that this is an annoation of. Currently this * can be a Pod or Rim. * * @return */ public Object getSailEntity(); public void setSailEntity(Object entity); }
Testing
The AnnotationService can be tested by first running the main class:
src/test/java/ net.sf.sail.test.annotation.BuildAnnotationTestCurnit
which create a curnit
target/curnit-ANNOTATION_TEST.jar
Then run the main class:
src/test/java/ net.sf.sail.test.annotation.AnnotationLauncherTest
The curnit built contains a AnnotationTestBean which gets the annotation from itself and prints it out.
The Launcher runs the curnit in an enviroment that has a AnnotationServiceTestImpl setup. This test annotation service always returns an annotation foreach entity that is requested.
Changes to add the Annotation Service
Runtime Changes
- created IAnnotation
- created AnnotationService - like AgentService
- updated SessionContext.SerivceProvider so it can provide AnnotationService
- updated SessionDataService so it can provide an AnnotationService
- updated PreviewSessionDataService so it returns a null annotation service
- updated DelegatingDataService so it stores and provides annotation service
- updated SessionManagerImpl so it gets the AnnotationService out of the serviceContext
and passes it to the DelegatingDataService - created MemoryAnnotation which is a simple annotation implementation
Testing Changes
- created annotationTestBundles.xml which has the standard preview bundles plus a
testing annotation service. - created AnnotationLauncherTest to run the BundleLauncher with annotationTestBundles.xml
- created AnnotationServiceTestImpl to provide a dummy implementation of the AnnotationService
- created AnnotationTestBean to simply request the annotation of itself and print them out.
- created BuildAnnotationTestCurnit to create a curnit with the AnnotationTestBean