/** Invoke the Object.method() called through FlashRemoting */ public Object invoke(Message message) { Object results = null; if (message instanceof RemotingMessage) { // RemotingDestinationControl remotingDestination = // (RemotingDestinationControl)this.getControl().getParentControl();//destination; RemotingMessage remotingMessage = (RemotingMessage) message; // re-map our special "loadDpProxy" to the user defined hibernate // load method. if ("loadDPProxy".equals(remotingMessage.getOperation())) { try { remotingMessage.setOperation(getLoadMethodName()); List paramArray = remotingMessage.getParameters(); List args = new ArrayList(); args.add(Class.forName(paramArray.get(1).getClass().getName())); args.add(paramArray.get(0)); remotingMessage.setParameters(args); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } } /* * // Add support for the source="" attribute of the RemoteObject * tag. This give developer the option // of using a single * destination for all java calls, and defining the java class in * their mxml // note: This can be turned off at the desination * level by defined a <source/> other then "*" try { FactoryInstance * factoryInstance = remotingDestination.getFactoryInstance(); * String className = factoryInstance.getSource(); * // check for * wildcard in destination, and if exists use source * defined in mxml if( "*".equals(className) ) { sourceClass = * remotingMessage.getSource(); * factoryInstance.setSource(sourceClass); } }catch( Throwable ex ){ * ex.printStackTrace();} */ System.out.println("{operation})****************" + remotingMessage.getOperation()); // Deserialize the incoming object data List inArgs = remotingMessage.getParameters(); if (inArgs != null && inArgs.size() > 0) { try { long s1 = new Date().getTime(); Object o = SerializationFactory.getDeserializer(SerializationFactory.HIBERNATESERIALIZER) .translate( this, (RemotingMessage) remotingMessage.clone(), getLoadMethodName(), property_hibernateSessionFactoryClass, property_getCurrentSessionMethod, inArgs); remotingMessage.setParameters((List) o); long e1 = new Date().getTime(); System.out.println("{deserialize} " + (e1 - s1)); // remotingMessage.setBody(body); } catch (Exception ex) { ex.printStackTrace(); // throw error back to flex // todo: replace with custom exception RuntimeException re = new RuntimeException(ex.getMessage()); re.setStackTrace(ex.getStackTrace()); throw re; } } long s2 = new Date().getTime(); // invoke the user class.method() results = super.invoke(remotingMessage); long e2 = new Date().getTime(); System.out.println("{invoke} " + (e2 - s2)); // serialize the result out try { long s3 = new Date().getTime(); results = SerializationFactory.getSerializer(SerializationFactory.HIBERNATESERIALIZER) .translate( property_hibernateSessionFactoryClass, property_getCurrentSessionMethod, results); long e3 = new Date().getTime(); System.out.println("{serialize} " + (e3 - s3)); } catch (Exception ex) { ex.printStackTrace(); // throw error back to flex // todo: replace with custom exception RuntimeException re = new RuntimeException(ex.getMessage()); re.setStackTrace(ex.getStackTrace()); throw re; } } return results; }