[undertow-dev] Getting name of the default server, host and servlet container from the Undertow subsystem

Gytis Trikleris gytis at redhat.com
Wed May 22 06:53:55 EDT 2013


Hello,

I am using Undertow to register servlet in the WilfFly service I am 
working on. Everything works fine with default values. However, I need a 
way to get server, host, and servlet container names in case user will 
change them in standalone.xml. Could anybody recommend any solutions?

Here is the brief extract of my service code showing how do I register 
deployment:

        /...//
        //private
        InjectedValue<org.wildfly.extension.undertow.ServletContainerService>
        injectedServletContainerService = new InjectedValue<>();//
        //private InjectedValue<org.wildfly.extension.undertow.Host>
        injectedHost = new InjectedValue<>();//
        //...//
        //    private void deployCoordinatorServlet(final
        io.undertow.servlet.api.DeploymentInfo deploymentInfo) throws
        //ServletException//{//
        //        io.undertow.servlet.api.DeploymentManager manager =
        injectedServletContainerService.getValue().getServletContainer().addDeployment(deploymentInfo);//
        //
        //        manager.deploy();//
        //
        //injectedHost.getValue().registerDeployment(deploymentInfo,
        manager.start());//
        //    }//
        //.../

Service dependencies are registered during subsystem's boot time as follows:

        /...
        private final ServiceName hostServiceName =
        UndertowService.virtualHostName("default-server", "default-host");
        private final ServiceName servletContainerServiceName =
        UndertowService.SERVLET_CONTAINER.append("default");
        ...//
        //    @Override
             public void performBoottime(OperationContext context,
        ModelNode operation, ModelNode model,
                     ServiceVerificationHandler verificationHandler,
        List<ServiceController<?>> newControllers)
                     throws OperationFailedException {

                 final CoordinatorService coordinatorService = new
        CoordinatorService();

                 final ServiceBuilder<CoordinatorService> builder =
        context.getServiceTarget().addService(RTSSubsystemExtension.COORDINATOR,
        coordinatorService)
                         .addDependency(hostServiceName, Host.class,
        coordinatorService.getInjectedHost())
                         .addDependency(servletContainerServiceName,
        ServletContainerService.class,
        coordinatorService.getInjectedServletContainerService());
                 ...
             }//
        /

        /.../


Hope I have explained my problem clear enough.

Thanks,
Gytis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20130522/93b934f7/attachment.html 


More information about the undertow-dev mailing list