Package org.drools.spring.metadata

Examples of org.drools.spring.metadata.MethodMetadata


        List conditionRuleReflectMethods = new ArrayList();

        Method[] pojoMethods = pojo.getClass().getMethods();
        for (int i = 0; i < pojoMethods.length; i++) {
            Method pojoMethod = pojoMethods[i];
            MethodMetadata methodMetadata = methodMetadataSource.getMethodMetadata(pojoMethod);
            if (methodMetadata == null) {
                if (log.isDebugEnabled()) {
                    log.debug("No metadata for method " + pojoMethod.toString());
                }
                continue;
            }

            ArgumentMetadata[] argumentsMetadata = getArgumentMetadata(pojoMethod);
            Argument[] arguments = getArguments(rule, argumentsMetadata);

            if (methodMetadata.getMethodType() == MethodMetadata.METHOD_CONDITION) {
                assertReturnType(pojoMethod, boolean.class);
                rule.addCondition(
                        new PojoCondition(new RuleReflectMethod(rule, pojo, pojoMethod, arguments)));
                log.info("Condition method added to rule: " + pojoMethod.toString());

            } else if (methodMetadata.getMethodType() == MethodMetadata.METHOD_CONSEQUENCE) {
                conditionRuleReflectMethods.add(
                        new RuleReflectMethod(rule, pojo, pojoMethod, arguments));
                log.info("Consequence method added to rule: " + pojoMethod.toString());
            } else if (methodMetadata.getMethodType() == MethodMetadata.OBJECT_CONDITION) {
                if (arguments.length != 0) {
                    throw new InvalidPojoConditionException("Rule pojo condition must not have arguments"
                                                            + ": method = " + pojoMethod + ", arguments = " + arguments);
                }
                try {
View Full Code Here


    private void buildObjectConditions(Rule rule, Object pojo) throws DroolsException {
        Method[] pojoMethods = pojo.getClass().getMethods();
        for (int i = 0; i < pojoMethods.length; i++) {
            Method pojoMethod = pojoMethods[i];
            MethodMetadata methodMetadata = methodMetadataSource.getMethodMetadata(pojoMethod);
            if (methodMetadata == null) {
                continue;
            }
   
            ArgumentMetadata[] argumentsMetadata = getArgumentMetadata(pojoMethod);
            Argument[] arguments = getArguments(rule, argumentsMetadata);
   
            if (methodMetadata.getMethodType() == MethodMetadata.METHOD_CONDITION) {
                assertReturnType(pojoMethod, boolean.class);
                rule.addCondition(new PojoCondition(new RuleReflectMethod(rule, pojo, pojoMethod, arguments)));
   
            }
        }
View Full Code Here

TOP

Related Classes of org.drools.spring.metadata.MethodMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.