Search in sources :

Example 1 with SubscriptionScanner

use of com.yahoo.elide.graphql.subscriptions.hooks.SubscriptionScanner in project elide by yahoo.

the class TestBinder method configure.

@Override
protected void configure() {
    EntityDictionary dictionary = EntityDictionary.builder().injector(injector::inject).build();
    dictionary.scanForSecurityChecks();
    bind(dictionary).to(EntityDictionary.class);
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(EMBEDDED_JMS_URL);
    bind(connectionFactory).to(ConnectionFactory.class);
    // Primary Elide instance for CRUD endpoints.
    bindFactory(new Factory<Elide>() {

        @Override
        public Elide provide() {
            HashMapDataStore inMemoryStore = new HashMapDataStore(Set.of(Book.class, Author.class, Publisher.class, ChatBot.class));
            Elide elide = buildElide(inMemoryStore, dictionary);
            elide.doScans();
            SubscriptionScanner subscriptionScanner = SubscriptionScanner.builder().connectionFactory(connectionFactory).dictionary(elide.getElideSettings().getDictionary()).scanner(elide.getScanner()).build();
            subscriptionScanner.bindLifecycleHooks();
            return elide;
        }

        @Override
        public void dispose(Elide elide) {
        }
    }).to(Elide.class).named("elide");
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) HashMapDataStore(com.yahoo.elide.core.datastore.inmemory.HashMapDataStore) SubscriptionScanner(com.yahoo.elide.graphql.subscriptions.hooks.SubscriptionScanner) Elide(com.yahoo.elide.Elide) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary)

Example 2 with SubscriptionScanner

use of com.yahoo.elide.graphql.subscriptions.hooks.SubscriptionScanner in project elide by yahoo.

the class ElideSubscriptionScanningConfiguration method onStartOrRefresh.

@EventListener(value = { ContextRefreshedEvent.class, RefreshScopeRefreshedEvent.class })
public void onStartOrRefresh(ApplicationEvent event) {
    Elide elide = refreshableElide.getElide();
    SubscriptionScanner scanner = SubscriptionScanner.builder().deliveryDelay(Message.DEFAULT_DELIVERY_DELAY).messagePriority(Message.DEFAULT_PRIORITY).timeToLive(Message.DEFAULT_TIME_TO_LIVE).deliveryMode(Message.DEFAULT_DELIVERY_MODE).scanner(elide.getScanner()).dictionary(elide.getElideSettings().getDictionary()).connectionFactory(connectionFactory).build();
    scanner.bindLifecycleHooks();
}
Also used : SubscriptionScanner(com.yahoo.elide.graphql.subscriptions.hooks.SubscriptionScanner) Elide(com.yahoo.elide.Elide) RefreshableElide(com.yahoo.elide.RefreshableElide) EventListener(org.springframework.context.event.EventListener)

Example 3 with SubscriptionScanner

use of com.yahoo.elide.graphql.subscriptions.hooks.SubscriptionScanner in project elide by yahoo.

the class ElideStandaloneSubscriptionSettings method subscriptionScanner.

/**
 * Returns the scanner that searches for subscription annotations and binds life cycle hooks for them.
 * @param elide The elide instance.
 * @param connectionFactory The JMS connection factory where subscription messages should be sent.
 * @return The scanner.
 */
default SubscriptionScanner subscriptionScanner(Elide elide, ConnectionFactory connectionFactory) {
    SubscriptionScanner scanner = SubscriptionScanner.builder().deliveryDelay(Message.DEFAULT_DELIVERY_DELAY).messagePriority(Message.DEFAULT_PRIORITY).timeToLive(Message.DEFAULT_TIME_TO_LIVE).deliveryMode(Message.DEFAULT_DELIVERY_MODE).scanner(elide.getScanner()).dictionary(elide.getElideSettings().getDictionary()).connectionFactory(connectionFactory).build();
    scanner.bindLifecycleHooks();
    return scanner;
}
Also used : SubscriptionScanner(com.yahoo.elide.graphql.subscriptions.hooks.SubscriptionScanner)

Aggregations

SubscriptionScanner (com.yahoo.elide.graphql.subscriptions.hooks.SubscriptionScanner)3 Elide (com.yahoo.elide.Elide)2 RefreshableElide (com.yahoo.elide.RefreshableElide)1 HashMapDataStore (com.yahoo.elide.core.datastore.inmemory.HashMapDataStore)1 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)1 ConnectionFactory (javax.jms.ConnectionFactory)1 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)1 EventListener (org.springframework.context.event.EventListener)1