protected boolean isCallAllowed(Invocation mi) { Method m = mi.getMethod(); if (m.equals(getEJBHome) || m.equals(getHandle) || m.equals(getPrimaryKey) || m.equals(isIdentical) || m.equals(remove)) { return true; } return false; }
/** See if the given exception e is compatible with an exception declared as thrown by the invocation method. @param invocation - the current invocation @param e - the exception thrown by the invocation @return true if e is a declared exception, false otherwise */ public boolean isAppException(Invocation invocation, Throwable e) { Method m = invocation.getMethod(); Class[] exceptions = m.getExceptionTypes(); boolean isAppException = false; for(int n = 0; isAppException == false && n < exceptions.length; n ++) { Class exType = exceptions[n]; isAppException = exType.isInstance(e); } return isAppException; }
public Object invoke(Invocation invocation) throws Throwable { // Is this create()? boolean create = invocation.getMethod().getName().equals("create"); // Do we have a cached version? if (create && cached != null) return cached; // Not a cached create Object result = super.invoke(invocation); // We now have something to cache if (create) cached = result; return result; } }
public Object invoke(Invocation mi) throws Exception { final boolean remoteInvocation = mi instanceof MarshalledInvocation; if(remoteInvocation) { ((MarshalledInvocation)mi).setMethodMap(methodMap); } final Object result; if(invokeTargetMethod) { String signature[] = (String[])signatureMap.get(mi.getMethod()); result = server.invoke(targetName, mi.getMethod().getName(), mi.getArguments(), signature); } else { result = server.invoke(targetName, "invoke", new Object[]{mi}, Invocation.INVOKE_SIGNATURE); } return result; }
/** * Return any target object name relevent for this invocation.<p> * * Methods that don't pass arguments that could be custom classes are ignored.<p> * * Classloading and registerMBean are ignored, * they shouldn't be available remotely */ public ObjectName getObjectNameFromArguments(Invocation invocation) { String method = invocation.getMethod().getName(); if (method.equals("invoke") || method.equals("setAttribute") || method.equals("setAttributes") || method.equals("addNotificationListener") || method.equals("removeNotificationListener")) { return (ObjectName) invocation.getArguments()[0]; } return null; }
public Object invokeHome(Invocation mi) throws Exception { long begin = System.currentTimeMillis(); try { return super.invokeHome(mi); } finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } } }
public Object invoke(Invocation mi) throws Exception { long begin = System.currentTimeMillis(); try { return super.invoke(mi); } finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } } }
public MarshalledInvocation(Invocation invocation) { this.payload = invocation.payload; this.as_is_payload = invocation.as_is_payload; this.method = invocation.getMethod(); this.objectName = invocation.getObjectName(); this.args = invocation.getArguments(); this.invocationType = invocation.getType(); this.transient_payload = invocation.transient_payload; this.invocationContext = invocation.invocationContext; }
private int startTransaction(final Invocation invocation) throws Exception { // Get the old timeout and set any new timeout int oldTimeout = -1; if (tm instanceof TransactionTimeoutConfiguration) { oldTimeout = ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); int newTimeout = container.getBeanMetaData().getTransactionTimeout(invocation.getMethod()); tm.setTransactionTimeout(newTimeout); } tm.begin(); return oldTimeout; }
public Object invoke(Invocation invocation) throws Exception { Object result = null; if(invocation instanceof MarshalledInvocation){ MarshalledInvocation mi = (MarshalledInvocation)invocation; mi.setMethodMap(marshalledInvocationMapping); } final Method targetMethod = invocation.getMethod(); final Class targetClass = targetMethod.getDeclaringClass(); final Object[] targetArguments = invocation.getArguments(); final Object retVal = internalInvoke(targetClass, targetMethod, targetArguments, invocation.getId()); if(!(retVal instanceof Serializable) && retVal != null){ log.debug("Creating proxy for instance " + retVal); result = createProxy(retVal); } return result; }
private boolean shouldBypassSecurity(Invocation mi) throws Exception { // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), "BYPASSED-SECURITY"); if (this.runAsIdentity != null) SecurityActions.pushRunAsIdentity(runAsIdentity); return true; } return false; }
/** * Delegates to the persistence manager postCreateEntityMethod. */ public void postCreateHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
public EJBLocalObject createLocalHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBLocalObject(); }
public EJBObject createHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBObject(); }
/** * Delegates to the persistence manager postCreateEntityMethod. */ public void postCreateLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
public Object invokeHome(Invocation mi) throws Exception { Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } try { return mi.performCall(StatelessSessionContainer.this, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
/** * Local home interface implementation */ public EJBLocalObject createLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBLocalObject final EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().createEntity(mi.getMethod(), mi.getArguments(), ctx); // The context implicitely carries the EJBObject createCount++; return localProxyFactory.getEntityEJBLocalObject(ctx.getId(), true); }
/** * This method takes care of the wiring of the "EJBObject" trio * (target, context, proxy). It delegates to the persistence manager. */ public EJBObject createHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBObject getPersistenceManager().createEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); // The context implicitely carries the EJBObject createCount++; return ((EntityEnterpriseContext)mi.getEnterpriseContext()).getEJBObject(); }
protected boolean changed (org.jboss.invocation.Invocation mi, org.jboss.ejb.EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() == null) return true; if(!container.isReadOnly()) { java.lang.reflect.Method method = mi.getMethod(); if(method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { return invalidateRelated ? container.getPersistenceManager().isModified(ctx) : container.getPersistenceManager().isStoreRequired(ctx); } } return false; }
public Object invoke(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); Object bean = ectx.getInstance(); EJBContext ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invoke(mi.getMethod(), args, bean); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; } } return getNext().invoke(mi); } }