This content has been marked as final.
Show 2 replies
-
1. Re: How do you inject diferent implementations in Seam?
bravocharlie.seam.signup.benny.me.uk Jun 6, 2008 4:02 PM (in response to joaobmonteiro)How about
@Name("incidenteServiceDdsi") public class IncidenteServiceDdsiImpl implements IncidenteService { } @Name("incidenteServiceXyz") public class IncidenteServiceXyzImpl implements IncidenteService { } @Name("incidenteService") public class IncidenteServiceManager { @In UserProfile userProfile @Unwrap public IncidenteService getIncidenteService(){ if (userProfile.getType() == ...){ return Component.getInstance("incidenteServiceDdsi"); } else { ... } } }
-
2. Re: How do you inject diferent implementations in Seam?
joaobmonteiro Jun 6, 2008 4:44 PM (in response to joaobmonteiro)Hi Ben,
Thanks for this sweet solution! I was not aware of using @Unwrap.
Looking further in documentation, I wonder if I could use
@Factory('incidenteService') in somewhere like this:
@Name("serviceFactory") public class ServiceFactory { @Factory("incidenteService") public IncidenteService getIncidenteService(){ //some business logic to decide //which implementation } }
I will try both approaches.
Thanks again!