Choosing a @Produces method for CDI when more than one are available

Evan Knowles

Basically, I need a way to disable one (framework supplied) @Produces method in favour of using my own @Produces method.

More specifically, I'm working with jBPM 6 and attempting to get it working correctly inside a container. The HumanTaskServiceProducer uses the drool's EnvironmentFactory, which always generates a new Environment. The code for caching the Environment in that EnvironmentFactory is commented out for some reason.

This means that jBPM picks up the JTA transaction manager rather than the Container transaction manager. I'm trying to supply my own producer for the task service that correctly sets the environment instead of using the default one.

Does anyone know of a way to specify a producer to use? In hope I tried specifying it as an @Alternative, but that doesn't seem to have worked. Either that, or a way to specify the environment on the HumanTaskServiceProducer.

Antoine Sabot-Durand

If you use CDI 1.0, alternatives don't work across different bean archives.

Otherwise (in CDI 1.1+) be careful to activate your alternative as specified here.

The best solution for you is probably to specialize your producer. You'll have to:

  • inherit the class containing the original producer method,
  • override the producer method and
  • annotated it with @Specializes.

You'll find all the info on producer specialization in the spec.

If you can't use specialization, your last solution is to create a portable extension that exclude the class containing the original producer from bean discovery (create a observer on ProcessAnnotatedType event and call the veto() method on the event) so your producer will not be in conflict with the original one.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL foreign key choosing more than one option

From Dev

Query produces no records for a field when adding more than one condition to JOIN or WHERE clause

From Dev

What is the precedence when more than one method overload matches?

From Dev

Rails delegate method with more than one association

From Dev

Can method return more than one type

From Dev

Mockery Doctrine / Repository with more than one method

From Dev

Can a method return more than one value?

From Dev

method to return more than one array

From Dev

java : Why the thread priority is not followed when there are more than one print statements in run method?

From Dev

Can there be more than one template method in an implementation of the Template Method pattern?

From Dev

More than one HttpPost Method in one Controller not working in Web Api

From Dev

How to disable more than one NumericUpDown controls using one method?

From Java

Is there a way I can return more than one integer from a method?

From Dev

jQuery syntax - use more than one find method?

From Dev

Capitalizing more than one attribute in a Rails before_save method

From Dev

Returning more than one value from a method in c#

From Dev

More than one method with the same parameter types in a class

From Dev

How to return more than one value in a Thrift service method?

From Dev

ActiveRecord - "first" method in "scope" returns more than one record

From Dev

returning more than one method on submit html form

From Dev

presentation compiler: type completion in method call with more than one argument

From Dev

Using more than one delimiter for .split method in Ruby

From Dev

How can I return from a method more than one variable?

From Dev

Java 8 Method Reference more than one different constructors

From Dev

groupby.apply method taking more than one arguments

From Dev

Mock a method that returns a Stream and is called more than one time

From Dev

Can I add more than one override method in a constructor in Java?

From Dev

Is it possible to have more than one main() method in a C# program?

From Dev

controller action contains more than one model method call?

Related Related

  1. 1

    MySQL foreign key choosing more than one option

  2. 2

    Query produces no records for a field when adding more than one condition to JOIN or WHERE clause

  3. 3

    What is the precedence when more than one method overload matches?

  4. 4

    Rails delegate method with more than one association

  5. 5

    Can method return more than one type

  6. 6

    Mockery Doctrine / Repository with more than one method

  7. 7

    Can a method return more than one value?

  8. 8

    method to return more than one array

  9. 9

    java : Why the thread priority is not followed when there are more than one print statements in run method?

  10. 10

    Can there be more than one template method in an implementation of the Template Method pattern?

  11. 11

    More than one HttpPost Method in one Controller not working in Web Api

  12. 12

    How to disable more than one NumericUpDown controls using one method?

  13. 13

    Is there a way I can return more than one integer from a method?

  14. 14

    jQuery syntax - use more than one find method?

  15. 15

    Capitalizing more than one attribute in a Rails before_save method

  16. 16

    Returning more than one value from a method in c#

  17. 17

    More than one method with the same parameter types in a class

  18. 18

    How to return more than one value in a Thrift service method?

  19. 19

    ActiveRecord - "first" method in "scope" returns more than one record

  20. 20

    returning more than one method on submit html form

  21. 21

    presentation compiler: type completion in method call with more than one argument

  22. 22

    Using more than one delimiter for .split method in Ruby

  23. 23

    How can I return from a method more than one variable?

  24. 24

    Java 8 Method Reference more than one different constructors

  25. 25

    groupby.apply method taking more than one arguments

  26. 26

    Mock a method that returns a Stream and is called more than one time

  27. 27

    Can I add more than one override method in a constructor in Java?

  28. 28

    Is it possible to have more than one main() method in a C# program?

  29. 29

    controller action contains more than one model method call?

HotTag

Archive