Hi,
I was wondering how an object provided by an Instance<X> could be
disposed through the correct @Disposes method without explicitly
calling that method.
For example:
public class FTPClientProducer {
@Produces
FTPClient newFTPClient() {...}
void closeFTPClient(@Disposes FTPClient ftpClient) {...}
}
@Stateless
public class MyService {
@Inject
Instance<FTPClient> ftpClientProvider;
void doSomething() {
FTPClient ftpClient = ftpClientProvider.get();
try {
...
} finally {
??? (close ftpClient )
}
}
}
Ideally, I would like to replace ??? by something like:
ftpClientProvider.dispose(ftpClient);
Is there something in CDI which provides that kind of feature?
Regards,
Xavier