Implementing a ChoiceStrategy

23 views
Skip to first unread message

Marcus

unread,
Sep 8, 2009, 8:45:11 PM9/8/09
to legstar-user
We are experiencing a problem with the default ChoiceBinding
behaviour. From the code, I see that we can implement a
ICobolUnmarshalChoiceStrategy to control the ChoiceBinding logic.
However, I'm not sure what of the best way to inject this Strategy
into the Binding.

I've hacked together the following code:

PhxerrRecTransformers transformers = new PhxerrRecTransformers();
PhxerrRecHostToJavaTransformer hostToJava =
(PhxerrRecHostToJavaTransformer) transformers.getHostToJava();
PhxerrRecBinding binding = (PhxerrRecBinding)
hostToJava.getCachedBinding();
binding._phxerrHeaderChoice.setUnmarshalChoiceStrategyClassName
("au.com.zurich.phoenix.polisy.batch.util.PhxerrRecChoiceStrategy");

Can you provide a code example of the best practice to implement a
ChoiceStrategy?

Thanks in advance,
Mark

Fady Moussallam

unread,
Sep 9, 2009, 2:35:27 AM9/9/09
to legsta...@googlegroups.com
Hello Marcus,

The topic deserves an entire wiki page. I will work on that.

In the meanwhile, there are test cases in the code base that might help you:

Step 1: Edit the XSD to add the unmarshalChoiceStrategyClassName
attribute: Example:
http://code.google.com/p/legstar/source/browse/trunk/legstar-schemagen/src/test/schema/redsimpt.xsd.

Step 2: Bind the edited XSD normally. The
unmarshalChoiceStrategyClassName attribute is propagated on the JAXB
class and the binding class now expect to corresponding
unmarshalChoiceStrategyClassName value to be available from the classpath.

Step 3: Write the strategy class. Several examples are available at
http://code.google.com/p/legstar/source/browse/trunk/#trunk/legstar-coxbrt/src/test/cust/java/com/legstar/coxb/cust

Let me know how it goes.

Fady

Reply all
Reply to author
Forward
0 new messages