本文整理汇总了Java中com.networknt.service.SingletonServiceFactory类的典型用法代码示例。如果您正苦于以下问题:Java SingletonServiceFactory类的具体用法?Java SingletonServiceFactory怎么用?Java SingletonServiceFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SingletonServiceFactory类属于com.networknt.service包,在下文中一共展示了SingletonServiceFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTestHandler
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
static RoutingHandler getTestHandler() {
return Handlers.routing()
.add(Methods.GET, "/get", exchange -> {
SessionManager sessionManager = SingletonServiceFactory.getBean(SessionManager.class);
Session session = sessionManager.getSession(exchange);
if(session == null) {
session = sessionManager.createSession(exchange);
session.setAttribute(COUNT, 0);
logger.debug("first time access create a session and count is 0 sessionId = " + session.getId());
}
Integer count = (Integer) session.getAttribute(COUNT);
logger.debug("not the first time, get count from session = " + count + " sessionId = " + session.getId());
exchange.getResponseHeaders().add(new HttpString(COUNT), count.toString());
session.setAttribute(COUNT, ++count);
});
}
开发者ID:networknt,项目名称:light-session-4j,代码行数:17,代码来源:JdbcSessionMultipleTest.java
示例2: TestServer
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
private TestServer() {
DataSource ds = (DataSource) SingletonServiceFactory.getBean(DataSource.class);
try (Connection connection = ds.getConnection()) {
String schemaResourceName = "/create_h2.sql";
InputStream in = TestServer.class.getResourceAsStream(schemaResourceName);
if (in == null) {
throw new RuntimeException("Failed to load resource: " + schemaResourceName);
}
InputStreamReader reader = new InputStreamReader(in, UTF_8);
RunScript.execute(connection, reader);
} catch (SQLException e) {
e.printStackTrace();
}
}
开发者ID:networknt,项目名称:light-oauth2,代码行数:17,代码来源:TestServer.java
示例3: TestServer
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
private TestServer() {
DataSource ds = (DataSource) SingletonServiceFactory.getBean(DataSource.class);
try (Connection connection = ds.getConnection()) {
String schemaResourceName = "/create_h2.sql";
InputStream in = TestServer.class.getResourceAsStream(schemaResourceName);
if (in == null) {
throw new RuntimeException("Failed to load resource: " + schemaResourceName);
}
InputStreamReader reader = new InputStreamReader(in, UTF_8);
RunScript.execute(connection, reader);
} catch (SQLException e) {
e.printStackTrace();
}
}
开发者ID:networknt,项目名称:light-oauth2,代码行数:18,代码来源:TestServer.java
示例4: TestServer
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
private TestServer() {
DataSource ds = (DataSource) SingletonServiceFactory.getBean(DataSource.class);
try (Connection connection = ds.getConnection()) {
// Runscript doesn't work need to execute batch here.
String schemaResourceName = "/create_h2.sql";
InputStream in = TestServer.class.getResourceAsStream(schemaResourceName);
if (in == null) {
throw new RuntimeException("Failed to load resource: " + schemaResourceName);
}
InputStreamReader reader = new InputStreamReader(in, UTF_8);
RunScript.execute(connection, reader);
} catch (SQLException e) {
e.printStackTrace();
}
}
开发者ID:networknt,项目名称:light-oauth2,代码行数:18,代码来源:TestServer.java
示例5: runOnceBeforeClass
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
@BeforeClass
public static void runOnceBeforeClass() {
System.out.println("@BeforeClass - runOnceBeforeClass");
DataSource ds = (DataSource) SingletonServiceFactory.getBean(DataSource.class);
try (Connection connection = ds.getConnection()) {
String schemaResourceName = "/create_h2.sql";
InputStream in = CacheStartupHookProviderTest.class.getResourceAsStream(schemaResourceName);
if (in == null) {
throw new RuntimeException("Failed to load resource: " + schemaResourceName);
}
InputStreamReader reader = new InputStreamReader(in, UTF_8);
RunScript.execute(connection, reader);
} catch (SQLException e) {
e.printStackTrace();
}
}
开发者ID:networknt,项目名称:light-oauth2,代码行数:20,代码来源:CacheStartupHookProviderTest.java
示例6: setUp
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception
{
int port = 9000;
clientUrl = new URLImpl(Constants.PROTOCOL_LIGHT, "127.0.0.1", 0, service);
clientUrl.addParameter("group", "aaa");
serviceUrl = new URLImpl(Constants.PROTOCOL_LIGHT, "127.0.0.1", 8001, service);
serviceUrl.addParameter("group", "aaa");
InstanceSpec spec = new InstanceSpec(null, port, -1, -1, true, 1,-1, -1,new HashMap<>());
zookeeper = new TestingServer(spec, true);
client = (ZooKeeperClient)SingletonServiceFactory.getBean(ZooKeeperClient.class);
registry = (ZooKeeperRegistry)SingletonServiceFactory.getBean(Registry.class);
System.out.println("client = " + client + " registry = " + registry);
}
开发者ID:networknt,项目名称:light-4j,代码行数:18,代码来源:ZooKeeperRegistryTest.java
示例7: shutdown
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
static public void shutdown() {
// need to unregister the service
if(config.enableRegistry && registry != null && config.enableHttp) {
registry.unregister(serviceHttpUrl);
if(logger.isInfoEnabled()) logger.info("unregister serviceHttpUrl " + serviceHttpUrl);
}
if(config.enableRegistry && registry != null && config.enableHttps) {
registry.unregister(serviceHttpsUrl);
if(logger.isInfoEnabled()) logger.info("unregister serviceHttpsUrl " + serviceHttpsUrl);
}
ShutdownHookProvider[] shutdownHookProviders = SingletonServiceFactory.getBeans(ShutdownHookProvider.class);
if(shutdownHookProviders != null) Arrays.stream(shutdownHookProviders).forEach(s -> s.onShutdown());
stop();
logger.info("Cleaning up before server shutdown");
}
开发者ID:networknt,项目名称:light-4j,代码行数:19,代码来源:Server.java
示例8: setUp
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
@Before
public void setUp() {
myReplyConsumer = SingletonServiceFactory.getBean(MyReplyConsumer.class);
logger.debug("myReplyConsumer = " + myReplyConsumer);
commandProducer = SingletonServiceFactory.getBean(CommandProducer.class);
logger.debug("commandProducer = " + commandProducer);
myTestCommandHandler = SingletonServiceFactory.getBean(MyTestCommandHandler.class);
logger.debug("myTestCommandHandler = " + myTestCommandHandler);
}
开发者ID:networknt,项目名称:light-tram-4j,代码行数:10,代码来源:TramCommandsAndEventsIntegrationIT.java
示例9: consumerCommandDispatcher
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public CommandDispatcher consumerCommandDispatcher() {
MyTestCommandHandler target = Mockito.spy(new MyTestCommandHandler());
ChannelMapping channelMapping = SingletonServiceFactory.getBean(ChannelMapping.class);
MessageConsumer messageConsumer = SingletonServiceFactory.getBean(MessageConsumer.class);
MessageProducer messageProducer = SingletonServiceFactory.getBean(MessageProducer.class);
return new CommandDispatcher("customerCommandDispatcher",
target.defineCommandHandlers(), channelMapping, messageConsumer, messageProducer);
}
开发者ID:networknt,项目名称:light-tram-4j,代码行数:9,代码来源:TramCommandsAndEventsServiceInitializer.java
示例10: getCustomerCommandDispatcher
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public static CommandDispatcher getCustomerCommandDispatcher() {
CustomerCommandHandler customerCommandHandler = SingletonServiceFactory.getBean(CustomerCommandHandler.class);
ChannelMapping channelMapping = SingletonServiceFactory.getBean(ChannelMapping.class);
MessageProducer messageProducer = SingletonServiceFactory.getBean(MessageProducer.class);
MessageConsumer messageConsumer = SingletonServiceFactory.getBean(MessageConsumer.class);
SagaLockManager sagaLockManager = SingletonServiceFactory.getBean(SagaLockManager.class);
return new SagaCommandDispatcher("customerCommandDispatcher",
customerCommandHandler.commandHandlerDefinitions(),
channelMapping,
messageConsumer,
messageProducer,
sagaLockManager);
}
开发者ID:networknt,项目名称:light-saga-4j,代码行数:14,代码来源:ComponentFactory.java
示例11: getOrderCommandDispatcher
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public static CommandDispatcher getOrderCommandDispatcher() {
OrderCommandHandler orderCommandHandler = SingletonServiceFactory.getBean(OrderCommandHandler.class);
ChannelMapping channelMapping = SingletonServiceFactory.getBean(ChannelMapping.class);
MessageProducer messageProducer = SingletonServiceFactory.getBean(MessageProducer.class);
MessageConsumer messageConsumer = SingletonServiceFactory.getBean(MessageConsumer.class);
SagaLockManager sagaLockManager = SingletonServiceFactory.getBean(SagaLockManager.class);
return new SagaCommandDispatcher("orderCommandDispatcher",
orderCommandHandler.commandHandlerDefinitions(),
channelMapping,
messageConsumer,
messageProducer,
sagaLockManager);
}
开发者ID:networknt,项目名称:light-saga-4j,代码行数:15,代码来源:ComponentFactory.java
示例12: channelMapping
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public ChannelMapping channelMapping() {
TramCommandsAndEventsIntegrationData data = SingletonServiceFactory.getBean(TramCommandsAndEventsIntegrationData.class);
return DefaultChannelMapping.builder()
.with("CustomerAggregate", data.getAggregateDestination())
.with("customerService", data.getCommandChannel())
.build();
}
开发者ID:networknt,项目名称:light-saga-4j,代码行数:8,代码来源:OrderCustomerServiceInitializer.java
示例13: decryptObject
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
private static Object decryptObject(Object object) {
if(object instanceof String) {
if(((String)object).startsWith(Decryptor.CRYPT_PREFIX)) {
Decryptor decryptor = SingletonServiceFactory.getBean(Decryptor.class);
if(decryptor == null) throw new RuntimeException("No implementation of Decryptor is defined in service.yml");
object = decryptor.decrypt((String)object);
}
}
return object;
}
开发者ID:networknt,项目名称:light-4j,代码行数:12,代码来源:DecryptUtil.java
示例14: testDirectRegistry
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
@Test
public void testDirectRegistry() {
Registry registry = (Registry)SingletonServiceFactory.getBean(Registry.class);
URL subscribeUrl = URLImpl.valueOf("light://localhost:8080/token");
List<URL> urls = registry.discover(subscribeUrl);
Assert.assertEquals(1, urls.size());
subscribeUrl = URLImpl.valueOf("light://localhost:8080/code");
urls = registry.discover(subscribeUrl);
Assert.assertEquals(2, urls.size());
}
开发者ID:networknt,项目名称:light-4j,代码行数:13,代码来源:DirectRegistryTest.java
示例15: setUp
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
client = (MockConsulClient)SingletonServiceFactory.getBean(ConsulClient.class);
registry = (ConsulRegistry)SingletonServiceFactory.getBean(Registry.class);
serviceUrl = MockUtils.getMockUrl(8001);
serviceUrl2 = MockUtils.getMockUrl(8002);
serviceid = ConsulUtils.convertConsulSerivceId(serviceUrl);
serviceid2 = ConsulUtils.convertConsulSerivceId(serviceUrl2);
clientUrl = MockUtils.getMockUrl("127.0.0.1", 0);
clientUrl2 = MockUtils.getMockUrl("127.0.0.2", 0);
sleepTime = ConsulConstants.SWITCHER_CHECK_CIRCLE + 500;
}
开发者ID:networknt,项目名称:light-4j,代码行数:15,代码来源:ConsulRegistryTest.java
示例16: onStartup
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
@Override
public void onStartup() {
MessageConsumer messageConsumer = (MessageConsumer) SingletonServiceFactory.getBean(MessageConsumer.class);
TodoEventConsumer todoEventConsumer = (TodoEventConsumer) SingletonServiceFactory.getBean(TodoEventConsumer.class);
domainEventDispatcher = new DomainEventDispatcher("todoServiceEvents", todoEventConsumer.domainEventHandlers(), messageConsumer);
domainEventDispatcher.initialize();
}
开发者ID:networknt,项目名称:light-example-4j,代码行数:8,代码来源:StartUpTramMessageDispacher.java
示例17: onShutdown
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public void onShutdown() {
EventTableChangesToAggregateTopicTranslator<PublishedEvent> translator = SingletonServiceFactory.getBean(EventTableChangesToAggregateTopicTranslator.class);
if(translator != null) {
try {
translator.stop();
} catch (Exception e) {
logger.error("Exception: ", e);
}
}
CuratorFramework curatorFramework = SingletonServiceFactory.getBean(CuratorFramework.class);
if(curatorFramework != null) {
curatorFramework.close();
}
logger.info("CdcServerShutdownHookProvider is called");
}
开发者ID:networknt,项目名称:light-eventuate-4j,代码行数:16,代码来源:CdcServerShutdownHookProvider.java
示例18: pollingDao
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public PollingDao pollingDao() {
DataSource ds = (DataSource) SingletonServiceFactory.getBean(DataSource.class);
EventPollingDataProvider pollingDataProvider= (EventPollingDataProvider) SingletonServiceFactory.getBean(EventPollingDataProvider.class);
return new PollingDao (pollingDataProvider, ds,
cdcConfig.getMaxEventsPerPolling(),
cdcConfig.getMaxAttemptsForPolling(),
cdcConfig.getPollingRetryIntervalInMilliseconds());
}
开发者ID:networknt,项目名称:light-eventuate-4j,代码行数:10,代码来源:PollingCdcServiceInitializer.java
示例19: pollingEventTableChangesToAggregateTopicTranslator
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public EventTableChangesToAggregateTopicTranslator<PublishedEvent> pollingEventTableChangesToAggregateTopicTranslator() {
CdcKafkaPublisher<PublishedEvent> mySQLCdcKafkaPublisher = SingletonServiceFactory.getBean(CdcKafkaPublisher.class);
CdcProcessor<PublishedEvent> mySQLCdcProcessor = SingletonServiceFactory.getBean(CdcProcessor.class);
CuratorFramework curatorFramework = SingletonServiceFactory.getBean(CuratorFramework.class);
return new EventTableChangesToAggregateTopicTranslator<>(mySQLCdcKafkaPublisher,
mySQLCdcProcessor,
curatorFramework,
cdcConfig);
}
开发者ID:networknt,项目名称:light-eventuate-4j,代码行数:11,代码来源:PollingCdcServiceInitializer.java
示例20: mySqlBinaryLogClient
import com.networknt.service.SingletonServiceFactory; //导入依赖的package包/类
public MySqlBinaryLogClient<PublishedEvent> mySqlBinaryLogClient() throws IOException, TimeoutException {
IWriteRowsEventDataParser<PublishedEvent> eventDataParser = SingletonServiceFactory.getBean(IWriteRowsEventDataParser.class);
SourceTableNameSupplier sourceTableNameSupplier = SingletonServiceFactory.getBean(SourceTableNameSupplier.class);
return new MySqlBinaryLogClient<>(eventDataParser,
cdcConfig.getDbUser(),
cdcConfig.getDbPass(),
cdcConfig.getDbHost(),
cdcConfig.getDbPort(),
cdcConfig.getBinlogClientId(),
sourceTableNameSupplier.getSourceTableName(),
cdcConfig.getMySqlBinLogClientName());
}
开发者ID:networknt,项目名称:light-eventuate-4j,代码行数:13,代码来源:MySqlCdcServiceInitializer.java
注:本文中的com.networknt.service.SingletonServiceFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论