Examples of AnnotationDescr


Examples of org.drools.compiler.lang.descr.AnnotationDescr

    }

    protected void processMetadataAnnotations(Pattern pattern, Map<String, AnnotationDescr> annotationMap) {
        for ( String key : annotationMap.keySet() ) {
            if ( ! Pattern.ATTR_LISTENED_PROPS.equals( key ) ) {
                AnnotationDescr ann = annotationMap.get( key );
                AnnotationDefinition def = new AnnotationDefinition( key );
                for ( String propKey : ann.getValues().keySet() ) {
                    def.getValues().put( propKey, new AnnotationDefinition.AnnotationPropertyVal( propKey, null, ann.getValue( propKey ), null ) );
                }
                pattern.getAnnotations().put( key, def );
            }
        }       
    }
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

    protected void processListenedPropertiesAnnotation(RuleBuildContext context,
                                                     PatternDescr patternDescr,
                                                     Pattern pattern,
                                                     Map<String, AnnotationDescr> annotationMap) {
        AnnotationDescr listenedProps = annotationMap.get(Pattern.ATTR_LISTENED_PROPS);
        if (listenedProps != null) {
            List<String> settableProperties = getSettableProperties(context, patternDescr, pattern);

            List<String> listenedProperties = new ArrayList<String>();
            for (String propertyName : listenedProps.getValue().toString().split(",")) {
                propertyName = propertyName.trim();
                if (propertyName.equals("*") || propertyName.equals("!*")) {
                    if (listenedProperties.contains("*") || listenedProperties.contains("!*")) {
                        context.addError( new DescrBuildError( context.getParentDescr(),
                                patternDescr,
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

                                                                this.buildStack);
        this.declarationResolver.setPackage(pkg);
        this.ruleDescr = ruleDescr;

        if ( ruleDescr instanceof QueryDescr ) {
            AnnotationDescr abductive = ruleDescr.getAnnotation( Abductive.class.getSimpleName() );
            if ( abductive == null ) {
                this.rule = new Query( ruleDescr.getName() );
            } else {
                this.rule = new AbductiveQuery( ruleDescr.getName(), abductive.getValue( "mode" ) );
            }
        } else {
            this.rule = new Rule(ruleDescr.getName());
        }
        this.rule.setPackage(pkg.getName());
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

    }

    public void buildMetaAttributes(final RuleBuildContext context ) {
        Rule rule = context.getRule();
        for ( String metaAttr : context.getRuleDescr().getAnnotationNames() ) {
            AnnotationDescr ad = context.getRuleDescr().getAnnotation( metaAttr );
            if ( ad.hasValue() ) {
                if ( ad.getValues().size() == 1 ) {
                    rule.addMetaAttribute( metaAttr,
                                           resolveValue( ad.getSingleValue() ) );
                } else {
                    rule.addMetaAttribute( metaAttr,
                                           ad.getValueMap() );
                }
            } else {
                rule.addMetaAttribute( metaAttr,
                                       null );
            }
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

        buildSalience( context );

        buildEnabled( context );
       
        AnnotationDescr ann = ruleDescr.getAnnotation( "activationListener" );
        if ( ann != null && !StringUtils.isEmpty( ann.getSingleValue() ) ) {
            rule.setActivationListener( MVELSafeHelper.getEvaluator().evalToString( ann.getSingleValue() ) );
        }

        ann = ruleDescr.getAnnotation( "Eager" );
        if ( enforceEager || ( ann != null && trueOrDefault( ann.getSingleValue() ) ) ) {
            rule.setEager( true );
        }

        ann = ruleDescr.getAnnotation( "Direct" );
        if ( ann != null && trueOrDefault( ann.getSingleValue() ) ) {
            rule.setActivationListener( "direct" );
        }

        //        buildDuration( context );
    }
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

        }

        Declaration[] declarations = new Declaration[ params.length ];

        if ( query.isAbductive() ) {
            AnnotationDescr ann = queryDescr.getAnnotation( Abductive.class.getSimpleName() );
            String returnName = ann.getValue( "target" );
            try {
                Class<?> returnKlass = context.getPkg().getTypeResolver().resolveType( returnName.replace( ".class", "" ) );
                ClassObjectType objectType = new ClassObjectType( returnKlass, false );
                objectType = context.getPkg().getClassFieldAccessorStore().getClassObjectType( objectType,
                                                                                               (AbductiveQuery) query );
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

            } else if ( tdescr.getSuperTypes().isEmpty() ) {
                tdescr.addSuperType("java.lang.Object");
            }
        }

        AnnotationDescr traitableAnn = typeDescr.getAnnotation(Traitable.class.getSimpleName());
        boolean traitable = traitableAnn != null;

        String[] fullSuperTypes = new String[typeDescr.getSuperTypes().size() + 1];
        int j = 0;
        for (QualifiedName qname : typeDescr.getSuperTypes()) {
            fullSuperTypes[j++] = qname.getFullName();
        }
        fullSuperTypes[j] = Thing.class.getName();

        List<String> interfaceList = new ArrayList<String>();
        interfaceList.add(traitable ? Externalizable.class.getName() : Serializable.class.getName());
        if (traitable) {
            interfaceList.add(TraitableBean.class.getName());
        }
        String[] interfaces = interfaceList.toArray(new String[interfaceList.size()]);

        // prepares a class definition
        ClassDefinition def;
        switch ( type.getKind() ) {
            case TRAIT:
                def = new ClassDefinition( fullName,
                                           Object.class.getName(),
                                           fullSuperTypes );
                break;
            case ENUM:
                def = new EnumClassDefinition( fullName,
                                               fullSuperTypes[0],
                                               null );
                break;
            case CLASS:
            default:
                def = new ClassDefinition( fullName,
                                           fullSuperTypes[0],
                                           interfaces );
                def.setTraitable( traitable, traitableAnn != null &&
                                             traitableAnn.getValue( "logical" ) != null &&
                                             Boolean.valueOf( traitableAnn.getValue( "logical" ) ) );
        }

        return def;
    }
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

    private void discoverHierarchyForRedeclarations( TypeDeclarationDescr typeDescr, PackageDescr packageDescr ) {
        PackageRegistry pkReg = kbuilder.getPackageRegistry( packageDescr.getName() );
        if ( ! TypeDeclarationUtils.isNovelClass( typeDescr, pkReg ) ) {
            Class typeClass = TypeDeclarationUtils.getExistingDeclarationClass( typeDescr, pkReg );
            AnnotationDescr kind = typeDescr.getAnnotation( TypeDeclaration.Kind.ID );
            if ( typeClass != null && kind != null && kind.hasValue() && TypeDeclaration.Kind.TRAIT == TypeDeclaration.Kind.parseKind( kind.getSingleValue() ) ) {
                fillStaticInterfaces( typeDescr, typeClass );
            } else {
                typeDescr.getSuperTypes().clear();
                typeDescr.addSuperType( typeClass.isInterface() || typeClass == Object.class ?
                                        Object.class.getName() :
View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

    }


    protected void processTypeAnnotations( AbstractClassTypeDeclarationDescr typeDescr, TypeDeclaration type, TypeDeclaration parent ) {
        // is it a regular fact or an event?
        AnnotationDescr annotationDescr = getSingleAnnotation(typeDescr, TypeDeclaration.Role.ID);
        String role = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
        if (role != null) {
            type.setRole(TypeDeclaration.Role.parseRole(role));
        }
        /*
        else if (parent != null) {
            // FIXME : Should this be here, since Drools 6 does not namely support annotation inheritance?
            type.setRole(parent.getRole());
        }
        */

        annotationDescr = getSingleAnnotation(typeDescr, TypeDeclaration.ATTR_TYPESAFE);
        String typesafe = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
        if (typesafe != null) {
            type.setTypesafe(Boolean.parseBoolean(typesafe));
        }
        /*
        else if (parent != null && isSet(parent.getSetMask(), TypeDeclaration.TYPESAFE_BIT)) {
            // FIXME : Should this be here, since Drools 6 does not namely support annotation inheritance?
            type.setTypesafe(parent.isTypesafe());
        }
        */

        // is it a pojo or a template?
        annotationDescr = getSingleAnnotation(typeDescr, TypeDeclaration.Format.ID);
        String format = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
        if (format != null) {
            type.setFormat(TypeDeclaration.Format.parseFormat(format));
        }

        // is it a class, a trait or an enum?
        annotationDescr = getSingleAnnotation(typeDescr, TypeDeclaration.Kind.ID);
        String kind = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
        if (kind != null) {
            type.setKind(TypeDeclaration.Kind.parseKind(kind));
        }
        if (typeDescr instanceof EnumDeclarationDescr ) {
            type.setKind(TypeDeclaration.Kind.ENUM);
        }

        annotationDescr = getSingleAnnotation( typeDescr, TypeDeclaration.ATTR_CLASS );
        String className = (annotationDescr != null) ? annotationDescr.getSingleValue() : null;
        if (isEmpty(className)) {
            className = type.getTypeName();
        }


View Full Code Here

Examples of org.drools.compiler.lang.descr.AnnotationDescr

        annotationDescr = getSingleAnnotation( typeDescr, TypeDeclaration.ATTR_PROP_CHANGE_SUPPORT );
        type.setDynamic( annotationDescr != null );
    }

    protected AnnotationDescr getSingleAnnotation( AbstractClassTypeDeclarationDescr typeDescr, String name ) {
        AnnotationDescr annotationDescr = typeDescr.getAnnotation(name);
        if (annotationDescr != null && annotationDescr.isDuplicated()) {
            kbuilder.addBuilderResult(new TypeDeclarationError(typeDescr,
                                                               "Duplicated annotation '" + name +
                                                               "' for type declaration of '" +
                                                               typeDescr.getTypeName() + "'"));
            return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.