Drivers are concrete implementations of a {@link Store}. In addition to implementing this interface, the instantiatable driver class must be annotated with {@link DriverInfo}, provide a public constructor with no arguments and implement {@link ReadableDriver} and/or{@link WritableDriver} depending on the operations supported. For example,a driver that only allows importing of Keys would only implement {@link ReadableDriver}. The {@link WrappingDriver} interface should be implemented for drivers that support wrapping/unwrapping of Keys.
When instantiated, {@link #initialize(K2Context)} will be invoked on thedriver to provide the context of the current K2 session. After a successful initialization, {@link #open(URI)} will be called to actually allocateresources for performing storage operations on the specified storage address. This method may throw {@link IllegalAddressException} if the address is notrecognized by the driver. Finally, {@link #close()} will be called to freeresources, after the user has performed the storage operations. Note that it is NOT safe to allocate resources before {@link #open(URI)} is called,e.g. during construction or on initialize.
Drivers need not be concerned with thread safety, or methods invoked when they are not supported, or methods invoked when {@link #open(URI)} has notbeen called, or methods invoked when {@link #close()} has been called. The{@link Store} wrapper will manage all access to the driver by ensuring thatcalls are synchronized, methods are not invoked when inappropriate, etc.
A note about open/close and network-based stores: It is possible for the network connection to drop after the driver is opened. However, the driver must not implicitly close the store in this event. As long as the store is still open, the connection should be reattempted. @author darylseah@gmail.com (Daryl Seah)
The DriverManager will try to load as many drivers as it can find and then for any given connection request, it will ask each driver in turn to try to connect to the target URL.
It is strongly recommended that each Driver class should be small and standalone so that the Driver class can be loaded and queried without bringing in vast quantities of supporting code.
When a Driver class is loaded, it should create an instance of itself and register it with the DriverManager. This means that a user can load and register a driver by doing Class.forName("foo.bah.Driver") @see org.gjt.mm.mysql.Connection @see java.sql.Driver @author Mark Matthews @version $Id: Driver.java 20 2008-01-17 12:47:41Z gnovelli $
The JDBC Driver uses URLs to specify the location of specific data. URL format typically takes the form "xxxx:yyyy:SpecificData", where "xxxx:yyyy" is termed the subprotocol and is normally the same for all uses of a particular driver. "SpecificData" is a string which identifies the particular data source that the driver should use.
Implementation note:
The simplest way to use this is to instantiate it with the InputSource and OutputStream, then set the renderer desired, and calling run();
Here is an example use of Driver which outputs PDF:
Driver driver = new Driver(new InputSource (args[0]), new FileOutputStream(args[1])); driver.setRenderer(RENDER_PDF); driver.run();If neccessary, calling classes can call into the lower level methods to setup and render. Methods can be called to set the Renderer to use, the (possibly multiple) ElementMapping(s) to use and the OutputStream to use to output the results of the rendering (where applicable). In the case of the Renderer and ElementMapping(s), the Driver may be supplied either with the object itself, or the name of the class, in which case Driver will instantiate the class itself. The advantage of the latter is it enables runtime determination of Renderer and ElementMapping(s).
Once the Driver is set up, the render method is called. Depending on whether DOM or SAX is being used, the invocation of the method is either render(Document) or buildFOTree(Parser, InputSource) respectively.
A third possibility may be used to build the FO Tree, namely calling getContentHandler() and firing the SAX events yourself.
Once the FO Tree is built, the format() and render() methods may be called in that order.
Here is an example use of Driver which outputs to AWT:
Driver driver = new Driver(); driver.setRenderer(new org.apache.fop.render.awt.AWTRenderer(translator)); driver.render(parser, fileInputSource(args[0]));
Classes implementing this interface basically act as factory for creating connections to coverage sources like files, WCS services, WMS services, databases, etc...
This class also offers basic create / delete functionality (which can be useful for file based coverage formats).
Purpose of this class is to provide basic information about a certain coverage service/format as well as about the parameters needed in order to connect to a source which such a service/format is able to work against.
Notice that as part as the roll of a "factory" interface this class makes available an {@link #isAvailable()} method which should check if all theneeded dependencies which can be jars as well as native libs or configuration files. @author Simone Giannecchini, GeoSolutions. @author Jody Garnett @since 2.5 @source $URL$
Class.forName("org.h2.Driver"); Connection conn = DriverManager.getConnection( "jdbc:h2:˜/test", "sa", "sa");
The DriverManager will try to load as many drivers as it can find and then for any given connection request, it will ask each driver in turn to try to connect to the target URL.
It is strongly recommended that each Driver class should be small and standalone so that the Driver class can be loaded and queried without bringing in vast quantities of supporting code.
When a Driver class is loaded, it should create an instance of itself and register it with the DriverManager. This means that a user can load and register a driver by doing Class.forName("foo.bah.Driver") @see org.postgresql.PGConnection @see java.sql.Driver
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|