001 // $HeadURL:
002 // /cvsroot/deegree/src/org/deegree/ogcwebservices/wcs/WCSServiceFactory.java,v
003 // 1.4 2004/06/18 15:50:30 tf Exp $
004 /*----------------------------------------------------------------------------
005 This file is part of deegree, http://deegree.org/
006 Copyright (C) 2001-2009 by:
007 Department of Geography, University of Bonn
008 and
009 lat/lon GmbH
010
011 This library is free software; you can redistribute it and/or modify it under
012 the terms of the GNU Lesser General Public License as published by the Free
013 Software Foundation; either version 2.1 of the License, or (at your option)
014 any later version.
015 This library is distributed in the hope that it will be useful, but WITHOUT
016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
018 details.
019 You should have received a copy of the GNU Lesser General Public License
020 along with this library; if not, write to the Free Software Foundation, Inc.,
021 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022
023 Contact information:
024
025 lat/lon GmbH
026 Aennchenstr. 19, 53177 Bonn
027 Germany
028 http://lat-lon.de/
029
030 Department of Geography, University of Bonn
031 Prof. Dr. Klaus Greve
032 Postfach 1147, 53001 Bonn
033 Germany
034 http://www.geographie.uni-bonn.de/deegree/
035
036 e-mail: info@deegree.org
037 ----------------------------------------------------------------------------*/
038 package org.deegree.ogcwebservices.wmps;
039
040 import java.net.URL;
041
042 import org.deegree.framework.log.ILogger;
043 import org.deegree.framework.log.LoggerFactory;
044 import org.deegree.ogcwebservices.wcs.configuration.InvalidConfigurationException;
045 import org.deegree.ogcwebservices.wmps.configuration.WMPSConfiguration;
046 import org.deegree.ogcwebservices.wmps.configuration.WMPSConfigurationDocument;
047
048 /**
049 * Service Factory class handles the WMPService Instance.
050 *
051 * @author <a href="mailto:deshmukh@lat-lon.de">Anup Deshmukh</a>
052 * @version 2.0
053 */
054 public final class WMPServiceFactory {
055
056 private static final ILogger LOG = LoggerFactory.getLogger( WMPServiceFactory.class );
057
058 private static WMPSConfiguration CONFIG;
059
060 /**
061 * Returns a WMPService instance
062 *
063 * @return WMPService
064 */
065 public static WMPService getService() {
066 return WMPServiceFactory.getInstance( CONFIG );
067 }
068
069 /**
070 * Returns a WMPService instance
071 *
072 * @param config
073 * @return WMPService
074 */
075 public static WMPService getInstance( WMPSConfiguration config ) {
076 return new WMPService( config );
077 }
078
079 /**
080 * Returns true/false depending on the initialized state of the instance.
081 *
082 * @return boolean
083 */
084 public static boolean isInitialized() {
085 return CONFIG != null;
086 }
087
088 /**
089 * Sets the WMPSConfiguration
090 *
091 * @param wmpsConfiguration
092 */
093 public static void setConfiguration( WMPSConfiguration wmpsConfiguration ) {
094 CONFIG = wmpsConfiguration;
095 /**
096 * if service instance are already created destroy all instances create new service
097 * instances and put in pool
098 */
099 LOG.logInfo( CONFIG.getServiceIdentification().getTitle() + " (" + CONFIG.getVersion()
100 + ") service pool initialized." );
101 }
102
103 /**
104 * Sets the service configuration
105 *
106 * @param serviceConfigurationUrl
107 * @throws InvalidConfigurationException
108 */
109 public static void setConfiguration( URL serviceConfigurationUrl )
110 throws InvalidConfigurationException {
111
112 try {
113 WMPSConfigurationDocument doc = new WMPSConfigurationDocument();
114 doc.load( serviceConfigurationUrl );
115 WMPSConfiguration conf = doc.parseConfiguration();
116 WMPServiceFactory.setConfiguration( conf );
117 } catch ( Exception e ) {
118 e.printStackTrace();
119 throw new InvalidConfigurationException( "WPSServiceFactory", e.getMessage() );
120 }
121 }
122 }