Reputation: 1112
I am working on a hibernate project and I'm moving some logic from a BLL class to a DTO, and I was wondering if it's possible to inject objects into a DTO? The code from the BLL class relied on a lot of imported beans, but when I tried importing them into my DTO object my applicationContext would mess up.
FlightHelper class:
public class FlightHelper {
@Inject
private InjectedClass injectedClass;
public void testMethod(Flight flight) {
...code here
flight.getPrice(injectedClass);
}
}
Flight class:
public class Flight {
public void getPrice(InjectedClass injectedClass) {
...code here
}
}
Upvotes: 0
Views: 60
Reputation: 3525
Yes, you can.
However, the design is not very nice because you have a very strong interaction between Flight and FlightHelper classes.
Upvotes: 1
Reputation: 47290
yes you can, but you might want to instead inject them in the other class aswell.
Upvotes: 0