use of com.tvd12.ezyfox.bean.EzyPropertiesMap in project ezyhttp by youngmonkeys.
the class ApplicationContextBuilder method createBeanContext.
protected EzyBeanContext createBeanContext() {
if (packageToScans.isEmpty()) {
throw new IllegalStateException("must scan at least one package");
}
Set<String> allPackageToScans = new HashSet<>();
allPackageToScans.add(DEFAULT_PACKAGE_TO_SCAN);
allPackageToScans.addAll(packageToScans);
EzyReflection reflection = EzyPackages.scanPackages(allPackageToScans);
addComponentClassesFromReflection(reflection);
allPackageToScans.addAll(packageToScans);
allPackageToScans.addAll(getPackagesToScanFromProviders(reflection));
reflection = EzyPackages.scanPackages(allPackageToScans);
Set controllerClasses = reflection.getAnnotatedClasses(Controller.class);
Set interceptorClases = reflection.getAnnotatedClasses(Interceptor.class);
Set exceptionHandlerClasses = reflection.getAnnotatedClasses(ExceptionHandler.class);
Set bodyConverterClasses = reflection.getAnnotatedClasses(BodyConvert.class);
Set stringConverterClasses = reflection.getAnnotatedClasses(StringConvert.class);
Set bootstrapClasses = reflection.getAnnotatedClasses(ApplicationBootstrap.class);
Map<String, Class> serviceClasses = getServiceClasses(reflection);
EzyPropertiesMap propertiesMap = getPropertiesMap(reflection);
EzyBeanContext beanContext = newBeanContextBuilder().scan(allPackageToScans).addSingletonClasses(componentClasses).addSingletonClasses(serviceClasses).addSingletonClasses(controllerClasses).addSingletonClasses(interceptorClases).addSingletonClasses(exceptionHandlerClasses).addSingletonClasses(bodyConverterClasses).addSingletonClasses(stringConverterClasses).addSingletonClasses(bootstrapClasses).propertiesMap(propertiesMap).addSingleton("systemObjectMapper", objectMapper).addSingleton("componentManager", componentManager).addSingleton("requestHandlerManager", requestHandlerManager).addSingleton("featureURIManager", requestHandlerManager.getFeatureURIManager()).addSingleton("requestURIManager", requestHandlerManager.getRequestURIManager()).addAllClasses(EzyPackages.scanPackage(DEFAULT_PACKAGE_TO_SCAN)).build();
setComponentProperties(beanContext);
registerComponents(beanContext);
addRequestHandlers(beanContext);
addResourceRequestHandlers(beanContext);
addExceptionHandlers();
return beanContext;
}
use of com.tvd12.ezyfox.bean.EzyPropertiesMap in project ezyhttp by youngmonkeys.
the class ApplicationContextBuilderTest method getPropertiesMapNull.
@Test
public void getPropertiesMapNull() {
// given
EzyReflection reflection = mock(EzyReflection.class);
when(reflection.getExtendsClass(EzyPropertiesMap.class)).thenReturn(null);
ApplicationContextBuilder sut = new ApplicationContextBuilder();
// when
EzyPropertiesMap actual = MethodInvoker.create().object(sut).method("getPropertiesMap").param(EzyReflection.class, reflection).invoke(EzyPropertiesMap.class);
// then
Asserts.assertNull(actual);
}
Aggregations