The Java Activation Framework
The Java Activation Framework (JAF) can be used by beans
that work with many external data types, such as media retrieved from
files and streams. It is essentially a generalized content/protocol
handler mechanism for JavaBeans. The javax.activation package
contains an extensible set of classes that wrap arbitrary, raw data
sources to provide access to their data as streams or objects, identify
the MIME type of the data, and enumerate a registered set of “commands”
for operating on the data.
The JAF provides two primary interfaces: DataSource and DataHandler. The DataSource acts like the protocol handlers we
discussed in Chapter 14. It wraps the data
source and determines a MIME type for the data stream. The DataHandler acts like a content handler, except
it provides a great deal more than access to the data. A DataHandler is constructed to wrap a DataSource and interpret the data in different
forms. It also provides a list of command operations that can be used to
access the data. DataHandler also
implements the java.awt.datatransfer.Transferable interface,
allowing data to be passed among application components in a well-defined
way.