Examples of AnnotationDefinition


Examples of org.drools.core.factmodel.AnnotationDefinition

        for ( String annotationName : typeDescr.getAnnotationNames() ) {
            Class annotation = resolveAnnotation( annotationName,
                                                  pkgRegistry.getTypeResolver() );
            if ( annotation != null ) {
                try {
                    AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation,
                                                                                            typeDescr.getAnnotations().get( annotationName ).getValueMap(),
                                                                                            pkgRegistry.getTypeResolver() );
                    def.addAnnotation( annotationDefinition );
                } catch ( NoSuchMethodException nsme ) {
                    this.results.add( new TypeDeclarationError( typeDescr,
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

                for ( String annotationName : field.getAnnotationNames() ) {
                    Class annotation = resolveAnnotation( annotationName,
                                                          pkgRegistry.getTypeResolver() );
                    if ( annotation != null ) {
                        try {
                            AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation,
                                                                                                    field.getAnnotations().get( annotationName ).getValueMap(),
                                                                                                    pkgRegistry.getTypeResolver() );
                            fieldDef.addAnnotation( annotationDefinition );
                        } catch ( NoSuchMethodException nsme ) {
                            this.results.add( new TypeDeclarationError( field,
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

                if ( classDef.getDefinedClass() == null || classDef.getDefinedClass().getAnnotation( Trait.class ) == null ) {
                    AnnotationVisitor av0 = cw.visitAnnotation( Type.getDescriptor( Trait.class ), true);
                    List<AnnotationDefinition> annotations = classDef.getAnnotations();
                    if ( annotations != null && ! annotations.isEmpty() ) {
                        for ( Iterator<AnnotationDefinition> iter = annotations.iterator(); iter.hasNext(); ) {
                            AnnotationDefinition adef = iter.next();
                            if ( Trait.class.getName().equals( adef.getName() ) ) {
                                if ( adef.getPropertyValue( "logical" ) != null ) {
                                    av0.visit( "logical", (Boolean) adef.getPropertyValue( "logical" ) );
                                }
                                if ( adef.getPropertyValue( "impl" ) != null ) {
                                    av0.visit( "impl", Type.getType( (Class) adef.getPropertyValue( "impl" ) ) );
                                }
                                break;
                            }
                        }
                    }
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

                if ( classDef.getDefinedClass() == null || classDef.getDefinedClass().getAnnotation( Trait.class ) == null ) {
                    AnnotationVisitor av0 = cw.visitAnnotation( Type.getDescriptor( Trait.class ), true);
                    List<AnnotationDefinition> annotations = classDef.getAnnotations();
                    if ( annotations != null && ! annotations.isEmpty() ) {
                        for ( Iterator<AnnotationDefinition> iter = annotations.iterator(); iter.hasNext(); ) {
                            AnnotationDefinition adef = iter.next();
                            if ( Trait.class.getName().equals( adef.getName() ) ) {
                                if ( adef.getPropertyValue( "logical" ) != null ) {
                                    av0.visit( "logical", (Boolean) adef.getPropertyValue( "logical" ) );
                                }
                                if ( adef.getPropertyValue( "impl" ) != null ) {
                                    av0.visit( "impl", Type.getType( (Class) adef.getPropertyValue( "impl" ) ) );
                                }
                                break;
                            }
                        }
                    }
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

    protected void processMetadataAnnotations( PatternDescr patternDescr, Pattern pattern, TypeResolver typeResolver ) {
        for ( AnnotationDescr ann : patternDescr.getAnnotations() ) {
            String annFQN = ann.getFullyQualifiedName();
            if ( !Watch.class.getCanonicalName().equals(annFQN) ) {
                AnnotationDefinition def = buildAnnotationDef( ann, typeResolver );
                pattern.getAnnotations().put( annFQN, def );
            }
        }       
    }
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

            }
        }       
    }

    private AnnotationDefinition buildAnnotationDef( AnnotationDescr annotationDescr, TypeResolver resolver ) {
        AnnotationDefinition annotationDefinition = null;
        try {
            annotationDefinition = AnnotationDefinition.build( resolver.resolveType( annotationDescr.getFullyQualifiedName() ),
                                                               annotationDescr.getValueMap(),
                                                               resolver );
            return annotationDefinition;
        } catch ( Exception e ) {
            e.printStackTrace();
            annotationDefinition = new AnnotationDefinition( annotationDescr.getFullyQualifiedName() );
            for ( String propKey : annotationDescr.getValues().keySet() ) {
                Object value = annotationDescr.getValue( propKey );
                if ( value instanceof AnnotationDescr ) {
                    value = buildAnnotationDef( (AnnotationDescr) value, resolver );
                }
                annotationDefinition.getValues().put( propKey, new AnnotationDefinition.AnnotationPropertyVal( propKey, null, value, null ) );
            }
            return annotationDefinition;
        }
    }
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

                continue;
            }

            if ( annotation != null && annotation.isAnnotation() ) {
                try {
                    AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation,
                                                                                            annotationDescr.getValueMap(),
                                                                                            resolver );
                    def.addAnnotation(annotationDefinition);
                } catch (NoSuchMethodException nsme) {
                    kbuilder.addBuilderResult(new TypeDeclarationError(typeDescr,
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

                        }
                    }
                    Annotation annotation = AnnotationFactory.buildAnnotation(typeResolver, annotationDescr);
                    if (annotation != null) {
                        try {
                            AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation.annotationType(),
                                                                                                    field.getAnnotation(annotationDescr.getFullyQualifiedName()).getValueMap(),
                                                                                                    typeResolver );
                            fieldDef.addAnnotation( annotationDefinition );
                        } catch ( Exception e ) {
                            kbuilder.addBuilderResult( new TypeDeclarationError( field,
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

    public void buildMetaAttributes(final RuleBuildContext context ) {
        RuleImpl rule = context.getRule();
        for ( String metaAttr : context.getRuleDescr().getAnnotationNames() ) {
            AnnotationDescr ad = context.getRuleDescr().getAnnotation( metaAttr );
            try {
                AnnotationDefinition annotationDefinition = AnnotationDefinition.build( context.getDialect().getTypeResolver().resolveType( ad.getFullyQualifiedName() ),
                                                                                        ad.getValueMap(),
                                                                                        context.getDialect().getTypeResolver() );
                if ( annotationDefinition.getValues().size() == 1 && annotationDefinition.getValues().containsKey( AnnotationDescr.VALUE ) ) {
                    rule.addMetaAttribute( metaAttr, annotationDefinition.getPropertyValue( AnnotationDescr.VALUE ) );
                } else {
                    Map<String,Object> map = new HashMap<String,Object>( annotationDefinition.getValues().size() );
                    for ( String key : annotationDefinition.getValues().keySet() ) {
                        map.put( key, annotationDefinition.getPropertyValue( key ) );
                    }
                    rule.addMetaAttribute( metaAttr, map );
                }
            } catch ( Exception e ) {
                if ( ad.hasValue() ) {
View Full Code Here

Examples of org.drools.core.factmodel.AnnotationDefinition

        if ( ! classLoader.isClassInUse( extName ) ) {
            try {
                ClassDefinition extDef = new ClassDefinition( extName );
                extDef.setSuperClass( Object.class.getName() );

                AnnotationDefinition annot = new AnnotationDefinition( Trait.class.getName() );
                extDef.addAnnotation( annot );

                String[] supers = new String[] { Thing.class.getName(), trait.getName() };
                extDef.setInterfaces( supers );
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.