use of org.springframework.context.support.FileSystemXmlApplicationContext in project spring-security by spring-projects.
the class ClientApplication method main.
public static void main(String[] args) {
String username = System.getProperty("username", "");
String password = System.getProperty("password", "");
String nrOfCallsString = System.getProperty("nrOfCalls", "");
if ("".equals(username) || "".equals(password)) {
System.out.println("You need to specify the user ID to use, the password to use, and optionally a number of calls " + "using the username, password, and nrOfCalls system properties respectively. eg for user rod, " + "use: -Dusername=rod -Dpassword=koala' for a single call per service and " + "use: -Dusername=rod -Dpassword=koala -DnrOfCalls=10 for ten calls per service.");
System.exit(-1);
} else {
int nrOfCalls = 1;
if (!"".equals(nrOfCallsString)) {
nrOfCalls = Integer.parseInt(nrOfCallsString);
}
ListableBeanFactory beanFactory = new FileSystemXmlApplicationContext("clientContext.xml");
ClientApplication client = new ClientApplication(beanFactory);
client.invokeContactManager(new UsernamePasswordAuthenticationToken(username, password), nrOfCalls);
System.exit(0);
}
}
use of org.springframework.context.support.FileSystemXmlApplicationContext in project Asqatasun by Asqatasun.
the class Asqatasun method initServices.
/**
*
* @param asqatasunHome
*/
private void initServices(String asqatasunHome) {
ApplicationContext springApplicationContext = new FileSystemXmlApplicationContext(asqatasunHome + "/" + APPLICATION_CONTEXT_FILE_PATH);
BeanFactory springBeanFactory = springApplicationContext;
auditService = (AuditService) springBeanFactory.getBean("auditService");
auditDataService = (AuditDataService) springBeanFactory.getBean("auditDataService");
webResourceDataService = (WebResourceDataService) springBeanFactory.getBean("webResourceDataService");
webResourceStatisticsDataService = (WebResourceStatisticsDataService) springBeanFactory.getBean("webResourceStatisticsDataService");
processResultDataService = (ProcessResultDataService) springBeanFactory.getBean("processResultDataService");
processRemarkDataService = (ProcessRemarkDataService) springBeanFactory.getBean("processRemarkDataService");
parameterDataService = (ParameterDataService) springBeanFactory.getBean("parameterDataService");
parameterElementDataService = (ParameterElementDataService) springBeanFactory.getBean("parameterElementDataService");
auditService.add(this);
}
use of org.springframework.context.support.FileSystemXmlApplicationContext in project ignite by apache.
the class ClientPropertiesConfigurationSelfTest method testSpringConfig.
/**
* Validate spring client configuration.
*
* @throws Exception In case of any exception.
*/
public void testSpringConfig() throws Exception {
GridClientConfiguration cfg = new FileSystemXmlApplicationContext(GRID_CLIENT_SPRING_CONFIG.toString()).getBean(GridClientConfiguration.class);
assertEquals(Arrays.asList("127.0.0.1:11211"), new ArrayList<>(cfg.getServers()));
assertNull(cfg.getSecurityCredentialsProvider());
Collection<GridClientDataConfiguration> dataCfgs = cfg.getDataConfigurations();
assertEquals(1, dataCfgs.size());
GridClientDataConfiguration dataCfg = dataCfgs.iterator().next();
assertEquals("partitioned", dataCfg.getName());
assertNotNull(dataCfg.getPinnedBalancer());
assertEquals(GridClientRandomBalancer.class, dataCfg.getPinnedBalancer().getClass());
assertNotNull(dataCfg.getAffinity());
assertEquals(GridClientPartitionAffinity.class, dataCfg.getAffinity().getClass());
}
use of org.springframework.context.support.FileSystemXmlApplicationContext in project ignite by apache.
the class ClientStartNodeTask method getConfig.
/**
* Load grid configuration for specified node type.
*
* @param type Node type to load configuration for.
* @return Grid configuration for specified node type.
*/
static IgniteConfiguration getConfig(String type) {
String path = NODE_CFG.get(type);
if (path == null)
throw new IllegalArgumentException("Unsupported node type: " + type);
URL url = U.resolveIgniteUrl(path);
BeanFactory ctx = new FileSystemXmlApplicationContext(url.toString());
return (IgniteConfiguration) ctx.getBean("grid.cfg");
}
use of org.springframework.context.support.FileSystemXmlApplicationContext in project ignite by apache.
the class GridAbstractTest method loadConfiguration.
/**
* Loads configuration from the given Spring XML file.
*
* @param springCfgPath Path to file.
* @return Grid configuration.
* @throws IgniteCheckedException If load failed.
*/
@SuppressWarnings("deprecation")
protected IgniteConfiguration loadConfiguration(String springCfgPath) throws IgniteCheckedException {
URL cfgLocation = U.resolveIgniteUrl(springCfgPath);
if (cfgLocation == null)
cfgLocation = U.resolveIgniteUrl(springCfgPath, false);
assert cfgLocation != null;
ApplicationContext springCtx;
try {
springCtx = new FileSystemXmlApplicationContext(cfgLocation.toString());
} catch (BeansException e) {
throw new IgniteCheckedException("Failed to instantiate Spring XML application context.", e);
}
Map cfgMap;
try {
// Note: Spring is not generics-friendly.
cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
} catch (BeansException e) {
throw new IgniteCheckedException("Failed to instantiate bean [type=" + IgniteConfiguration.class + ", err=" + e.getMessage() + ']', e);
}
if (cfgMap == null)
throw new IgniteCheckedException("Failed to find a single grid factory configuration in: " + springCfgPath);
if (cfgMap.isEmpty())
throw new IgniteCheckedException("Can't find grid factory configuration in: " + springCfgPath);
else if (cfgMap.size() > 1)
throw new IgniteCheckedException("More than one configuration provided for cache load test: " + cfgMap.values());
IgniteConfiguration cfg = (IgniteConfiguration) cfgMap.values().iterator().next();
cfg.setNodeId(UUID.randomUUID());
return cfg;
}
Aggregations