Java Code Examples for org.apache.commons.configuration2.io.FileHandler#addFileHandlerListener()
The following examples show how to use
org.apache.commons.configuration2.io.FileHandler#addFileHandlerListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoSaveListener.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Updates the {@code FileHandler}. This method is called by the builder * when a new configuration instance was created which is associated with a * new file handler. It updates the internal file handler reference and * performs necessary listener registrations. * * @param fh the new {@code FileHandler} (can be <b>null</b>) */ public synchronized void updateFileHandler(final FileHandler fh) { if (handler != null) { handler.removeFileHandlerListener(this); } if (fh != null) { fh.addFileHandlerListener(this); } handler = fh; }
Example 2
Source File: TestAutoSaveListener.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether the file handler can be updated and is correctly * initialized. */ @Test public void testUpdateFileHandler() { final FileHandler handler = EasyMock.createMock(FileHandler.class); final FileHandler handler2 = EasyMock.createMock(FileHandler.class); handler.addFileHandlerListener(listener); handler.removeFileHandlerListener(listener); handler2.addFileHandlerListener(listener); EasyMock.replay(handler, handler2); listener.updateFileHandler(handler); listener.updateFileHandler(handler2); EasyMock.verify(handler, handler2); }
Example 3
Source File: TestAutoSaveListener.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether updateFileHandler() can deal with null input. This is used * for removing the listener when it is no longer needed. */ @Test public void testUpdateFileHandlerNull() { final FileHandler handler = EasyMock.createMock(FileHandler.class); handler.addFileHandlerListener(listener); handler.removeFileHandlerListener(listener); EasyMock.replay(handler); listener.updateFileHandler(handler); listener.updateFileHandler(null); EasyMock.verify(handler); }