[ 
https://issues.apache.org/jira/browse/JUDDI-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15006722#comment-15006722
 ] 

Matthieu Ghilain edited comment on JUDDI-942 at 11/16/15 2:30 PM:
------------------------------------------------------------------

What I think is that it should not be necessary to declare it? The 
UDDIClerckServlet could be transformed to a UDDIClerckServletListener so that 
it is automatically instantiated in Servlet 3.0 env.

At the moment I don't have any web.xml and I am not planning to have one. I am 
therefore instantiating your servlet dynamically like this:

{code:title=UDDIServletContextListener.java|borderStyle=solid}
@WebListener
public class UDDIServletContextListener implements ServletContextListener {
    private static final Logger logger = 
LoggerFactory.getLogger(UDDIServletContextListener .class);
    private static final String JUDDI_SERVLET_NAME = "juddi-servlet";

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        logger.info("Registering JUDDI servlet '"+JUDDI_SERVLET_NAME+"' to 
automatically register service");
        ServletContext servletContext = servletContextEvent.getServletContext();
        ServletRegistration.Dynamic dynamic = 
servletContext.addServlet(JUDDI_SERVLET_NAME, UDDIClerkServlet.class);
        dynamic.setLoadOnStartup(1);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
    }

}
{code}

Instead you could replace the context initialized content by the content of the 
UDDIClerck init method and your auto registration would work directly out of 
the box! What do you think of this?



was (Author: ghila...@gmail.com):
What I think is that it should not be necessary to declare it? The 
UDDIClerckServlet could be transformed to a UDDIClerckServletListener so that 
it is automatically instantiated in Servlet 3.0 env.

At the moment I don't have any web.xml and I am not planning to have one. I am 
therefore instantiating your servlet dynamically like this:

{code:title=UDDIServletContextListener .java|borderStyle=solid}
@WebListener
public class UDDIServletContextListener implements ServletContextListener {
    private static final Logger logger = 
LoggerFactory.getLogger(UDDIServletContextListener .class);
    private static final String JUDDI_SERVLET_NAME = "juddi-servlet";

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        logger.info("Registering JUDDI servlet '"+JUDDI_SERVLET_NAME+"' to 
automatically register service");
        ServletContext servletContext = servletContextEvent.getServletContext();
        ServletRegistration.Dynamic dynamic = 
servletContext.addServlet(JUDDI_SERVLET_NAME, UDDIClerkServlet.class);
        dynamic.setLoadOnStartup(1);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
    }

}
{code}

Instead you could replace the context initialized content by the content of the 
UDDIClerck init method and your auto registration would work directly out of 
the box! What do you think of this?


> Automatic instantiation of UDDIClerkServlet
> -------------------------------------------
>
>                 Key: JUDDI-942
>                 URL: https://issues.apache.org/jira/browse/JUDDI-942
>             Project: jUDDI
>          Issue Type: Improvement
>          Components: juddi-client
>    Affects Versions: 3.3.1
>            Reporter: Matthieu Ghilain
>
> It would be useful to not have to instantiate manually the UDDIClerkServlet 
> when running in a Servlet 3.0 env. Would it be possible to add a class 
> implementing ServletContextListener which would instantiate automatically the 
> UDDIClerkServlet?
> Therefore the registration of services would be done automatically by adding 
> the JUDDI annotations on the web services classes.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to