org.web3j.protocol.Web3jService Java Examples

The following examples show how to use org.web3j.protocol.Web3jService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSocketHealthCheckService.java    From eventeum with Apache License 2.0 6 votes vote down vote up
public WebSocketHealthCheckService(Web3jService web3jService,
                                   BlockchainService blockchainService,
                                   ReconnectionStrategy failureListener,
                                   SubscriptionService subscriptionService,
                                   EventeumValueMonitor valueMonitor,
                                   EventStoreService eventStoreService,
                                   Integer syncingThreshold,
                                   ScheduledThreadPoolExecutor taskScheduler,
                                   Long healthCheckPollInterval
) {
    super(blockchainService, failureListener, subscriptionService,
            valueMonitor, eventStoreService, syncingThreshold, taskScheduler, healthCheckPollInterval);

    if (web3jService instanceof EventeumWebSocketService) {
        this.webSocketClient = ((EventeumWebSocketService)web3jService).getWebSocketClient();
    } else {
        throw new BlockchainException(
                "Non web socket service passed to WebSocketHealthCheckService");
    }

}
 
Example #2
Source File: NodeBeanRegistrationStrategy.java    From eventeum with Apache License 2.0 6 votes vote down vote up
private String registerBlockchainServiceBean(Node node, Web3j web3j, BeanDefinitionRegistry registry) {
    final String blockSubStrategyBeanName = registerBlockSubscriptionStrategyBean(node, web3j, registry);

    final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
            net.consensys.eventeum.chain.service.Web3jService.class);

    builder.addConstructorArgValue(node.getName())
            .addConstructorArgValue(web3j)
            .addConstructorArgReference(String.format(CONTRACT_EVENT_DETAILS_FACTORY_BEAN_NAME, node.getName()))
            .addConstructorArgReference("defaultEventBlockManagementService")
            .addConstructorArgReference(blockSubStrategyBeanName);

    final String beanName = String.format(WEB3J_SERVICE_BEAN_NAME, node.getName());
    registry.registerBeanDefinition(beanName, builder.getBeanDefinition());

    return beanName;
}
 
Example #3
Source File: JsonRpc2_0Web3j.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
public JsonRpc2_0Web3j(
        Web3jService web3jService, long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    this.web3jService = web3jService;
    this.web3jRx = new JsonRpc2_0Rx(this, scheduledExecutorService);
    this.blockTime = pollingInterval;
    this.scheduledExecutorService = scheduledExecutorService;
}
 
Example #4
Source File: JsonRpc2_0Web3j.java    From web3j with Apache License 2.0 5 votes vote down vote up
public JsonRpc2_0Web3j(
        Web3jService web3jService,
        long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    this.web3jService = web3jService;
    this.web3jRx = new JsonRpc2_0Rx(this, scheduledExecutorService);
    this.blockTime = pollingInterval;
    this.scheduledExecutorService = scheduledExecutorService;
}
 
Example #5
Source File: Request.java    From web3j with Apache License 2.0 5 votes vote down vote up
public Request(String method, List<S> params, Web3jService web3jService, Class<T> type) {
    this.method = method;
    this.params = params;
    this.id = nextId.getAndIncrement();
    this.web3jService = web3jService;
    this.responseType = type;
}
 
Example #6
Source File: Request.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
public Request(String method, List<S> params,
               Web3jService web3jService, Class<T> type) {
    this.method = method;
    this.params = params;
    this.id = nextId.getAndIncrement();
    this.web3jService = web3jService;
    this.responseType = type;
}
 
Example #7
Source File: JsonRpc2_0Besu.java    From web3j with Apache License 2.0 5 votes vote down vote up
public JsonRpc2_0Besu(
        Web3jService web3jService,
        long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    super(web3jService, pollingInterval, scheduledExecutorService);
    this.besuRx = new JsonRpc2_0BesuRx(this, scheduledExecutorService);
    this.blockTime = pollingInterval;
}
 
