You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Marco Corona <ma...@concensus.com> on 2013/05/30 18:11:47 UTC
Global Alternatives
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
Re: Global Alternatives
Posted by Marco Corona <ma...@concensus.com>.
Thank you for your responses, as it turns out I write my own little hack
for this situation to work. Thank you!
On Thu, Jun 6, 2013 at 2:12 AM, Mark Struberg <st...@yahoo.de> wrote:
> 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 <ma...@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 <co...@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
> >> <ma...@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
> >> >
> >>
> >
>
Re: Global Alternatives
Posted by Mark Struberg <st...@yahoo.de>.
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 <ma...@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 <co...@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
>> <ma...@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
>> >
>>
>
Re: Global Alternatives
Posted by Marco Corona <ma...@concensus.com>.
Thank 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 <co...@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
> <ma...@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
> >
>
Re: Global Alternatives
Posted by Cody Lerum <co...@gmail.com>.
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
<ma...@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
>