001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.data;
017:
018: import java.io.IOException;
019: import org.opengis.util.InternationalString;
020: import org.geotools.factory.Factory;
021:
022: /**
023: * Constructs a live DataAccess connection from a set of parameters.
024: * <p>
025: * Parameters are specified using a Java Bean; the DataAccesFinder utility class will take care of
026: * allowing you to work with Map<String,Serializable> as a transfer object of bean properties.
027: * </p>
028: *
029: * @author Jody Garnett
030: * @author Thomas Marti
031: * @author Stefan Schmid
032: *
033: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/community-schemas/community-schema-ds/src/main/java/org/geotools/data/DataAccessFactory.java $
034: * @version $Id: DataAccessFactory.java 26609 2007-08-20 15:29:33Z groldan $
035: */
036: public interface DataAccessFactory extends Factory {
037: /**
038: * Display name for this DataAccess in the current locale.
039: *
040: * @return human readable display name
041: */
042: public InternationalString getName();
043:
044: /**
045: * Test to ensure the correct environment is available for this Factory to function.
046: * <p>
047: * Implementations usually check such things as availablity of required JDBC drivers,
048: * or Java Advanced Imaging formats that they intend to use.
049: * </p>
050: * @return <code>true</code>, if needed environment is found
051: */
052: public boolean isAvailable();
053:
054: /**
055: * A java bean (with default properties values) describing connection parameters.
056: *
057: * @return Java Bean describing parameters required for data access
058: */
059: Object createAccessBean();
060:
061: /**
062: * <p>Test to see if this factory is suitable for processing this connectionParamsBean.</p>
063: *
064: * <p>This method is often an <code>instanceof</code> check followed by ensuring required
065: * bean properties (i.e. connection parameters) are not <code>null</code>.</p>
066: *
067: * @param connectionPrametersBean
068: * @return <code>true</code>, if bean has valid parameters to attempt a connection
069: */
070: boolean canAccess(Object connectionPrametersBean);
071:
072: /**
073: * <p>Connect to a physical data storage location and provide <code>DataAccess</code> class for
074: * interaction.</p>
075: *
076: * <p>A new <code>DataAccess</code> class is created on each call; end-users should either store
077: * this instance as a Singleton (gasp!) or make use of the GeoTools catalog facilities to manage
078: * connections.</p>
079: *
080: * @param bean Bean capturing connection parameters, should be of the same type as provided by
081: * createConnectionBean
082: * @return The created <code>DataAccess</code> instance
083: * @throws IOException If there were any problems setting up the connection
084: */
085: DataAccess createAccess(Object bean) throws IOException;
086:
087: /**
088: * Please note that creating a new physical storage location
089: * may require additional parameters beyond that needed for
090: * simple connection.
091: *
092: * @return Java Bean describing parameters required for creation
093: */
094: Object createContentBean();
095:
096: /**
097: * <p>Confirm that this factory is suitable for creating the physical storage
098: * location described by the provided bean.</p>
099: *
100: * <p>Implementations may also chose to check security concerns (such as the ability
101: * to write to disk) as part of this method.</p>
102: *
103: * @param bean Bean capturing connection/creation parameters, should be of the same
104: * type as provided by {@link #createContentBean()}
105: * @return <code>true</code>, if bean has valid parameters to attempt a connection
106: */
107: boolean canCreateContent(Object bean);
108:
109: /**
110: * Set up a new physical storage location, and supply a <code>DataAccess</code> class
111: * for interaction.
112: *
113: * @param bean Bean capturing connection/creation parameters, should be of the same
114: * type as provided by {@link #createContentBean()}
115: * @return The created <code>DataAccess</code> instance
116: */
117: DataAccess createContent(Object bean);
118: }
|