Example #8
Source File: NodeBeanRegistrationStrategy.java    From eventeum with Apache License 2.0 5 votes vote down vote up
private String registerNodeFailureListener(Node node,
                                           String blockchainServiceBeanName,
                                           Web3jService web3jService,
                                           BeanDefinitionRegistry registry) {
    final BeanDefinition beanDefinition;

    if (isWebSocketUrl(node.getUrl())) {
        final EventeumWebSocketService webSocketService = (EventeumWebSocketService) web3jService;
        beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(WebSocketResubscribeNodeFailureListener.class)
                .getBeanDefinition();

        beanDefinition.getConstructorArgumentValues()
                .addIndexedArgumentValue(3, webSocketService.getWebSocketClient());

    } else {
        beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(HttpReconnectionStrategy.class)
                .getBeanDefinition();
    }

    beanDefinition.getConstructorArgumentValues()
            .addIndexedArgumentValue(1, new RuntimeBeanReference(blockchainServiceBeanName));


    final String beanName = String.format(NODE_FAILURE_LISTENER_BEAN_NAME, node.getName());
    registry.registerBeanDefinition(beanName, beanDefinition);

    return beanName;
}
 
Example #9
Source File: JsonRpc2_0Web3j.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public JsonRpc2_0Web3j(
        Web3jService web3jService, long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    this.web3jService = web3jService;
    this.web3jRx = new JsonRpc2_0Rx(this, scheduledExecutorService);
    this.blockTime = pollingInterval;
    this.scheduledExecutorService = scheduledExecutorService;
}
 
Example #10
Source File: Request.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public Request(String method, List<S> params,
               Web3jService web3jService, Class<T> type) {
    this.method = method;
    this.params = params;
    this.id = nextId.getAndIncrement();
    this.web3jService = web3jService;
    this.responseType = type;
}
 
Example #11
Source File: NodeBeanRegistrationStrategy.java    From eventeum with Apache License 2.0 5 votes vote down vote up
private String registerNodeHealthCheckBean(Node node,
                                           String blockchainServiceBeanName,
                                           Web3jService web3jService,
                                           String nodeFailureListenerBeanName,
                                           BeanDefinitionRegistry registry) {
    final BeanDefinitionBuilder builder;

    if (isWebSocketUrl(node.getUrl())) {
        builder = BeanDefinitionBuilder.genericBeanDefinition(WebSocketHealthCheckService.class)
                .addConstructorArgValue(web3jService);
    } else {
        builder = BeanDefinitionBuilder.genericBeanDefinition(NodeHealthCheckService.class);
    }

    builder.addConstructorArgReference(blockchainServiceBeanName);
    builder.addConstructorArgReference(nodeFailureListenerBeanName);
    builder.addConstructorArgReference("defaultSubscriptionService");
    builder.addConstructorArgReference("eventeumValueMonitor");
    builder.addConstructorArgReference("defaultEventStoreService");
    builder.addConstructorArgValue(node.getSyncingThreshold());
    builder.addConstructorArgReference("taskScheduler");
    builder.addConstructorArgValue(node.getHealthcheckInterval());

    final String beanName = String.format(NODE_HEALTH_CHECK_BEAN_NAME, node.getName());
    registry.registerBeanDefinition(beanName, builder.getBeanDefinition());

    return beanName;
}
 
Example #12
Source File: JsonRpc2_0Web3jTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testStopExecutorOnShutdown() {
    ScheduledExecutorService scheduledExecutorService = mock(ScheduledExecutorService.class);

    Web3j web3j = Web3j.build(
            mock(Web3jService.class), 10, scheduledExecutorService
    );

    web3j.shutdown();

    verify(scheduledExecutorService).shutdown();
}
 
Example #13
Source File: NodeBeanRegistrationStrategy.java    From eventeum with Apache License 2.0 5 votes vote down vote up
public void register(Node node, BeanDefinitionRegistry registry) {
    registerContractEventDetailsFactoryBean(node, registry);

    final Web3jService web3jService = buildWeb3jService(node);
    final Web3j web3j = buildWeb3j(node, web3jService);
    final String blockchainServiceBeanName = registerBlockchainServiceBean(node, web3j, registry);
    registerNodeServicesBean(node, web3j, blockchainServiceBeanName, registry);
    final String nodeFailureListenerBeanName =
            registerNodeFailureListener(node, blockchainServiceBeanName, web3jService, registry);
    registerNodeHealthCheckBean(node, blockchainServiceBeanName, web3jService, nodeFailureListenerBeanName, registry);


}
 
