deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: Global Alternatives
Date Thu, 06 Jun 2013 06:12:02 GMT
Hi Marco!

The globalAlternatives is a neat hack to work around parts of the BDA troubles in CDI-1.0
[1].
Unfortunately I fear it is quite some work to make it working for multiple arbitrary qualifiers
on the same interface.

A possible alternative way to solve your problem would be to use @Specializes in your case.
I guess you have 2 base implementations, thus you can do

@Specializes
public class MyImpl1 extends BaseImpl1 {


and the same for the 2nd class

The downside is that you need to have the original classes in the compile classpath. But this
will really work on any container.


LieGrue,
strub



[1] https://issues.jboss.org/browse/CDI-18



----- Original Message -----
> From: Marco Corona <marco.corona@concensus.com>
> To: users@deltaspike.apache.org
> Cc: 
> Sent: Wednesday, 5 June 2013, 17:29
> Subject: Re: Global Alternatives
> 
>T hank you for your response, I successfully got the globalAlternatives to
> work, except one issue. I have an interface and two default
> implementations. Both implementations are active because of a qualifier
> because of an enum value.
> 
> @MyQualifier(MyEnum.PROP1)
> class MyImpl1 implements MyInterface{
> ...
> }
> @MyQualifier(MyEnum.PROP2)
> class MyImpl2 implements MyInterface{
> ...
> }
> 
> Now I need to replace both of these implementations, but filling the
> apache-deltaspike.properties with the following:
> 
> globalAlternatives.com.example.MyInterface=com.example.OtherImpl1
> globalAlternatives.com.example.MyInterface=com.example.OtherImpl2
> 
> doesn't work because com.example.MyInterface is the key so it is only
> activating one of the lines.
> Do you think it is possible to do what I am trying to achieve? If so, can
> you lend some advice?
> Thank you
> 
> 
> On Thu, May 30, 2013 at 2:52 PM, Cody Lerum <cody.lerum@gmail.com> wrote:
> 
>>  If this is in 0.4 then an example for enabling the
>>  BeanManagedUserTransactionStrategy
>>  for Transaction support would be
>> 
>>  /src/main/resources/META-INF/apache-deltaspike.properties
>> 
>>  contents are
>> 
>> 
>> 
> globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy=org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy
>> 
>>  The prefix of "globalAlternatives." is required in 0.4
>> 
>>  The location as built in my war it ends up @
>> 
>> 
> myApp.war\WEB-INF\classes\META-INF\apache-deltaspike.properties
>> 
>> 
>> 
>>  On Thu, May 30, 2013 at 10:11 AM, Marco Corona
>>  <marco.corona@concensus.com>wrote:
>> 
>>  > Hello,
>>  > I have been trying to figure out how enable global alternatives, yet I
>>  > can't seem to find much documentation on the issue at all. Can 
> anyone
>>  point
>>  > me in the right direction or even give me an example?
>>  > Thank you,
>>  > Marco Corona
>>  >
>> 
> 

Mime
View raw message