/** Make sure a JNDI context is available */ public boolean isAvailable() { try { GeoTools.getInitialContext(GeoTools.getDefaultHints()); return true; } catch (Exception e) { return false; } } }
/** * Determines if the datastore is available. * * <p>Check in an Initial Context is available, that is all what can be done Checking for the * right jdbc jars in the classpath is not possible here */ public boolean isAvailable() { try { GeoTools.getInitialContext(GeoTools.getDefaultHints()); return true; } catch (NamingException e) { return false; } }
DataSource source = null; try { context = GeoTools.getInitialContext(new Hints(hints)); source = (DataSource) context.lookup(datasourceName); } catch (IllegalArgumentException exception) {
ctx = GeoTools.getInitialContext(GeoTools.getDefaultHints()); } catch (NamingException e) { throw new RuntimeException(e);
public DataSource createNewDataSource(Map params) throws IOException { String refName = (String) JNDI_REFNAME.lookUp(params); try { return (DataSource) GeoTools.getInitialContext(GeoTools.getDefaultHints()).lookup(refName); } catch (Exception e) { throw new DataSourceException("Could not find the specified data source in JNDI", e); } }
ctx = GeoTools.getInitialContext(GeoTools.getDefaultHints()); } catch (NamingException e) { throw new RuntimeException(e);
/** * Implementation of {@code fixName} method. If the context is {@code null}, then the * {@linkplain #getInitialContext GeoTools initial context} will be fetch only when first * needed. */ private static String fixName(Context context, final String name, final Hints hints) { String fixed = null; if (name != null) { final StringTokenizer tokens = new StringTokenizer(name, ":/"); while (tokens.hasMoreTokens()) { final String part = tokens.nextToken(); if (fixed == null) { fixed = part; } else try { if (context == null) { context = getInitialContext(hints); } fixed = context.composeName(fixed, part); } catch (NamingException e) { Logging.unexpectedException(GeoTools.class, "fixName", e); return name; } } } return fixed; }
/** * Determines if the datastore is available. * * <p>Check in an Initial Context is available, that is all what can be done Checking for the * right jdbc jars in the classpath is not possible here * * @see org.geotools.data.DataAccessFactory#isAvailable() */ public boolean isAvailable() { try { GeoTools.getInitialContext(GeoTools.getDefaultHints()); } catch (NamingException e) { return false; } return delegateFactory.isAvailable(); }
public AbstractEpsgFactory(final Hints userHints) throws FactoryException { super(MAXIMUM_PRIORITY - 20); // The following hints have no effect on this class behaviour, // but tell to the user what this factory do about axis order. hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.FALSE); hints.put(Hints.FORCE_STANDARD_AXIS_DIRECTIONS, Boolean.FALSE); hints.put(Hints.FORCE_STANDARD_AXIS_UNITS, Boolean.FALSE); // // We need to obtain our DataSource if (userHints != null) { Object hint = userHints.get(Hints.EPSG_DATA_SOURCE); if (hint instanceof String) { String name = (String) hint; try { dataSource = (DataSource) GeoTools.getInitialContext(userHints).lookup(name); } catch (NamingException e) { throw new FactoryException("A EPSG_DATA_SOURCE hint is required:" + e); } hints.put(Hints.EPSG_DATA_SOURCE, dataSource); } else if (hint instanceof DataSource) { dataSource = (DataSource) hint; hints.put(Hints.EPSG_DATA_SOURCE, dataSource); } else { throw new FactoryException("A EPSG_DATA_SOURCE hint is required."); } } else { throw new FactoryException("A EPSG_DATA_SOURCE hint is required."); } }
/** * We expect the EPSG_DATASOURCE to provide a DataSource. Either: * * <ul> * <li>A name we can use to look up the DataSource in the initial context * <li>An actual DataSource instance * </ul> * * @param hints * @return DataSource */ static DataSource lookupDataSource(Hints hints) throws FactoryException { Object hint = hints.get(Hints.EPSG_DATA_SOURCE); if (hint instanceof DataSource) { return (DataSource) hint; } else if (hint instanceof String) { String name = (String) hint; InitialContext context; try { context = GeoTools.getInitialContext(hints); // name = GeoTools.fixName( context, name ); return (DataSource) context.lookup(name); } catch (Exception e) { throw new FactoryException("EPSG_DATA_SOURCE '" + name + "' not found:" + e, e); } } throw new FactoryException("EPSG_DATA_SOURCE must be provided"); }