2 Replies Latest reply on Apr 29, 2014 6:09 AM by jocelyn.duc

    How to register a custom marshalling strategy?

    jocelyn.duc

      Hi everybody,

       

      I know how to create a custom marshalling strategy and use it in a jUnit test. The strategy must be registered to the RuntimeEnvironment, as a new OBJECT_MARHALLING_STRATEGIES.

       

      My goal is to provide a ready-to-install custom jbpm-console. Is there a simple way to add my strategy to the 6.0.1 jbpm-console? A way as simple as I can add custom fields and custom workitemhandlers in the dependencies folder? It seems to not working with marshalling strategies!

       

      Thank you

       

      Jocelyn

        • 1. Re: How to register a custom marshalling strategy?
          swiderski.maciej

          unfortunately there is no easy way to register custom marshaling strategies in console at the moment, in 6.1 it should be made possible via deployment descriptors. For now you should abuse the use of CDI based work item handler producers to grab a session from argument and simply add your strategy into the ksession environment. See docs about WorkItemHandlerProducer (section 5.4.4.2.1) that will be then invoked for every ksession loaded/created.

           

          HTH

          1 of 1 people found this helpful
          • 2. Re: Re: How to register a custom marshalling strategy?
            jocelyn.duc

            Hello,

             

            Here is the workaround I have done to register my custom marshalling strategy to the jbpm-console (6.0.1). It seems to work! But I am not sure if it is necessary to register again the default Serializable strategy

             

            public class EncapsulatedDataWorkItemHandler implements WorkItemHandler {
            
              public EncapsulatedDataWorkItemHandler(KieSession ksession) {
                ObjectMarshallingStrategy[] oms = {
                  new EncapsulatedDataPlaceholderResolverStrategy(EncapsulatedDataObjectMarshallingStrategyAcceptor.DEFAULT),
                  new SerializablePlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT)
                };
            
                Environment env = ksession.getEnvironment();
                env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, oms);
              }
              ...
            }
            

             

            CustomWorkItemHandlers.conf:

             

            [
              "Log": new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler(),
              "WebService": new org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler(ksession),
              "Rest": new org.jbpm.process.workitem.rest.RESTWorkItemHandler(),
              "Service Task" : new org.jbpm.process.workitem.bpmn2.ServiceTaskHandler(ksession),
              "Encapsulated Data" : new my.package.EncapsulatedDataWorkItemHandler(ksession)
            ]
            

             

            HTH