Search in sources :

Example 1 with StartContext

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

the class HttpRemoteNamingServerService method start.

@Override
public void start(StartContext startContext) throws StartException {
    final Context namingContext = new NamingContext(namingStore.getValue(), new Hashtable<String, Object>());
    HttpRemoteNamingService service = new HttpRemoteNamingService(namingContext);
    pathHandlerInjectedValue.getValue().addPrefixPath(NAMING, service.createHandler());
}
Also used : NamingContext(org.jboss.as.naming.NamingContext) StopContext(org.jboss.msc.service.StopContext) StartContext(org.jboss.msc.service.StartContext) Context(javax.naming.Context) NamingContext(org.jboss.as.naming.NamingContext) HttpRemoteNamingService(org.wildfly.httpclient.naming.HttpRemoteNamingService)

Example 2 with StartContext

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

the class WeldExecutorServices method start.

@Override
public void start(StartContext context) throws StartException {
    final ThreadGroup threadGroup = new ThreadGroup("Weld ThreadGroup");
    final ThreadFactory factory = new JBossThreadFactory(threadGroup, Boolean.FALSE, null, THREAD_NAME_PATTERN, null, null);
    // set TCCL to null for new threads to make sure no deployment classloader leaks through this executor's TCCL
    // Weld does not mind having null TCCL in this executor
    this.executor = Executors.newFixedThreadPool(bound, runnable -> {
        Thread thread = factory.newThread(runnable);
        if (WildFlySecurityManager.isChecking()) {
            AccessController.doPrivileged(new PrivilegedAction<Void>() {

                public Void run() {
                    thread.setContextClassLoader(null);
                    return null;
                }
            });
        } else {
            thread.setContextClassLoader(null);
        }
        return thread;
    });
}
Also used : JBossThreadFactory(org.jboss.threads.JBossThreadFactory) Service(org.jboss.msc.service.Service) StopContext(org.jboss.msc.service.StopContext) StartContext(org.jboss.msc.service.StartContext) PrivilegedAction(java.security.PrivilegedAction) AbstractExecutorServices(org.jboss.weld.executor.AbstractExecutorServices) Executors(java.util.concurrent.Executors) Services(org.jboss.as.server.Services) ExecutorServices(org.jboss.weld.manager.api.ExecutorServices) WildFlySecurityManager(org.wildfly.security.manager.WildFlySecurityManager) ServiceName(org.jboss.msc.service.ServiceName) AccessController(java.security.AccessController) ThreadFactory(java.util.concurrent.ThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) StartException(org.jboss.msc.service.StartException) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) JBossThreadFactory(org.jboss.threads.JBossThreadFactory) PrivilegedAction(java.security.PrivilegedAction)

Example 3 with StartContext

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

the class CacheDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) {
    DeploymentUnit unit = context.getDeploymentUnit();
    final ServiceName name = unit.getServiceName();
    EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final CapabilityServiceSupport support = unit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    final ServiceTarget target = context.getServiceTarget();
    @SuppressWarnings("rawtypes") Collection<ValueDependency<CacheFactoryBuilder>> cacheDependencies = moduleDescription.getComponentDescriptions().stream().filter(StatefulComponentDescription.class::isInstance).map(description -> new InjectedValueDependency<>(getCacheFactoryBuilderServiceName((StatefulComponentDescription) description), CacheFactoryBuilder.class)).distinct().collect(Collectors.toList());
    Service<Void> service = new AbstractService<Void>() {

        @Override
        public void start(StartContext context) {
            // Install dependencies for each distinct cache factory builder referenced by the deployment
            cacheDependencies.stream().map(Value::getValue).distinct().forEach(builder -> builder.installDeploymentUnitDependencies(support, target, name));
        }
    };
    ServiceBuilder<Void> builder = target.addService(name.append("cache-dependencies-installer"), service);
    cacheDependencies.forEach(dependency -> dependency.register(builder));
    builder.install();
    // Install versioned marshalling configuration
    InjectedValue<ModuleDeployment> deployment = new InjectedValue<>();
    Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    target.addService(MarshallingConfigurationRepositoryValue.getServiceName(name), new ValueService<>(new MarshallingConfigurationRepositoryValue(deployment, new ImmediateValue<>(module)))).addDependency(name.append(ModuleDeployment.SERVICE_NAME), ModuleDeployment.class, deployment).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) ServiceTarget(org.jboss.msc.service.ServiceTarget) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) AbstractService(org.jboss.msc.service.AbstractService) ValueDependency(org.wildfly.clustering.service.ValueDependency) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ValueService(org.jboss.msc.service.ValueService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) CacheFactoryBuilder(org.jboss.as.ejb3.cache.CacheFactoryBuilder) ImmediateValue(org.jboss.msc.value.ImmediateValue) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) StartContext(org.jboss.msc.service.StartContext) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) Value(org.jboss.msc.value.Value) ImmediateValue(org.jboss.msc.value.ImmediateValue) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) InjectedValue(org.jboss.msc.value.InjectedValue) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 4 with StartContext

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

