0 Replies Latest reply on Apr 21, 2011 11:37 AM by mstencel

    Accessing Spring Beans within process definition

    mstencel Newbie

      Are there any solution how to access Spring beans in process definition directly? The goal is to access custom beans in actions or other properties  without any need to map them implicitly for each process instance.

      I tried one solution overriding default global resolver with a kind of Spring based, that searches an identifier in the Spring Context. Then every Spring bean id that is used should be declared as global within the rulebase.




      import org.drools.base.MapGlobalResolver;

      import org.springframework.context.ApplicationContext;


      public class SpringGlobalResolver extends MapGlobalResolver {


          private ApplicationContext ctx;


          public SpringGlobalResolver(ApplicationContext ctx)






          public Object resolveGlobal(String identifier) {


              if ( ctx!=null && ctx.containsBean(identifier))

                  return ctx.getBean(identifier);


              return super.resolveGlobal(identifier);








      And then I registered it to knowledge session by putting to environment map:




                new SpringGlobalResolver(ctx));




      Is this the correct approach or is there another solution? Maybe Spring beans could be exposed and access as parameters e.g.


      And I suppose they shouldn't be persisted.