public static ComponentMessagesSource buildComponentMessagesSource(UpdateListenerHub updateListenerHub, @Autobuild ComponentMessagesSourceImpl service) { updateListenerHub.addUpdateListener(service); return service; }
public void run() { // On a race condition, multiple threads may hit this method briefly. If we've // already done a check, don't run it again. if (System.currentTimeMillis() - lastCheck >= checkInterval) { // Fire the update event which will force a number of checks and then // corresponding invalidation events. updateListenerHub.fireCheckForUpdates(); lastCheck = System.currentTimeMillis(); } } };
@PostInjection public void registerAsUpdateListener(UpdateListenerHub hub) { hub.addUpdateListener(this); }
/** * This allows tests the exists() method. */ @Test public void component_class_reload() throws Exception { // Ensure it doesn't already exist: assertFalse(source.exists(SYNTH_COMPONENT_CLASSNAME)); // Create the class on the fly. createSynthComponentClass("Original"); assertTrue(source.exists(SYNTH_COMPONENT_CLASSNAME)); getMocksControl().resetToNice(); Named named = (Named) createComponent(SYNTH_COMPONENT_CLASSNAME); assertEquals(named.getName(), "Original"); long dtm = helper.readDTM(SYNTH_COMPONENT_CLASSNAME); while (true) { createSynthComponentClass("Updated"); if (helper.readDTM(SYNTH_COMPONENT_CLASSNAME) != dtm) break; // Keep re-writing the file until we see the DTM change. } // Detect the change and clear out the internal caches UpdateListenerHub hub = registry.getService("UpdateListenerHub", UpdateListenerHub.class); hub.fireCheckForUpdates(); // This will be the new version of the class named = (Named) createComponent(SYNTH_COMPONENT_CLASSNAME); assertEquals(named.getName(), "Updated"); }
@PostInjection public void registerWithUpdateListenerHub(UpdateListenerHub hub) { hub.addUpdateListener(this); }
@PostInjection public void registerAsUpdateListener(UpdateListenerHub hub) { hub.addUpdateListener(this); }
private <T> T createReloadingProxy(Class<T> interfaceClass, final Class<? extends T> implementationClass, ObjectLocator locator) { ReloadableObjectCreator creator = new ReloadableObjectCreator(proxyFactory, implementationClass.getClassLoader(), implementationClass.getName(), loggerSource.getLogger(implementationClass), this, locator); getService(UpdateListenerHub.class).addUpdateListener(creator); return proxyFactory.createProxy(interfaceClass, implementationClass, (ObjectCreator<T>) creator, String.format("<Autoreload proxy %s(%s)>", implementationClass.getName(), interfaceClass.getName())); }
private <T> T createReloadingProxy(Class<T> interfaceClass, final Class<? extends T> implementationClass, ObjectLocator locator) { ReloadableObjectCreator creator = new ReloadableObjectCreator(proxyFactory, implementationClass.getClassLoader(), implementationClass.getName(), loggerSource.getLogger(implementationClass), this, locator); getService(UpdateListenerHub.class).addUpdateListener(creator); return proxyFactory.createProxy(interfaceClass, implementationClass, (ObjectCreator<T>) creator, String.format("<Autoreload proxy %s(%s)>", implementationClass.getName(), interfaceClass.getName())); }
@PostInjection public void listenForUpdates(UpdateListenerHub hub) { invalidationHub.addInvalidationCallback(this); hub.addUpdateListener(this); }
private Object createReloadableProxy(ServiceBuilderResources resources) { ReloadableServiceImplementationObjectCreator reloadableCreator = new ReloadableServiceImplementationObjectCreator(proxyFactory, resources, proxyFactory.getClassLoader(), serviceImplementationClass.getName()); resources.getService(UpdateListenerHub.class).addUpdateListener(reloadableCreator); if (eagerLoad) { reloadableCreator.createObject(); } return proxyFactory.createProxy(serviceInterfaceClass, resources.getServiceImplementation(), reloadableCreator, getDescription()); } }
private Object createReloadableProxy(ServiceBuilderResources resources) { ReloadableServiceImplementationObjectCreator reloadableCreator = new ReloadableServiceImplementationObjectCreator(proxyFactory, resources, proxyFactory.getClassLoader(), serviceImplementationClass.getName()); resources.getService(UpdateListenerHub.class).addUpdateListener(reloadableCreator); if (eagerLoad) { reloadableCreator.createObject(); } return proxyFactory.createProxy(serviceInterfaceClass, resources.getServiceImplementation(), reloadableCreator, getDescription()); } }