Title: Templates in the Themis Structural Computing Environment
1Templates in the Themis Structural Computing
Environment
- Van Lepthien
- University of Colorado, Boulder
- 11 November 2002
2Structural Computing
- Evolution from Open Hypermedia
- Open hypermedia provides sophisticated
application infrastructure (support for
distribution, persistence, event notification)
over traditional hypermedia structures. - Structural computing is a generalization that
tries to provide these services over generic
structures. - Structural computing aims to provide
hypermedia-like tools to developers to support
domain-specific application development.
3Overview
- Themis is a structural computing environment
focused on structure templates and structure
transformation - Start with generic structure server and make it
easy to define new structures provide basic
services help automate structure transformation - Purpose of this talk
- Explain benefits of the structural computing
approach. - Demonstrate the power of adding a template
mechanism to the core functionality of Themis.
4Themis Class Structure
Themis
5Themis Components
- Attribute
- A name value pair.
- The name is a character string.
- A name is unique within an element.
- The value can be one ofnull, String, Numeric,
Object, or Element - Object
- An immutable object which is stored in the Themis
repository
6Implementation Class Structure
Themis
7Comparison of Data Representations
- To show further motivation for the structural
computing approach, we now review how traditional
approaches to data modeling handle a
representative example. - Example
- Shipment from one location to another.
- The shipment contains a number of packages
- Each package may have a packing list describing
its contents. - A package may take part in more than one shipment.
8Comparison Overview
- Logical view
- Hierarchical Database View
- Relational Database View
- Object Oriented Database View
- Structure Repository View
9Data RepresentationLogical View
Shipment
Location
Shipment
Source
Location
Destination
Source
Destination
Location
Package
Package
Package
PackingList
PackingList
Item
Item
Item
Item
Item
Item
Item
10Data RepresentationHierarchical DatabaseLogical
View
Shipment
Source
Shipment
Source
Destination
Destination
Package
Package
Package
Package
PackingList
PackingList
PackingList
Item
Item
Item
Item
Item
Item
Item
Item
Item
Item
11Data RepresentationHierarchical
DatabasePhysical View
Shipment
Source
Destination
?
Package
PackingList
Item
Item
Item
Item
?
ø
PackingList
Package
Package
Item
Item
Item
ø
ø
?
ø
Shipment
Source
Destination
?
PackingList
Package
Item
Item
Item
ø
ø
12Data RepresentationRelational DatabaseLogical
View
Shipment
Location
has-Source
contains
has-Destination
Package
has
0..1
PackingList
0..
Product
Item
contains
instantiates
13Data RepresentationRelational DatabasePhysical
View
Shipment
Item
Location
Shipment-Package
Product
PackingList
Package
14Data RepresentationObject DatabaseLogical View
15Data RepresentationObject DatabasePhysical View
- We dont see it, so we probably dont care.
16Data RepresentationStructure Repository
Shipment
Shipment
Source
Whouse A
ABC Co.
Destination
Source
Destination
MW Dist
Package
Package
Package
X Mfg. Co. PackingList
A. Corp PackingList
Item
Item
Item
Item
Item
Item
Item
http//ACorp.com/Catalog/...
Product
Product
Product
Product
Product
Product
Product
17Simple Structures
class Shipment extends Collection
Shipment(Repository r, ID src, ID dest, Set
packages) super(r) Attribute typeAttr
new Attribute("type","shipment") Attribute
srcAttr new Attribute("source",src)
Attribute dstAttr new Attribute("destination",de
st) addAttribute(typeAttr)
addAttribute(srcAttr) addAttribute(dstAttr)
copy(packages)
attribute source
atom Whouse
attribute loc_name
collection Shipment
attribute Address
atom DistCenter
attribute destination
class Warehouse extends Atom
Warehouse(Repository r,String name, Address
address) super(r) Attribute typeAttr
new Attribute("type","Warehouse") Attribute
nameAttr new Attribute("loc_name",name)
ObjectID lAddress r.addObject(address)
Attribute addrAttr new Attribute("Address",lAddr
ess) addAttribute(typeAttr)
addAttribute(nameAttr) addAttribute(addrAttr)
attribute loc_name
attribute Address
atom Package
atom Package
atom Package
class DistCenter extends Atom
DistCenter(Repository r, String name, Address
address, Person manager)
Collection PackingList
XMfgCoPackingList
Warehouse source new Warehouse(repository,
Portland, new Address(US,123 5th St,
Portland,OR))
DistCenter dest new DistCenter(repository,
Chicago, new Address(US,4900 State St,
Chicago,IL))
atom A-Item
atom A-Item
atom A-Item
atom A-Item
Set packages
Shipment shipment new Shipment( repository,
source, dest, packages)
18Drawbacks of Simple Structures
- Structure classes must be known to the client
applications. - Versioning of a structure type will require tight
coordination with and among clients. - Client applications are forced to be written in
Java. - A client can implement its own version of a
structure, which may be incompatible with other
implementations.
19Template Motivation
- We want a generic description of a structure
- A shipment has a source, a destination, and
contains a set of packages
attribute source
source?
collection Shipment
attribute destination
destination?
atom Package
atom Package
atom Package
- Specifically, from the Shipment point of view, we
may know nothing about the instantiations of
source, destination, or the content of packages.
20Template Objectives
- Structures need to be defined without requiring
Java classes for instantiation. We call such a
definition a template. - A structure definition needs to be reusable as a
substructure of another structure. - Values of a structures elements need to be set
in the template (either as constants or as
defaults) or by the client application when the
structure is to be instantiated. - The client application needs to be able to set
the values for an instantiation without knowing
the internal details of the structure. - The application needs to be able to retrieve
values from a instantiated template based
structure without knowing internal details of the
structure.
21Template Definition(1)
template Warehouse
Template t newTemplate(r, Warehouse")
Atom warehouse t.createAtom() t.elementName(w
arehouse , Warehouse") Attribute typeAttr
new Attribute("type",warehouse")
atom Warehouse
Attribute loc_name
instantiationName Name
Attribute loc new Attribute(loc_name") t.set
Instantiation(loc,Name")
warehouse.addAttribute(loc)
Attribute address
Attribute addr new Attribute(address") t.
setInstantiation(addr,Address")
warehouse.addAttribute(addr)
instantiationName Address
t.end()
22Template Definition(2)
Template t newTemplate(r, "Shipment")
template Shipment
Collection shipment t.createCollection() t.el
ementName(shipment, "Shipment") Attribute
typeAttr new Attribute("type","shipment")
attribute source
collection Shipment
instantiationName Source
Attribute sn new Attribute("source") t.setIns
tantiation(sn,Source")
shipment.addAttribute(sn)
attribute destination
instantiationName Packages
Attribute dn new Attribute("destination")
t.setInstantiation(dw,Destination") shipment.ad
dAttribute(dn)
instantiationName Destination
t.setInstantiation(shipment, Packages")
t.end()
23Template Instantiation(1)
template Warehouse
Repository r Repository.openRepository() Templ
ateInstantiator src r.getTemplateInstantiator
(Warehouse)
atom Warehouse
Attribute loc_name
src.setValue(Name,Portland)
ObjectID oid r.createObject( new
Address(US,123 5th St,
Portland,OR))
instantiationName Name
src.setValue(Address, oid )
src.instantiate()
Attribute address
Atom aSrc src.getElement(Warehouse)
instantiationName Address
Name
String Portland
Address US,123 5th St., Portland, OR))
atom Warehouse
Attribute loc_name
Address
Attribute address
objectId (address)
Serialized_object Address
24Template Instantiation(2)
Repository r Repository.openRepository() Ato
m aSrc Atom aDest Set packages
template Shipment
attribute source
collection Shipment
instantiationName Source
TemplateInstantiator ship r.getTemplateInstan
tiator(Shipment)
attribute destination
ship.setValue(Source,aSrc)
instantiationName Packages
ship.setValue(Destination,aDest)
ship.setValue(Packages, packages )
instantiationName Destination
ship.instantiate()
String Portland
attribute source
atom Warehouse
Attribute loc_name
collection Shipment
Attribute address
objectId (address)
Serialized_object Address
attribute destination
Atom Package
atom DistCenter
Attribute address
Atom Package
Atom Package
25Subtemplates
- Subtemplates can be included in a template by use
of the includeTemplate( templateName, label)
method. The label is used for distinguishing
instanitationNames in the subtemplate. For
instance, if the Shipment template explicitly
included a warehouse as a source, this code would
be used
Template t newTemplate(r, "Shipment")
Subtemplate wSource includeTemplate(
Warehouse, source) Atom aSrc
wSourct.getElement(Warehouse) Attribute source
new Attribute(source, aSrc) t.end()
Instantiation code would include
TemplateInstantiator ship r.getTemplateInstan
tiator(Shipment) Ship.setValue(source.Name,
Portland)
26Future Work
- Reflection in Templates
- Template-Based Transformations
- XML Template Definition / Import / Export
27Summation
- Structural computing leverages the techniques of
open hypermedia to offer substantial benefits for
applications that have to deal with a
heterogeneous set of entities. - The Themis template mechanism offers a way to
develop persistent structure definitions that
enable application developers to share structures
without being tied to any particular data
representation.
28References
- 1Peter J. Nürnberg and John J. Leggett. As We
Should Have Thought. In Eighth ACM Conference on
Hypertext, pages 96101, Southampton , UK, April
1997. - 2K. M. Anderson, S. A. Sherba, W. V. Lepthien,
The Themis Structural Computing Environment -
Structural Templates and Transformations,
Journal Of Network And Computer Applications,
Special Issue on Structural Computing, vol. 25,
no. 4. October 2002.