Package org.drools.rule

Examples of org.drools.rule.TypeDeclaration


        return clone;
    }

    private void initBuiltinTypeDeclarations() {
        TypeDeclaration colType = new TypeDeclaration( "Collection" );
        colType.setTypesafe( false );
        colType.setTypeClass( Collection.class );
        builtinTypes.put("java.util.Collection",
                colType);

        TypeDeclaration mapType = new TypeDeclaration( "Map" );
        mapType.setTypesafe(false);
        mapType.setTypeClass( Map.class );
        builtinTypes.put( "java.util.Map",
                          mapType );

        TypeDeclaration activationType = new TypeDeclaration( "Activation" );
        activationType.setTypesafe( false );
        activationType.setTypeClass(Activation.class);
        builtinTypes.put( Activation.class.getCanonicalName(),
                          activationType );

        TypeDeclaration thingType = new TypeDeclaration( Thing.class.getSimpleName() );
        thingType.setKind( TypeDeclaration.Kind.TRAIT );
        thingType.setTypeClass( Thing.class );
        builtinTypes.put( Thing.class.getCanonicalName(),
                          thingType );
    }
View Full Code Here


        }
        pkg.getClassFieldAccessorStore().merge( newPkg.getClassFieldAccessorStore() );
        pkg.getDialectRuntimeRegistry().onBeforeExecute();

        // we have to do this before the merging, as it does some classloader resolving
        TypeDeclaration lastType = null;
        try {
            // Resolve the class for the type declaation
            if (newPkg.getTypeDeclarations() != null) {
                // add type declarations
                for (TypeDeclaration type : newPkg.getTypeDeclarations().values()) {
                    lastType = type;
                    type.setTypeClass( this.rootClassLoader.loadClass( type.getTypeClassName() ) );
                }
            }
        } catch (ClassNotFoundException e) {
            throw new RuntimeDroolsException( "unable to resolve Type Declaration class '" + lastType.getTypeName() +
                                              "'" );
        }

        // now merge the new package into the existing one
        mergePackage( pkg,
View Full Code Here

    public TypeDeclaration getAndRegisterTypeDeclaration( Class<?> cls, String packageName ) {
        if (cls.isPrimitive() || cls.isArray()) {
            return null;
        }
        TypeDeclaration typeDeclaration = getCachedTypeDeclaration( cls );
        if (typeDeclaration != null) {
            registerTypeDeclaration( packageName, typeDeclaration );
            return typeDeclaration;
        }
        typeDeclaration = getExistingTypeDeclaration( cls );
View Full Code Here

    public TypeDeclaration getTypeDeclaration( Class<?> cls ) {
        if (cls.isPrimitive() || cls.isArray())
            return null;

        // If this class has already been accessed, it'll be in the cache
        TypeDeclaration tdecl = getCachedTypeDeclaration( cls );
        return tdecl != null ? tdecl : createTypeDeclaration( cls );
    }
View Full Code Here

        TypeDeclaration tdecl = getCachedTypeDeclaration( cls );
        return tdecl != null ? tdecl : createTypeDeclaration( cls );
    }

    private TypeDeclaration createTypeDeclaration( Class<?> cls ) {
        TypeDeclaration typeDeclaration = getExistingTypeDeclaration( cls );

        if (typeDeclaration == null) {
            typeDeclaration = createTypeDeclarationForBean( cls );
        }
View Full Code Here

        }
    }

    private TypeDeclaration getExistingTypeDeclaration( Class<?> cls ) {
        // Check if we are in the built-ins
        TypeDeclaration typeDeclaration = this.builtinTypes.get( ( cls.getName() ) );
        if (typeDeclaration == null) {
            // No built-in
            // Check if there is a user specified typedeclr
            PackageRegistry pkgReg = this.pkgRegistryMap.get( ClassUtils.getPackage( cls ) );
            if (pkgReg != null) {
View Full Code Here

        // Iterate and for each typedeclr assign it's value if it's not already set
        // We start from the rear as those are the furthest away classes and interfaces
        TypeDeclaration[] tarray = tdecls.toArray( new TypeDeclaration[tdecls.size()] );
        for (int i = tarray.length - 1; i >= 0; i--) {
            TypeDeclaration currentTDecl = tarray[i];
            if (!isSet( typeDeclaration.getSetMask(),
                        TypeDeclaration.ROLE_BIT ) && isSet( currentTDecl.getSetMask(),
                                                             TypeDeclaration.ROLE_BIT )) {
                typeDeclaration.setRole( currentTDecl.getRole() );
            }
            if (!isSet( typeDeclaration.getSetMask(),
                        TypeDeclaration.FORMAT_BIT ) && isSet( currentTDecl.getSetMask(),
                                                               TypeDeclaration.FORMAT_BIT )) {
                typeDeclaration.setFormat( currentTDecl.getFormat() );
            }
            if (!isSet( typeDeclaration.getSetMask(),
                        TypeDeclaration.TYPESAFE_BIT ) && isSet( currentTDecl.getSetMask(),
                                                                 TypeDeclaration.TYPESAFE_BIT )) {
                typeDeclaration.setTypesafe( currentTDecl.isTypesafe() );
            }
        }

        this.cacheTypes.put( cls.getName(),
                             typeDeclaration );
View Full Code Here

        this.cacheTypes.put( cls.getName(),
                             typeDeclaration );
    }

    private TypeDeclaration createTypeDeclarationForBean( Class<?> cls ) {
        TypeDeclaration typeDeclaration = new TypeDeclaration( cls.getSimpleName() );
        typeDeclaration.setTypeClass( cls );

        PropertySpecificOption propertySpecificOption = configuration.getOption(PropertySpecificOption.class);
        boolean propertyReactive = propertySpecificOption.isPropSpecific(cls.isAnnotationPresent(PropertyReactive.class),
                                                                         cls.isAnnotationPresent(ClassReactive.class));
View Full Code Here

    public boolean buildTypeDeclarationInterfaces( Class cls,
            Set<TypeDeclaration> tdecls ) {
        PackageRegistry pkgReg;

        TypeDeclaration tdecl = this.builtinTypes.get((cls.getName()));
        if (tdecl == null) {
            String pkg = ClassUtils.getPackage( cls );
            pkgReg = this.pkgRegistryMap.get( pkg );
            if (pkgReg != null) {
                tdecl = pkgReg.getPackage().getTypeDeclaration( cls.getName().substring( pkg.length() + 1 ) );
View Full Code Here

        boolean isSuperClassDeclared = true; //in the same package, or in a previous one

        if (pack != null) {

            // look for the supertype declaration in available packages
            TypeDeclaration superTypeDeclaration = pack.getTypeDeclaration( simpleSuperTypeName );

            if (superTypeDeclaration != null) {
                ClassDefinition classDef = superTypeDeclaration.getTypeClassDef();
                // inherit fields
                for (FactField fld : classDef.getFields()) {
                    TypeFieldDescr inheritedFlDescr = buildInheritedFieldDescrFromDefinition( fld, typeDescr );
                    fieldMap.put( inheritedFlDescr.getFieldName(),
                                  inheritedFlDescr );
                }

                // new classes are already distinguished from tagged external classes
                isSuperClassTagged = !superTypeDeclaration.isNovel();
            } else {
                isSuperClassDeclared = false;
            }

        } else {
View Full Code Here

TOP

Related Classes of org.drools.rule.TypeDeclaration

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.