Check Oracle documentation for setEndToEndMetrics for older Versions; for 12c
setClientInfo.
In either case you need a real connection, not the proxy.
The advantage of using this approach compared to a call of DBMS_APPLICATION_INFO is that it needs no roundtrip to the database. The information is transferred and set with the next JDBC call.
UPDATE
A simple example for iBatis follows.
1) You must unwind the connection to get the real Oracle connection
Connection con = unwindConnection(sqlMapClient.getCurrentConnection());
2) define the E2E identifiers - as you correct stated after requesting the connection from pool or event before each action
String[] metrics = new String[OracleConnection.END_TO_END_STATE_INDEX_MAX];
metrics[OracleConnection.END_TO_END_ACTION_INDEX] = 'myAction3';
metrics[OracleConnection.END_TO_END_CLIENTID_INDEX] = 'myClient3';
metrics[OracleConnection.END_TO_END_MODULE_INDEX] = 'myModule3';
con.setEndToEndMetrics(metrics, (short) 0);
3) after the next JDBC roundtrip to DB the identifier are set
select ACTION, CLIENT_IDENTIFIER, MODULE
from v$session where ....
myAction3 myClient3 myModule3