This task describes how to programmatically retrieve and call the AccessIntent API during the execution of BMP entity bean methods.
InitialContext ic = new InitialContext(); AccessIntentService aiService = ic.lookup("java:comp/websphere/AppProfile/AccessIntentService");
AccessIntent ai = aiService.getAccessIntent (myEntityCtx);
int concurrency = ai.getConcurrencyControl(); int accessType = ai.getAccessType(); if ( (concurrency == AccessIntent.CONCURRENCY_CONTROL_PESSIMISTIC) && (accessType == AccessIntent.ACCESS_TYPE_UPDATE) ) { int exclusive = ai.getPessimisticUpdateLockHint(); // . . . } // . . .For a detailed example of the use of the AccessIntent API, see Example: Using IBM extended APIs to share connections between CMP beans and BMP beans.
Note: The access intent object reference retrieved from
the java:comp lookup is current for the duration of the method in which the
reference was looked up. Depending on how you configured the application profile,
subsequent calls of the same method might not retrieve the same access intent
reference. You can only look up the object reference during the call of a
BMP entity bean's method; the reference does not exist during a request on
a CMP entity bean. Therefore, access intent object references should not be
cached beyond, or used outside of, the scope of the execution of any given
BMP method.