/projects/geotools-9.2/modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStoreFactory.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus · Java · 116 lines · 79 code · 15 blank · 22 comment · 0 complexity · 446c9e4d0f19840fb779c9bab37149a4 MD5 · raw file

  1. package org.geotools.data.mongodb;
  2. import java.awt.RenderingHints;
  3. import java.io.Serializable;
  4. import java.util.Collections;
  5. import java.util.List;
  6. import java.util.Map;
  7. import java.util.logging.Logger;
  8. import org.geotools.data.DataStore;
  9. import org.geotools.data.DataStoreFactorySpi;
  10. /**
  11. *
  12. * @author Gerald Gay, Data Tactics Corp.
  13. * @source $URL$
  14. *
  15. * (C) 2011, Open Source Geospatial Foundation (OSGeo)
  16. *
  17. * @see The GNU Lesser General Public License (LGPL)
  18. */
  19. /* This library is free software; you can redistribute it and/or modify it under the terms of the
  20. * GNU Lesser General Public License as published by the Free Software Foundation; either version
  21. * 2.1 of the License, or (at your option) any later version.
  22. *
  23. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  24. * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. * Lesser General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Lesser General Public License along with this library;
  28. * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  29. * 02110-1301 USA */
  30. public class MongoDataStoreFactory implements DataStoreFactorySpi
  31. {
  32. private static final String FACTORY_DESCRIPTION = "MongoDB GeoServer Plugin";
  33. private static final String FACTORY_DISPLAY_NAME = "MongoDB";
  34. /** Package logger */
  35. static private final Logger log = MongoPluginConfig.getLog();
  36. public DataStore createNewDataStore (Map<String, Serializable> map)
  37. {
  38. return createDataStore( map );
  39. }
  40. public DataStore createDataStore (Map<String, Serializable> params)
  41. {
  42. DataStore theStore = null;
  43. log.info( "DataStore.createDataStore()" );
  44. try
  45. {
  46. MongoPluginConfig config = new MongoPluginConfig( params );
  47. theStore = new MongoDataStore( config );
  48. log.info( "DataStore.createDataStore(); theStore=" + theStore );
  49. }
  50. catch (Throwable t)
  51. {
  52. log.severe( t.getLocalizedMessage() );
  53. }
  54. return theStore;
  55. }
  56. public boolean isAvailable ()
  57. {
  58. boolean result = false;
  59. try
  60. {
  61. // basic check to ensure mongo jar available
  62. Class.forName( "com.mongodb.BasicDBObject" );
  63. result = true;
  64. }
  65. catch (Throwable t)
  66. {
  67. log.severe( "Mongo Plugin: The MongoDB JAR file was not found on the class path." );
  68. }
  69. return result;
  70. }
  71. public boolean canProcess (Map<String, Serializable> params)
  72. {
  73. boolean result = true;
  74. try
  75. {
  76. new MongoPluginConfig( params );
  77. }
  78. catch (MongoPluginException e)
  79. {
  80. result = false;
  81. }
  82. return result;
  83. }
  84. public DataStoreFactorySpi.Param[] getParametersInfo ()
  85. {
  86. List<Param> params = MongoPluginConfig.getPluginParams();
  87. return params.toArray( new Param[params.size()] );
  88. }
  89. public String getDescription ()
  90. {
  91. return FACTORY_DESCRIPTION;
  92. }
  93. public String getDisplayName ()
  94. {
  95. return FACTORY_DISPLAY_NAME;
  96. }
  97. public Map<RenderingHints.Key, ?> getImplementationHints ()
  98. {
  99. return Collections.emptyMap();
  100. }
  101. }