List of usage examples for java.lang Class getModifiers
@HotSpotIntrinsicCandidate public native int getModifiers();
From source file:org.interreg.docexplore.GeneralConfigPanel.java
String browseClasses(File file) { try {//from ww w .java2s .co m List<Class<?>> metaDataPlugins = new LinkedList<Class<?>>(); List<Class<?>> analysisPlugins = new LinkedList<Class<?>>(); List<Class<?>> clientPlugins = new LinkedList<Class<?>>(); List<Class<?>> serverPlugins = new LinkedList<Class<?>>(); List<Class<?>> inputPlugins = new LinkedList<Class<?>>(); List<URL> urls = Startup.extractDependencies(file.getName().substring(0, file.getName().length() - 4), file.getName()); urls.add(file.toURI().toURL()); URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[] {}), this.getClass().getClassLoader()); JarFile jarFile = new JarFile(file); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (!entry.getName().endsWith(".class") || entry.getName().indexOf('$') > 0) continue; String className = entry.getName().substring(0, entry.getName().length() - 6).replace('/', '.'); Class<?> clazz = null; try { clazz = loader.loadClass(className); System.out.println("Reading " + className); } catch (NoClassDefFoundError e) { System.out.println("Couldn't read " + className); } if (clazz == null) continue; if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) continue; if (MetaDataPlugin.class.isAssignableFrom(clazz)) metaDataPlugins.add(clazz); if (AnalysisPlugin.class.isAssignableFrom(clazz)) analysisPlugins.add(clazz); if (ClientPlugin.class.isAssignableFrom(clazz)) clientPlugins.add(clazz); if (ServerPlugin.class.isAssignableFrom(clazz)) serverPlugins.add(clazz); if (InputPlugin.class.isAssignableFrom(clazz)) inputPlugins.add(clazz); } jarFile.close(); @SuppressWarnings("unchecked") Pair<String, String>[] classes = new Pair[metaDataPlugins.size() + analysisPlugins.size() + clientPlugins.size() + serverPlugins.size() + inputPlugins.size()]; if (classes.length == 0) throw new Exception("Invalid plugin (no entry points were found)."); int cnt = 0; for (Class<?> clazz : metaDataPlugins) classes[cnt++] = new Pair<String, String>(clazz.getName(), "MetaData plugin") { public String toString() { return first + " (" + second + ")"; } }; for (Class<?> clazz : analysisPlugins) classes[cnt++] = new Pair<String, String>(clazz.getName(), "Analysis plugin") { public String toString() { return first + " (" + second + ")"; } }; for (Class<?> clazz : clientPlugins) classes[cnt++] = new Pair<String, String>(clazz.getName(), "Reader client plugin") { public String toString() { return first + " (" + second + ")"; } }; for (Class<?> clazz : serverPlugins) classes[cnt++] = new Pair<String, String>(clazz.getName(), "Reader server plugin") { public String toString() { return first + " (" + second + ")"; } }; for (Class<?> clazz : inputPlugins) classes[cnt++] = new Pair<String, String>(clazz.getName(), "Reader input plugin") { public String toString() { return first + " (" + second + ")"; } }; @SuppressWarnings("unchecked") Pair<String, String> res = (Pair<String, String>) JOptionPane.showInputDialog(this, "Please select an entry point for the plugin:", "Plugin entry point", JOptionPane.QUESTION_MESSAGE, null, classes, classes[0]); if (res != null) return res.first; } catch (Throwable e) { ErrorHandler.defaultHandler.submit(e); } return null; }
From source file:com.evolveum.midpoint.prism.PrismContainer.java
public PrismContainer(QName name, Class<C> compileTimeClass) { super(name);//from w w w .j av a 2s . c om if (Modifier.isAbstract(compileTimeClass.getModifiers())) { throw new IllegalArgumentException("Can't use class '" + compileTimeClass.getSimpleName() + "' as compile-time class for " + name + "; the class is abstract."); } this.compileTimeClass = compileTimeClass; }
From source file:javadz.beanutils.MethodUtils.java
/** * <p>Return an accessible method (that is, one that can be invoked via * reflection) that implements the specified Method. If no such method * can be found, return <code>null</code>.</p> * * @param clazz The class of the object/*from w w w . j a v a 2 s . c om*/ * @param method The method that we wish to call * @return The accessible method * @since 1.8.0 */ public static Method getAccessibleMethod(Class clazz, Method method) { // Make sure we have a method to check if (method == null) { return (null); } // If the requested method is not public we cannot call it if (!Modifier.isPublic(method.getModifiers())) { return (null); } boolean sameClass = true; if (clazz == null) { clazz = method.getDeclaringClass(); } else { sameClass = clazz.equals(method.getDeclaringClass()); if (!method.getDeclaringClass().isAssignableFrom(clazz)) { throw new IllegalArgumentException( clazz.getName() + " is not assignable from " + method.getDeclaringClass().getName()); } } // If the class is public, we are done if (Modifier.isPublic(clazz.getModifiers())) { if (!sameClass && !Modifier.isPublic(method.getDeclaringClass().getModifiers())) { setMethodAccessible(method); // Default access superclass workaround } return (method); } String methodName = method.getName(); Class[] parameterTypes = method.getParameterTypes(); // Check the implemented interfaces and subinterfaces method = getAccessibleMethodFromInterfaceNest(clazz, methodName, parameterTypes); // Check the superclass chain if (method == null) { method = getAccessibleMethodFromSuperclass(clazz, methodName, parameterTypes); } return (method); }
From source file:ca.uhn.fhir.context.FhirContext.java
/** * Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed * for extending the core library./* www . j ava2s .c o m*/ */ public RuntimeResourceDefinition getResourceDefinition(Class<? extends IBaseResource> theResourceType) { validateInitialized(); if (theResourceType == null) { throw new NullPointerException("theResourceType can not be null"); } if (Modifier.isAbstract(theResourceType.getModifiers())) { throw new IllegalArgumentException( "Can not scan abstract or interface class (resource definitions must be concrete classes): " + theResourceType.getName()); } RuntimeResourceDefinition retVal = (RuntimeResourceDefinition) myClassToElementDefinition .get(theResourceType); if (retVal == null) { retVal = scanResourceType(theResourceType); } return retVal; }
From source file:org.solmix.datax.support.InvokerObject.java
@SuppressWarnings({ "unchecked", "rawtypes" }) protected Object adaptValue(Class<?> targetType, Object argument, GenericParameterNode node, Class<?> javaClass, Class<?> javaCollectionClass, Class<?> javaKeyClass) { if (isCollection(targetType)) { try {// w w w . j a v a2 s . c o m Object newArgValue; if (javaCollectionClass != void.class) { newArgValue = javaCollectionClass.newInstance(); } else if (targetType.isInterface() || Modifier.isAbstract(targetType.getModifiers())) { if (Map.class.isAssignableFrom(targetType)) { newArgValue = new LinkedMap(); } else if (List.class.isAssignableFrom(targetType)) { newArgValue = new ArrayList<Object>(); } else if (Set.class.isAssignableFrom(targetType)) { newArgValue = new HashSet<Object>(); } else if (Queue.class.isAssignableFrom(targetType)) { newArgValue = new LinkedList<Object>(); } else if (Collection.class.isAssignableFrom(targetType)) { newArgValue = new ArrayList<Object>(); } else newArgValue = argument.getClass().newInstance(); } else { newArgValue = targetType.newInstance(); } Iterator<Object> i = null; Object key = null; Class<?> keyClass = Object.class; Class<?> valueClass = null; Class<?> argType = argument.getClass(); if (Collection.class.isAssignableFrom(targetType)) { if (argument instanceof Map) { Map map = (Map) argument; if (map.size() == 1) { Iterator mapi = map.entrySet().iterator(); java.util.Map.Entry mape = (java.util.Map.Entry) mapi.next(); if (mape.getValue() instanceof Collection) { argument = mape.getValue(); argType = argument.getClass(); } else if (mape.getValue() instanceof Map) { argument = new ArrayList(); ((List) argument).add(mape.getValue()); argType = argument.getClass(); } } } i = ((Collection) argument).iterator(); if (node != null) valueClass = node.getClassByIndex(0); } else if (Collection.class.isAssignableFrom(argType) && Map.class.isAssignableFrom(targetType)) { if (((Collection) argument).size() == 1) { argument = ((Collection) argument).iterator().next(); argType = argument.getClass(); i = ((Map) argument).keySet().iterator(); } } else { i = ((Map) argument).keySet().iterator(); if (node != null) { keyClass = node.getClassByIndex(0); valueClass = node.getClassByIndex(1); } } if (javaClass != null) valueClass = javaClass; if (javaKeyClass != null) keyClass = javaKeyClass; boolean resetValueClass = false; if (valueClass == null) resetValueClass = true; while (i.hasNext()) { Object value = null; if (resetValueClass) valueClass = null; if (Collection.class.isAssignableFrom(targetType)) { value = i.next(); } else { key = i.next(); value = ((Map) argument).get(key); } if (valueClass == null && value != null) valueClass = value.getClass(); Object newValue = null; if (value != null) { newValue = adaptValue(valueClass, value, node != null ? node.getChildNode() : null, javaClass, javaCollectionClass, javaKeyClass); } Object newKey = key; if (keyClass != Object.class) { newKey = adaptValue(keyClass, value, node != null ? node.getChildNode() : null, null, null, null); } if (Collection.class.isAssignableFrom(targetType)) ((Collection) newArgValue).add(newValue); else ((Map) argument).put(newKey, newValue); } return newArgValue; } catch (Exception e) { throw new InvokerException("transform argumnt type:" + targetType.getName() + " to value:" + argument.getClass().getName(), e); } } else { if (targetType.isAssignableFrom(argument.getClass())) { return targetType.cast(argument); } else { try { return TransformUtils.transformType(targetType, argument); } catch (Exception e) { throw new InvokerException("transform argument value", e); } } } }
From source file:org.statefulj.framework.core.StatefulFactory.java
/** * @return/* w ww . j a v a2 s .c om*/ * @throws InstantiationException * @throws IllegalAccessException */ private void loadEndpointBinders(Reflections reflections, Map<String, EndpointBinder> binders) throws InstantiationException, IllegalAccessException { Set<Class<? extends EndpointBinder>> endpointBinders = reflections.getSubTypesOf(EndpointBinder.class); for (Class<?> binderClass : endpointBinders) { if (!Modifier.isAbstract(binderClass.getModifiers())) { EndpointBinder binder = (EndpointBinder) binderClass.newInstance(); binders.put(binder.getKey(), binder); } } }
From source file:org.codehaus.groovy.grails.commons.AbstractGrailsClass.java
/** * Used by all child classes to create a new instance and get the name right. * * @param clazz the Grails class/*ww w . ja va 2 s . c o m*/ * @param trailingName the trailing part of the name for this class type */ public AbstractGrailsClass(Class<?> clazz, String trailingName) { Assert.notNull(clazz, "Clazz parameter should not be null"); this.clazz = clazz; fullName = clazz.getName(); packageName = ClassUtils.getPackageName(clazz); naturalName = GrailsNameUtils.getNaturalName(clazz.getName()); shortName = ClassUtils.getShortClassName(clazz); name = GrailsNameUtils.getLogicalName(clazz, trailingName); propertyName = GrailsNameUtils.getPropertyNameRepresentation(shortName); if (StringUtils.isBlank(name)) { logicalPropertyName = propertyName; } else { logicalPropertyName = GrailsNameUtils.getPropertyNameRepresentation(name); } classPropertyFetcher = ClassPropertyFetcher.forClass(clazz); isAbstract = Modifier.isAbstract(clazz.getModifiers()); }
From source file:org.statefulj.framework.core.StatefulFactory.java
/** * @param reflections// w w w . j av a 2 s .c om * @throws InstantiationException * @throws IllegalAccessException */ private void loadPersistenceSupportBeanFactories(Reflections reflections, Map<Class<?>, PersistenceSupportBeanFactory> persistenceFactories) throws InstantiationException, IllegalAccessException { Set<Class<? extends PersistenceSupportBeanFactory>> persistenceFactoryTypes = reflections .getSubTypesOf(PersistenceSupportBeanFactory.class); for (Class<?> persistenceFactoryType : persistenceFactoryTypes) { if (!Modifier.isAbstract(persistenceFactoryType.getModifiers())) { PersistenceSupportBeanFactory factory = (PersistenceSupportBeanFactory) persistenceFactoryType .newInstance(); Class<?> key = factory.getKey(); if (key != null) { persistenceFactories.put(key, factory); } } } }
From source file:com.bstek.dorado.idesupport.initializer.CommonRuleTemplateInitializer.java
public void initRuleTemplate(RuleTemplate ruleTemplate, InitializerContext initializerContext) throws Exception { TypeInfo typeInfo = TypeInfo.parse(ruleTemplate.getType()); if (typeInfo == null) { return;// w w w .ja v a2 s. com } Class<?> type = typeInfo.getType(); RuleTemplateManager ruleTemplateManager = initializerContext.getRuleTemplateManager(); ruleTemplate.setAbstract(Modifier.isAbstract(type.getModifiers())); // ??SuperType?ParentTemplate Class<?> superType = type.getSuperclass(); List<Class<?>> superTypes = new ArrayList<Class<?>>(); while (superType != null && !superType.equals(Object.class) && !superType.equals(ClientEventSupportedObject.class)) { RuleTemplate parentRuleTemplate = ruleTemplateManager.getRuleTemplate(superType); if (parentRuleTemplate != null) { if (superTypes.isEmpty()) { ruleTemplate.setParents(new RuleTemplate[] { parentRuleTemplate }); } break; } superTypes.add(superType); superType = superType.getSuperclass(); } // ?AbstractParentTemplate RuleTemplate parentRuleTemplate = null; if (!superTypes.isEmpty()) { for (int i = superTypes.size() - 1; i >= 0; i--) { superType = superTypes.get(i); RuleTemplate newRuleTemplate = createRuleTemplate(ruleTemplateManager, superType, parentRuleTemplate); parentRuleTemplate = newRuleTemplate; } if (parentRuleTemplate != null && ruleTemplate.getParents() == null) { ruleTemplate.setParents(new RuleTemplate[] { parentRuleTemplate }); } } XmlNodeInfo xmlNodeInfo = getXmlNodeInfo(type); String scope = xmlNodeInfo.getScope(); if (StringUtils.isEmpty(scope) && Component.class.isAssignableFrom(type)) { Widget widget = type.getAnnotation(Widget.class); boolean isDeclaredAnnotation = (widget != null && ArrayUtils.indexOf(type.getDeclaredAnnotations(), widget) >= 0); if (widget != null && !ruleTemplate.isAbstract()) { if (StringUtils.isNotEmpty(widget.name()) && !widget.name().equals(ruleTemplate.getName()) && (isDeclaredAnnotation || !AssembledComponent.class.isAssignableFrom(type))) { ruleTemplate.setLabel(widget.name()); } } if (!(widget != null && isDeclaredAnnotation && !Modifier.isAbstract(type.getModifiers()))) { scope = "protected"; } } if (StringUtils.isNotEmpty(scope) && StringUtils.isEmpty(ruleTemplate.getScope())) { ruleTemplate.setScope(scope); } String nodeName = xmlNodeInfo.getNodeName(); if (StringUtils.isNotEmpty(nodeName)) { ruleTemplate.setNodeName(nodeName); } if (StringUtils.isEmpty(ruleTemplate.getLabel())) { String label = xmlNodeInfo.getLabel(); if (StringUtils.isNotEmpty(label)) { ruleTemplate.setLabel(label); } else if (!ruleTemplate.isAbstract()) { ruleTemplate.setLabel(type.getSimpleName()); } } if (StringUtils.isNotEmpty(xmlNodeInfo.getIcon())) { ruleTemplate.setIcon(xmlNodeInfo.getIcon()); } int clientTypes = ClientType.parseClientTypes(xmlNodeInfo.getClientTypes()); if (clientTypes > 0) { ruleTemplate.setClientTypes(clientTypes); } else if (Control.class.isAssignableFrom(type) && "public".equals(ruleTemplate.getScope())) { ruleTemplate.setClientTypes(ClientType.DESKTOP); } if (!ruleTemplate.isDeprecated() && xmlNodeInfo.isDeprecated()) { ruleTemplate.setDeprecated(true); } IdeObject ideObject = type.getAnnotation(IdeObject.class); if (ideObject != null && ArrayUtils.indexOf(type.getDeclaredAnnotations(), ideObject) >= 0) { if (StringUtils.isNotEmpty(ideObject.labelProperty())) { ruleTemplate.setLabelProperty(ideObject.labelProperty()); } ruleTemplate.setVisible(ideObject.visible()); } // search icon if (ruleTemplate.getIcon() == null) { String basePath = '/' + StringUtils.replaceChars(type.getName(), '.', '/'), iconPath; iconPath = basePath + ".png"; if (getClass().getResource(iconPath) != null) { ruleTemplate.setIcon(iconPath); } else { iconPath = basePath + ".gif"; if (getClass().getResource(iconPath) != null) { ruleTemplate.setIcon(iconPath); } } } if (Component.class.isAssignableFrom(type)) { Widget widget = type.getAnnotation(Widget.class); if (widget != null) { if (ArrayUtils.indexOf(type.getDeclaredAnnotations(), widget) >= 0) { if (StringUtils.isEmpty(ruleTemplate.getCategory())) { ruleTemplate.setCategory(widget.category()); } ruleTemplate.setAutoGenerateId(widget.autoGenerateId()); } } } List<String> robots = null; Map<String, RobotInfo> robotMap = robotRegistry.getRobotMap(); for (Map.Entry<String, RobotInfo> entry : robotMap.entrySet()) { RobotInfo robotInfo = entry.getValue(); if (robotInfo != null) { String pattern = robotInfo.getViewObject(); if (PathUtils.match(pattern, ruleTemplate.getName())) { if (robots == null) { robots = new ArrayList<String>(); } robots.add(robotInfo.getName() + '|' + robotInfo.getLabel()); } } } if (robots != null) { ruleTemplate.setRobots(robots.toArray(new String[0])); } initProperties(ruleTemplate, typeInfo, xmlNodeInfo, initializerContext); initChildTemplates(ruleTemplate, typeInfo, xmlNodeInfo, initializerContext); initClientEvent(ruleTemplate, typeInfo, initializerContext); if (xmlNodeInfo != null && !xmlNodeInfo.getImplTypes().isEmpty()) { Set<Class<?>> implTypes = ClassUtils.findClassTypes(xmlNodeInfo.getImplTypes().toArray(new String[0]), type); for (Class<?> implType : implTypes) { if (implType.equals(type)) { continue; } if (ruleTemplateManager.getRuleTemplate(implType) == null) { // ?parentRuleTemplate??RuleTemplateinit? createRuleTemplate(ruleTemplateManager, implType, null); } } } }
From source file:com.bstek.dorado.config.xml.XmlParserHelper.java
protected void doInitObjectParser(Context context, ObjectParser objectParser, XmlNodeInfo xmlNodeInfo, Class<?> beanType) throws Exception { objectParser.setAnnotationOwnerType(beanType); if (!Modifier.isAbstract(beanType.getModifiers())) { objectParser.setImpl(beanType.getName()); }// w w w .j a v a 2 s.c om if (xmlNodeInfo != null) { if (StringUtils.isNotEmpty(xmlNodeInfo.getDefinitionType())) { objectParser.setDefinitionType(xmlNodeInfo.getDefinitionType()); } Map<String, XmlParser> propertyParsers = objectParser.getPropertyParsers(); Map<String, XmlParser> subParsers = objectParser.getSubParsers(); if (!(objectParser instanceof CompositePropertyParser)) { boolean inheritable = objectParser.isInheritable() || xmlNodeInfo.isInheritable(); objectParser.setInheritable(inheritable); if (inheritable) { if (propertyParsers.get("parent") == null) { objectParser.registerPropertyParser("parent", beanFactory.getBean(IGNORE_PARSER, XmlParser.class)); } } boolean scopable = objectParser.isScopable() || xmlNodeInfo.isScopable(); objectParser.setScopable(scopable); if (scopable) { if (propertyParsers.get("scope") == null) { objectParser.registerPropertyParser("scope", beanFactory.getBean(IGNORE_PARSER, XmlParser.class)); } } for (String fixedProperty : xmlNodeInfo.getFixedProperties().keySet()) { if (propertyParsers.get(fixedProperty) == null) { objectParser.registerPropertyParser(fixedProperty, beanFactory.getBean(IGNORE_PARSER, XmlParser.class)); } } } for (XmlSubNode xmlSubNode : xmlNodeInfo.getSubNodes()) { if (StringUtils.isNotEmpty(xmlSubNode.propertyType())) { List<XmlParserInfo> xmlParserInfos = getSubNodeXmlParserInfos(context, beanType, xmlSubNode.propertyName(), null, xmlSubNode); if (xmlParserInfos != null) { for (XmlParserInfo xmlParserInfo : xmlParserInfos) { objectParser.registerSubParser(xmlParserInfo.getPath(), xmlParserInfo.getParser()); } } } else if (StringUtils.isNotEmpty(xmlSubNode.nodeName()) && StringUtils.isNotEmpty(xmlSubNode.parser())) { BeanWrapper beanWrapper = BeanFactoryUtils.getBean(xmlSubNode.parser(), Scope.instant); objectParser.registerSubParser(xmlSubNode.nodeName(), (XmlParser) beanWrapper.getBean()); } } for (Map.Entry<String, XmlProperty> entry : xmlNodeInfo.getProperties().entrySet()) { XmlProperty xmlProperty = entry.getValue(); XmlParserInfo xmlParserInfo = getPropertyXmlParserInfo(context, beanType, xmlProperty.propertyName(), null, xmlProperty); if (xmlParserInfo != null) { objectParser.registerPropertyParser(xmlParserInfo.getPath(), xmlParserInfo.getParser()); } } if (ClientEventSupported.class.isAssignableFrom(beanType) && subParsers.get("ClientEvent") == null) { objectParser.registerSubParser("ClientEvent", beanFactory.getBean(CLIENT_EVENT_PARSER, XmlParser.class)); } } PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(beanType); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { String propertyName = propertyDescriptor.getName(); if ("class".equals(propertyName)) { continue; } Method readMethod = propertyDescriptor.getReadMethod(); if (readMethod == null) { continue; } if (readMethod.getDeclaringClass() != beanType) { try { readMethod = beanType.getMethod(readMethod.getName(), readMethod.getParameterTypes()); } catch (NoSuchMethodException e) { // do nothing } } TypeInfo typeInfo; Class<?> propertyType = propertyDescriptor.getPropertyType(); if (Collection.class.isAssignableFrom(propertyType)) { typeInfo = TypeInfo.parse((ParameterizedType) readMethod.getGenericReturnType(), true); propertyType = typeInfo.getType(); } else { typeInfo = new TypeInfo(propertyType, false); } XmlSubNode xmlSubNode = readMethod.getAnnotation(XmlSubNode.class); if (xmlSubNode != null) { if (StringUtils.isNotEmpty(xmlSubNode.propertyName())) { throw new IllegalArgumentException("@XmlSubNode.propertyName should be empty. [" + beanType.getName() + '#' + propertyName + "]"); } List<XmlParserInfo> xmlParserInfos = getSubNodeXmlParserInfos(context, beanType, propertyName, typeInfo, xmlSubNode); if (xmlParserInfos != null) { for (XmlParserInfo xmlParserInfo : xmlParserInfos) { objectParser.registerSubParser(xmlParserInfo.getPath(), xmlParserInfo.getParser()); } } } else { XmlProperty xmlProperty = readMethod.getAnnotation(XmlProperty.class); if (xmlProperty != null && StringUtils.isNotEmpty(xmlProperty.propertyName())) { throw new IllegalArgumentException("@XmlProperty.propertyName should be empty. [" + beanType.getName() + '#' + propertyName + "]"); } XmlParserInfo xmlParserInfo = getPropertyXmlParserInfo(context, beanType, propertyName, typeInfo, xmlProperty); if (xmlParserInfo != null) { XmlParser parser = xmlParserInfo.getParser(); if (parser instanceof TextPropertyParser) { TextPropertyParser textPropertyParser = (TextPropertyParser) parser; if (textPropertyParser.getTextParser() == null) { TextParser textParser = textParserHelper.getTextParser(propertyType); textPropertyParser.setTextParser(textParser); } } objectParser.registerPropertyParser(xmlParserInfo.getPath(), parser); } } } if (objectParser instanceof ObjectParserInitializationAware) { ((ObjectParserInitializationAware) objectParser).postObjectParserInitialized(objectParser); } Map<String, XmlParserHelperListener> listenerMap = ((ListableBeanFactory) beanFactory) .getBeansOfType(XmlParserHelperListener.class); for (XmlParserHelperListener listener : listenerMap.values()) { listener.onInitParser(this, objectParser, beanType); } }