We use Cassandra (and the DataStax driver) to store our entities. As such we have a custom entity service that creates new instances of our entity classes when it retrieves data from Cassandra.
I also need to inject services into my entity classes using CDI. How do I do this? When I simply at the @Inject annotation, it never gets injected.
public class Customer{ @Inject private Event<DeactivationEvent> events; private String uid; public void setUid(String uid){ this.uid = uid; } public String getUid(){ return this.uid; } public void deactivate(){ events.fire( new DeactivationEvent() ); } } public CassandraEntityService{ public Customer findCustomer(String uid){ ...whatever lookup logic... Customer customer = new Customer(); customer.setUid(..) customer.set... return customer; } }
Thanks.