Examples of ClassDefinition


Examples of org.drools.factmodel.ClassDefinition

        Class coreKlass = core.getClass();


        // get the trait classDef
        ClassDefinition tdef = TraitRegistry.getInstance().getTrait( trait.getName() );
        ClassDefinition cdef = TraitRegistry.getInstance().getTraitable( coreKlass.getName() );

        String proxyName = getProxyName( tdef, cdef );
        String wrapperName = getPropertyWrapperName( tdef, cdef );

        ReteooComponentFactory rcf = ruleBase.getConfiguration().getComponentFactory();

//        JavaDialectRuntimeData data = ruleBase.gett
//
//                ((JavaDialectRuntimeData) getPackage( tdef.getDefinedClass().getPackage().getName() ).getDialectRuntimeRegistry().
//                getDialectData( "java" ));



        TraitPropertyWrapperClassBuilder propWrapperBuilder = (TraitPropertyWrapperClassBuilder) rcf.getClassBuilderFactory().getPropertyWrapperBuilder();
//        switch ( mode ) {
//            case TRIPLES    : propWrapperBuilder = new TraitTriplePropertyWrapperClassBuilderImpl();
//                break;
//            case MAP        : propWrapperBuilder = new TraitMapPropertyWrapperClassBuilderImpl();
//                break;
//            default         : throw new RuntimeException( " This should not happen : unexpected property wrapping method " + mode );
//        }
        propWrapperBuilder.init( tdef );
        try {
            byte[] propWrapper = propWrapperBuilder.buildClass( cdef );
            ruleBase.registerAndLoadTypeDefinition( wrapperName, propWrapper );

//            String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( wrapperName );
//            data.putClassDefinition( resourceName, propWrapper );
//            data.write( resourceName, propWrapper );

        } catch (Exception e) {
            e.printStackTrace();
        }


        TraitProxyClassBuilder proxyBuilder = (TraitProxyClassBuilder) rcf.getClassBuilderFactory().getTraitProxyBuilder();
//        switch ( mode ) {
//            case TRIPLES    : proxyBuilder = new TraitTripleProxyClassBuilderImpl();
//                break;
//            case MAP        : proxyBuilder = new TraitMapProxyClassBuilderImpl();
//                break;
//            default         : throw new RuntimeException( " This should not happen : unexpected property wrapping method " + mode );
//        }
        proxyBuilder.init( tdef, rcf.getBaseTraitProxyClass() );
        try {
            byte[] proxy = proxyBuilder.buildClass( cdef );
            ruleBase.registerAndLoadTypeDefinition( proxyName, proxy );

//            String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( proxyName );
//            data.putClassDefinition( resourceName, proxy );
//            data.write( resourceName, proxy );

        } catch (Exception e) {
            e.printStackTrace();
        }

//        data.onBeforeExecute();

        try {
            long mask = TraitRegistry.getInstance().getFieldMask( trait.getName(), cdef.getDefinedClass().getName() );
            Class<T> proxyClass = (Class<T>) ruleBase.getRootClassLoader().loadClass( proxyName, true );
            bindAccessors( proxyClass, tdef, cdef, mask );
            Class<T> wrapperClass = (Class<T>) ruleBase.getRootClassLoader().loadClass( wrapperName, true );
            bindCoreAccessors( wrapperClass, cdef );
            return proxyClass;
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        }

        File smaliFile = fileNameHandler.getUniqueFilenameForClass(classDescriptor);

        //create and initialize the top level string template
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);

        //write the disassembly
        Writer writer = null;
        try
        {
            File smaliParent = smaliFile.getParentFile();
            if (!smaliParent.exists()) {
                if (!smaliParent.mkdirs()) {
                    // check again, it's likely it was created in a different thread
                    if (!smaliParent.exists()) {
                        System.err.println("Unable to create directory " + smaliParent.toString() + " - skipping class");
                        return false;
                    }
                }
            }

            if (!smaliFile.exists()){
                if (!smaliFile.createNewFile()) {
                    System.err.println("Unable to create file " + smaliFile.toString() + " - skipping class");
                    return false;
                }
            }

            BufferedWriter bufWriter = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(smaliFile), "UTF8"));

            writer = new IndentingWriter(bufWriter);
            classDefinition.writeTo((IndentingWriter)writer);
        } catch (Exception ex) {
            System.err.println("\n\nError occurred while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class");
            ex.printStackTrace();
            // noinspection ResultOfMethodCallIgnored
            smaliFile.delete();
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        options.useImplicitReferences = false;

        for (ClassDef classDef: dexFile.getClasses()) {
            StringWriter stringWriter = new StringWriter();
            IndentingWriter writer = new IndentingWriter(stringWriter);
            ClassDefinition classDefinition = new ClassDefinition(options, classDef);
            classDefinition.writeTo(writer);
            writer.close();

            String className = classDef.getType();
            String smaliPath = String.format("%s%s%s.smali", test, File.separatorChar,
                    className.substring(1, className.length() - 1));
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = false;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = false;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = false;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
View Full Code Here

Examples of org.jf.baksmali.Adaptors.ClassDefinition

        baksmaliOptions options = new baksmaliOptions();
        options.useImplicitReferences = true;

        StringWriter stringWriter = new StringWriter();
        IndentingWriter writer = new IndentingWriter(stringWriter);
        ClassDefinition classDefinition = new ClassDefinition(options, classDef);
        classDefinition.writeTo(writer);
        writer.close();

        Assert.assertEquals(TextUtils.normalizeWhitespace(expected),
                TextUtils.normalizeWhitespace(stringWriter.toString()));
    }
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.