Java Reference
In-Depth Information
second is the javaType attribute, which specifies which Java types should be han-
dled by this TypeHandlerCallback . Finally, the third attribute, which is optional,
allows you to specify the JDBC (i.e., database) type that this TypeHandlerCallback
should be applied to. So in our case, we're working with a Java type of boolean
and a JDBC type of VARCHAR . If we didn't specify the data type, this type handler
would be used by default for all boolean types. However, it would not override any
type handlers with a more specific definition. Thus the type handler registration
that most specifically matches both the Java type and the JDBC type is the one that
will be used.
Custom type handlers are by far the most common form of extension in iBA-
TIS . This is mostly due to the wide range of nonstandard features and data types
supported by relational database systems. In the remaining sections, we discuss
other forms of extension that are rarer but still useful to know about.
12.3 Working with a CacheController
iBATIS includes a number of built-in caching implementations. These have already
been discussed in previous chapters, but to refresh your memory, table 12.3 sum-
marizes the various cache implementations.
Table 12.3
Summary of cache implementations
The least recently used (LRU) cache keeps track of cached entries based
upon when they were last accessed. The cache entry accessed least
recently is removed if needed to make room for newer entries.
The first-in, first-out (FIFO) cache simply removes the oldest item in the
cache to make room for new items.
MemoryCacheController The Memory cache allows the Java memory model and garbage collector
to determine when cached entries should be removed.
The OpenSymphony cache is an adapter to a very advanced third-party cach-
ing solution called OSCache. OSCache supports various caching models of
its own, as well as advanced features such as distributed caching.
iBATIS provides an interface called CacheController that allows you to implement
your own custom caching solution, or to plug in an existing third-party caching
solution. The CacheController interface is fairly simple, and looks like this:
public interface CacheController {
public void configure(Properties props);
public void putObject(CacheModel cacheModel,
Object key, Object object);
Search WWH ::

Custom Search