/** * Get the classloader. * * @param beanMetaData the bean meta data * @return meta data's classloader * @throws UndeclaredThrowableException for any error */ protected ClassLoader getClassLoader(BeanMetaData beanMetaData) { try { return Configurator.getClassLoader(beanMetaData); } catch (Throwable t) { throw new UndeclaredThrowableException(t); } }
/** * Instantiate and configure a bean * * @param config the confg * @param info the bean info * @param metaData the bean metadata * @return the instantiated and configured object * @throws Throwable for any error */ public static Object instantiateAndConfigure(KernelConfig config, BeanInfo info, BeanMetaData metaData) throws Throwable { Object result = instantiate(config, info, metaData); if (metaData != null) configure(result, info, metaData); return result; }
/** * Find a constructor * * @param trace whether trace is enabled * @param info the bean info * @param metaData the constructor metadata * @return the constructor join point * @throws Exception for any error */ public static ConstructorJoinpoint findConstructor(boolean trace, BeanInfo info, ConstructorMetaData metaData) throws Exception { return findConstructor(trace, info, metaData, null); }
/** * Configure a bean property * * @param trace whether trace is enabled * @param object the object to configure * @param info the bean info * @param cl the classloader * @param metaData the property metadata * @throws Throwable for any error */ public static void configure(boolean trace, Object object, BeanInfo info, ClassLoader cl, PropertyMetaData metaData) throws Throwable { PropertyInfo ainfo = resolveProperty(trace, info, cl, metaData.getName(), metaData.getType()); configure(trace, object, ainfo, cl, metaData); }
ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData()); KernelConfigurator configurator = context.getKernel().getConfigurator(); ClassInfo classInfo; String[] parameterTypes = Configurator.getParameterTypes(false, parameters); MethodInfo methodInfo = Configurator.findMethodInfo(classInfo, factoryMethod, parameterTypes, factoryClassName != null, true); return applyCollectionOrMapCheck(methodInfo.getParameterTypes()[parameter.getIndex()]); String[] paramTypes = Configurator.getParameterTypes(false, parameters); ConstructorInfo ci = Configurator.findConstructorInfo(beanInfo.getClassInfo(), paramTypes); return applyCollectionOrMapCheck(ci.getParameterTypes()[parameter.getIndex()]);
ClassLoader cl = getClassLoader(beanMetaData); MethodJoinpoint joinPoint = findMethod(trace, factoryInfo, cl, metaData.getFactoryMethod(), parameters, false, true); joinPoint.setTarget(factory); MethodInfo minfo = joinPoint.getMethodInfo(); Object[] params = getParameters(trace, cl, pinfos, parameters); joinPoint.setArguments(params); MethodJoinpoint joinPoint = findMethod(trace, factoryInfo, cl, metaData.getFactoryMethod(), parameters, true, true); MethodInfo minfo = joinPoint.getMethodInfo(); Object[] params = getParameters(trace, cl, pinfos, parameters); joinPoint.setArguments(params); ConstructorJoinpoint joinPoint = findConstructor(trace, info, metaData, object); ConstructorInfo cinfo = joinPoint.getConstructorInfo(); Object[] params = getParameters(trace, cl, pinfos, metaData.getParameters()); joinPoint.setArguments(params); return findConstructor(trace, info, metaData, object);
ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData()); propertyInfo = Configurator.resolveProperty(log.isTraceEnabled(), context.getBeanInfo(), cl, property, signature); methodInfo = Configurator.findMethodInfo(getClassInfo(context), methodName, new String[]{signature}); callback = CallbackCreatorUtil.createCallback(context, methodInfo, whenRequired, dependentState, cardinality);
/** * Unconfigure a bean * * @param object the object to unconfigure * @param info the bean info * @param metaData the bean metadata * @throws Throwable for any error */ public static void unconfigure(Object object, BeanInfo info, BeanMetaData metaData) throws Throwable { if (object == null) throw new IllegalArgumentException("Null object"); if (info == null) throw new IllegalArgumentException("Null bean info"); if (metaData == null) throw new IllegalArgumentException("Null bean metadata"); ClassLoader cl = getClassLoader(metaData); Set<PropertyMetaData> propertys = metaData.getProperties(); if (propertys != null && propertys.isEmpty() == false) { for (Iterator<PropertyMetaData> i = metaData.getProperties().iterator(); i.hasNext();) { PropertyMetaData property = i.next(); unconfigure(object, cl, info, property); } } }
/** * Configure a bean * * @param object the object to configure * @param info the bean info * @param metaData the bean metadata * @throws Throwable for any error */ public static void configure(Object object, BeanInfo info, BeanMetaData metaData) throws Throwable { boolean trace = log.isTraceEnabled(); if (object == null) throw new IllegalArgumentException("Null object"); if (info == null) throw new IllegalArgumentException("Null bean info"); if (metaData == null) throw new IllegalArgumentException("Null bean metadata"); Set<PropertyMetaData> properties = metaData.getProperties(); if (properties != null && properties.isEmpty() == false) { ClassLoader cl = getClassLoader(metaData); for (Iterator<PropertyMetaData> i = metaData.getProperties().iterator(); i.hasNext();) { PropertyMetaData property = i.next(); configure(trace, object, info, cl, property); } } }
ClassLoader cl = Configurator.getClassLoader((BeanMetaData) null); try return Configurator.instantiateAndConfigure(this, info, metaData);
throw new IllegalArgumentException("Null name"); String[] paramTypes = getParameterTypes(trace, parameters); MethodInfo minfo = findMethodInfo(info.getClassInfo(), name, paramTypes, isStatic, isPublic); JoinpointFactory jpf = info.getJoinpointFactory(); MethodJoinpoint joinPoint = jpf.getMethodJoinpoint(minfo); Object[] params = getParameters(trace, cl, pinfos, parameters); joinPoint.setArguments(params);
public TypeInfo getType(MetaDataVisitor visitor, MetaDataVisitorNode previous) throws Throwable { if (previous instanceof ParameterMetaData == false) throw new IllegalArgumentException("Previous node is not ParameterMetaData as expected: " + previous); ParameterMetaData parameter = (ParameterMetaData) previous; KernelControllerContext context = visitor.getControllerContext(); String method = (methodName != null ? methodName : type); String[] parameterTypes = Configurator.getParameterTypes(false, parameters); MethodInfo methodInfo = Configurator.findMethodInfo(getClassInfo(context), method, parameterTypes); return applyCollectionOrMapCheck(methodInfo.getParameterTypes()[parameter.getIndex()]); }
if (equals(typeNames, typeInfos) || isAssignable(tif, cl, typeNames, typeInfos))
public Joinpoint getConstructorJoinPoint(BeanInfo info, ConstructorMetaData metaData, BeanMetaData beanMetaData) throws Throwable { return Configurator.getConstructorJoinPoint(config, info, metaData, beanMetaData); }
public MethodJoinpoint getMethodJoinPoint(BeanInfo info, ClassLoader cl, String name, List<ParameterMetaData> parameters, boolean isStatic, boolean isPublic) throws Throwable { return Configurator.findMethod(info, cl, name, parameters, isStatic, isPublic); }
/** * Configure a bean property * * @param object the object to configure * @param info the bean info * @param cl the classloader * @param metaData the property metadata * @throws Throwable for any error */ public static void configure(Object object, BeanInfo info, ClassLoader cl, PropertyMetaData metaData) throws Throwable { boolean trace = log.isTraceEnabled(); configure(trace, object, info, cl, metaData); }
/** * Resolve a constructor * * @param trace whether trace is enabled * @param info the bean info * @param metaData the constructor metadata * @return the constructor info */ public static ConstructorInfo resolveConstructor(boolean trace, BeanInfo info, ConstructorMetaData metaData) { if (info == null) throw new IllegalArgumentException("Null bean info"); List<ParameterMetaData> params = Collections.emptyList(); if (metaData != null && metaData.getParameters() != null) params = metaData.getParameters(); String[] paramTypes = new String[params.size()]; if (params.isEmpty() == false) { int x = 0; for (Iterator<ParameterMetaData> i = params.iterator(); i.hasNext();) { ParameterMetaData pdata = i.next(); paramTypes[x++] = pdata.getType(); } } return findConstructorInfo(info.getClassInfo(), paramTypes); }
typeInfos[i] = parameterInfos[i].getParameterType(); return Configurator.equals(typeNames, typeInfos);
/** * Validate method invocation. * Use jsr303 constraints. * * @param name the method name * @param signature the method signature * @param paramaters the parameter values * @throws Throwable for any error */ protected void validateMethodValues(String name, String[] signature, Object[] paramaters) throws Throwable { BeanValidatorBridge bridge = KernelControllerContextAction.getBeanValidatorBridge(this); if (bridge != null) { MethodInfo methodInfo = Configurator.findMethodInfo(getInfo().getClassInfo(), name, signature); bridge.validateMethodValues(this, getTarget(), methodInfo, paramaters); } } }
Signature pis = createParametersSignature( pi.getName(), Configurator.getParameterTypes(log.isTraceEnabled(), typeInfos),