本文整理汇总了Java中org.apache.commons.configuration.Configuration.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.setProperty方法的具体用法?Java Configuration.setProperty怎么用?Java Configuration.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStartup
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
if (getPort() == 0) {
LOGGER.warn(
"spring boot embed web container listen port is 0, serviceComb will not use container's port to handler RESTful request.");
return;
}
// web container did not did listen now.
// so mock to listen, and then close.
try (ServerSocket ss = new ServerSocket(getPort(), 0, getAddress())) {
if (StringUtils.isEmpty(ServletConfig.getServletUrlPattern())) {
// ensure the servlet will be instantiated
Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource();
configuration.setProperty(ServletConfig.KEY_SERVLET_URL_PATTERN, ServletConfig.DEFAULT_URL_PATTERN);
}
RestServletInjector.defaultInject(servletContext);
ServletUtils.saveUrlPrefix(servletContext);
} catch (IOException e) {
throw new ServletException(e);
}
}
示例2: testOnStartup
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Test
public void testOnStartup() throws Exception {
Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource();
String urlPattern = "/rest/*";
configuration.setProperty(ServletConfig.KEY_SERVLET_URL_PATTERN, urlPattern);
ServletContext servletContext = mock(ServletContext.class);
Dynamic dynamic = mock(Dynamic.class);
when(servletContext.addServlet(RestServletInjector.SERVLET_NAME, RestServlet.class)).thenReturn(dynamic);
RestServletInitializer restServletInitializer = new RestServletInitializer();
restServletInitializer.setPort(TEST_PORT);
restServletInitializer.onStartup(servletContext);
verify(dynamic).setAsyncSupported(true);
verify(dynamic).addMapping(urlPattern);
verify(dynamic).setLoadOnStartup(0);
}
示例3: onBootEvent
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Override
public void onBootEvent(BootEvent event) {
if (!EventType.BEFORE_PRODUCER_PROVIDER.equals(event.getEventType())) {
return;
}
String defaultExecutor = DynamicPropertyFactory.getInstance()
.getStringProperty(ExecutorManager.KEY_EXECUTORS_DEFAULT, null)
.get();
if (defaultExecutor != null) {
LOGGER.info("Edge service default executor is {}.", defaultExecutor);
return;
}
// change default to reactive mode
Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource();
configuration.setProperty(ExecutorManager.KEY_EXECUTORS_DEFAULT, ExecutorManager.EXECUTOR_REACTIVE);
LOGGER.info("Set ReactiveExecutor to be edge service default executor.");
}
示例4: testGetServletUrlPattern
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Test
public void testGetServletUrlPattern() {
DynamicPropertyFactory.getInstance();
Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource();
configuration.setProperty(ServletConfig.KEY_SERVLET_URL_PATTERN, "/*");
Assert.assertEquals("/*", ServletConfig.getServletUrlPattern());
}
示例5: setUp
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource();
configuration.clearProperty(ServletConfig.KEY_SERVLET_URL_PATTERN);
configuration.setProperty(ServletConfig.KEY_CSE_REST_ADDRESS, LISTEN_ADDRESS);
PowerMockito.mockStatic(NetUtils.class);
PowerMockito.when(NetUtils.parseIpPortFromURI(anyString())).thenReturn(new IpPort(LISTEN_ADDRESS, TEST_PORT));
PowerMockito.when(NetUtils.canTcpListen(anyObject(), anyInt())).thenReturn(false);
}
示例6: configuration
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Override
public Configuration configuration() {
if (this.origConfig != null) {
return this.origConfig;
} else {
Configuration ans = new BaseConfiguration();
ans.setProperty(DB_PATH_KEY, dbPath.toString());
ans.setProperty(ALLOW_FULL_GRAPH_SCANS_KEY, allowFullGraphScans);
ans.setProperty(DEFAULT_ISOLATION_LEVEL_KEY, defaultIsolationLevel.toString());
ans.setProperty(TX_LOG_THRESHOLD_KEY, getTxLogThreshold());
ans.setProperty(REORG_FACTOR_KEY, getReorgFactor());
ans.setProperty(CREATE_DIR_IF_MISSING_KEY, createDirIfMissing);
ans.setProperty(VERTEX_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));
ans.setProperty(EDGE_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));
return ans;
}
}
示例7: deserialize
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
final Configuration conf = new BaseConfiguration();
conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
final TinkerGraph graph = TinkerGraph.open(conf);
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
if (jsonParser.getCurrentName().equals("vertices")) {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
v.attach(Attachable.Method.getOrCreate(graph));
}
}
} else if (jsonParser.getCurrentName().equals("edges")) {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
e.attach(Attachable.Method.getOrCreate(graph));
}
}
}
}
return graph;
}
示例8: shouldPersistWithRelativePath
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Test
public void shouldPersistWithRelativePath() {
final String graphLocation = TestHelper.convertToRelative(TinkerGraphTest.class,
new File(TestHelper.makeTestDataDirectory(TinkerGraphTest.class))) + "shouldPersistToGryoRelative.kryo";
final File f = new File(graphLocation);
if (f.exists() && f.isFile()) f.delete();
final Configuration conf = new BaseConfiguration();
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
final TinkerGraph graph = TinkerGraph.open(conf);
TinkerFactory.generateModern(graph);
graph.close();
final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
IoTest.assertModernGraph(reloadedGraph, true, false);
reloadedGraph.close();
}
示例9: shouldPersistToGraphML
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Test
public void shouldPersistToGraphML() {
final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGraphML.xml";
final File f = new File(graphLocation);
if (f.exists() && f.isFile()) f.delete();
final Configuration conf = new BaseConfiguration();
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "graphml");
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
final TinkerGraph graph = TinkerGraph.open(conf);
TinkerFactory.generateModern(graph);
graph.close();
final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
IoTest.assertModernGraph(reloadedGraph, true, true);
reloadedGraph.close();
}
示例10: shouldPersistToGraphSON
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Test
public void shouldPersistToGraphSON() {
final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGraphSON.json";
final File f = new File(graphLocation);
if (f.exists() && f.isFile()) f.delete();
final Configuration conf = new BaseConfiguration();
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "graphson");
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
final TinkerGraph graph = TinkerGraph.open(conf);
TinkerFactory.generateModern(graph);
graph.close();
final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
IoTest.assertModernGraph(reloadedGraph, true, false);
reloadedGraph.close();
}
示例11: shouldPersistToGryo
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Test
public void shouldPersistToGryo() {
final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGryo.kryo";
final File f = new File(graphLocation);
if (f.exists() && f.isFile()) f.delete();
final Configuration conf = new BaseConfiguration();
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
final TinkerGraph graph = TinkerGraph.open(conf);
TinkerFactory.generateModern(graph);
graph.close();
final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
IoTest.assertModernGraph(reloadedGraph, true, false);
reloadedGraph.close();
}
示例12: shouldPersistToAnyGraphFormat
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Test
public void shouldPersistToAnyGraphFormat() {
final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToAnyGraphFormat.dat";
final File f = new File(graphLocation);
if (f.exists() && f.isFile()) f.delete();
final Configuration conf = new BaseConfiguration();
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, TestIoBuilder.class.getName());
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
final TinkerGraph graph = TinkerGraph.open(conf);
TinkerFactory.generateModern(graph);
//Test write graph
graph.close();
assertEquals(TestIoBuilder.calledOnMapper, 1);
assertEquals(TestIoBuilder.calledGraph, 1);
assertEquals(TestIoBuilder.calledCreate, 1);
try (BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(f))){
os.write("dummy string".getBytes());
} catch (Exception e) {
e.printStackTrace();
}
//Test read graph
final TinkerGraph readGraph = TinkerGraph.open(conf);
assertEquals(TestIoBuilder.calledOnMapper, 1);
assertEquals(TestIoBuilder.calledGraph, 1);
assertEquals(TestIoBuilder.calledCreate, 1);
}
示例13: createTheCrew
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
public static TinkerGraph createTheCrew() {
final Configuration conf = getNumberIdManagerConfiguration();
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name());
final TinkerGraph g = TinkerGraph.open(conf);
generateTheCrew(g);
return g;
}
示例14: getNumberIdManagerConfiguration
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
private static Configuration getNumberIdManagerConfiguration() {
final Configuration conf = new BaseConfiguration();
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, TinkerGraph.DefaultIdManager.INTEGER.name());
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, TinkerGraph.DefaultIdManager.INTEGER.name());
conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, TinkerGraph.DefaultIdManager.LONG.name());
return conf;
}
示例15: read
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@Override
public TinkerGraph read(final Kryo kryo, final Input input, final Class<TinkerGraph> tinkerGraphClass) {
final Configuration conf = new BaseConfiguration();
conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
final TinkerGraph graph = TinkerGraph.open(conf);
final int len = input.readInt();
final byte[] bytes = input.readBytes(len);
try (final ByteArrayInputStream stream = new ByteArrayInputStream(bytes)) {
GryoReader.build().mapper(() -> kryo).create().readGraph(stream, graph);
} catch (Exception io) {
throw new RuntimeException(io);
}
return graph;
}