/** * Creates a new {@code ConfigurationBuilderEvent} based on the passed in * event, but with the source changed to this builder. This method is called * when an event was received from a managed builder. In this case, the * event has to be passed to the builder listeners registered at this * object, but with the correct source property. * * @param event the event received from a managed builder * @return the event to be propagated */ private ConfigurationBuilderEvent createEventWithChangedSource( final ConfigurationBuilderEvent event) { if (ConfigurationBuilderResultCreatedEvent.RESULT_CREATED.equals(event .getEventType())) { return new ConfigurationBuilderResultCreatedEvent(this, ConfigurationBuilderResultCreatedEvent.RESULT_CREATED, ((ConfigurationBuilderResultCreatedEvent) event) .getConfiguration()); } @SuppressWarnings("unchecked") final // This is safe due to the constructor of ConfigurationBuilderEvent EventType<? extends ConfigurationBuilderEvent> type = (EventType<? extends ConfigurationBuilderEvent>) event .getEventType(); return new ConfigurationBuilderEvent(this, type); }
/** * Clears an existing result object. An invocation of this method causes a * new {@code ImmutableConfiguration} object to be created the next time * {@link #getConfiguration()} is called. */ public void resetResult() { T oldResult; synchronized (this) { oldResult = result; result = null; resultDeclaration = null; } if (oldResult != null) { removeEventListeners(oldResult); } fireBuilderEvent(new ConfigurationBuilderEvent(this, ConfigurationBuilderEvent.RESET)); }
/** * Handles events received from managed configuration builders. This method * creates a new event with a source pointing to this builder and propagates * it to all registered listeners. * * @param event the event received from a managed builder */ private void handleManagedBuilderEvent(final ConfigurationBuilderEvent event) { if (ConfigurationBuilderEvent.RESET.equals(event.getEventType())) { resetResult(); } else { fireBuilderEvent(createEventWithChangedSource(event)); } }
public T getConfiguration() throws ConfigurationException fireBuilderEvent(new ConfigurationBuilderEvent(this, ConfigurationBuilderEvent.CONFIGURATION_REQUEST));