You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by di...@apache.org on 2003/09/23 21:38:52 UTC
cvs commit: ws-site/targets/jaxme/js/patterns chains.html proxy.html typesafeenum.html versioning.html chains.pdf proxy.pdf typesafeenum.pdf versioning.pdf
dims 2003/09/23 12:38:52
Added: targets/jaxme/js/patterns chains.html proxy.html
typesafeenum.html versioning.html chains.pdf
proxy.pdf typesafeenum.pdf versioning.pdf
Log:
jaxme website
Revision Changes Path
1.1 ws-site/targets/jaxme/js/patterns/chains.html
Index: chains.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Proxy chains (also known as: Delegator pattern)</title>
<link type="text/css" href="../../skin/page.css" rel="stylesheet">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<!--================= start Navigation Path ==================-->
<table summary="navigation path" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td nowrap="nowrap" valign="middle" bgcolor="#CFDCED" height="20"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><!--===== breadcrumb trail (javascript-generated) ====--><font size="2" face="Arial, Helvetica, Sans-serif"><script src="../../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script></font></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" height="2"><img height="2" width="2" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Navigation Path ==================-->
<!--================= start Banner ==================-->
<table summary="header with logos" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<!--================= start Group Logo ==================-->
<td bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/"><img border="0" class="logoImage" alt="JaxMe 2" src="../../images/group-logo.gif"></a></td>
<!--================= end Group Logo ==================-->
<!--================= start Project Logo ==================--><td width="100%" align="center" bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/">JaxMe 2</a></td>
<!--================= end Project Logo ==================-->
<!--================= start Search ==================--><td valign="top" rowspan="2" bgcolor="#294563">
<form target="_blank" action="http://www.google.com/search" method="get">
<table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
<tr>
<td colspan="3"><img height="10" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap"><input value="ws.apache.org/JaxMe/" name="sitesearch" type="hidden"><input size="15" name="q" id="query" type="text"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><input name="Search" value="Search" type="submit">
<br>
<font face="Arial, Helvetica, Sans-serif" size="2" color="white">
the JaxMe 2 site
</font></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-left.gif"></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-right.gif"></td>
</tr>
</table>
</form>
</td>
<!--================= start Search ==================--><td bgcolor="#294563"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" bgcolor="#294563" colspan="2">
<!--================= start Tabs ==================-->
<div class="tab">
<table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../index.html">JaxMe 2</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../api/index.html">JAXB API</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="selected tab" style="height: 1.8em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-left.gif"></td><td valign="middle" bgcolor="#4C6C8F"><font color="#ffffff" size="2" face="Arial, Helvetica, Sans-serif"><b><a class="base-selected" href="../../js/index.html">JaxMeJS</a></b></font></td><td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-right.gif"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../xs/index.html">JaxMeXS</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!--================= end Tabs ==================-->
</td><td bgcolor="#294563"><img alt="" width="1" height="1" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" colspan="4"><img width="1" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Banner ==================-->
<!--================= start Menu, NavBar, Content ==================-->
<table summary="page content" bgcolor="#ffffff" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table summary="menu" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--================= start left top NavBar ==================-->
<td rowspan="3" valign="top">
<table summary="blue line" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#CFDCED"><font color="#4C6C8F" size="4" face="Arial, Helvetica, Sans-serif"> </font></td>
</tr>
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td>
<!--================= end left top NavBar ==================--><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap" valign="top" bgcolor="#4C6C8F">
<!--================= start Menu items ==================-->
<div class="menu">
<ul>
<li>
<font color="#CFDCED">JaxMeJS</font>
<ul>
<li>
<a href="../index.html">Introduction</a>
</li>
<li>
<a href="../factory.html">The JavaSource factory</a>
</li>
<li>
<a href="../methods.html">Writing methods</a>
</li>
<li>
<a href="../placeholders.html">Placeholders</a>
</li>
<li>
<a href="../optimizations.html">Optimizations</a>
</li>
<li>
<a href="../sql.html">Writing SQL</a>
</li>
</ul>
</li>
<li>
<font color="#CFDCED">Patterns</font>
<ul>
<li>
<a href="proxy.html">Proxy Objects</a>
</li>
<li>
<a href="proxy.html#multiple_inheritance">Multiple Inheritance</a>
</li>
<li>
<a href="typesafeenum.html">Typesafe Enumerations</a>
</li>
<li>
<span class="sel"><font color="#ffcc00">Proxy chains</font></span>
</li>
<li>
<a href="versioning.html">Versioning</a>
</li>
</ul>
</li>
</ul>
</div>
<!--================= end Menu items ==================-->
</td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" align="left" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-left.gif"></td><td bgcolor="#4C6C8F"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" align="right" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-right.gif"></td>
</tr>
<tr>
<td height="1" bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td><td valign="top" width="100%">
<table summary="content" width="100%" border="0" cellpadding="0" cellspacing="0">
<!--================= start middle NavBar ==================-->
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td align="left" width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="right" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end middle NavBar ==================-->
<!--================= start Content==================-->
<tr>
<td align="left" width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="100%">
<div xmlns:xhtml="http://www.w3.org/1999/xhtml" class="content">
<table class="title" summary="">
<tr>
<td valign="middle">
<h1>Proxy chains (also known as: Delegator pattern)</h1>
</td><td nowrap="nowrap" width="40" align="center"><a class="dida" href="chains.pdf"><img alt="PDF" src="../../skin/images/pdfdoc.gif" class="skin"><br>
PDF</a></td>
</tr>
</table>
<a name="chains"></a>
<p>The proxy chain is best explained with the situation it was made for.
Suggest a really complex source generator with varying options. For example,
a child element of an object can have multiplicity zero, one or more: In
the latter case the child element will most probably be represented by a
list. Quite necessarily the source generator will sonner or later be
bloated with statements like</p>
<pre class="code">
if (child.isMultiple()) {
// Do something, working with a List
...
} else {
// Do something else, working with a single element
}
</pre>
<p>Even worse, the code will in both cases look quite similar: As soon as the
list item is fetched and casted to a proper type, this is just like working
with a single item. As time goes by, more and more similar options come into
play: Localization, varying datatypes, and so on. Soon you start to think of
better solutions.</p>
<p>The first attempt is typically subclassing. For example, if you have
a source generator for the case multiplicity zero or one, it can well
be expanded to the general case, with multiplicity two or more being
handled in the subclass. Localization is handled in the next subclass,
and so on. Your code looks much better now and becomes maintainable
again.</p>
<p>However, time goes by, and more options are added to the source generator:
Transaction handling, encoding issues, and so on. Soon you find yourself in
trouble again: The subclassing approach doesn't work so well anymore, because
in a subclass chain E -> D -> C -> B -> A (where B is a subclass of A, C is
a subclass of B, and so on) you sometimes want all of them, but sometimes
only D -> C -> A or E -> A. At that point of thinking a new approach was born:
The event chain.</p>
<p>The idea is replacing the subclasses with an event interface. For example,
suggest that the source generator might contain code like the following:</p>
<pre class="code">
public class FooGeneratorImpl implements FooGenerator {
public JavaSource getFooClass() {
JavaSource js = factory.newJavaSource(fooClassName, "public");
getXMethod(js);
getYMethod(js);
getZMethod(js);
}
...
}
</pre>
<p>The corresponding interface might look like this:</p>
<pre class="code">
public interface FooGenerator {
public JavaSource getFooClass();
public JavaMethod getXMethod(JavaSource js);
public JavaMethod getYMethod(JavaSource js);
public JavaMethod getZMethod(JavaSource js);
}
</pre>
<p>If you take this methods as events, then you might well write a default
class A implementing the interface. The other classes are implemented as
subclasses of an automatically generated <a href="proxy.html">proxy class</a>.
For example, the class B might just add another method to the <span class="codefrag">Foo</span>.
This might look like the following:</p>
<pre class="code">
public class B extends FooGeneratorProxy {
// Override only the getFooClass() method, all other methods are
// passed to the base generator by the proxy.
public JavaSource getFooClass() {
JavaSource result = super.getFooClass();
JavaMethod bMethod = result.newJavaMethod("bMethod", "void", "public");
return result;
}
}
</pre>
<p>Likewise, the C class might change the interface of method X, and so on.
Any feature is implemented by a single class, which you can optionally add
to the chain (turning the feature on) or remove from the chain (turning the
feature off).</p>
<p>However, there's still a problem left: When you are inside A (the topmost
class) and do a <span class="codefrag">getXMethod()</span>, then you call your own class and
not the chains bottom. This problem is fixed by the following design:</p>
<table class="ForrestTable" cellspacing="1" cellpadding="4">
<tr>
<td colspan="5" rowspan="1">Controller</td><td colspan="1" rowspan="1">Implements FooGenerator</td>
</tr>
<tr>
<td colspan="1" rowspan="1">E</td><td colspan="1" rowspan="1">D</td><td colspan="1" rowspan="1">C</td><td colspan="1" rowspan="1">B</td><td colspan="1" rowspan="1">A</td>
<td colspan="1" rowspan="1">Implements ChainedFooGenerator</td>
</tr>
</table>
<p>The <span class="codefrag">ChainedFooGenerator</span> is exactly matching the
<span class="codefrag">FooGenerator</span> interface, the exception being an additional
parameter <span class="codefrag">FooGenerator pController</span> in all methods. The
FooGenerator interface can be created automatically, also an
implementation of FooGenerator calling the first element in the chain of
<span class="codefrag">ChainedFooGenerator</span> implementations. The manually created classes
have to be changed slightly, here's the updated <span class="codefrag">FooGeneratorImpl</span>:</p>
<pre class="code">
public class FooGeneratorImpl implements ChainedFooGenerator {
public JavaSource getFooClass(FooGenerator pController) {
JavaSource js = factory.newJavaSource(fooClassName, "public");
pController.getXMethod(js);
pController.getYMethod(js);
pController.getZMethod(js);
}
...
}
</pre>
<p>Likewise, here is the updated B class:</p>
<pre class="code">
public class B extends ChainedFooGeneratorProxy {
// Override only the getFooClass() method, all other methods are
// passed to the base generator by the proxy.
public JavaSource getFooClass(FooGenerator pController) {
JavaSource result = super.getFooClass(pController);
JavaMethod bMethod = result.newJavaMethod("bMethod", "void", "public");
return result;
}
}
</pre>
<p>The proxy chain pattern is implemented by the
<a href="../../apidocs/org/apache/ws/jaxme/js/pattern/ChainGenerator.html">ChainGenerator</a>.
From within Ant, it looks like the following:</p>
<pre class="code">
<chainGenerator destDir="src">
<chain
controllerInterfaceName="com.dcx.sein.dbtk.generator.javasg.IModelSG"
chainInterfaceName="com.dcx.sein.dbtk.generator.javasg.auto.IChainedModelSG"
proxyClassName="com.dcx.sein.dbtk.generator.javasg.auto.ChainedModelSGProxy"
implementationClassName="com.dcx.sein.dbtk.generator.javasg.auto.ModelSGImpl"/>
<chain
controllerInterfaceName="com.dcx.sein.dbtk.generator.javasg.IObjectSG"
chainInterfaceName="com.dcx.sein.dbtk.generator.javasg.auto.IChainedObjectSG"
proxyClassName="com.dcx.sein.dbtk.generator.javasg.auto.ChainedObjectSGProxy"
implementationClassName="com.dcx.sein.dbtk.generator.javasg.auto.ObjectSGImpl"/>
</chainGenerator>
</pre>
<p>The <span class="codefrag">controllerInterfaceName</span> is the name of the basic interface.
This is what you actually want to use from the outside. The controller interface
must be available as a compiled class, because it is inspected with Java reflection.
The other classes are generated: The <span class="codefrag">chainInterfaceName</span> is the interface
being implemented by the manually written classes. The <span class="codefrag">proxyClassName</span>
is an automatically generated implementation of the <span class="codefrag">chainInterface</span>,
which passes all events to the next element in the chain. And the
<span class="codefrag">implementationClassName</span> is an also automatically generated implementation
of <span class="codefrag">controllerInterface</span>, that works internally by passing all events
to the first element in the chain.</p>
<div class="attribution"></div>
</div>
</td><td width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end Content==================-->
</table>
</td>
</tr>
</table>
<!--================= end Menu, NavBar, Content ==================-->
<!--================= start Footer ==================-->
<table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"><a href="../../skin/images/label.gif"></a><a href="../../skin/images/page.gif"></a><a href="../../skin/images/chapter.gif"></a><a href="../../skin/images/chapter_open.gif"></a><a href="../../skin/images/current.gif"></a><a href="/favicon.ico"></a></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CFDCED" class="copyright" align="center"><font size="2" face="Arial, Helvetica, Sans-Serif">Copyright ©
2003 Apache Software Foundation All rights reserved.<script type="text/javascript" language="JavaScript"><!--
document.write(" - "+"Last Published: " + document.lastModified);
// --></script></font></td>
</tr>
<tr>
<td colspan="2" align="left" bgcolor="#CFDCED" class="logos"></td>
</tr>
</table>
<!--================= end Footer ==================-->
</body>
</html>
1.1 ws-site/targets/jaxme/js/patterns/proxy.html
Index: proxy.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Proxy objects</title>
<link type="text/css" href="../../skin/page.css" rel="stylesheet">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<!--================= start Navigation Path ==================-->
<table summary="navigation path" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td nowrap="nowrap" valign="middle" bgcolor="#CFDCED" height="20"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><!--===== breadcrumb trail (javascript-generated) ====--><font size="2" face="Arial, Helvetica, Sans-serif"><script src="../../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script></font></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" height="2"><img height="2" width="2" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Navigation Path ==================-->
<!--================= start Banner ==================-->
<table summary="header with logos" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<!--================= start Group Logo ==================-->
<td bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/"><img border="0" class="logoImage" alt="JaxMe 2" src="../../images/group-logo.gif"></a></td>
<!--================= end Group Logo ==================-->
<!--================= start Project Logo ==================--><td width="100%" align="center" bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/">JaxMe 2</a></td>
<!--================= end Project Logo ==================-->
<!--================= start Search ==================--><td valign="top" rowspan="2" bgcolor="#294563">
<form target="_blank" action="http://www.google.com/search" method="get">
<table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
<tr>
<td colspan="3"><img height="10" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap"><input value="ws.apache.org/JaxMe/" name="sitesearch" type="hidden"><input size="15" name="q" id="query" type="text"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><input name="Search" value="Search" type="submit">
<br>
<font face="Arial, Helvetica, Sans-serif" size="2" color="white">
the JaxMe 2 site
</font></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-left.gif"></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-right.gif"></td>
</tr>
</table>
</form>
</td>
<!--================= start Search ==================--><td bgcolor="#294563"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" bgcolor="#294563" colspan="2">
<!--================= start Tabs ==================-->
<div class="tab">
<table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../index.html">JaxMe 2</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../api/index.html">JAXB API</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="selected tab" style="height: 1.8em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-left.gif"></td><td valign="middle" bgcolor="#4C6C8F"><font color="#ffffff" size="2" face="Arial, Helvetica, Sans-serif"><b><a class="base-selected" href="../../js/index.html">JaxMeJS</a></b></font></td><td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-right.gif"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../xs/index.html">JaxMeXS</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!--================= end Tabs ==================-->
</td><td bgcolor="#294563"><img alt="" width="1" height="1" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" colspan="4"><img width="1" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Banner ==================-->
<!--================= start Menu, NavBar, Content ==================-->
<table summary="page content" bgcolor="#ffffff" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table summary="menu" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--================= start left top NavBar ==================-->
<td rowspan="3" valign="top">
<table summary="blue line" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#CFDCED"><font color="#4C6C8F" size="4" face="Arial, Helvetica, Sans-serif"> </font></td>
</tr>
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td>
<!--================= end left top NavBar ==================--><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap" valign="top" bgcolor="#4C6C8F">
<!--================= start Menu items ==================-->
<div class="menu">
<ul>
<li>
<font color="#CFDCED">JaxMeJS</font>
<ul>
<li>
<a href="../index.html">Introduction</a>
</li>
<li>
<a href="../factory.html">The JavaSource factory</a>
</li>
<li>
<a href="../methods.html">Writing methods</a>
</li>
<li>
<a href="../placeholders.html">Placeholders</a>
</li>
<li>
<a href="../optimizations.html">Optimizations</a>
</li>
<li>
<a href="../sql.html">Writing SQL</a>
</li>
</ul>
</li>
<li>
<font color="#CFDCED">Patterns</font>
<ul>
<li>
<span class="sel"><font color="#ffcc00">Proxy Objects</font></span>
</li>
<li>
<a href="proxy.html#multiple_inheritance">Multiple Inheritance</a>
</li>
<li>
<a href="typesafeenum.html">Typesafe Enumerations</a>
</li>
<li>
<a href="chains.html">Proxy chains</a>
</li>
<li>
<a href="versioning.html">Versioning</a>
</li>
</ul>
</li>
</ul>
</div>
<!--================= end Menu items ==================-->
</td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" align="left" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-left.gif"></td><td bgcolor="#4C6C8F"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" align="right" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-right.gif"></td>
</tr>
<tr>
<td height="1" bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td><td valign="top" width="100%">
<table summary="content" width="100%" border="0" cellpadding="0" cellspacing="0">
<!--================= start middle NavBar ==================-->
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td align="left" width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="right" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end middle NavBar ==================-->
<!--================= start Content==================-->
<tr>
<td align="left" width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="100%">
<div xmlns:xhtml="http://www.w3.org/1999/xhtml" class="content">
<table class="title" summary="">
<tr>
<td valign="middle">
<h1>Proxy objects</h1>
</td><td nowrap="nowrap" width="40" align="center"><a class="dida" href="proxy.pdf"><img alt="PDF" src="../../skin/images/pdfdoc.gif" class="skin"><br>
PDF</a></td>
</tr>
</table>
<ul class="minitoc">
<li>
<a href="#Proxy+objects">Proxy objects</a>
</li>
<li>
<a href="#Multiple+Inheritance">Multiple Inheritance</a>
</li>
</ul>
<a name="proxy_objects"></a>
<a name="N1000D"></a><a name="Proxy+objects"></a>
<h3>Proxy objects</h3>
<div style="margin-left: 0 ; border: 2px">
<p>A proxy class is a class that implements a list of interfaces specified at
compile time. The proxy object typically holds a reference to an internal
object that implements the same interfaces (or parts of them). The proxy
object is implemented by delegating method calls to the internal object.
This is the same principle as implemented by the class
<span class="codefrag">java.lang.reflect.Proxy</span>, which created proxy objects dynamically
at runtime using Java reflection.</p>
<p>Compared to the standard Proxy class, the generator has the obvious
disadvantage, that you have to specify the implemented interfaces at runtime.
On the other hand, it allows both to select the proxy objects super class and
the derivation of subclasses. In fact the derivation of a subclass is much
more obvious, simple and faster than the use of an InvocationHandler.</p>
<p>The proxy generator is implemented by the class
<a href="../../apidocs/org/apache/ws/jaxme/js/pattern/ProxyGenerator.html">ProxyGenerator</a>.
Use of the ProxyGenerator is demonstrated in the Ant target "generate.proxy".</p>
</div>
<a name="multiple_inheritance"></a>
<a name="N10026"></a><a name="Multiple+Inheritance"></a>
<h3>Multiple Inheritance</h3>
<div style="margin-left: 0 ; border: 2px">
<p>Multiple inheritance is a design pattern which is not so easy to implement
in Java - unless you use the
<a href="../../apidocs/org/apache/ws/jaxme/js/pattern/ProxyGenerator.html">ProxyGenerator</a>.
This is demonstrated by the JUnit test
<a href="../../apidocs/org/apache/ws/jaxme/js/junit/MultipleInheritanceTest.html">MultipleInheritanceTest</a>,
which creates a subclass of <span class="codefrag">java.util.Observable</span>, that also inherits
from <span class="codefrag">java.util.ArrayList</span>. The example implements a list, which
notifies its observers whenever the <span class="codefrag">add()</span> method is invoked.</p>
</div>
<div class="attribution"></div>
</div>
</td><td width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end Content==================-->
</table>
</td>
</tr>
</table>
<!--================= end Menu, NavBar, Content ==================-->
<!--================= start Footer ==================-->
<table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"><a href="../../skin/images/label.gif"></a><a href="../../skin/images/page.gif"></a><a href="../../skin/images/chapter.gif"></a><a href="../../skin/images/chapter_open.gif"></a><a href="../../skin/images/current.gif"></a><a href="/favicon.ico"></a></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CFDCED" class="copyright" align="center"><font size="2" face="Arial, Helvetica, Sans-Serif">Copyright ©
2003 Apache Software Foundation All rights reserved.<script type="text/javascript" language="JavaScript"><!--
document.write(" - "+"Last Published: " + document.lastModified);
// --></script></font></td>
</tr>
<tr>
<td colspan="2" align="left" bgcolor="#CFDCED" class="logos"></td>
</tr>
</table>
<!--================= end Footer ==================-->
</body>
</html>
1.1 ws-site/targets/jaxme/js/patterns/typesafeenum.html
Index: typesafeenum.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Typesafe enumerations</title>
<link type="text/css" href="../../skin/page.css" rel="stylesheet">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<!--================= start Navigation Path ==================-->
<table summary="navigation path" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td nowrap="nowrap" valign="middle" bgcolor="#CFDCED" height="20"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><!--===== breadcrumb trail (javascript-generated) ====--><font size="2" face="Arial, Helvetica, Sans-serif"><script src="../../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script></font></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" height="2"><img height="2" width="2" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Navigation Path ==================-->
<!--================= start Banner ==================-->
<table summary="header with logos" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<!--================= start Group Logo ==================-->
<td bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/"><img border="0" class="logoImage" alt="JaxMe 2" src="../../images/group-logo.gif"></a></td>
<!--================= end Group Logo ==================-->
<!--================= start Project Logo ==================--><td width="100%" align="center" bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/">JaxMe 2</a></td>
<!--================= end Project Logo ==================-->
<!--================= start Search ==================--><td valign="top" rowspan="2" bgcolor="#294563">
<form target="_blank" action="http://www.google.com/search" method="get">
<table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
<tr>
<td colspan="3"><img height="10" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap"><input value="ws.apache.org/JaxMe/" name="sitesearch" type="hidden"><input size="15" name="q" id="query" type="text"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><input name="Search" value="Search" type="submit">
<br>
<font face="Arial, Helvetica, Sans-serif" size="2" color="white">
the JaxMe 2 site
</font></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-left.gif"></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-right.gif"></td>
</tr>
</table>
</form>
</td>
<!--================= start Search ==================--><td bgcolor="#294563"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" bgcolor="#294563" colspan="2">
<!--================= start Tabs ==================-->
<div class="tab">
<table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../index.html">JaxMe 2</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../api/index.html">JAXB API</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="selected tab" style="height: 1.8em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-left.gif"></td><td valign="middle" bgcolor="#4C6C8F"><font color="#ffffff" size="2" face="Arial, Helvetica, Sans-serif"><b><a class="base-selected" href="../../js/index.html">JaxMeJS</a></b></font></td><td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-right.gif"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../xs/index.html">JaxMeXS</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!--================= end Tabs ==================-->
</td><td bgcolor="#294563"><img alt="" width="1" height="1" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" colspan="4"><img width="1" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Banner ==================-->
<!--================= start Menu, NavBar, Content ==================-->
<table summary="page content" bgcolor="#ffffff" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table summary="menu" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--================= start left top NavBar ==================-->
<td rowspan="3" valign="top">
<table summary="blue line" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#CFDCED"><font color="#4C6C8F" size="4" face="Arial, Helvetica, Sans-serif"> </font></td>
</tr>
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td>
<!--================= end left top NavBar ==================--><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap" valign="top" bgcolor="#4C6C8F">
<!--================= start Menu items ==================-->
<div class="menu">
<ul>
<li>
<font color="#CFDCED">JaxMeJS</font>
<ul>
<li>
<a href="../index.html">Introduction</a>
</li>
<li>
<a href="../factory.html">The JavaSource factory</a>
</li>
<li>
<a href="../methods.html">Writing methods</a>
</li>
<li>
<a href="../placeholders.html">Placeholders</a>
</li>
<li>
<a href="../optimizations.html">Optimizations</a>
</li>
<li>
<a href="../sql.html">Writing SQL</a>
</li>
</ul>
</li>
<li>
<font color="#CFDCED">Patterns</font>
<ul>
<li>
<a href="proxy.html">Proxy Objects</a>
</li>
<li>
<a href="proxy.html#multiple_inheritance">Multiple Inheritance</a>
</li>
<li>
<span class="sel"><font color="#ffcc00">Typesafe Enumerations</font></span>
</li>
<li>
<a href="chains.html">Proxy chains</a>
</li>
<li>
<a href="versioning.html">Versioning</a>
</li>
</ul>
</li>
</ul>
</div>
<!--================= end Menu items ==================-->
</td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" align="left" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-left.gif"></td><td bgcolor="#4C6C8F"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" align="right" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-right.gif"></td>
</tr>
<tr>
<td height="1" bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td><td valign="top" width="100%">
<table summary="content" width="100%" border="0" cellpadding="0" cellspacing="0">
<!--================= start middle NavBar ==================-->
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td align="left" width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="right" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end middle NavBar ==================-->
<!--================= start Content==================-->
<tr>
<td align="left" width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="100%">
<div xmlns:xhtml="http://www.w3.org/1999/xhtml" class="content">
<table class="title" summary="">
<tr>
<td valign="middle">
<h1>Typesafe enumerations</h1>
</td><td nowrap="nowrap" width="40" align="center"><a class="dida" href="typesafeenum.pdf"><img alt="PDF" src="../../skin/images/pdfdoc.gif" class="skin"><br>
PDF</a></td>
</tr>
</table>
<p>Typesafe enumerations are classes with a private constructor and only
a few defined instances. Each instance does have a name and a value. As
of Java 1.5, they will be part of the Java language. For those of us,
who are still stuck with older versions, a source generator is a good
solution.</p>
<pre class="code">
<enumGenerator targetClass="org.apache.ws.jaxme.js.junit.EnumExample"
destDir="${build.src}">
<item name="JOE" value="John Doe"/>
<item name="POPEYE" value="Olivia's Lover"/>
<item name="DONALD" value="The Duck King"/>
</enumGenerator>
</pre>
<p>This will generate a class looking roughly like this:</p>
<pre class="code">
public class EnumExample {
private String name;
private String value;
private EnumExample(String pName, String pValue) {
name = pName;
value = pValue;
}
public String getName() { return name; }
public String getValue() { return value; }
public final static EnumExample JOE = new EnumExample("JOE", "John Doe");
public final static EnumExample POPEYE = new EnumExample("POPEYE", "Olivia's Lover");
public final static EnumExample DONALD = new EnumExample("DONALD", "The Duck King");
}
</pre>
<p>The important thing with this enumeration is that there cannot be other
instances besides <span class="codefrag">JOE</span>, <span class="codefrag">POPEYE</span> and <span class="codefrag">DONALD</span>.</p>
<div class="attribution"></div>
</div>
</td><td width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end Content==================-->
</table>
</td>
</tr>
</table>
<!--================= end Menu, NavBar, Content ==================-->
<!--================= start Footer ==================-->
<table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"><a href="../../skin/images/label.gif"></a><a href="../../skin/images/page.gif"></a><a href="../../skin/images/chapter.gif"></a><a href="../../skin/images/chapter_open.gif"></a><a href="../../skin/images/current.gif"></a><a href="/favicon.ico"></a></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CFDCED" class="copyright" align="center"><font size="2" face="Arial, Helvetica, Sans-Serif">Copyright ©
2003 Apache Software Foundation All rights reserved.<script type="text/javascript" language="JavaScript"><!--
document.write(" - "+"Last Published: " + document.lastModified);
// --></script></font></td>
</tr>
<tr>
<td colspan="2" align="left" bgcolor="#CFDCED" class="logos"></td>
</tr>
</table>
<!--================= end Footer ==================-->
</body>
</html>
1.1 ws-site/targets/jaxme/js/patterns/versioning.html
Index: versioning.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>The version generator</title>
<link type="text/css" href="../../skin/page.css" rel="stylesheet">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<!--================= start Navigation Path ==================-->
<table summary="navigation path" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td nowrap="nowrap" valign="middle" bgcolor="#CFDCED" height="20"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><!--===== breadcrumb trail (javascript-generated) ====--><font size="2" face="Arial, Helvetica, Sans-serif"><script src="../../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script></font></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" height="2"><img height="2" width="2" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Navigation Path ==================-->
<!--================= start Banner ==================-->
<table summary="header with logos" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<!--================= start Group Logo ==================-->
<td bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/"><img border="0" class="logoImage" alt="JaxMe 2" src="../../images/group-logo.gif"></a></td>
<!--================= end Group Logo ==================-->
<!--================= start Project Logo ==================--><td width="100%" align="center" bgcolor="#294563"><a href="http://ws.apache.org/JaxMe/">JaxMe 2</a></td>
<!--================= end Project Logo ==================-->
<!--================= start Search ==================--><td valign="top" rowspan="2" bgcolor="#294563">
<form target="_blank" action="http://www.google.com/search" method="get">
<table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
<tr>
<td colspan="3"><img height="10" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap"><input value="ws.apache.org/JaxMe/" name="sitesearch" type="hidden"><input size="15" name="q" id="query" type="text"><img height="1" width="5" alt="" src="../../skin/images/spacer.gif" class="spacer"><input name="Search" value="Search" type="submit">
<br>
<font face="Arial, Helvetica, Sans-serif" size="2" color="white">
the JaxMe 2 site
</font></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-left.gif"></td><td><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td><img alt="" border="0" height="10" width="9" src="../../skin/images/search-right.gif"></td>
</tr>
</table>
</form>
</td>
<!--================= start Search ==================--><td bgcolor="#294563"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" bgcolor="#294563" colspan="2">
<!--================= start Tabs ==================-->
<div class="tab">
<table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../index.html">JaxMe 2</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../api/index.html">JAXB API</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="selected tab" style="height: 1.8em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-left.gif"></td><td valign="middle" bgcolor="#4C6C8F"><font color="#ffffff" size="2" face="Arial, Helvetica, Sans-serif"><b><a class="base-selected" href="../../js/index.html">JaxMeJS</a></b></font></td><td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="../../skin/images/tabSel-right.gif"></td>
</tr>
</table>
</td><td width="6"><img alt="" height="8" width="6" src="../../skin/images/spacer.gif"></td><td valign="bottom">
<table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a class="base-not-selected" href="../../xs/index.html">JaxMeXS</a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="../../skin/images/tab-right.gif"></td>
</tr>
<tr>
<td colspan="3" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!--================= end Tabs ==================-->
</td><td bgcolor="#294563"><img alt="" width="1" height="1" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#4C6C8F" colspan="4"><img width="1" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
<!--================= end Banner ==================-->
<!--================= start Menu, NavBar, Content ==================-->
<table summary="page content" bgcolor="#ffffff" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table summary="menu" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--================= start left top NavBar ==================-->
<td rowspan="3" valign="top">
<table summary="blue line" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td bgcolor="#CFDCED"><font color="#4C6C8F" size="4" face="Arial, Helvetica, Sans-serif"> </font></td>
</tr>
<tr>
<td bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td>
<!--================= end left top NavBar ==================--><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap" valign="top" bgcolor="#4C6C8F">
<!--================= start Menu items ==================-->
<div class="menu">
<ul>
<li>
<font color="#CFDCED">JaxMeJS</font>
<ul>
<li>
<a href="../index.html">Introduction</a>
</li>
<li>
<a href="../factory.html">The JavaSource factory</a>
</li>
<li>
<a href="../methods.html">Writing methods</a>
</li>
<li>
<a href="../placeholders.html">Placeholders</a>
</li>
<li>
<a href="../optimizations.html">Optimizations</a>
</li>
<li>
<a href="../sql.html">Writing SQL</a>
</li>
</ul>
</li>
<li>
<font color="#CFDCED">Patterns</font>
<ul>
<li>
<a href="proxy.html">Proxy Objects</a>
</li>
<li>
<a href="proxy.html#multiple_inheritance">Multiple Inheritance</a>
</li>
<li>
<a href="typesafeenum.html">Typesafe Enumerations</a>
</li>
<li>
<a href="chains.html">Proxy chains</a>
</li>
<li>
<span class="sel"><font color="#ffcc00">Versioning</font></span>
</li>
</ul>
</li>
</ul>
</div>
<!--================= end Menu items ==================-->
</td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td valign="bottom" align="left" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-left.gif"></td><td bgcolor="#4C6C8F"><img height="10" width="10" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td valign="bottom" align="right" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="../../skin/images/menu-right.gif"></td>
</tr>
<tr>
<td height="1" bgcolor="#294563"><img width="1" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
</table>
</td><td valign="top" width="100%">
<table summary="content" width="100%" border="0" cellpadding="0" cellspacing="0">
<!--================= start middle NavBar ==================-->
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td align="left" width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="right" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
</font><img width="10" height="8" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end middle NavBar ==================-->
<!--================= start Content==================-->
<tr>
<td align="left" width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td><td align="left" width="100%">
<div xmlns:xhtml="http://www.w3.org/1999/xhtml" class="content">
<table class="title" summary="">
<tr>
<td valign="middle">
<h1>The version generator</h1>
</td><td nowrap="nowrap" width="40" align="center"><a class="dida" href="versioning.pdf"><img alt="PDF" src="../../skin/images/pdfdoc.gif" class="skin"><br>
PDF</a></td>
</tr>
</table>
<ul class="minitoc">
<li>
<a href="#The+version+generator">The version generator</a>
</li>
<li>
<a href="#Limitations">Limitations</a>
</li>
<li>
<a href="#Column+updaters">Column updaters</a>
</li>
<li>
<a href="#Using+the+version+generator">Using the version generator</a>
</li>
</ul>
<a name="introduction"></a>
<a name="N1000D"></a><a name="The+version+generator"></a>
<h3>The version generator</h3>
<div style="margin-left: 0 ; border: 2px">
<p>A versioned object is an object with a composed primary key:
We call the first part the version ID and the second part the version number.
Objects with the same ID are called versions of the object. If the versioned
object is stored in a single SQL table, a new version can obviously be derived
as follows:</p>
<ol>
<li>Read the row containing the base version.</li>
<li>Create a copy of the row in memory.</li>
<li>Update the version number in the in-memory clone.</li>
<li>Insert the clone into the database.</li>
</ol>
<p>There is nothing special. Things look quite different, if we have multiple
tables. For example, suggest that we have a database with the tables
"Organization", "Person", and "Email Address". Any organization might have
associated persons as contacts. Organizations and persons, however, might
have an unlimited number of email addresses. Foreign keys are used to
join the different tables. The organization can be viewed as a collection
of a row in "Organization" and zero or more rows in "Person". How about
creating a new version of an organization? This is not so convenient:</p>
<ol>
<li>Read the row containing the organization and clone it,
following the above steps.</li>
<li>The cloned row doesn't have any associated email addresses,
but the base organization probably does. In other words, we need
to read the relevant email addresses into memory, update the
organization reference and create new instances of the in-memory
email addresses, possibly creating a new ID.</li>
<li>The cloned organization doesn't have any associated persons,
but the base organization probably does. You guess the following:
We need to clone the persons as well, updating references and
assigning new ID's.</li>
<li>We are not yet done: The persons might be referenced by email
adresses. So we continue ... you guess.</li>
</ol>
<p>The version generator is able to create Java code for you, which is
doing exactly the above. It takes as input a list of tables and an
ID generation procedure for any table, and that's it.</p>
</div>
<a name="limitations"></a>
<a name="N1003D"></a><a name="Limitations"></a>
<h3>Limitations</h3>
<div style="margin-left: 0 ; border: 2px">
<p>The current version of the version generator has some restrictions. In
particular the following rules apply:</p>
<ol>
<li>Let <span class="codefrag">T1</span>, <span class="codefrag">T2</span>, <span class="codefrag">T3</span>, ... be the
tables being cloned.</li>
<li>No table may reference itself. For example, <span class="codefrag">T3</span> must
not have a reference to <span class="codefrag">T3</span>.</li>
<li>No table may have forward references. A forward reference is a
foreign key to another table, which is positioned behind itself
in the table. For example, <span class="codefrag">T2</span> and <span class="codefrag">T3</span>
may reference <span class="codefrag">T1</span>, but neither <span class="codefrag">T2</span> nor
<span class="codefrag">T3</span> may reference <span class="codefrag">T1</span> nor may <span class="codefrag">T3</span>
reference <span class="codefrag">T2</span>.</li>
<li>All foreign keys must reference the primary key. As a consequence,
each referenced table must have a primary key.</li>
</ol>
<p>In essence, the requirements are, that there are no direct or indirect
circular references and that there is a set of columns that allow to
remember, which rows already have been cloned.</p>
</div>
<a name="columnUpdaters"></a>
<a name="N10082"></a><a name="Column+updaters"></a>
<h3>Column updaters</h3>
<div style="margin-left: 0 ; border: 2px">
<p>Column updaters are used to perform the required modifications for the
in-memory rows. For example, there is a column updater that updates a
foreign keys value from an object that has already been cloned to its
clone. Column updaters are implementing the interface
<a href="../../apidocs/org/apache/ws/jaxme/js/pattern/VersionGenerator.ColumnUpdater.html">
VersionGenerator.ColumnUpdater</a>.</p>
<p>The main thing to understand when writing a column updater is that it
is not invoked at runtime, but as a part of the source generation stage.
It emits Java code taking an object array as input and modifying the
array. As an example, we demonstrate a very basic column updater,
which is simply incrementing the version number. We assume that the
version number is an integer, stored in the tables second column:</p>
<pre class="code">
public class VerNumIncrementer implements VersionGenerator.ColumnUpdater {
public void update(JavaMethod pMethod,
VersionGenerator.TableInfo pTableInfo,
DirectAccessible pConnection,
DirectAccessible pMap,
DirectAccessible pRow) {
pMethod.addLine(pRow, "[2] = new Integer(((Integer) ",
pRow, "[2]).intValue()+1);");
}
}
</pre>
<p>The column updaters arguments are as follows:</p>
<dl>
<dt>pMethod</dt>
<dd>The method being generated.</dd>
<dt>pTableInfo</dt>
<dd>Holds the generators view of the table being
cloned by the method <span class="codefrag">pMethod</span>. The most important property
is the <span class="codefrag">table</span> property, which returns an instance of
<a href="../../apidocs/org/apache/ws/jaxme/sqls/Table.html">Table</a> with the table name
and column list.</dd>
<dt>pConnection</dt>
<dd>A variable name which is holding an open
database connection in the generated source.</dd>
<dt>pMap</dt>
<dd>A variable name with a map used to note the column
which have already been cloned. The tables keys are the primary keys before cloning,
and the tables values are the keys after cloning. The map is used
to adjust foreign key references.</dd>
<dt>pRow</dt>
<dd>A variable name representing an array of objects,
one for any column in the table. The object types correspond to the
column data types: For example, a VARCHAR or CHAR column is mapped
to a String, INT, or BIGINT, columns are mapped to Integer and
Long, respectively, and so on.</dd>
</dl>
</div>
<a name="use"></a>
<a name="N100C3"></a><a name="Using+the+version+generator"></a>
<h3>Using the version generator</h3>
<div style="margin-left: 0 ; border: 2px">
<p>To use the version generator, you need a set of tables (subject to the
limitations described <a href="#limitations">above</a>). For any table,
you also need a ColumnUpdater. If you have that, the generator is invoked
like this:</p>
<pre class="code">
import org.apache.ws.jaxme.js.JavaQNameImpl;
import org.apache.ws.jaxme.js.JavaSource;
import org.apache.ws.jaxme.js.JavaSourceFactory;
import org.apache.ws.jaxme.js.pattern.VersionGenerator;
import org.apache.ws.jaxme.js.pattern.VersionGenerator.ColumnUpdater;
import org.apache.ws.jaxme.sqls.Table;
Table[] tables; // Supplied by you
ColumnUpdater updaters; // Supplied by you, same length than tables array
JavaSourceFactory factory = new JavaSourceFactory();
VersionGenerator vgen = new VersionGenerator();
vgen.setGeneratingLogging(true);
for (int i = 0; i < tables.length; i++) {
vgen.addTable(tables[i], updaters[i]);
}
JavaSource js = factory.newJavaSource(JavaQNameImpl.getInstance("com.foo", "Bar"),
JavaSource.PUBLIC);
vgen.getCloneMethod(js);
</pre>
<p>You might replace the VersionGenerator with a subclass, because the above
code would emit logging statements using the
<a href="../../apidocs/org/apache/ws/jaxme/logging/package-summary.html">
org.apache.ws.jaxme.logging package</a>.
If you do not favour this, replace the methods <span class="codefrag">logEntering</span>,
<span class="codefrag">logExiting</span>, <span class="codefrag">logFinest</span>, <span class="codefrag">logFinestEntering</span>,
and <span class="codefrag">logFinestEntering</span> with your own implementations.</p>
</div>
<div class="attribution"></div>
</div>
</td><td width="10"><img width="10" height="1" alt="" src="../../skin/images/spacer.gif" class="spacer"></td>
</tr>
<!--================= end Content==================-->
</table>
</td>
</tr>
</table>
<!--================= end Menu, NavBar, Content ==================-->
<!--================= start Footer ==================-->
<table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1" width="1" alt="" src="../../skin/images/spacer.gif" class="spacer"><a href="../../skin/images/label.gif"></a><a href="../../skin/images/page.gif"></a><a href="../../skin/images/chapter.gif"></a><a href="../../skin/images/chapter_open.gif"></a><a href="../../skin/images/current.gif"></a><a href="/favicon.ico"></a></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CFDCED" class="copyright" align="center"><font size="2" face="Arial, Helvetica, Sans-Serif">Copyright ©
2003 Apache Software Foundation All rights reserved.<script type="text/javascript" language="JavaScript"><!--
document.write(" - "+"Last Published: " + document.lastModified);
// --></script></font></td>
</tr>
<tr>
<td colspan="2" align="left" bgcolor="#CFDCED" class="logos"></td>
</tr>
</table>
<!--================= end Footer ==================-->
</body>
</html>
1.1 ws-site/targets/jaxme/js/patterns/chains.pdf
<<Binary file>>
1.1 ws-site/targets/jaxme/js/patterns/proxy.pdf
<<Binary file>>
1.1 ws-site/targets/jaxme/js/patterns/typesafeenum.pdf
<<Binary file>>
1.1 ws-site/targets/jaxme/js/patterns/versioning.pdf
<<Binary file>>