Package org.drools.core.rule

Examples of org.drools.core.rule.TypeDeclaration$TimestampAccessorSetter


                        // add type declarations
                        for ( TypeDeclaration newDecl : newPkg.getTypeDeclarations().values() ) {
                            lastType = newDecl.getTypeClassName();


                            TypeDeclaration typeDeclaration = this.classTypeDeclaration.get( newDecl.getTypeClassName() );
                            if ( typeDeclaration == null ) {
                                String className = newDecl.getTypeClassName();

                                byte [] def = runtime.getClassDefinition(JavaDialectRuntimeData.convertClassToResourcePath(className));
                                Class<?> definedKlass = registerAndLoadTypeDefinition( className, def );

                                if ( definedKlass == null && typeDeclaration.isNovel() ) {
                                    throw new RuntimeException( "Registering null bytes for class " + className );
                                }

                                if (newDecl.getTypeClassDef() == null) {
                                    newDecl.setTypeClassDef( new ClassDefinition() );
                                }
                                newDecl.getTypeClassDef().setDefinedClass( definedKlass );
                                newDecl.setTypeClass( definedKlass );

                                this.classTypeDeclaration.put( className, newDecl );
                                typeDeclaration = newDecl;
                            } else {
                                Class<?> definedKlass = typeDeclaration.getTypeClass();

                                newDecl.getTypeClassDef().setDefinedClass( definedKlass );
                                newDecl.setTypeClass( definedKlass );

                                mergeTypeDeclarations( typeDeclaration,
View Full Code Here


        public TypeDeclaration candidate = null;
        public int             score     = Integer.MAX_VALUE;
    }

    public TypeDeclaration getTypeDeclaration( Class<?> clazz ) {
        TypeDeclaration typeDeclaration = this.classTypeDeclaration.get( clazz.getName() );
        if (typeDeclaration == null) {
            // check super classes and keep a score of how up in the hierarchy is there a declaration
            TypeDeclarationCandidate candidate = checkSuperClasses( clazz );
            // now check interfaces
            candidate = checkInterfaces( clazz,
View Full Code Here

        return typeDeclaration;
    }

    private TypeDeclarationCandidate checkSuperClasses( Class<?> clazz ) {

        TypeDeclaration typeDeclaration = null;
        Class<?> current = clazz.getSuperclass();
        int score = 0;
        while ( typeDeclaration == null && current != null ) {
            score++;
            typeDeclaration = this.classTypeDeclaration.get( current.getName() );
View Full Code Here

                                                      TypeDeclarationCandidate baseline,
                                                      int level ) {
        TypeDeclarationCandidate candidate = null;
        if (baseline == null || level < baseline.score) {
            // search
            TypeDeclaration typeDeclaration;
            for (Class<?> ifc : clazz.getInterfaces()) {
                typeDeclaration = this.classTypeDeclaration.get( ifc.getName() );
                if (typeDeclaration != null) {
                    candidate = new TypeDeclarationCandidate();
                    candidate.candidate = typeDeclaration;
View Full Code Here

    private List<String> getSettableProperties(InternalWorkingMemory workingMemory, Class<?> classType, String pkgName) {
        if ( pkgName.equals( "java.lang" ) || pkgName.equals( "java.util" ) ) {
            return Collections.EMPTY_LIST;
        }
        Package pkg = workingMemory.getRuleBase().getPackage( pkgName );
        TypeDeclaration tdecl =  pkg != null ? pkg.getTypeDeclaration( classType ) : null;
        return tdecl != null ? tdecl.getSettableProperties() : Collections.EMPTY_LIST;
    }
View Full Code Here

    }

    protected  <K> ClassDefinition lookupClassDefinition( K core ) {
        Package pack = this.getWorkingMemory().getRuleBase().getPackage( core.getClass().getPackage().getName() );
        if ( pack != null ) {
            TypeDeclaration decl = pack.getTypeDeclaration( core.getClass() );
            if ( decl != null ) {
                return decl.getTypeClassDef();
            }
        }
        return null;
    }
View Full Code Here

        //'duration' field must still be there
        field = factType.getField("duration");
        assertNotNull( field );

        //New Annotations must be there too
        TypeDeclaration typeDeclaration = ((KnowledgePackageImpl)kbuilder.getKnowledgePackages().iterator().next()).getTypeDeclaration("EventA");

        assertEquals(TypeDeclaration.Role.EVENT, typeDeclaration.getRole());
        assertEquals("duration", typeDeclaration.getDurationAttribute());

    }
View Full Code Here

                        // add type declarations
                        for ( TypeDeclaration newDecl : newPkg.getTypeDeclarations().values() ) {
                            lastType = newDecl.getTypeClassName();


                            TypeDeclaration typeDeclaration = this.classTypeDeclaration.get( newDecl.getTypeClassName() );
                            if ( typeDeclaration == null ) {
                                String className = newDecl.getTypeClassName();

                                byte [] def = runtime.getClassDefinition(convertClassToResourcePath(className));
                                Class<?> definedKlass = registerAndLoadTypeDefinition( className, def );

                                if ( definedKlass == null && typeDeclaration.isNovel() ) {
                                    throw new RuntimeException( "Registering null bytes for class " + className );
                                }

                                if (newDecl.getTypeClassDef() == null) {
                                    newDecl.setTypeClassDef( new ClassDefinition() );
                                }
                                newDecl.getTypeClassDef().setDefinedClass( definedKlass );
                                newDecl.setTypeClass( definedKlass );

                                this.classTypeDeclaration.put( className, newDecl );
                                typeDeclaration = newDecl;
                            } else {
                                Class<?> definedKlass = typeDeclaration.getTypeClass();

                                newDecl.getTypeClassDef().setDefinedClass( definedKlass );
                                newDecl.setTypeClass( definedKlass );

                                mergeTypeDeclarations( typeDeclaration,
View Full Code Here

        public TypeDeclaration candidate = null;
        public int             score     = Integer.MAX_VALUE;
    }

    public TypeDeclaration getTypeDeclaration( Class<?> clazz ) {
        TypeDeclaration typeDeclaration = this.classTypeDeclaration.get( clazz.getName() );
        if (typeDeclaration == null) {
            // check super classes and keep a score of how up in the hierarchy is there a declaration
            TypeDeclarationCandidate candidate = checkSuperClasses( clazz );
            // now check interfaces
            candidate = checkInterfaces( clazz,
View Full Code Here

        return typeDeclaration;
    }

    private TypeDeclarationCandidate checkSuperClasses( Class<?> clazz ) {

        TypeDeclaration typeDeclaration = null;
        Class<?> current = clazz.getSuperclass();
        int score = 0;
        while ( typeDeclaration == null && current != null ) {
            score++;
            typeDeclaration = this.classTypeDeclaration.get( current.getName() );
View Full Code Here

TOP

Related Classes of org.drools.core.rule.TypeDeclaration$TimestampAccessorSetter

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.