Class ServerEnvironmentService

  • All Implemented Interfaces:
    org.jboss.msc.Service, org.jboss.msc.service.Service<ServerEnvironment>, org.jboss.msc.value.Value<ServerEnvironment>

    public class ServerEnvironmentService
    extends Object
    implements org.jboss.msc.service.Service<ServerEnvironment>
    Exposes the ServerEnvironment via a Service.

    Services that need access to the ServerEnvironment can use this service to have it injected. For example, suppose we have a service MyService that has a field injectedEnvironment into which it wants the ServerEnvironment injected. And suppose MyService exposes a utility method to facilitate installing it via a ServiceTarget. The ServerEnvironment injection could be done as follows:

     public static void addService(BatchBuilder batchBuilder) {
         MyService myService = new MyService();
         InjectedValue injectedEnvironment = myService.injectedEnvironment;
    
         batchBuilder.addService(MyService.SERVICE_NAME, myService)
                     .addSystemDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, injectedEnvironment);
     }
     
    Author:
    Brian Stansberry
    • Field Detail

      • SERVICE_NAME

        public static final org.jboss.msc.service.ServiceName SERVICE_NAME
        Standard ServiceName under which a ServerEnvironmentService would be registered
    • Method Detail

      • addService

        public static void addService​(ServerEnvironment serverEnvironment,
                                      org.jboss.msc.service.ServiceTarget target)
        Adds a ServerEnvironmentService based on the given serverEnvironment to the given batch under name SERVICE_NAME.
        Parameters:
        serverEnvironment - the ServerEnvironment. Cannot be null
        target - the batch builder. Cannot be null
      • start

        public void start​(org.jboss.msc.service.StartContext context)
                   throws org.jboss.msc.service.StartException
        Specified by:
        start in interface org.jboss.msc.Service
        Specified by:
        start in interface org.jboss.msc.service.Service<ServerEnvironment>
        Throws:
        org.jboss.msc.service.StartException
      • stop

        public void stop​(org.jboss.msc.service.StopContext context)
        Specified by:
        stop in interface org.jboss.msc.Service
        Specified by:
        stop in interface org.jboss.msc.service.Service<ServerEnvironment>