@Test public void testSPIRegistration() throws Exception { Connection connection = new TestConnection(); Connection wrapper = new WrapperConnection(connection); GenericUnWrapper.CONNECTION_METHODS.put( WrapperConnection.class, WrapperConnection.class.getMethod("getUnderlyingConnection", null)); UnWrapper uw = DataSourceFinder.getUnWrapper(wrapper); assertNotNull("registed and canUnwrap", uw); if (uw instanceof GenericUnWrapper) { assertSame("Generic unwrapper is working", connection, uw.unwrap(wrapper)); } } }
UnWrapper unwrapper = uwMap.get(testCon.getClass()); if (unwrapper == null) { unwrapper = DataSourceFinder.getUnWrapper(testCon); if (unwrapper == null) { unwrapper = UNWRAPPER_NOT_FOUND;
UnWrapper uw = DataSourceFinder.getUnWrapper(conn); assertNotNull(uw); assertTrue(uw.canUnwrap(conn)); uw = DataSourceFinder.getUnWrapper(st); assertNotNull(uw); assertTrue(uw.canUnwrap(st)); uw = DataSourceFinder.getUnWrapper(ps); assertNotNull(uw); assertTrue(uw.canUnwrap(ps));
public OracleFeatureWriter(FeatureReader <SimpleFeatureType, SimpleFeature> fReader, QueryData queryData ) throws IOException { super(fReader, queryData); Connection conn = queryData.getConnection(); if(!(conn instanceof OracleConnection)) { UnWrapper uw = DataSourceFinder.getUnWrapper(conn); if(uw != null) conn = uw.unwrap(conn); } OracleConnection oracleConnection = (OracleConnection) conn; this.converter = new GeometryConverter(oracleConnection); }
/** * @see org.geotools.data.jdbc.fidmapper.FIDMapper#createID(java.sql.Connection, org.geotools.feature.Feature, Statement) */ public String createID(Connection conn, SimpleFeature feature, Statement statement) throws IOException { try { if(!(statement instanceof PGStatement)) { UnWrapper uw = DataSourceFinder.getUnWrapper(statement); if(uw != null) statement = uw.unwrap(statement); } PGStatement pgStatement = (PGStatement) statement; return String.valueOf(pgStatement.getLastOID()); } catch (SQLException e) { throw new DataSourceException("Problems occurred while getting last generate oid from Postgresql statement", e); } catch (ClassCastException e) { throw new DataSourceException("Statement is not a PGStatement. OIDFidMapper can be used only with Postgres!", e); } }
UnWrapper unwrapper = DataSourceFinder.getUnWrapper(conn); OracleConnection oraConn = (OracleConnection) unwrapper.unwrap(conn); GeometryConverter converter = new GeometryConverter(oraConn, new GeometryFactory());
UnWrapper uw = DataSourceFinder.getUnWrapper(conn); if(uw != null) conn = uw.unwrap(conn);