List of usage examples for org.springframework.core.io UrlResource UrlResource
public UrlResource(String path) throws MalformedURLException
From source file:com.moreopen.config.center.ConfigCenterLauncher.java
public static void main(String[] args) throws Exception { final String PROFILE_NAME = "/app.properties"; Properties properties = PropertiesLoaderUtils .loadProperties(new UrlResource(ConfigCenterLauncher.class.getResource(PROFILE_NAME))); int port = Integer.parseInt(properties.getProperty("webserver.port")); if (port == 0) { logger.error("property: config.webserver.port not found, please check " + PROFILE_NAME); return;/*from ww w . ja v a2s. c om*/ } // launch the monitor console server new ConfigCenterLauncher(port).run(); server.join(); }
From source file:com.example.JobUtil.java
public static Resource getResource(final String resourcePath) { if (resourcePath == null) { return null; }/*from w w w .j a v a 2 s. co m*/ Resource resource = null; String profile = System.getProperty("spring.profiles.active"); if (!StringUtils.hasText(profile) || ("loc").equals(profile)) { resource = new ClassPathResource(resourcePath); return resource; } try { resource = new UrlResource(resourcePath); } catch (Exception e) { log.error("resource error : {}", e.toString()); return null; } return resource; }
From source file:org.activiti.spring.SpringConfigurationHelper.java
public static ProcessEngine buildProcessEngine(URL resource) { log.debug(//from w w w. java2s . c o m "==== BUILDING SPRING APPLICATION CONTEXT AND PROCESS ENGINE ========================================="); ApplicationContext applicationContext = new GenericXmlApplicationContext(new UrlResource(resource)); Map<String, ProcessEngine> beansOfType = applicationContext.getBeansOfType(ProcessEngine.class); if ((beansOfType == null) || (beansOfType.isEmpty())) { throw new ActivitiException("no " + ProcessEngine.class.getName() + " defined in the application context " + resource.toString()); } ProcessEngine processEngine = beansOfType.values().iterator().next(); log.debug( "==== SPRING PROCESS ENGINE CREATED =================================================================="); return processEngine; }
From source file:org.jtheque.i18n.I18NResourceFactory.java
/** * Construct a new I18NResource from the given URL. * * @param name The name of the file.//from w w w. ja v a2 s . co m * @param url The url to create the resource to. * * @return The I18NResource to the URL. */ public static I18NResource fromURL(String name, URL url) { Resource resource = new UrlResource(url); return new I18NResourceImpl(name, resource); }
From source file:fr.xebia.demo.wicket.blog.service.AbstractServiceTest.java
@BeforeClass public static void setUpClass() { randomizer = new Random(); long startTime = System.currentTimeMillis(); logger.info("Initializing Services"); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); URL configuration = contextClassLoader.getResource("applicationContext-service.xml"); factory = new XmlBeanFactory(new UrlResource(configuration)); long endTime = System.currentTimeMillis(); logger.info("Initialisation des services en " + ((endTime - startTime) / 1000.0) + " s"); }
From source file:org.jboss.fuse.wsdl2rest.util.SpringCamelContextFactory.java
/** * Create a single {@link SpringCamelContext} from the given URL * @throws IllegalStateException if the given URL does not contain a single context definition */// w w w .ja v a 2 s.c o m public static SpringCamelContext createSingleCamelContext(URL contextUrl, ClassLoader classsLoader) throws Exception { List<SpringCamelContext> list = createCamelContextList(new UrlResource(contextUrl), classsLoader); IllegalStateAssertion.assertEquals(1, list.size(), "Single context expected in: " + contextUrl); return list.get(0); }
From source file:org.wildfly.extension.camel.SpringCamelContextFactory.java
/** * Create a {@link SpringCamelContext} from the given URL */// w w w . ja v a2s . co m public static CamelContext createSpringCamelContext(URL contextUrl, ClassLoader classsLoader) throws Exception { return createSpringCamelContext(new UrlResource(contextUrl), classsLoader); }
From source file:br.com.caelum.vraptor.ioc.spring.WebinfClassesPatternResolver.java
protected Resource[] findAllClassPathResources(String location) throws IOException { return new Resource[] { new UrlResource("file:/" + webinfClassesDirectory) }; }
From source file:de.langmi.spring.batch.examples.complex.file.renamefile.simple.SimpleRenameFileTaskletStep.java
/** */ @Override/*from w w w.j ava 2 s. c o m*/ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { // get used output file String outputFilePath = (String) chunkContext.getStepContext().getJobParameters().get("output.file"); UrlResource oldFile = new UrlResource(outputFilePath); // get desired output file name String desiredOutputFilePath = (String) chunkContext.getStepContext().getJobExecutionContext() .get("desired.output.file"); UrlResource newFile = new UrlResource(desiredOutputFilePath); // rename oldFile.getFile().renameTo(newFile.getFile()); return RepeatStatus.FINISHED; }
From source file:com.openmeap.model.ModelTestUtils.java
static public BeanFactory newModelBeans() { return new XmlBeanFactory(new UrlResource(ModelTestUtils.class.getResource("mock/mockModelBeans.xml"))); }