Oracle WebCenter Sites (MOSC)

MOSC Banner

Deploying Custom Singletons

edited Apr 4, 2014 12:00PM in Oracle WebCenter Sites (MOSC) 5 commentsAnswered

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?

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center