Search in sources :

Example 1 with Registration

use of org.wildfly.clustering.Registration in project wildfly by wildfly.

the class RemoteCacheContainerResource method register.

@Override
public Registration register(String cache) {
    ChildResourceProvider handler = this.apply(CHILD_TYPE);
    handler.getChildren().add(cache);
    return new Registration() {

        @Override
        public void close() {
            handler.getChildren().remove(cache);
        }
    };
}
Also used : ChildResourceProvider(org.jboss.as.clustering.controller.ChildResourceProvider) SimpleChildResourceProvider(org.jboss.as.clustering.controller.SimpleChildResourceProvider) Registration(org.wildfly.clustering.Registration)

Example 2 with Registration

use of org.wildfly.clustering.Registration in project wildfly by wildfly.

the class CacheContainerResource method register.

@Override
public Registration register(String cache) {
    ChildResourceProvider provider = this.apply(CHILD_TYPE);
    provider.getChildren().add(cache);
    return new Registration() {

        @Override
        public void close() {
            provider.getChildren().remove(cache);
        }
    };
}
Also used : ChildResourceProvider(org.jboss.as.clustering.controller.ChildResourceProvider) Registration(org.wildfly.clustering.Registration)

Example 3 with Registration

use of org.wildfly.clustering.Registration in project wildfly by wildfly.

the class ConcurrentBroadcastCommandDispatcherFactoryTestCase method registration.

@Test
public void registration() {
    BroadcastReceiver receiver1 = mock(BroadcastReceiver.class);
    BroadcastReceiver receiver2 = mock(BroadcastReceiver.class);
    BroadcastReceiverRegistrar registrar = new ConcurrentBroadcastCommandDispatcherFactory(this.factory);
    byte[] data1 = new byte[] { 1 };
    byte[] data2 = new byte[] { 2 };
    byte[] data3 = new byte[] { 3 };
    try (Registration registration1 = registrar.register(receiver1)) {
        try (Registration registration2 = registrar.register(receiver2)) {
            registrar.receive(data1);
            verify(receiver1).receive(data1);
            verify(receiver2).receive(data1);
        }
        registrar.receive(data2);
        verify(receiver1).receive(data2);
        verifyNoMoreInteractions(receiver2);
    }
    registrar.receive(data3);
    verifyNoMoreInteractions(receiver1);
    verifyNoMoreInteractions(receiver2);
}
Also used : Registration(org.wildfly.clustering.Registration) Test(org.junit.Test)

Example 4 with Registration

use of org.wildfly.clustering.Registration in project wildfly by wildfly.

the class CacheContainerServiceConfigurator method cacheStopped.

@CacheStopped
public CompletionStage<Void> cacheStopped(CacheStoppedEvent event) {
    String cacheName = event.getCacheName();
    ServiceValueCaptor<Cache<?, ?>> captor = this.registry.remove(this.createCacheServiceName(cacheName));
    if (captor != null) {
        captor.accept(null);
    }
    try (Registration registration = this.registrations.remove(cacheName)) {
        InfinispanLogger.ROOT_LOGGER.cacheStopped(cacheName, this.name);
    }
    return CompletableFutures.completedNull();
}
Also used : Registration(org.wildfly.clustering.Registration) Cache(org.infinispan.Cache) CacheStopped(org.infinispan.notifications.cachemanagerlistener.annotation.CacheStopped)

Example 5 with Registration

use of org.wildfly.clustering.Registration in project wildfly by wildfly.

the class SingletonPolicyResource method register.

@Override
public Registration register(ServiceName service) {
    boolean deployment = Services.JBOSS_DEPLOYMENT.isParentOf(service);
    ChildResourceProvider provider = this.apply(deployment ? DEPLOYMENT_CHILD_TYPE : SERVICE_CHILD_TYPE);
    String name = (deployment ? SingletonDeploymentResourceDefinition.pathElement(service) : SingletonServiceResourceDefinition.pathElement(service)).getValue();
    provider.getChildren().add(name);
    return new Registration() {

        @Override
        public void close() {
            provider.getChildren().remove(name);
        }
    };
}
Also used : ChildResourceProvider(org.jboss.as.clustering.controller.ChildResourceProvider) SimpleChildResourceProvider(org.jboss.as.clustering.controller.SimpleChildResourceProvider) Registration(org.wildfly.clustering.Registration)

Aggregations

Registration (org.wildfly.clustering.Registration)6 ChildResourceProvider (org.jboss.as.clustering.controller.ChildResourceProvider)3 SimpleChildResourceProvider (org.jboss.as.clustering.controller.SimpleChildResourceProvider)2 Test (org.junit.Test)2 UUID (java.util.UUID)1 Cache (org.infinispan.Cache)1 CacheStopped (org.infinispan.notifications.cachemanagerlistener.annotation.CacheStopped)1 ImmutableSession (org.wildfly.clustering.web.session.ImmutableSession)1 ImmutableSessionAttributes (org.wildfly.clustering.web.session.ImmutableSessionAttributes)1 ImmutableSessionMetaData (org.wildfly.clustering.web.session.ImmutableSessionMetaData)1 SessionExpirationListener (org.wildfly.clustering.web.session.SessionExpirationListener)1