public boolean before(Authentication authentication, MethodInvocation mi, PreInvocationAttribute preAttr) { PythonInterpreterPreInvocationAttribute pythonAttr = (PythonInterpreterPreInvocationAttribute) preAttr; String script = pythonAttr.getScript(); PythonInterpreter python = new PythonInterpreter(); python.set("authentication", authentication); python.set("args", createArgumentMap(mi)); python.set("method", mi.getMethod().getName()); Resource scriptResource = new PathMatchingResourcePatternResolver() .getResource(script); try { python.execfile(scriptResource.getInputStream()); } catch (IOException e) { throw new IllegalArgumentException("Couldn't run python script, " + script, e); } PyObject allowed = python.get("allow"); if (allowed == null) { throw new IllegalStateException("Python script did not set the permit flag"); } return (Boolean) Py.tojava(allowed, Boolean.class); }
protected void configureSqlSessionFactory(SqlSessionFactoryBean sessionFactoryBean, DataSource dataSource) throws IOException { PathMatchingResourcePatternResolver pathResolver = new PathMatchingResourcePatternResolver(); sessionFactoryBean.setDataSource(dataSource); sessionFactoryBean.setTypeAliasesPackage(ENTITY_PACKAGE_PREFIX); sessionFactoryBean.setConfigLocation(pathResolver.getResource(CONFIG_LOCATION_PATH)); sessionFactoryBean.setMapperLocations(pathResolver.getResources(MAPPER_LOCATIONS_PATH)); } }
@Bean @Conditional(DBCondition.class) public SqlSessionFactory sqlSessionFactory() throws Exception { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setDataSource(roundRobinDataSourceProxy()); sqlSessionFactoryBean.setConfigLocation(new PathMatchingResourcePatternResolver().getResource(configLocation)); sqlSessionFactoryBean.setMapperLocations( new PathMatchingResourcePatternResolver().getResources(mapperLocations)); return sqlSessionFactoryBean.getObject(); }
private static Resource getResourceForLocation(String location, ClassLoader classLoader) { return new PathMatchingResourcePatternResolver(classLoader).getResource(location); }
@Bean public SqlSessionFactory sqlSessionFactoryBean() throws Exception { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setDataSource(dataSource()); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); sqlSessionFactoryBean.setConfigLocation(resolver.getResource("classpath:mybatis-config.xml")); sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml")); return sqlSessionFactoryBean.getObject(); }
/** * Prepares for the creation of an SSLContext using the supplied * key/trust stores and passwords. * @param keyStore A {@link Resource} pattern pointing to the keyStore. * @param trustStore A {@link Resource} pattern pointing to the trustStore. * @param keyStorePassword The password for the keyStore. * @param trustStorePassword The password for the trustStore. */ public DefaultTcpSSLContextSupport(String keyStore, String trustStore, String keyStorePassword, String trustStorePassword) { Assert.notNull(keyStore, "keyStore cannot be null"); Assert.notNull(trustStore, "trustStore cannot be null"); Assert.notNull(keyStorePassword, "keyStorePassword cannot be null"); Assert.notNull(trustStorePassword, "trustStorePassword cannot be null"); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); this.keyStore = resolver.getResource(keyStore); this.trustStore = resolver.getResource(trustStore); this.keyStorePassword = keyStorePassword.toCharArray(); this.trustStorePassword = trustStorePassword.toCharArray(); }
@Bean public SqlSessionFactory sqlSessionFactoryBean() throws Exception { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setDataSource(dataSource()); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); sqlSessionFactoryBean.setConfigLocation(resolver.getResource("classpath:/mybatis/config.xml")); sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/mapper/*Mapper.xml")); return sqlSessionFactoryBean.getObject(); }
@Override public Resource convert(String source) { return new PathMatchingResourcePatternResolver().getResource(source); } });
@Override public Resource getResource( String location ) { try { return super.getResource( URLDecoder.decode( location, "UTF-8" ) ); } catch ( UnsupportedEncodingException e ) { throw new RuntimeException( e ); } }
@Override public Resource getResource( String location ) { try { return super.getResource( URLDecoder.decode( location, "UTF-8" ) ); } catch ( UnsupportedEncodingException e ) { throw new RuntimeException( e ); } }
/** * Default constructor. */ public WsdlScenarioGenerator(Environment environment) { wsdlResource = new PathMatchingResourcePatternResolver().getResource(environment.getProperty(SIMULATOR_WSDL_LOCATION_PROPERTY, environment.getProperty(SIMULATOR_WSDL_LOCATION_ENV, ""))); }
/** * Constructor using Spring environment. */ public HttpScenarioGenerator(Environment environment) { swaggerResource = new PathMatchingResourcePatternResolver().getResource(environment.getProperty(SIMULATOR_SWAGGER_API_PROPERTY, environment.getProperty(SIMULATOR_SWAGGER_API_ENV, ""))); contextPath = environment.getProperty(SIMULATOR_SWAGGER_CONTEXT_PATH_PROPERTY, environment.getProperty(SIMULATOR_SWAGGER_CONTEXT_PATH_ENV, contextPath)); }
@Override protected void initialize(org.apache.tomcat.jdbc.pool.DataSource dataSource) { PathMatchingResourcePatternResolver pathResolver = new PathMatchingResourcePatternResolver(); Resource schema = pathResolver.getResource("classpath:scripts/payment-schema.sql"); Resource data = pathResolver.getResource("classpath:scripts/payment-data.sql"); DatabasePopulator databasePopulator = new ResourceDatabasePopulator(schema, data); DatabasePopulatorUtils.execute(databasePopulator, dataSource); }
/** * Adds Citrus message schema to repository if available on classpath. * @param schemaName The name of the schema within the citrus schema package */ protected void addCitrusSchema(String schemaName) throws IOException, SAXException, ParserConfigurationException { Resource resource = new PathMatchingResourcePatternResolver().getResource("classpath:com/consol/citrus/schema/" + schemaName + ".xsd"); if (resource.exists()) { addXsdSchema(resource); } }
public InputStream getDocument(String documentPath) throws IOException { if (isForbidden(documentPath)) { throw new IOException("Document path: " + documentPath + " is within a protected directory, cannot retrieve input stream"); } String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); return resource.getInputStream(); }
public InputStream getDocument(String documentPath) throws IOException { if (isForbidden(documentPath)) { throw new IOException("Document path: " + documentPath + " is within a protected directory, cannot retrieve input stream"); } String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); return resource.getInputStream(); }
/** * Reads SQL statements from external file resource. File resource can hold several * multi-line statements and comments. * * @param context the current test context. * @return list of SQL statements. */ protected List<String> createStatementsFromFileResource(TestContext context, SqlUtils.LastScriptLineDecorator lineDecorator) { return SqlUtils.createStatementsFromFileResource(new PathMatchingResourcePatternResolver() .getResource(context.replaceDynamicContentInString(sqlResourcePath)), lineDecorator); }
public boolean hasDocument(String documentPath) { boolean has = false; if (!isForbidden(documentPath)) { String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); has = resource.exists(); } return has; }
public long lastModified(String documentPath) throws IOException { long lastModified = -1; if (!isForbidden(documentPath)) { String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); lastModified = resource.lastModified(); } return lastModified; }
public long lastModified(String documentPath) throws IOException { long lastModified = -1; if (!isForbidden(documentPath)) { String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); lastModified = resource.lastModified(); } return lastModified; }