When using Guice, how to restrict clients to getting instances from a specific group of classes (aka the Facebook problem)?
Imagine I architect my system using ports-and-adapters and I have an admin adapter side, a business logic component, and a data-access side used by the business component. How to allow clients only to get instances of the interfaces on the admin adapter side?
In code:
The admin adapter:
public interface Admin { /* ... */ }
class AdminImpl implements Admin {
@Inject
AdminImpl(BusLogic bl) { /* .... */ }
/* ... */
}
The business logic:
public interface BusLogic { /* ... */ }
I would like to make the injector at the app level only return instances of the Admin
interface.
Thanks