タイトルは私の問題を説明しています。コンストラクターがクラスを受け入れるGuice `Module`を挿入するには?
など。
public class EntryDAOModule extends AbstractModule {
@Override
protected void configure() {
bind(EntryDAO.class).to(EntryDTOMongoImpl.class); // what should this be?
}
}
示すように、何が.to
へのパラメータである必要があり、以下に挙げる:
EntryDAOMongoImpl
クラスインスタンス化するにはどうすればよい
public class GenericDAOMongoImpl<T, K extends Serializable> extends BasicDAO<T, K> {
public GenericDAOMongoImpl(Class<T> entityClass) throws UnknownHostException {
super(entityClass, ConnectionManager.getDataStore());
}
}
public class EntryDAOMongoImpl extends GenericDAOMongoImpl<EntryDTOMongoImpl, ObjectId> implements EntryDAO<EntryDTOMongoImpl> {
private static final Logger logger = Logger.getLogger(EntryDAOMongoImpl.class);
@Inject
public EntryDAOMongoImpl(Class<EntryDTOMongoImpl> entityClass) throws UnknownHostException {
super(entityClass);
}
...
}
:あなたが行っている何
Injector injector = Guice.createInjector(new EntryDAOModule());
this.entryDAO = injector.getInstance(EntryDAO.class); // what should this be?
あなたはスーパーGenericDAOMongoImplの()コンストラクタにEntryDAOMongImplのコンストラクタからEntryDTOMongoImpl.classを供給しようとしている場合に役立ちます私に教えてください? –
@johncarl - はいごめんなさい - 明確にするために 'GenericDAOMongoImpl'クラスを追加しました。 – wulfgarpro
ああ、私は...その道で答えを見る –