@Override public void onEvent(ConfigurationBuilderEvent event) { if (builder.getReloadingController().checkForReloading(null)) { getLogger().debug("Reloading " + config); } } });
private Configuration getConfiguration() throws LookupFailureException { try { if (builder != null) { return builder.getConfiguration(); } } catch (final ConfigurationException e) { throw new LookupFailureException("Failed to get configuration due to " + e.getMessage(), e); } return null; }
@OnEnabled public void onEnabled(final ConfigurationContext context) throws InitializationException { final String config = context.getProperty(CONFIGURATION_FILE).evaluateAttributeExpressions().getValue(); final FileBasedBuilderParameters params = new Parameters().fileBased().setFile(new File(config)); this.builder = new ReloadingFileBasedConfigurationBuilder<>(resultClass).configure(params); builder.addEventListener(ConfigurationBuilderEvent.CONFIGURATION_REQUEST, new EventListener<ConfigurationBuilderEvent>() { @Override public void onEvent(ConfigurationBuilderEvent event) { if (builder.getReloadingController().checkForReloading(null)) { getLogger().debug("Reloading " + config); } } }); try { // Try getting configuration to see if there is any issue, for example wrong file format. // Then throw InitializationException to keep this service in 'Enabling' state. builder.getConfiguration(); } catch (ConfigurationException e) { throw new InitializationException(e); } }
/** * {@inheritDoc} This method is overridden to adapt the return type. */ @Override public CombinedConfigurationBuilder configure(final BuilderParameters... params) { super.configure(params); return this; }
@Override public void inheritFrom(final Map<String, ?> source) { super.inheritFrom(source); copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_OUTPUT); }
/** * {@inheritDoc} This implementation takes some more properties into account * that are defined in this class. */ @Override public void inheritFrom(final Map<String, ?> source) { super.inheritFrom(source); copyPropertiesFrom(source, PROP_INCLUDES_ALLOWED, PROP_IO_FACTORY); }
@Override public void inheritFrom(final Map<String, ?> source) { super.inheritFrom(source); copyPropertiesFrom(source, PROP_DOCUMENT_BUILDER, PROP_ENTITY_RESOLVER, PROP_SCHEMA_VALIDATION, PROP_VALIDATING); }
/** * Initializes a parameters object for an XML configuration with properties * already set for this parent builder. * * @param params the parameters object */ private void initChildXMLParameters(final XMLBuilderProperties<?> params) { params.setEntityResolver(currentXMLParameters.getEntityResolver()); }
/** * {@inheritDoc} This implementation copies some more properties defined by * this class. */ @Override public void inheritFrom(final Map<String, ?> source) { super.inheritFrom(source); copyPropertiesFrom(source, PROP_EXPRESSION_ENGINE); }
/** * Removes the listener for the auto save mechanism if it is currently * active. */ private void removeAutoSaveListener() { if (autoSaveListener != null) { removeEventListener(ConfigurationEvent.ANY, autoSaveListener); autoSaveListener.updateFileHandler(null); autoSaveListener = null; } }
@Override public XMLBuilderParametersImpl setEntityResolver(final EntityResolver resolver) { storeProperty(PROP_ENTITY_RESOLVER, resolver); return this; }
@Override public DatabaseBuilderParametersImpl setValueColumn(final String name) { storeProperty(PROP_VALUE_COLUMN, name); return this; }
/** * {@inheritDoc} This implementation stores the passed in {@code BeanHelper} * object in the internal parameters map, but uses a reserved key, so that * it is not used for the initialization of properties of the managed * configuration object. The {@code fetchBeanHelper()} method can be used to * obtain the {@code BeanHelper} instance from a parameters map. */ @Override public BasicBuilderParameters setBeanHelper(final BeanHelper beanHelper) { return setProperty(PROP_BEAN_HELPER, beanHelper); }
/** * Creates a new instance of {@code ReloadingFileBasedConfigurationBuilder} * which produces result objects of the specified class. * * @param resCls the result class (must not be <b>null</b> * @throws IllegalArgumentException if the result class is <b>null</b> */ public ReloadingFileBasedConfigurationBuilder(final Class<? extends T> resCls) { super(resCls); reloadingController = createReloadingController(); }
/** * Removes all initialization parameters of this builder. This method can be * called if this builder is to be reused for creating result objects with a * different configuration. */ public void resetParameters() { setParameters(null); }
/** * {@inheritDoc} This implementation stores the expression engine in the * internal parameters map. */ @Override public HierarchicalBuilderParametersImpl setExpressionEngine( final ExpressionEngine engine) { storeProperty(PROP_EXPRESSION_ENGINE, engine); return this; } }
@Override public PropertiesBuilderParametersImpl setIOFactory(final IOFactory factory) { storeProperty(PROP_IO_FACTORY, factory); return this; } }
/** * {@inheritDoc} This method is overridden here to change the result type. */ @Override public FileBasedConfigurationBuilder<T> configure( final BuilderParameters... params) { super.configure(params); return this; }
@Override public XMLBuilderParametersImpl setDocumentBuilder( final DocumentBuilder docBuilder) { storeProperty(PROP_DOCUMENT_BUILDER, docBuilder); return this; }
@Override public XMLBuilderParametersImpl setPublicID(final String pubID) { storeProperty(PROP_PUBLIC_ID, pubID); return this; }