Example #14
Source File: JsonRpc2_0Besu.java    From web3j with Apache License 2.0 4 votes vote down vote up
public JsonRpc2_0Besu(final Web3jService web3jService) {
    this(web3jService, DEFAULT_BLOCK_TIME, Async.defaultExecutorService());
}
 
Example #15
Source File: JsonRpc2_0Admin.java    From web3j with Apache License 2.0 4 votes vote down vote up
public JsonRpc2_0Admin(
        Web3jService web3jService,
        long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    super(web3jService, pollingInterval, scheduledExecutorService);
}
 
Example #16
Source File: JsonRpc2_0Geth.java    From web3j with Apache License 2.0 4 votes vote down vote up
public JsonRpc2_0Geth(Web3jService web3jService) {
    super(web3jService);
}
 
Example #17
Source File: Geth.java    From web3j with Apache License 2.0 4 votes vote down vote up
static Geth build(Web3jService web3jService) {
    return new JsonRpc2_0Geth(web3jService);
}
 
Example #18
Source File: Admin.java    From web3j with Apache License 2.0 4 votes vote down vote up
static Admin build(Web3jService web3jService) {
    return new JsonRpc2_0Admin(web3jService);
}
 
Example #19
Source File: Admin.java    From web3j with Apache License 2.0 4 votes vote down vote up
static Admin build(
        Web3jService web3jService,
        long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    return new JsonRpc2_0Admin(web3jService, pollingInterval, scheduledExecutorService);
}
 
Example #20
Source File: JsonRpc2_0Parity.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public JsonRpc2_0Parity(Web3jService web3jService) {
    super(web3jService);
}
 
Example #21
Source File: JsonRpc2_0Quorum.java    From web3j-quorum with Apache License 2.0 4 votes vote down vote up
public JsonRpc2_0Quorum(
        Web3jService web3jService,
        long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    super(web3jService, pollingInterval, scheduledExecutorService);
}
 
Example #22
Source File: JsonRpc2_0Quorum.java    From web3j-quorum with Apache License 2.0 4 votes vote down vote up
public JsonRpc2_0Quorum(Web3jService web3jService) {
    super(web3jService);
}
 
Example #23
Source File: Quorum.java    From web3j-quorum with Apache License 2.0 4 votes vote down vote up
static Quorum build(Web3jService web3jService) {
    return new JsonRpc2_0Quorum(web3jService);
}
 
Example #24
Source File: BatchRequest.java    From web3j with Apache License 2.0 4 votes vote down vote up
public BatchRequest(Web3jService web3jService) {
    this.web3jService = web3jService;
}
 
Example #25
Source File: EnsResolverTest.java    From web3j with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    web3jService = mock(Web3jService.class);
    web3j = Web3j.build(web3jService);
    ensResolver = new EnsResolver(web3j);
}
 
Example #26
Source File: JsonRpc2_0RxTest.java    From web3j with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    web3jService = mock(Web3jService.class);
    web3j = Web3j.build(web3jService, 1000, Executors.newSingleThreadScheduledExecutor());
}
 
Example #27
Source File: FilterTester.java    From web3j with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    web3jService = mock(Web3jService.class);
    web3j = Web3j.build(web3jService, 1000, scheduledExecutorService);
}
 
Example #28
Source File: JsonRpc2_0Parity.java    From web3j with Apache License 2.0 4 votes vote down vote up
public JsonRpc2_0Parity(Web3jService web3jService) {
    super(web3jService);
}
 
Example #29
Source File: JsonRpc2_0Parity.java    From web3j with Apache License 2.0 4 votes vote down vote up
public JsonRpc2_0Parity(
        Web3jService web3jService,
        long pollingInterval,
        ScheduledExecutorService scheduledExecutorService) {
    super(web3jService, pollingInterval, scheduledExecutorService);
}
 
Example #30
Source File: Eea.java    From web3j with Apache License 2.0 4 votes vote down vote up
static Eea build(Web3jService web3jService) {
    return new JsonRpc2_0Eea(web3jService);
}