@Test public void testUsesServiceLoaderWhenItCan() { ClassLoader cl = new CheatingClassLoader(); SizeOfEngineLoader loader = new SizeOfEngineLoader(cl); assertThat(loader.createSizeOfEngine(10, true, true), sameInstance(constantSizeOfEngine)); }
@Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); }
SizeOfEngineLoader implements SizeOfEngineFactory { @Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); } }
SizeOfEngineLoader implements SizeOfEngineFactory { @Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); } SizeOfEngineLoader(ClassLoader classLoader); private  SizeOfEngineLoader(); }
SizeOfEngineLoader implements SizeOfEngineFactory { @Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); } SizeOfEngineLoader(ClassLoader classLoader); private  SizeOfEngineLoader(); static SizeOfEngine newSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent); @Override SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent); void reload(); synchronized boolean load(Class<? extends SizeOfEngineFactory> clazz, boolean reload); }
SizeOfEngineLoader implements SizeOfEngineFactory { @Override public SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent) { SizeOfEngineFactory currentFactory = this.factory; if (currentFactory != null) { return currentFactory.createSizeOfEngine(maxObjectCount, abort, silent); } return new DefaultSizeOfEngine(maxObjectCount, abort, silent); } SizeOfEngineLoader(ClassLoader classLoader); private  SizeOfEngineLoader(); static SizeOfEngine newSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent); @Override SizeOfEngine createSizeOfEngine(final int maxObjectCount, final boolean abort, final boolean silent); void reload(); synchronized boolean load(Class<? extends SizeOfEngineFactory> clazz, boolean reload); static final SizeOfEngineLoader INSTANCE; }