Exercise for the reader

120 views
Skip to first unread message

mottagio

unread,
Oct 31, 2011, 10:34:41 AM10/31/11
to CDI Advocate
From tutorial:
Exercise for the reader. Change the injection point qualifiers to make
only the StandardAtmTransport get injected. Send me your solution on
the CDI group mailing list. Don't get discouraged if you get a stack
trace or two that is part of the learning process. The first one to
send gets put on the CDI wall of fame (everyone else gets an honorable
mention).

My solution:

@Inject @Default @StandardFrameRelaySwitchingFlubber
private ATMTransport transport;

Regards

Luciano Sousa

unread,
Aug 30, 2013, 7:58:30 AM8/30/13
to cdiadv...@googlegroups.com
My solution
---------------------------------------------------------------------------------------------------------------------------------------------------
//@Qualifier
@Stereotype
@Retention(RetentionPolicy.RUNTIME)
@Target({TYPE,METHOD,FIELD,PARAMETER})
@Alternative
public @interface StandardFrameRelaySwitchingFlubber {

}

//@Qualifier
@Stereotype
@Retention(RetentionPolicy.RUNTIME)
@Target({TYPE,METHOD,FIELD,PARAMETER})
@Alternative
public @interface SuperFast {

}

<?xml version="1.0" encoding="UTF-8"?>
    <alternatives>
    <stereotype>org.cdi.advocacy.SuperFast</stereotype>
    <stereotype>org.cdi.advocacy.StandardFrameRelaySwitchingFlubber</stereotype>
    </alternatives>
</beans>

public class AutomatedTellerMachineImpl implements AutomatedTellerMachine {
@Inject
private ATMTransport transport;
...
Reply all
Reply to author
Forward
0 new messages