openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xavier Dury <kal...@hotmail.com>
Subject Instance<X> and @Disposes
Date Mon, 23 Jun 2014 14:25:41 GMT
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 		 	   		  
Mime
View raw message