Finally (I hope) there are some serious issues with the Shindig servlets.

1) These shindig servlets can“t handle multiple init/destroy cycles withing their lifetime, but the service lifetime is continued after a destroy. Thus when for example the dispather bundle restarts these servlets break.

Below is an example (not concerned with concurrency-error checking) strategy to deal with this type of problem. By ensuring that within your service lifecycle you create new servlet instances for each init/destroy cycle.

public class ServiceLifecycleAwareServletFactory implements Servlet {

    private final Class<? extends Servlet> m_instanceClass;
    private volatile Servlet m_instance;

    public ServiceLifecycleAwareServletFactory(Class<? extends Servlet> instanceClass) {
        m_instanceClass = instanceClass;
    }

    public void init(ServletConfig config) throws ServletException {
        if (m_instance == null) {
            try {
                m_instance = (Servlet) m_instanceClass.newInstance();
                m_instance.init(config);
            }
            catch (Exception e) {
                throw new ServletException(e);
            }
        }
    }

    public void destroy() {
        m_instance.destroy();
    }

    public ServletConfig getServletConfig() {
        return m_instance.getServletConfig();
    }

    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        m_instance.service(req, res);
    }

    public String getServletInfo() {
        return m_instance.getServletInfo();
    }
}

2) These shindig servlets are registered as DM components but not everywhere care is taken that DM callbacks differ from servlet lifecycle. Typically the Servlet#destroy is something DM will call. So do something like...

Component servletComponent = m_dependencyManager.createComponent()
            .setImplementation(new ServiceLifecycleAwareServletFactory(MyServlet.class))
            .setInterface(Servlet.class.getName(), servletProperties)
            .setCallbacks("dminit" , "dmstart", "dmstop", "dmdestroy");
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
Amdatu-developers mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-developers

Reply via email to