> From: Peter Donald [mailto:[EMAIL PROTECTED]]
>
> Same way as you deal with all resources. ie call close(),
> release() etc.
So can I assume that every component, or every XXXXManager
has a close() or release() method?
Is this how you intend it to work:
/**
* The ConnectionManager does not define
* a release() method, as you call close()
* on the connection instead.
*/
interface ConnectionManager {
public static final String ROLE = "...";
Connection getConnection ();
}
interface Connection {
void doSomething ();
void close ();
}
/**
* The OtherManager *must* define a release() method,
* as the Other interface provides no way for the client to
* indicate that it is finished using the Other instance.
*/
interface OtherManager {
public static final String ROLE = "...";
Other getInstance ();
void release (Other other);
}
/**
* This interface does not specify any way for the client to
* indicate that the instance can be put back into a pool.
*/
interface Other {
/**
* May be called any number of times in a transaction.
*/
void doSomething();
}
class MyComposer implements Composable {
private ConnectionManager connectionManager;
private OtherManager otherManager;
public void compose(ComponentManager manager) {
connectionManager = (ConnectionManager) manager.lookup
(ConnectionManager.ROLE);
otherManager = (OtherManager) manager.lookup (OtherManager.ROLE);
}
public void doWork () {
Connection conn = null;
Other other = null;
try {
conn = connectionManager.getConnection ();
other = otherManager.getInstance ();
conn.doSomething ();
other.doSomething ();
} catch (Exception e) {
} finally {
if (conn != null) conn.close ();
otherManager.release (other);
}
}
}
Basically, the contract is:
"Every pair of component C and its associated CManager interfaces
must define a method that, when called by the client, indicates
that the client is finished using the component C. The method
may be in the CManager interface - for example,
CManager.release (C c) - or in the C interface - for example,
C.close (). Note that this contract applies to component
*interfaces*.
even if the implementation does not require an end-of-transaction
signal from the client, the method must be specified so
implementations
that do require such a signal can recieve them."
How about that?
> The Connector API aims to standardize heavy
> resource management in J2EE
> land and JDBC will implement it in the future (unless JDK1.4
> version does?)
> and most vendors will use that API.
And what does that have to do with this? The Connector API is about
connecting different systems, not about the presense of a way to
explicitly release resources. I do note, however, that many interfaces
specify a close() method or other way of releasing resources.
/LS
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>