private void registerTimer(Invocation invocation) throws RollbackException, SystemException { Timer timer = (Timer) invocation.getArguments()[0]; Transaction transaction = invocation.getTransaction(); if (transaction != null && timer instanceof Synchronization) transaction.registerSynchronization((Synchronization) timer); }
/** Do some validation of the incoming parameters */ protected void validateArguments(Invocation mi) { if (mi.getType() == InvocationType.REMOTE) { Object[] params = mi.getArguments(); for (int i = 0; i < params.length; i++) { Object obj = params[i]; if (obj instanceof TimerHandle) throw new IllegalArgumentException("Cannot pass TimerHandle through remote interface"); } } }
/** * 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 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; }
public Object invoke(Invocation mi) throws Throwable { Method m = mi.getMethod(); String methodName = m.getName(); if (methodName.equals("setAsciiStream") || methodName.equals("setBinaryStream")) { Object[] args = mi.getArguments(); InputStream ins = (InputStream) args[1]; args[1] = new SerializableInputStream(ins); } else if (methodName.equals("setCharacterStream")) { Object[] args = mi.getArguments(); Reader rdr = (Reader) args[1]; args[1] = new SerializableReader(rdr); } return getNext().invoke(mi); } }
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; }
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; }
/** * 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 invoke(Invocation mi) throws Throwable { final Object[] arguments = mi.getArguments(); for (int i = 0; i < arguments.length; i++) { final Object argument = arguments[i]; if(wrapArgument(argument)){ arguments[i] = generateWrapper(argument); } } return getNext().invoke(mi); }
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); ejbObject.remove(); return null; } else throw new RemoveException("EJBHome.remove(Object) not allowed for session beans"); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
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(); }
Object id = mi.getArguments()[0]; if (id == null) throw new IllegalStateException("Cannot get a session interface with a null id");
public Object invokeHome(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EJBContext ctx = null; EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); if( ectx != null ) ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invokeHome(mi.getMethod(), args); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; } } return getNext().invokeHome(mi); }
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); } }
/** This method is for local calls when using pass-by-value*/ protected Object invokeLocalMarshalled(Invocation invocation) throws Exception { IMarshalledValue value = createMarshalledValueForCallByValue(invocation.getArguments()); MarshalledInvocation invocationCopy = createInvocationCopy(invocation, value); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); IMarshalledValue mv = createMarshalledValueForCallByValue(rtnValue); return mv.get(); } catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }