[rules-dev] Accessing Drools compiled classes

Edson Tirelli tirelli at post.com
Mon Oct 25 15:26:55 EDT 2010


   Not exactly sure how helpful would it be to store the generated
bytecodes in an osgi bundle. Anyway, there is no API right now to do
that, but you can use reflection to achieve the same:

        PackageCompilationData data = pkg.getPackageCompilationData();
        Field field = PackageCompilationData.class.getDeclaredField( "store" );
        field.setAccessible( true );
        Map<String, byte[]> store = (Map<String, byte[]>) field.get( data );

   If you can justify the need for such an API, I guess we could be
convinced to add one.

   Edson




2010/10/25 Guillaume Sauthier <guillaume.sauthier at ow2.org>:
> Hi team
>
> I've tried the IRC (without much success I admit), maybe here someone will
> have some thoughts to share :)
>
> I'm looking for a way to "intercept" the classes being generated by the
> drools compiler.
> I've seen that the classes bytecode is stored deep in
> PackageStore/JavaDialectRuntimeData, so deep that I cannot easily access it
> :)
> The objective is to be able to give theses classes to Bnd (I want to store
> all of that in an OSGi bundle) so that appropriate Import-Packages can be
> computed. That will avoid to have DynamicImport-Packages all around my
> bundles :)
>
> Currently, what I get from the drools compiler is a
> Collection<KnowledgePackage> but I have no API (or didn't find any) to
> access (or know) the classes generated by the compiler.
>
> Any ideas ?
> Thanks
> --Guillaume
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com



More information about the rules-dev mailing list