In my JIRA plug-in I have created a WebListener which add a websocket endpoint to the SeverContainer.
The problem is, when I make changes to my plugin and upload it in JIRA, the new code is not executed.
This is because the endpoint is not being deployed again. I get the following exception: Multiple Endpoints may not be deployed to the same path
My weblistener:
@WebListener
public class MyListener implements ServletContextListener {
private static final Logger LOG = LoggerFactory.getLogger(MyListener.class);
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
final ServerContainer serverContainer = (ServerContainer) servletContextEvent.getServletContext()
.getAttribute("javax.websocket.server.ServerContainer");
try {
serverContainer.addEndpoint(MyWebsocket.class); //Generates exception when the plug-in is updated
} catch (DeploymentException e) {
LOG.error("Error adding endpoint to the servercontainer: " + e.getMessage());
}
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
LOG.error("CONTEXT DESTROYED!");
}
}
My websocket:
@ServerEndpoint(value = "/websocket/{myPathParam}")
public class MyWebsocket {
private static final Logger LOG = LoggerFactory.getLogger(MyWebsocket.class);
@OnOpen
public void onOpen(Session session, @PathParam("myPathParam") String myPathParam) {
LOG.error("OnOpen");
}
@OnClose
public void onClose(Session session, @PathParam("myPathParam") String myPathParam) {
LOG.error("OnClose");
}
@OnMessage
public void onMessage(String message, Session session, @PathParam("myPathParam") String myPathParam) {
LOG.error("OnMessage: " + message);
}
}
Is there a way to remove the endpoint from the servercontainer, so it will be deployed again?