@Test public void testModelRetrievalFromBeanFactoryIsUsingOriginalBeanNameAndModelTypeAndInvokesCallback() { provideModel(); verifyModelBeanIsObtainedFromBeanFactory(); assertResourceModelFactoryProvidesModelReturnedFromCallback(); }
@Override public <T> T provideModel(@Nonnull ModelDefinition<T> modelDefinition, @Nonnull ContentToModelMappingCallback<T> callback) { if (!(modelDefinition instanceof SpringBasedModelDefinition)) { throw new IllegalArgumentException("Unable to provide the model " + modelDefinition + ": The model definition does not stem from spring. This factory should not have been asked to provide a model for it."); } SpringBasedModelDefinition springBasedModelDefinition = (SpringBasedModelDefinition) modelDefinition; T bean = factory.getBean(springBasedModelDefinition.getBeanName(), modelDefinition.getType()); return callback.map(bean); }
SpringResourceModelFactory implements ResourceModelFactory { @Override public <T> T provideModel(@Nonnull ModelDefinition<T> modelDefinition, @Nonnull ContentToModelMappingCallback<T> callback) { if (!(modelDefinition instanceof SpringBasedModelDefinition)) { throw new IllegalArgumentException("Unable to provide the model " + modelDefinition + ": The model definition does not stem from spring. This factory should not have been asked to provide a model for it."); } SpringBasedModelDefinition springBasedModelDefinition = (SpringBasedModelDefinition) modelDefinition; T bean = factory.getBean(springBasedModelDefinition.getBeanName(), modelDefinition.getType()); return callback.map(bean); } }
SpringResourceModelFactory implements ResourceModelFactory { @Override public <T> T provideModel(@Nonnull ModelDefinition<T> modelDefinition, @Nonnull ContentToModelMappingCallback<T> callback) { if (!(modelDefinition instanceof SpringBasedModelDefinition)) { throw new IllegalArgumentException("Unable to provide the model " + modelDefinition + ": The model definition does not stem from spring. This factory should not have been asked to provide a model for it."); } SpringBasedModelDefinition springBasedModelDefinition = (SpringBasedModelDefinition) modelDefinition; T bean = factory.getBean(springBasedModelDefinition.getBeanName(), modelDefinition.getType()); return callback.map(bean); } SpringResourceModelFactory(List<SpringBasedModelDefinition> modelDefinitions, ConfigurableListableBeanFactory factory); }
SpringResourceModelFactory implements ResourceModelFactory { @Override public <T> T provideModel(@Nonnull ModelDefinition<T> modelDefinition, @Nonnull ContentToModelMappingCallback<T> callback) { if (!(modelDefinition instanceof SpringBasedModelDefinition)) { throw new IllegalArgumentException("Unable to provide the model " + modelDefinition + ": The model definition does not stem from spring. This factory should not have been asked to provide a model for it."); } SpringBasedModelDefinition springBasedModelDefinition = (SpringBasedModelDefinition) modelDefinition; T bean = factory.getBean(springBasedModelDefinition.getBeanName(), modelDefinition.getType()); return callback.map(bean); } SpringResourceModelFactory(List<SpringBasedModelDefinition> modelDefinitions, ConfigurableListableBeanFactory factory); @Override @Nonnull Collection<ModelDefinition<?>> getModelDefinitions(); @Override T provideModel(@Nonnull ModelDefinition<T> modelDefinition, @Nonnull ContentToModelMappingCallback<T> callback); }
SpringResourceModelFactory implements ResourceModelFactory { @Override public <T> T provideModel(@Nonnull ModelDefinition<T> modelDefinition, @Nonnull ContentToModelMappingCallback<T> callback) { if (!(modelDefinition instanceof SpringBasedModelDefinition)) { throw new IllegalArgumentException("Unable to provide the model " + modelDefinition + ": The model definition does not stem from spring. This factory should not have been asked to provide a model for it."); } SpringBasedModelDefinition springBasedModelDefinition = (SpringBasedModelDefinition) modelDefinition; T bean = factory.getBean(springBasedModelDefinition.getBeanName(), modelDefinition.getType()); return callback.map(bean); } SpringResourceModelFactory(List<SpringBasedModelDefinition> modelDefinitions, ConfigurableListableBeanFactory factory); @Override @Nonnull Collection<ModelDefinition<?>> getModelDefinitions(); @Override T provideModel(@Nonnull ModelDefinition<T> modelDefinition, @Nonnull ContentToModelMappingCallback<T> callback);  }