org.iids.aos.negotiation
Class Template

java.lang.Object
  extended by org.iids.aos.negotiation.Template
All Implemented Interfaces:
java.io.Serializable

public class Template
extends java.lang.Object
implements java.io.Serializable

A wrapper class around the wsagreement.Template type. Allows for some more high-level access to the template fields.

A Template is a document that is presented by the service providers and mediators in AgentScape. It contains definitions of services that are offered, and the restrictions that apply to the range of values that can be set in these fields.

To services that are defined in a template can be obtained by the methods getServiceNames(), getService(java.lang.String) and getServices(). The Service objects that are returned from these functions describe the service, properties and restrictions of these services.

Author:
Reinier Timmer (rjtimmer@cs.vu.nl)
See Also:
Serialized Form

Constructor Summary
Template(Template template)
          Create a new Template, wrapping a wsagreement template.
 
Method Summary
 boolean definesServiceName(java.lang.String serviceName)
          A check to see if the template defines a specific SDT.
 Request generateRequest()
          Create a Request based on this template.
 Request generateRequest(java.lang.Object initiator)
          Create a Request based on this template.
 java.lang.String getName()
          Obtain the template name.
 AgentScapeID getPublisher()
          Obtain the AgentScapeID of the party that published this template.
 Service getService(java.lang.String serviceName)
          Obtain the service definition of a service defined in this template.
 java.util.List<java.lang.String> getServiceNames()
          List the names of all the services that are described in this template.
 java.util.List<Service> getServices()
          Obtain a list of the services defined in this template.
 Template getTemplate()
          Obtain the native form of the template.
static void main(java.lang.String[] args)
          Main method.
static Template readTemplate(java.io.File file)
          Read a template from a file.
 java.lang.String toString()
          Get the XML marshalled document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Template

public Template(Template template)
Create a new Template, wrapping a wsagreement template. The resulting Template can be used to query the template for information.

Method Detail

getTemplate

public Template getTemplate()
Obtain the native form of the template.

Returns:
A Template containing the native format of the template.

generateRequest

public Request generateRequest()
Create a Request based on this template. This copies the template information from the Template to the Request. Initially, no service properties are set in the Request.

Returns:
An empty request based on this Template.

generateRequest

public Request generateRequest(java.lang.Object initiator)
Create a Request based on this template. This copies the template information from the Template to the Request. This template is empty except for the agreement initiator field that is set to the value of initiator.

Parameters:
initiator - The party that initiated the request.
Returns:
An empty request based on this Template.

getName

public java.lang.String getName()
Obtain the template name.

Returns:
The name of the template.

getServiceNames

public java.util.List<java.lang.String> getServiceNames()
List the names of all the services that are described in this template. Each String can be used as an argument to getService(String) to obtain the respective service with the associated name.

Returns:
A list of all the service names described in this template. For each String in this list, there is exactly one associated Service.

definesServiceName

public boolean definesServiceName(java.lang.String serviceName)
A check to see if the template defines a specific SDT.

Returns:
true if the service is defined in the template
false if the service is not defined in the template

getService

public Service getService(java.lang.String serviceName)
                   throws TemplateException
Obtain the service definition of a service defined in this template. This service definition can be queried for settable fields.

Parameters:
serviceName - The name of the type of service (as defined in AgentScapeResources).
Returns:
The Service associated with serviceName.
Throws:
TemplateException

getServices

public java.util.List<Service> getServices()
Obtain a list of the services defined in this template.

Returns:
A list of all services that are described in this template. These Service objects can be queried for properties and restrictions that apply to the properties of this template.

getPublisher

public AgentScapeID getPublisher()
Obtain the AgentScapeID of the party that published this template.

Returns:
The AgentScapeID of the party (location manager, host manager or other service provider) that published this template.

toString

public java.lang.String toString()
Get the XML marshalled document. Really onlt required for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
A String containing the current Template information in XML representation.

readTemplate

public static Template readTemplate(java.io.File file)
Read a template from a file. This file should contain the template in XML format (as obtained from toString()).

Parameters:
file - The file containing the template in XML format.
Returns:
The Java representation of the template.

main

public static void main(java.lang.String[] args)
Main method. Used for debugging/testing only.



Copyright © 2003, 2004 IIDS Group. All Rights Reserved.