/** * Configure instance with configuration object provided by instance managed class. In order to perform instance * configuration, instance should implement {@link Configurable} and managed class should have configuration object, see * {@link ManagedClassSPI#getConfig()}. If both conditions are satisfied this method executes * {@link Configurable#config(Config)} on instance. * * @param managedClass managed class, * @param instance instance of given managed class. * @throws BugError if instance configuration fails either due to invalid configuration object or exception on configuration * user defined logic. */ @Override public void postProcessInstance(ManagedClassSPI managedClass, Object instance) { if (!(instance instanceof Configurable)) { return; } Config config = managedClass.getConfig(); if (config == null) { return; } try { ((Configurable) instance).config(config); } catch (ConfigException e) { throw new BugError("Invalid configuration for managed class |%s|:\r\n\t- %s", managedClass, e); } catch (Throwable t) { throw new BugError(t); } } }