Deploying Custom Singletons
Hello,
As part of our deploy process, we copy a JAR file into /cs/WEB-INF/lib to provide custom code to use in templates. However, it seems that Fatwire loads this jar multiple times and the JAR file gets passed through CGLIB at some point. This is causing some of our singleton beans to be instantiated 4 times.
For instance:
public class MySingletonPoller {
private static volatile Poller poller;
public synchronized static Poller getPoller(){
if(poller== null){
poller = new Poller();
System.out.print("Poller started...");
}
return poller;
}
}
What happens is that in this case we see "Poller started..." printed 4 times, and the polling task itself also started 4 times. What are we doing wrong here? Should we be deploying this code differently?