Now we are going to make use of this class. Skim through its source
code, just to appreciate that this is the place where we can interact with the inner
working of Tapestry??”configure, extend existing services or maybe even create some
custom services.
We are going to influence the way in which Tapestry manages application
state objects. All we need to do for this is to add one more method,
contributeApplicationStateManager to AppModule, thus contributing our own
way to manage an ASO. Here is how this method should look:
public void contributeApplicationStateManager(
MappedConfiguration
configuratio)
{
ApplicationStateCreator creator =
new ApplicationStateCreator()
{
public IDataSource create()
{
return new MockDataSource();
}
};
configuration.add(IDataSource.class,
new ApplicationStateContribution("session", creator));
}
First of all, we create an implementation of the ApplicationStateCreator interface
(which is a part of Tapestry), associated with type, IDataSource:
ApplicationStateCreator creator = ...
To do this, we are employing a convenient feature of the Java language named
"anonymous inner class".
Pages:
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170