/** * Throw an IllegalStateException if the current inMethodFlag * does not match the given flags */ public static void assertAllowedIn(String ctxMethod, int flags) { Stack inMethodStack = (Stack)threadLocal.get(); // Strict validation, the caller MUST set the in method flag if (inMethodStack.empty()) { throw new IllegalStateException("Cannot obtain inMethodFlag for: " + ctxMethod); } // The container should push a method flag into the context just before // a call to the instance method if (inMethodStack.empty() == false) { // Check if the given ctxMethod can be called from the ejb instance // this relies on the inMethodFlag being pushed prior to the call to the ejb method Integer inMethodFlag = ((Integer) inMethodStack.peek()); if ((inMethodFlag.intValue() & flags) == 0 && inMethodFlag.intValue() != IN_INTERCEPTOR_METHOD) { String message = ctxMethod + " should not be access from this bean method: " + methodMap.get(inMethodFlag); IllegalStateException ex = new IllegalStateException(message); log.error(message + ", allowed is " + getAllowedMethodList(flags), ex); throw ex; } } }