本文整理匯總了Java中org.walkmod.conf.entities.Configuration類的典型用法代碼示例。如果您正苦於以下問題:Java Configuration類的具體用法?Java Configuration怎麽用?Java Configuration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Configuration類屬於org.walkmod.conf.entities包,在下文中一共展示了Configuration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createConfig
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
private Configuration createConfig(String[] chains, ConfigurationProvider... cp)
throws InvalidConfigurationException {
Configuration config = new ConfigurationImpl();
try {
DynamicConfigurationProvider prov = new DynamicConfigurationProvider(options, chains);
prov.init(config);
prov.load();
ConfigurationManager cfgManager = new ConfigurationManager(config, cp);
DynamicModulesConfigurationProvider prov2 = new DynamicModulesConfigurationProvider();
prov2.init(config);
prov2.load();
config = cfgManager.getConfiguration();
config.setParameters(options.getMutableCopyOfDynamicArgs());
} catch (Exception e) {
printConfigError(e);
}
return config;
}
示例2: getConfiguration
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
/**
* Returns the equivalent configuration representation of the Walkmod config file.
*
* @return Configuration object representation of the config file.
* @throws Exception
* If the walkmod configuration file can't be read.
*/
public Configuration getConfiguration() throws Exception {
Configuration result = null;
if (cfg.exists()) {
userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
try {
ConfigurationManager manager = new ConfigurationManager(cfg, false);
manager.executeConfigurationProviders();
result = manager.getConfiguration();
} finally {
System.setProperty("user.dir", userDir);
}
}
return result;
}
示例3: createChainProxy
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Override
public ChainAdapter createChainProxy(Configuration configuration, String chain) {
Collection<ChainConfig> acs = configuration.getChainConfigs();
if (acs != null) {
Iterator<ChainConfig> it = acs.iterator();
boolean end = false;
ChainConfig acfg = null;
while (it.hasNext() && !end) {
acfg = it.next();
end = chain.equals(acfg.getName());
}
if (end) {
LOG.debug("Chain " + chain + " found");
ChainAdapter ap = new DefaultChainAdapter();
ap.setChainConfig(acfg);
ap.setChainInvocation(new DefaultChainInvocation());
ap.prepare();
return ap;
}
}
return null;
}
示例4: testTransformationsYaml
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Test
public void testTransformationsYaml() {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider("src/test/resources/yaml/basic.yml");
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.load();
Assert.assertNotNull(conf.getChainConfigs());
ChainConfig cc = conf.getChainConfigs().iterator().next();
Assert.assertNotNull(cc.getWalkerConfig().getTransformations());
Iterator<TransformationConfig> it = cc.getWalkerConfig().getTransformations().iterator();
TransformationConfig tc = it.next();
Assert.assertEquals("walkmod:commons:method-refactor", tc.getType());
Assert.assertEquals("src/conf/refactoring-methods.json", tc.getParameters().get("refactoringConfigFile"));
}
示例5: testChainsYaml
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Test
public void testChainsYaml() {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider("src/test/resources/yaml/chains.yml");
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.load();
Assert.assertNotNull(conf.getChainConfigs());
ChainConfig cc = conf.getChainConfigs().iterator().next();
Iterator<TransformationConfig> it = cc.getWalkerConfig().getTransformations().iterator();
TransformationConfig first = it.next();
Assert.assertEquals("walkmod:commons:method-refactor", first.getType());
Assert.assertNotNull(cc.getReaderConfig());
Assert.assertNotNull(cc.getWriterConfig());
}
示例6: testEmptyChain
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Test
public void testEmptyChain() throws Exception {
File file = new File("src/test/resources/yaml/addEmptychain.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
FileUtils.write(file, "");
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
ChainConfig chainCfg = new ChainConfigImpl();
try {
provider.addChainConfig(chainCfg, false, null);
String output = FileUtils.readFileToString(file);
Assert.assertEquals("", output);
} finally {
if (file.exists()) {
file.delete();
}
}
}
示例7: testInvalidPlugins
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Test
public void testInvalidPlugins() {
IvyConfigurationProvider provider = new IvyConfigurationProvider();
Configuration conf = new ConfigurationImpl();
provider.init(conf);
PluginConfig pc = new PluginConfigImpl();
pc.setGroupId("foo");
pc.setArtifactId("bar");
pc.setVersion("10");
conf.setPlugins(new LinkedList());
conf.getPlugins().add(pc);
Exception exception = null;
try {
provider.load();
} catch (ConfigurationException e) {
exception = e;
}
Assert.assertNotNull(exception);
}
示例8: execute
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Override
public void execute() throws Exception {
calculateClasspath();
List<String> consProv = getConstraintProviders();
if (consProv != null) {
Configuration conf = getChainConfig().getConfiguration();
constraintProv = new LinkedList<ConstraintProvider<?>>();
for (String cons : consProv) {
if (conf.containsBean(cons)) {
ConstraintProvider<?> cp = (ConstraintProvider) conf.getBean(cons, null);
constraintProv.add(cp);
}
}
}
super.execute();
deleteClassLoader();
}
示例9: runClassLoaderInitializers
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
protected void runClassLoaderInitializers(DefaultJavaWalker walker) {
ChainConfig currentChain = walker.getChainConfig();
Configuration conf = currentChain.getConfiguration();
List<InitializerConfig> initCfgs = conf.getInitializers();
Map<String, Object> params = conf.getParameters();
if (initCfgs == null || initCfgs.isEmpty()) {
BasicClasspathInitializer basicInitializer = new BasicClasspathInitializer(walker.getReaderPath(), walker.getParser());
basicInitializer.init(conf);
basicInitializer.load();
} else {
for (InitializerConfig ic : initCfgs) {
String name = ic.getType().substring(0, ic.getType().indexOf("-initializer"));
Object cfgProvider = conf.getBean(name, null);
if (cfgProvider != null) {
ConfigurationProvider cfg = (ConfigurationProvider) cfgProvider;
cfg.init(conf);
cfg.load();
}
}
}
updateVisitorClassLoaders(walker, (ClassLoader) params.get("classLoader"));
}
示例10: testGradleInitialization
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Test
public void testGradleInitialization() throws Exception {
File workDir = new File("src/test/resources/multiple");
File file = new File(workDir, "walkmod.xml");
File child1 = new File(new File(workDir, "bluewhale"), "walkmod.xml");
File child2 = new File(new File(workDir, "krill"), "walkmod.xml");
if (file.exists()) {
file.delete();
}
if (child1.exists()) {
child1.delete();
}
if (child2.exists()) {
child2.delete();
}
GradleInitializer initializer = new GradleInitializer();
XMLConfigurationProvider provider = new XMLConfigurationProvider(
workDir.getPath() + File.separator + "walkmod.xml", false);
initializer.execute(provider);
Assert.assertTrue(file.exists());
provider.load();
Configuration conf = provider.getConfiguration();
Assert.assertEquals(2, conf.getModules().size());
Assert.assertTrue(child1.exists());
Assert.assertTrue(child2.exists());
file.delete();
child1.delete();
child2.delete();
}
示例11: execute
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Override
public void execute() throws Exception {
if (help) {
command.usage("modules");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options());
Configuration cfg = facade.getConfiguration();
if(cfg == null){
log.error("Sorry, the current directory does not contain a walkmod configuration file or it is invalid.");
}
at = new V2_AsciiTable();
at.addRule();
at.addRow("MODULE");
at.addRule();
if (cfg != null) {
List<String> modules = cfg.getModules();
if (modules != null) {
for (String module : modules) {
at.addRow(module);
}
}
}
at.addRule();
}
}
示例12: readConfig
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
private Configuration readConfig(ConfigurationProvider... cp) throws InvalidConfigurationException {
Configuration config = null;
try {
ConfigurationManager cfgManager = new ConfigurationManager(cfg, cp);
config = cfgManager.getConfiguration();
config.setParameters(options.getMutableCopyOfDynamicArgs());
} catch (Exception e) {
printConfigError(e);
}
return config;
}
示例13: inspectPlugin
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
/**
* Retrieves the bean definitions that contains an specific plugin.
*
* @param plugin
* Plugin container of bean definitions.
* @return List of bean definitions.
*/
public List<BeanDefinition> inspectPlugin(PluginConfig plugin) {
Configuration conf = new ConfigurationImpl();
Collection<PluginConfig> plugins = new LinkedList<PluginConfig>();
plugins.add(plugin);
conf.setPlugins(plugins);
ConfigurationManager manager = new ConfigurationManager(conf, false, locateConfigurationProvider());
manager.executeConfigurationProviders();
return conf.getAvailableBeans(plugin);
}
示例14: testNullOverwriting
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Test
public void testNullOverwriting() {
LanguageConfigurationProvider provider = new LanguageConfigurationProvider();
Configuration conf = new ConfigurationImpl();
ChainConfig cc = new ChainConfigImpl();
cc.setName("test-chain");
ReaderConfig reader = new ReaderConfig();
WalkerConfig walker = new WalkerConfigImpl();
TransformationConfig transformation = new TransformationConfigImpl();
transformation.isMergeable(true);
List<TransformationConfig> transf = new LinkedList<TransformationConfig>();
transf.add(transformation);
walker.setParserConfig(new ParserConfigImpl());
walker.setTransformations(transf);
WriterConfig writer = new WriterConfigImpl();
cc.setReaderConfig(reader);
cc.setWalkerConfig(walker);
cc.setWriterConfig(writer);
conf.addChainConfig(cc);
provider.init(conf);
provider.load();
Assert.assertNotNull(reader.getPath());
Assert.assertNotNull(reader.getType());
Assert.assertNotNull(walker.getType());
Assert.assertNotNull(walker.getParserConfig().getType());
Assert.assertNotNull(writer.getPath());
Assert.assertNotNull(writer.getType());
Assert.assertNotNull(transformation.getMergePolicy());
Assert.assertNotNull(conf.getMergePolicies());
Collection<MergePolicyConfig> mergec = conf.getMergePolicies();
Assert.assertEquals(1, mergec.size());
MergePolicyConfig mpc = mergec.iterator().next();
Assert.assertNotNull(mpc.getDefaultObjectPolicy());
Assert.assertNotNull(mpc.getDefaultTypePolicy());
Map<String, String> entries = mpc.getPolicyEntries();
Assert.assertEquals(2, entries.size());
}
示例15: testVersion1_0
import org.walkmod.conf.entities.Configuration; //導入依賴的package包/類
@Test
public void testVersion1_0() throws Exception {
XMLConfigurationProvider prov = new XMLConfigurationProvider("src/test/resources/testFiles/walkmod.xml", false);
Configuration conf = new ConfigurationImpl();
prov.init(conf);
prov.load();
Assert.assertEquals(1, conf.getChainConfigs().size());
Assert.assertEquals("default", conf.getChainConfigs().iterator().next().getName());
}