当前位置: 首页>>代码示例>>Java>>正文


Java BeanDescFactory.getBeanDesc方法代码示例

本文整理汇总了Java中org.lastaflute.di.helper.beans.factory.BeanDescFactory.getBeanDesc方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDescFactory.getBeanDesc方法的具体用法?Java BeanDescFactory.getBeanDesc怎么用?Java BeanDescFactory.getBeanDesc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lastaflute.di.helper.beans.factory.BeanDescFactory的用法示例。


在下文中一共展示了BeanDescFactory.getBeanDesc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doCheckJsonBeanValidator

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected void doCheckJsonBeanValidator(Class<?> jsonBeanType, Map<String, Class<?>> genericMap) {
    final Deque<String> pathDeque = new LinkedList<String>(); // recycled
    final Set<Class<?>> mismatchedCheckedTypeSet = DfCollectionUtil.newHashSet(jsonBeanType);
    final Set<Class<?>> lonelyCheckedTypeSet = DfCollectionUtil.newHashSet(jsonBeanType);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(jsonBeanType);
    final int pdSide = beanDesc.getPropertyDescSize();
    for (int i = 0; i < pdSide; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        final Field field = pd.getField();
        if (field != null) {
            pathDeque.clear(); // to recycle
            checkJsonBeanMismatchedValidatorAnnotation(jsonBeanType, pd, field, pathDeque, mismatchedCheckedTypeSet, genericMap);
            pathDeque.clear(); // to recycle
            checkJsonBeanLonelyValidatorAnnotation(jsonBeanType, pd, field, pathDeque, lonelyCheckedTypeSet, genericMap);
        }
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:ExecuteMethodChecker.java

示例2: nativeFindByCode

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected static OptionalThing<Classification> nativeFindByCode(Class<?> cdefType, Object code) {
    assertArgumentNotNull("cdefType", cdefType);
    assertArgumentNotNull("code", code);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(cdefType);
    final String methodName = "of";
    final Method method;
    try {
        method = beanDesc.getMethod(methodName, new Class<?>[] { Object.class });
    } catch (BeanMethodNotFoundException e) {
        String msg = "Failed to get the method " + methodName + "() of the classification type: " + cdefType;
        throw new ClassificationFindByCodeMethodNotFoundException(msg, e);
    }
    @SuppressWarnings("unchecked")
    final OptionalThing<Classification> opt =
            (OptionalThing<Classification>) DfReflectionUtil.invokeStatic(method, new Object[] { code });
    return opt;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:LaClassificationUtil.java

示例3: nativeFindMeta

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected static OptionalThing<ClassificationMeta> nativeFindMeta(Class<?> defmetaType, String classificationName) { // old method
    assertArgumentNotNull("defmetaType", defmetaType);
    assertArgumentNotNull("classificationName", classificationName);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(defmetaType);
    final String methodName = "find";
    final Method method;
    try {
        method = beanDesc.getMethod(methodName, new Class<?>[] { String.class });
    } catch (BeanMethodNotFoundException e) {
        String msg = "Failed to get the method " + methodName + "() of the def-meta type: " + defmetaType;
        throw new ClassificationMetaFindMethodNotFoundException(msg, e);
    }
    @SuppressWarnings("unchecked")
    OptionalThing<ClassificationMeta> opt =
            (OptionalThing<ClassificationMeta>) DfReflectionUtil.invokeStatic(method, new Object[] { classificationName });
    return opt;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:LaClassificationUtil.java

示例4: invoke

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
public Object invoke(MethodInvocation invocation) throws Throwable {
    if (targetName == null) {
        throw new EmptyRuntimeException("targetName");
    }
    final Method method = invocation.getMethod();
    if (!LdiMethodUtil.isAbstract(method)) {
        return invocation.proceed();
    }
    String methodName = method.getName();
    if (methodNameMap.containsKey(methodName)) {
        methodName = (String) methodNameMap.get(methodName);
    }
    final Object target = container.getComponent(targetName);
    if (beanDesc == null) {
        beanDesc = BeanDescFactory.getBeanDesc(target.getClass());
    }
    if (!beanDesc.hasMethod(methodName)) {
        throw new BeanMethodNotFoundException(getTargetClass(invocation), methodName, invocation.getArguments());
    }
    return beanDesc.invoke(target, methodName, invocation.getArguments());
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:22,代码来源:PrototypeDelegateInterceptor.java

示例5: evaluate

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
@Override
public Object evaluate(Map<String, ? extends Object> context, LaContainer container, Class<?> conversionType) {
    final MethodInterceptor interceptor = MethodInterceptor.class.cast(container.getComponent(getInterceptorName(annotation)));
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(interceptor.getClass());
    for (final Method method : annotation.annotationType().getMethods()) {
        if (method.isBridge() || method.isSynthetic()) {
            continue;
        }
        final String propertyName = method.getName();
        if ("pointcut".equals(propertyName) || !beanDesc.hasPropertyDesc(propertyName)) {
            continue;
        }
        final PropertyDesc propertyDesc = beanDesc.getPropertyDesc(propertyName);
        if (!propertyDesc.isWritable()) {
            continue;
        }
        propertyDesc.setValue(interceptor, LdiMethodUtil.invoke(method, annotation, null));
    }
    return interceptor;
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:21,代码来源:MetaAnnotationAspectDefBuilder.java

示例6: resolveBeanExpression

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected static String resolveBeanExpression(Object obj, Map<Object, String> alreadyAppearedSet) {
    if (obj == null) {
        throw new IllegalArgumentException("The argument 'obj' should not be null.");
    }
    final Class<? extends Object> targetType = obj.getClass();
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(targetType);
    final int propertySize = beanDesc.getPropertyDescSize();
    final StringBuilder sb = new StringBuilder();
    sb.append("{");
    for (int i = 0; i < propertySize; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        final String propertyName = pd.getPropertyName();
        final Object propertyValue = pd.getValue(obj);
        final String exp = deriveExpression(propertyValue, alreadyAppearedSet, () -> {
            return resolveObjectString(propertyValue, alreadyAppearedSet);
        });
        sb.append(i > 0 ? ", " : "").append(propertyName).append("=").append(exp);
    }
    sb.append("}");
    return sb.toString();
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:22,代码来源:Lato.java

示例7: prepareJsonParameterDebugChallengeList

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected List<JsonDebugChallenge> prepareJsonParameterDebugChallengeList(Map<String, Object> retryMap, Class<?> beanType, String json,
        Integer elementIndex) {
    if (retryMap.isEmpty()) {
        return Collections.emptyList();
    }
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(beanType);
    final int fieldSize = beanDesc.getFieldSize();
    final List<JsonDebugChallenge> challengeList = new ArrayList<JsonDebugChallenge>(fieldSize);
    for (int i = 0; i < fieldSize; i++) {
        final Field field = beanDesc.getField(i);
        final JsonDebugChallenge challenge = createJsonDebugChallenge(retryMap, field.getName(), field.getType(), elementIndex);
        challengeList.add(challenge);
    }
    return Collections.unmodifiableList(challengeList);
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:16,代码来源:ActionFormMapper.java

示例8: setIndexedProperty

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected void setIndexedProperty(Object bean, String name, int[] indexes, Object value, FormMappingOption option) { // e.g. sea[0]
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
    if (!beanDesc.hasPropertyDesc(name)) {
        return;
    }
    final PropertyDesc pd = beanDesc.getPropertyDesc(name);
    if (!pd.isWritable()) {
        return;
    }
    if (value.getClass().isArray() && Array.getLength(value) > 0) {
        value = Array.get(value, 0);
    }
    final Class<?> propertyType = pd.getPropertyType();
    if (propertyType.isArray()) {
        Object array = pd.getValue(bean);
        final Class<?> elementType = getArrayElementType(propertyType, indexes.length);
        if (array == null) {
            int[] newIndexes = new int[indexes.length];
            newIndexes[0] = indexes[0] + 1;
            array = Array.newInstance(elementType, newIndexes);
        }
        array = expand(array, indexes, elementType);
        pd.setValue(bean, array);
        setArrayValue(array, indexes, value);
    } else { // e.g. List, ImmutableList, MutableList
        // process of your collections should be first because MutableList is java.util.List 
        final Optional<FormYourCollectionResource> yourCollection = findListableYourCollection(pd, option);
        if (yourCollection.isPresent()) { // e.g. ImmutableList, MutableList
            doSetIndexedPropertyListable(bean, name, indexes, value, beanDesc, pd, option, newList -> {
                @SuppressWarnings("unchecked")
                final List<Object> filtered = (List<Object>) yourCollection.get().getYourCollectionCreator().apply(newList);
                return filtered;
            });
        } else if (List.class.isAssignableFrom(propertyType)) {
            doSetIndexedPropertyListable(bean, name, indexes, value, beanDesc, pd, option, Function.identity());
        } else {
            throwIndexedPropertyNotListArrayException(beanDesc, pd);
        }
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:41,代码来源:ActionFormMapper.java

示例9: appendAspect

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
public void appendAspect(ComponentDef componentDef) {
    Class<?> componentClass = componentDef.getComponentClass();
    if (componentClass == null) {
        return;
    }
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(componentClass);
    if (!beanDesc.hasField(ASPECT)) {
        return;
    }
    String aspectStr = (String) beanDesc.getFieldValue(ASPECT, null);
    String[] array = LdiStringUtil.split(aspectStr, "=, ");
    String interceptor = null;
    String pointcut = null;
    if (array.length == 1) {
        interceptor = array[0];
    } else {
        for (int i = 0; i < array.length; i += 2) {
            String key = array[i].trim();
            String value = array[i + 1].trim();
            if (VALUE.equalsIgnoreCase(key)) {
                interceptor = value;
            } else if (POINTCUT.equalsIgnoreCase(key)) {
                pointcut = value;
            } else {
                throw new IllegalArgumentException(aspectStr);
            }
        }
    }
    appendAspect(componentDef, interceptor, pointcut);
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:31,代码来源:ConstantAnnotationHandler.java

示例10: setupProperties

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected Map<String, ActionFormProperty> setupProperties(Class<?> formType) {
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(formType);
    final int propertyDescSize = beanDesc.getPropertyDescSize();
    final Map<String, ActionFormProperty> map = new HashMap<String, ActionFormProperty>(propertyDescSize);
    for (int i = 0; i < propertyDescSize; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        if (pd.isReadable()) {
            final ActionFormProperty property = newActionFormProperty(pd);
            addProperty(map, property);
        }
    }
    return map;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:14,代码来源:ActionFormMeta.java

示例11: appendDestroyMethod

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
public void appendDestroyMethod(ComponentDef componentDef) {
    Class<?> componentClass = componentDef.getComponentClass();
    if (componentClass == null) {
        return;
    }
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(componentClass);
    if (!beanDesc.hasField(DESTROY_METHOD)) {
        return;
    }
    String destroyMethodStr = (String) beanDesc.getFieldValue(DESTROY_METHOD, null);
    if (LdiStringUtil.isEmpty(destroyMethodStr)) {
        return;
    }
    String[] array = LdiStringUtil.split(destroyMethodStr, ", ");
    for (int i = 0; i < array.length; ++i) {
        String methodName = array[i].trim();
        if (!beanDesc.hasMethod(methodName)) {
            throw new IllegalDestroyMethodAnnotationRuntimeException(componentClass, methodName);
        }
        Method[] methods = beanDesc.getMethods(methodName);
        if (methods.length != 1 || methods[0].getParameterTypes().length != 0) {
            throw new IllegalDestroyMethodAnnotationRuntimeException(componentClass, methodName);
        }
        if (!isDestroyMethodRegisterable(componentDef, methodName)) {
            continue;
        }
        appendDestroyMethod(componentDef, methodName);
    }
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:30,代码来源:ConstantAnnotationHandler.java

示例12: buildQueryString

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
protected String buildQueryString(Object queryForm) {
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(queryForm.getClass());
    final int propSize = beanDesc.getPropertyDescSize();
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < propSize; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        final Object value = beanDesc.getPropertyDesc(i).getValue(queryForm);
        if (value == null || (value instanceof String && ((String) value).isEmpty())) {
            continue;
        }
        sb.append(sb.length() == 0 ? "?" : "&");
        sb.append(encode(pd.getPropertyName())).append("=").append(encode(value.toString()));
    }
    return sb.toString();
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:16,代码来源:PagingNavi.java

示例13: appendInitMethod

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
public void appendInitMethod(ComponentDef componentDef) {
    Class<?> componentClass = componentDef.getComponentClass();
    if (componentClass == null) {
        return;
    }
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(componentClass);
    if (!beanDesc.hasField(INIT_METHOD)) {
        return;
    }
    String initMethodStr = (String) beanDesc.getFieldValue(INIT_METHOD, null);
    if (LdiStringUtil.isEmpty(initMethodStr)) {
        return;
    }
    String[] array = LdiStringUtil.split(initMethodStr, ", ");
    for (int i = 0; i < array.length; ++i) {
        String methodName = array[i].trim();
        if (!beanDesc.hasMethod(methodName)) {
            throw new IllegalInitMethodAnnotationRuntimeException(componentClass, methodName);
        }
        Method[] methods = beanDesc.getMethods(methodName);
        if (methods.length != 1 || methods[0].getParameterTypes().length != 0) {
            throw new IllegalInitMethodAnnotationRuntimeException(componentClass, methodName);
        }
        if (!isInitMethodRegisterable(componentDef, methodName)) {
            continue;
        }
        appendInitMethod(componentDef, methodName);
    }
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:30,代码来源:ConstantAnnotationHandler.java

示例14: createComponentDef

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
public ComponentDef createComponentDef(Class<?> componentClass, InstanceDef defaultInstanceDef, AutoBindingDef defaultAutoBindingDef,
        boolean defaultExternalBinding) {

    String name = null;
    InstanceDef instanceDef = defaultInstanceDef;
    AutoBindingDef autoBindingDef = defaultAutoBindingDef;
    boolean externalBinding = defaultExternalBinding;
    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(componentClass);
    if (!beanDesc.hasField(COMPONENT)) {
        return createComponentDef(componentClass, name, instanceDef, autoBindingDef, externalBinding);
    }
    Field field = beanDesc.getField(COMPONENT);
    if (!isConstantAnnotationField(field)) {
        return createComponentDef(componentClass, name, instanceDef, autoBindingDef, externalBinding);
    }
    String componentStr = (String) LdiFieldUtil.get(field, null);
    String[] array = LdiStringUtil.split(componentStr, "=, ");
    for (int i = 0; i < array.length; i += 2) {
        String key = array[i].trim();
        String value = array[i + 1].trim();
        if (NAME.equalsIgnoreCase(key)) {
            name = value;
        } else if (INSTANCE.equalsIgnoreCase(key)) {
            instanceDef = getInstanceDef(value, defaultInstanceDef);
        } else if (AUTO_BINDING.equalsIgnoreCase(key)) {
            autoBindingDef = getAutoBindingDef(value);
        } else if (EXTERNAL_BINDING.equalsIgnoreCase(key)) {
            externalBinding = Boolean.valueOf(value).booleanValue();
        } else {
            throw new IllegalArgumentException(componentStr);
        }
    }
    return createComponentDef(componentClass, name, instanceDef, autoBindingDef, externalBinding);
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:35,代码来源:ConstantAnnotationHandler.java

示例15: setTarget

import org.lastaflute.di.helper.beans.factory.BeanDescFactory; //导入方法依赖的package包/类
public void setTarget(Object target) {
    this.target = target;
    beanDesc = BeanDescFactory.getBeanDesc(target.getClass());
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:5,代码来源:DelegateInterceptor.java


注:本文中的org.lastaflute.di.helper.beans.factory.BeanDescFactory.getBeanDesc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。