/** * Create a PropertySource based on Properties loaded from the given resource * location and use the given class loader to load the resource, assuming it is * prefixed with {@code classpath:}. The name of the PropertySource will be * generated based on the {@link Resource#getDescription() description} of the * resource. */ public ResourcePropertySource(String location, ClassLoader classLoader) throws IOException { this(new DefaultResourceLoader(classLoader).getResource(location)); }
/** * Create a PropertySource having the given name based on Properties loaded from * the given resource location and using the given class loader to load the * resource (assuming it is prefixed with {@code classpath:}). */ public ResourcePropertySource(String name, String location, ClassLoader classLoader) throws IOException { this(name, new DefaultResourceLoader(classLoader).getResource(location)); }
/** * Create a PropertySource based on Properties loaded from the given resource * location. The name of the PropertySource will be generated based on the * {@link Resource#getDescription() description} of the resource. */ public ResourcePropertySource(String location) throws IOException { this(new DefaultResourceLoader().getResource(location)); }
/** * Create a PropertySource having the given name based on Properties loaded from * the given resource location. The default thread context class loader will be * used to load the resource (assuming the location string is prefixed with * {@code classpath:}. */ public ResourcePropertySource(String name, String location) throws IOException { this(name, new DefaultResourceLoader().getResource(location)); }
/** * Create a PropertySource based on Properties loaded from the given resource * location and use the given class loader to load the resource, assuming it is * prefixed with {@code classpath:}. The name of the PropertySource will be * generated based on the {@link Resource#getDescription() description} of the * resource. */ public ResourcePropertySource(String location, ClassLoader classLoader) throws IOException { this(new DefaultResourceLoader(classLoader).getResource(location)); }
/** * Create a PropertySource having the given name based on Properties loaded from * the given resource location and using the given class loader to load the * resource (assuming it is prefixed with {@code classpath:}). */ public ResourcePropertySource(String name, String location, ClassLoader classLoader) throws IOException { this(name, new DefaultResourceLoader(classLoader).getResource(location)); }
/** * Create a PropertySource having the given name based on Properties loaded from * the given resource location. The default thread context class loader will be * used to load the resource (assuming the location string is prefixed with * {@code classpath:}. */ public ResourcePropertySource(String name, String location) throws IOException { this(name, new DefaultResourceLoader().getResource(location)); }
/** * Create a PropertySource based on Properties loaded from the given resource * location. The name of the PropertySource will be generated based on the * {@link Resource#getDescription() description} of the resource. */ public ResourcePropertySource(String location) throws IOException { this(new DefaultResourceLoader().getResource(location)); }
@Before public void setUp() throws Exception { final ProtectionDomain empty = new ProtectionDomain(null, new Permissions()); provider = new SecurityContextProvider() { private final AccessControlContext acc = new AccessControlContext( new ProtectionDomain[] { empty }); @Override public AccessControlContext getAccessControlContext() { return acc; } }; DefaultResourceLoader drl = new DefaultResourceLoader(); Resource config = drl .getResource("/org/springframework/beans/factory/support/security/callbacks.xml"); beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config); beanFactory.setSecurityContextProvider(provider); }
public void initZooKeeperConfig(){ DefaultResourceLoader defaultClassLoader = new DefaultResourceLoader(); Resource resource = defaultClassLoader.getResource(GlobalConstants.ConfigFile.ZOOKEEPER_CONFIG); ZooKeeperConfig zooKeeperConfig = new ZooKeeperConfig(); zooKeeperConfig.setResource(resource); zooKeeperConfig.init(); this.zooKeeperConfig = zooKeeperConfig; } public void initDynamicConfig(){
public void initDynamicConfig(){ DefaultResourceLoader defaultResourceLoader = new DefaultResourceLoader(); Resource resource = defaultResourceLoader.getResource(GlobalConstants.ConfigFile.DYNAMIC_CONFIG); GameDynamicPropertiesConfig tempA5GameDynamicPropertiesConfig = new GameDynamicPropertiesConfig(); tempA5GameDynamicPropertiesConfig.setResource(resource); tempA5GameDynamicPropertiesConfig.init(); this.gameDynamicPropertiesConfig = tempA5GameDynamicPropertiesConfig; } @Override
/** * Dynamic sql session factory sql session factory. * * @param dynamicDataSource the dynamic data source * @param properties the properties * @return the sql session factory */ @Bean @ConfigurationProperties(prefix = MybatisProperties.MYBATIS_PREFIX) public SqlSessionFactory dynamicSqlSessionFactory( @Qualifier("dynamicDataSource") DataSource dynamicDataSource, MybatisProperties properties) { final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dynamicDataSource); sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(properties.getConfigLocation())); sessionFactory.setMapperLocations(properties.resolveMapperLocations()); try { return sessionFactory.getObject(); } catch (Exception e) { throw new SystemException(e); } }
/** * Adds a {@link Resource} to this builder. * * @param resource the resource * @return the {@link ResourceConfigurer} for chaining */ @Override public ResourceConfigurer<I> resource(String resource) { resources.add(resourceLoader.getResource(resource)); return this; }
import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; public static void myFunction() throws IOException { final DefaultResourceLoader loader = new DefaultResourceLoader(); LOGGER.info(loader.getResource("classpath:META-INF/resources/img/copyright.png").exists()); Resource resource = loader.getResource("classpath:META-INF/resources/img/copyright.png"); BufferedImage watermarkImage = ImageIO.read(resource.getFile()); }
/** * Create a PropertySource having the given name based on Properties loaded from * the given resource location and using the given class loader to load the * resource (assuming it is prefixed with {@code classpath:}). */ public ResourcePropertySource(String name, String location, ClassLoader classLoader) throws IOException { this(name, new DefaultResourceLoader(classLoader).getResource(location)); }
@Bean public KeyManager keyManager() { DefaultResourceLoader loader = new DefaultResourceLoader(); Resource storeFile = loader .getResource("classpath:/saml/samlKeystore.jks"); String storePass = "nalle123"; Map<String, String> passwords = new HashMap<String, String>(); passwords.put("apollo", "nalle123"); String defaultKey = "apollo"; return new JKSKeyManager(storeFile, storePass, passwords, defaultKey); }
@Bean public KeyManager keyManager() { DefaultResourceLoader loader = new DefaultResourceLoader(); Resource storeFile = loader .getResource("classpath:/security/samlKeystore.jks"); String storePass = "nalle123"; Map<String, String> passwords = new HashMap<String, String>(); passwords.put("apollo", "nalle123"); String defaultKey = "apollo"; return new JKSKeyManager(storeFile, storePass, passwords, defaultKey); }
protected Resource createResource(Element resourceDefinition) { String path = resourceDefinition.getAttribute(LOCATION_ATTR); if (!StringUtils.hasText(path)) { throw new ValidationConfigurationException("Resoruce path is required and cannot be empty"); } return new DefaultResourceLoader().getResource(path); }
protected Document generateDwrConfigDocument(String fileName) throws Exception { DefaultResourceLoader resourceLoader = new DefaultResourceLoader(ClassLoaderUtils.getDefaultClassLoader()); InputStream in = resourceLoader.getResource(fileName).getInputStream(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new DTDEntityResolver()); db.setErrorHandler(new LogErrorHandler()); Document doc = db.parse(in); return doc; }
Resource getRelative(final Resource baseRef, final String relative) { try { if (relative.startsWith("classpath:")) { return RESOURCE_LOADER.getResource(relative); } else { return baseRef.createRelative(relative); } } catch (final IOException e) { throw new ObjectRetrievalFailureException(Resource.class, baseRef, "Resource location has a relative path, however the configResource does not reference a file, so the relative path cannot be resolved. The location is: " + relative, null); } }