How do I make RMI services available only after the application is UP and running?

In my Spring application, I use the config application-rmi-context.xml

for RMI and import it into spring-application-context.xml

.

This makes RMI available as soon as the server starts up and the Spring context is loaded, and my application is still in the process of being fully loaded and running, but RMI is already available.

But I only need to make RMI available when my application is fully up and running.

Any suggestions?

+3


source to share


2 answers


You can use it like this:

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        classpath:spring/application-context.xml 
        classpath:spring/rmi-context.xml
        </param-value>
    </context-param>

      



The same problem exists for me as well. I solved it like this. You can also use offsetServlet for this

+3


source


So using the dispatcher servlet

  <servlet>
          <servlet-name>rmi-services</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:spring/rmi-context.xml</param-value>
          </init-param>
          <load-on-startup>3</load-on-startup>
    </servlet>

      



load-on-startup means when you want to load it in sequence

+1


source







All Articles