/** * @see AbstractApplicationContextFactory#createApplicationContext(ConfigurableApplicationContext, Object...) */ @Override protected ConfigurableApplicationContext createApplicationContext(ConfigurableApplicationContext parent, Object... resources) { ConfigurableApplicationContext context; if (allObjectsOfType(resources, Resource.class)) { context = new ResourceXmlApplicationContext(parent, resources); } else if (allObjectsOfType(resources, Class.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else if (allObjectsOfType(resources, String.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else { List<Class<?>> types = new ArrayList<>(); for (Object resource : resources) { types.add(resource.getClass()); } throw new IllegalArgumentException("No application context could be created for resource types: " + Arrays.toString(types.toArray())); } return context; }
public ResourceAnnotationApplicationContext(ConfigurableApplicationContext parent, Object... resources) { helper = new ApplicationContextHelper(parent, this, resources) { @Override protected String generateId(Object... configs) { if (allObjectsOfType(configs, Class.class)) { Class<?>[] types = Arrays.copyOfRange(configs, 0, configs.length, Class[].class); List<String> names = new ArrayList<String>(); for (Class<?> type : types) { names.add(type.getName()); } return StringUtils.collectionToCommaDelimitedString(names); } else { return Arrays.toString(configs); } } @Override protected void loadConfiguration(Object... configs) { if (allObjectsOfType(configs, Class.class)) { Class<?>[] types = Arrays.copyOfRange(configs, 0, configs.length, Class[].class); register(types); } else { String[] pkgs = Arrays.copyOfRange(configs, 0, configs.length, String[].class); scan(pkgs); } } }; refresh(); }
/** * @see AbstractApplicationContextFactory#createApplicationContext(ConfigurableApplicationContext, Object...) */ @Override protected ConfigurableApplicationContext createApplicationContext(ConfigurableApplicationContext parent, Object... resources) { ConfigurableApplicationContext context; if (allObjectsOfType(resources, Resource.class)) { context = new ResourceXmlApplicationContext(parent, resources); } else if (allObjectsOfType(resources, Class.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else if (allObjectsOfType(resources, String.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else { List<Class<?>> types = new ArrayList<Class<?>>(); for (Object resource : resources) { types.add(resource.getClass()); } throw new IllegalArgumentException("No application context could be created for resource types: " + Arrays.toString(types.toArray())); } return context; }
/** * @see AbstractApplicationContextFactory#createApplicationContext(ConfigurableApplicationContext, Object...) */ @Override protected ConfigurableApplicationContext createApplicationContext(ConfigurableApplicationContext parent, Object... resources) { ConfigurableApplicationContext context; if (allObjectsOfType(resources, Resource.class)) { context = new ResourceXmlApplicationContext(parent, resources); } else if (allObjectsOfType(resources, Class.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else if (allObjectsOfType(resources, String.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else { List<Class<?>> types = new ArrayList<Class<?>>(); for (Object resource : resources) { types.add(resource.getClass()); } throw new IllegalArgumentException("No application context could be created for resource types: " + Arrays.toString(types.toArray())); } return context; }
/** * @see AbstractApplicationContextFactory#createApplicationContext(ConfigurableApplicationContext, Object...) */ @Override protected ConfigurableApplicationContext createApplicationContext(ConfigurableApplicationContext parent, Object... resources) { ConfigurableApplicationContext context; if (allObjectsOfType(resources, Resource.class)) { context = new ResourceXmlApplicationContext(parent, resources); } else if (allObjectsOfType(resources, Class.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else if (allObjectsOfType(resources, String.class)) { context = new ResourceAnnotationApplicationContext(parent, resources); } else { List<Class<?>> types = new ArrayList<Class<?>>(); for (Object resource : resources) { types.add(resource.getClass()); } throw new IllegalArgumentException("No application context could be created for resource types: " + Arrays.toString(types.toArray())); } return context; }
@Override public String toString() { return "ResourceAnnotationApplicationContext:" + getId(); }
@Override public String toString() { return "ResourceAnnotationApplicationContext:" + getId(); }
@Override public String toString() { return "ResourceAnnotationApplicationContext:" + getId(); }
@Override protected void loadConfiguration(Object... configs) { if (allObjectsOfType(configs, Class.class)) { Class<?>[] types = Arrays.copyOfRange(configs, 0, configs.length, Class[].class); register(types); } else { String[] pkgs = Arrays.copyOfRange(configs, 0, configs.length, String[].class); scan(pkgs); } } };
@Override public String toString() { return "ResourceAnnotationApplicationContext:" + getId(); }