the class JaxrsSpringProcessor method getResteasySpringVirtualFile.

/**
     * Lookup Seam integration resource loader.
     *
     * @return the Seam integration resource loader
     * @throws DeploymentUnitProcessingException
     *          for any error
     */
protected synchronized VirtualFile getResteasySpringVirtualFile() throws DeploymentUnitProcessingException {
    if (resourceRoot != null) {
        return resourceRoot;
    }
    try {
        Module module = Module.getBootModuleLoader().loadModule(MODULE);
        URL fileUrl = module.getClassLoader().getResource(JAR_LOCATION);
        if (fileUrl == null) {
            throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
        }
        File dir = new File(fileUrl.toURI());
        File file = null;
        for (String jar : dir.list()) {
            if (jar.endsWith(".jar")) {
                file = new File(dir, jar);
                break;
            }
        }
        if (file == null) {
            throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
        }
        VirtualFile vf = VFS.getChild(file.toURI());
        final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider());
        Service<Closeable> mountHandleService = new Service<Closeable>() {

            public void start(StartContext startContext) throws StartException {
            }

            public void stop(StopContext stopContext) {
                VFSUtils.safeClose(mountHandle);
            }

            public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
                return mountHandle;
            }
        };
        ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SERVICE_NAME), mountHandleService);
        builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
        resourceRoot = vf;
        return resourceRoot;
    } catch (Exception e) {
        throw new DeploymentUnitProcessingException(e);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) StopContext(org.jboss.msc.service.StopContext) Closeable(java.io.Closeable) Service(org.jboss.msc.service.Service) TempFileProviderService(org.jboss.as.server.deployment.module.TempFileProviderService) URL(java.net.URL) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) StartException(org.jboss.msc.service.StartException) StartContext(org.jboss.msc.service.StartContext) Module(org.jboss.modules.Module) VirtualFile(org.jboss.vfs.VirtualFile) File(java.io.File)

Example 5 with StartContext

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

the class RemoteNamingServerService method start.

public synchronized void start(StartContext context) throws StartException {
    try {
        final Context namingContext = new NamingContext(namingStore.getValue(), new Hashtable<String, Object>());
        remoteNamingService = new RemoteNamingService(namingContext);
        remoteNamingService.start(endpoint.getValue());
    } catch (Exception e) {
        throw new StartException("Failed to start remote naming service", e);
    }
}
Also used : StopContext(org.jboss.msc.service.StopContext) StartContext(org.jboss.msc.service.StartContext) NamingContext(org.jboss.as.naming.NamingContext) Context(javax.naming.Context) StartException(org.jboss.msc.service.StartException) NamingContext(org.jboss.as.naming.NamingContext) RemoteNamingService(org.wildfly.naming.client.remote.RemoteNamingService) IOException(java.io.IOException) StartException(org.jboss.msc.service.StartException)

Aggregations

StartContext (org.jboss.msc.service.StartContext)6 StopContext (org.jboss.msc.service.StopContext)5 Service (org.jboss.msc.service.Service)3 StartException (org.jboss.msc.service.StartException)3 Context (javax.naming.Context)2 NamingContext (org.jboss.as.naming.NamingContext)2 Module (org.jboss.modules.Module)2 ServiceName (org.jboss.msc.service.ServiceName)2 Closeable (java.io.Closeable)1 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 AccessController (java.security.AccessController)1 PrivilegedAction (java.security.PrivilegedAction)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1