Writing Servlets

All servlets must implement the ServletAPI.Servlet Java interface.

package ServletAPI;
public interface Servlet {
    public String GetServletID() throws ServletAPIException;
    public String GetServletDescriptor() throws ServletAPIException;
    public String GetTypeSignatureID() throws ServletAPIException;
    public AttachmentRoleSpec[] GetAttachmentSpecification() throws ServletAPIException;
    public AttachmentDef GetAttachmentDefinition() throws ServletAPIException;
    public void SetDataStream(String roleName, String DSMIMEType, java.io.InputStream DSByteStream) throws AttachmentException, ServletAPIException;
    public String[] GetValidResultTypeList(ServletAPI.MethodSignature MethodSignature) throws ServletAPIException;
}

GetServletID()

GetServletID() should return the registered ID for this servlet.

GetServletDescriptor()

GetServletDescriptor() should return a description of the servlet intended for the user.

GetTypeSignatureID()

GetTypeSignatureID() should return the registered ID for the type signature of the type that this servlet implements.

GetAttachmentSpecification()

GetAttachmentSpecification() provides descriptions of the attachments in a AttachmentRoleSpec array. Each type of attachment the servlet intends to handle should have a AttachmentRoleSpec element in the array.

  package ServletAPI;

  public class AttachmentRoleSpec {
      public String roleName;
      public boolean requiredIndicator;
      public ServletAPI.Ordinality ordinality;
      public String[] MIMETypes;
      public AttachmentRoleSpec(String roleName, boolean requiredIndicator, ServletAPI.Ordinality ordinality, String[] MIMETypes);
  }
The variable roleName specifies the name to which attachments of this type will be referred to as. Setting the flag requiredIndicator marks this attachment type as mandatory, and no dissemination will be allowed unless an attachment of this type is present. The variable ordinality indicates how many data streams can be set to this attachment role. An ordinality of 1 would mean no more than one data stream is allowed to be attached to this role. Finally, MIMEtypes is simple an array of MIME types that this attachment role will accept as valid.

GetAttachmentDefinition

GetAttachmentDefinition() is intended to return an attachment definition for the servlet. This is to provide a machine-readable description of allowed attachments. An attachment definition would be created from the class ServletAPI.AttachmentDef.

  package ServletAPI;

  public class AttachmentDef {
      public String encoding;
      public byte[] definition;
      public AttachmentDef(String encoding, byte[] definition);
    }
This function is optional, and an empty array can be returned if no such information is necessary.

SetDataStream()

The method SetDataStream(String roleName, String MIMEType, java.io.InputStream DSByteStream) will be called by the repository server to attach data streams to the servlet. The servlet should read in the datastream, and store it internally for use when servlet methods are called.

GetValidResultTypeList()

The final method in the interface, GetValidResultTypeList(), should return an array of Strings containing all the MIME Types this servlet could possibly return.

Type Specific Methods

Additionally, any methods described in the servlets type signature must be implemented as well. These methods must strictly adhere to the specifications set forth in the type signature.

Example

An example servlet can be found in the file TestTypeImplementation.java.