Search in sources :

Example 21 with LifecycleEvent

use of org.jboss.msc.service.LifecycleEvent in project wildfly by wildfly.

the class WritableServiceBasedNamingStoreTestCase method setup.

@Before
public void setup() throws Exception {
    container = ServiceContainer.Factory.create();
    installOwnerService(OWNER_FOO);
    installOwnerService(OWNER_BAR);
    final CountDownLatch latch2 = new CountDownLatch(1);
    final NamingStoreService namingStoreService = new NamingStoreService();
    container.addService(ContextNames.JAVA_CONTEXT_SERVICE_NAME, namingStoreService).setInitialMode(ServiceController.Mode.ACTIVE).addListener(new LifecycleListener() {

        public void handleEvent(ServiceController<?> controller, LifecycleEvent event) {
            switch(event) {
                case UP:
                    {
                        latch2.countDown();
                        break;
                    }
                case FAILED:
                    {
                        latch2.countDown();
                        fail("Did not install store service - " + controller.getStartException().getMessage());
                        break;
                    }
                default:
                    break;
            }
        }
    }).install();
    latch2.await(10, TimeUnit.SECONDS);
    store = (WritableServiceBasedNamingStore) namingStoreService.getValue();
}
Also used : NamingStoreService(org.jboss.as.naming.service.NamingStoreService) LifecycleEvent(org.jboss.msc.service.LifecycleEvent) ServiceController(org.jboss.msc.service.ServiceController) LifecycleListener(org.jboss.msc.service.LifecycleListener) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Example 22 with LifecycleEvent

use of org.jboss.msc.service.LifecycleEvent in project wildfly by wildfly.

the class WritableServiceBasedNamingStoreTestCase method installOwnerService.

private void installOwnerService(ServiceName owner) throws InterruptedException {
    final CountDownLatch latch1 = new CountDownLatch(1);
    container.addService(JndiNamingDependencyProcessor.serviceName(owner), new RuntimeBindReleaseService()).setInitialMode(ServiceController.Mode.ACTIVE).addListener(new LifecycleListener() {

        public void handleEvent(ServiceController<?> controller, LifecycleEvent event) {
            switch(event) {
                case UP:
                    {
                        latch1.countDown();
                        break;
                    }
                case FAILED:
                    {
                        latch1.countDown();
                        fail("Did not install store service - " + controller.getStartException().getMessage());
                        break;
                    }
                default:
                    break;
            }
        }
    }).install();
    latch1.await(10, TimeUnit.SECONDS);
}
Also used : LifecycleEvent(org.jboss.msc.service.LifecycleEvent) ServiceController(org.jboss.msc.service.ServiceController) LifecycleListener(org.jboss.msc.service.LifecycleListener) CountDownLatch(java.util.concurrent.CountDownLatch) RuntimeBindReleaseService(org.jboss.as.naming.deployment.RuntimeBindReleaseService)

Aggregations

LifecycleEvent (org.jboss.msc.service.LifecycleEvent)22 LifecycleListener (org.jboss.msc.service.LifecycleListener)22 ServiceName (org.jboss.msc.service.ServiceName)11 CountDownLatch (java.util.concurrent.CountDownLatch)8 ContextNames (org.jboss.as.naming.deployment.ContextNames)8 ServiceController (org.jboss.msc.service.ServiceController)7 BinderService (org.jboss.as.naming.service.BinderService)6 ServiceBasedNamingStore (org.jboss.as.naming.ServiceBasedNamingStore)5 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)3 ExecutorService (java.util.concurrent.ExecutorService)2 DataSourceStatisticsService (org.jboss.as.connector.services.datasources.statistics.DataSourceStatisticsService)2 DataSourceReferenceFactoryService (org.jboss.as.connector.subsystems.datasources.DataSourceReferenceFactoryService)2 ContextListAndJndiViewManagedReferenceFactory (org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory)2 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 Module (org.jboss.modules.Module)2 ServiceContainer (org.jboss.msc.service.ServiceContainer)2 StartException (org.jboss.msc.service.StartException)2 CompletableFuture (java.util.concurrent.CompletableFuture)1