Examples of InvocationResponse


Examples of org.jboss.aop.joinpoint.InvocationResponse

            // Create a new EJB2.x Proxy
            proxy = (EJBObject) proxyFactory.createProxyEjb2x((Serializable) newStatefulInvocation.getId());
         }

         StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
         InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
         return response;
      }

      // SFSB remove()
      else if (unadvisedMethod.getName().equals(Ejb2xMethodNames.METHOD_NAME_HOME_REMOVE))
      {
         try
         {
            // Attempt to remove the bean
            destroySession(statefulInvocation.getId());
         }
         catch (NoSuchEJBException e)
         {
            String invokingClassName = method.getActualClassName();
            Throwable newException = this.constructProperNoSuchEjbException(e, invokingClassName);
            throw newException;
         }

         InvocationResponse response = new InvocationResponse(null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("getEJBHome"))
      {
         EJBHome ejbHome;
         if(CurrentRemoteProxyFactory.isSet())
         {
            ejbHome = CurrentRemoteProxyFactory.get(EJB2RemoteProxyFactory.class).createHome();
         }
         else
         {
            HomeHandleImpl homeHandle = null;
  
            RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
            if (remoteBindingAnnotation != null)
               homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
  
            ejbHome = homeHandle.getEJBHome();
         }

         InvocationResponse response = marshallResponse(statefulInvocation, ejbHome, null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
      {
         Object id = statefulInvocation.getId();

         InvocationResponse response = marshallResponse(statefulInvocation, id, null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("isIdentical"))
      {
         Object id = statefulInvocation.getId();
         EJBObject bean = (EJBObject) statefulInvocation.getArguments()[0];

         Object primaryKey = bean.getPrimaryKey();

         boolean isIdentical = id.equals(primaryKey);

         InvocationResponse response = marshallResponse(statefulInvocation, isIdentical, null);
         return response;
      }
      else
      {
         return null;
View Full Code Here

Examples of org.jboss.aop.joinpoint.InvocationResponse

            // pass the control to the simple singleton container
            Object result = this.delegate.invoke(containerInvocation);
  
            // create an InvocationResponse out of the result
            Map<Object, Object> responseContextInfo = containerInvocation.getResponseContextInfo();
            InvocationResponse invocationResponse = marshallResponse(invocation, result, responseContextInfo);
            return invocationResponse;
  
         }
         catch (Throwable throwable)
         {
View Full Code Here

Examples of org.jboss.aop.joinpoint.InvocationResponse

         }
         catch (Throwable throwable)
         {
            return marshallException(invocation, throwable, newSi.getResponseContextInfo());
         }
         InvocationResponse response = SessionContainer.marshallResponse(invocation, rtn, newSi
               .getResponseContextInfo());

         return response;
      }
      finally
View Full Code Here

Examples of org.jboss.aop.joinpoint.InvocationResponse

      // Create a pointer to a new Invocation
      StatefulContainerInvocation newSi = null;

      // Create a pointer to the response we'll return
      InvocationResponse response = null;

      // Create a pointer to the Session ID
      Serializable sessionId = null;

      /*
       * Setup Environment (Stack/Thread)
       */

      // Hold a reference to the existing TCL
      ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();

      // Set the Container's CL as TCL, required to unmarshall methods from the bean impl class
      Thread.currentThread().setContextClassLoader(this.getClassloader());

      try
      {

         /*
          * Obtain the target method (unmarshall from invocation)
          */

         // Cast
         assert invocation instanceof StatefulRemoteInvocation : SessionContainer.class.getName()
               + ".dynamicInoke supports only " + StatefulRemoteInvocation.class.getSimpleName()
               + ", but has been passed: " + invocation;
         StatefulRemoteInvocation si = (StatefulRemoteInvocation) invocation;

         // Get the method hash
         long methodHash = si.getMethodHash();
         log.debug("Received dynamic invocation for method with hash: " + methodHash);

         // Get the Method via MethodInfo from the Advisor
         Advisor advisor = this.getAdvisor();
         MethodInfo info = advisor.getMethodInfo(methodHash);
         Method unadvisedMethod = info.getMethod();
         SerializableMethod unadvisedMethodSerializable = new SerializableMethod(unadvisedMethod);

         // Get the invoked method from invocation metadata
         Object objInvokedMethod = si.getMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
               SessionSpecRemotingMetadata.KEY_INVOKED_METHOD);
         assert objInvokedMethod != null : "Invoked Method must be set on invocation metadata";
         assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type "
               + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
         SerializableMethod invokedMethod = (SerializableMethod) objInvokedMethod;

         Class<?> invokedBusinessInterface = Class.forName(invokedMethod.getActualClassName(), false, this.getClassloader());

         try
         {

            // Increment invocation statistics
            invokeStats.callIn();

            /*
             * Obtain Session ID
             */

            // Obtain the Session ID
            Object objSessionId = si.getMetaData(StatefulSessionRemotingMetadata.TAG_SFSB_INVOCATION,
                  StatefulSessionRemotingMetadata.KEY_SESSION_ID);
            if (objSessionId != null)
            {
               assert objSessionId instanceof Serializable : "Session IDs must be "
                     + Serializable.class.getSimpleName();
               sessionId = (Serializable) objSessionId;
            }

            if (info != null && unadvisedMethod != null && isHomeMethod(unadvisedMethodSerializable))
            {
               response = invokeHomeMethod(info, si);
            }
            else if (info != null && unadvisedMethod != null && isEjbObjectMethod(unadvisedMethodSerializable))
            {
               response = invokeEJBObjectMethod(invokedMethod, si);
            }
            else
            {
               if (unadvisedMethod.isBridge())
               {
                  unadvisedMethod = this.getNonBridgeMethod(unadvisedMethod);
                  info = super.getMethodInfo(unadvisedMethod);
               }

               if (sessionId == null)
               {
                  StatefulBeanContext ctx = getCache().create(null, null);
                  Object objNewId = ctx.getId();
                  assert objNewId instanceof Serializable : "Obtained new Session ID from cache, " + objNewId
                        + ", which is not " + Serializable.class.getSimpleName();
                  sessionId = (Serializable) objNewId;
               }

               /*
                * Build a new Invocation
                */

               // Construct the invocation
               newSi = new StatefulContainerInvocation(info, sessionId, invokedBusinessInterface);
               //newSi = new StatefulContainerInvocation(info.getInterceptors(), long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor, Object id);
               newSi.setArguments(si.getArguments());
               newSi.setMetaData(si.getMetaData());
               newSi.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
                     SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, invokedMethod, PayloadKey.AS_IS);

               //newSi.setAdvisor(getAdvisor());

               /*
                * Perform Invocation
                */

               // Create an object to hold the return value
               Object returnValue = null;

               try
               {
                  // Invoke
                  returnValue = newSi.invokeNext();
               }
               catch (NoSuchEJBException nsee)
               {
                  throw this.constructProperNoSuchEjbException(nsee, invokedMethod.getActualClassName());
               }
              
               // Marshall the response
               response = marshallResponse(invocation, returnValue, newSi.getResponseContextInfo());
               if (sessionId != null)
               {
                  response.addAttachment(StatefulConstants.NEW_ID, sessionId);
               }

               //               response = marshallResponse(invocation, rtn, newSi.getResponseContextInfo());
               //               if (newId != null) response.addAttachment(StatefulConstants.NEW_ID, newId);

View Full Code Here

Examples of org.jboss.aop.joinpoint.InvocationResponse

               StatefulSessionProxyFactory.class);

         // Create a new EJB2.x Proxy
         Object proxy = proxyFactory.createProxyEjb2x(sessionId);

         InvocationResponse response = marshallResponse(statefulInvocation, proxy, invocation.getResponseContextInfo());
         response.addAttachment(StatefulConstants.NEW_ID, sessionId);
         return response;
      }
      else if (unadvisedMethod.getName().equals("remove"))
      {
         Object argument = statefulInvocation.getArguments()[0];
         remove(argument);

         InvocationResponse response = new InvocationResponse(null);
         response.setContextInfo(statefulInvocation.getResponseContextInfo());
         return response;
      }
      else if (unadvisedMethod.getName().equals("getEJBMetaData"))
      {
         Class<?> remote = null;
         Class<?> home = null;
         Class<?> pkClass = Object.class;
         HomeHandleImpl homeHandle = null;

         Class<?>[] remotes = ProxyFactoryHelper.getRemoteInterfaces(this);
         if (remotes != null && remotes.length > 0)
         {
            remote = remotes[0];
         }
         RemoteHome homeAnnotation = this.getAnnotation(RemoteHome.class);
         if (homeAnnotation != null)
            home = homeAnnotation.value();

         RemoteHomeBinding remoteHomeBinding = this.getAnnotation(RemoteHomeBinding.class);
         assert remoteHomeBinding != null : "remoteHomeBinding is null";
         homeHandle = new HomeHandleImpl(remoteHomeBinding.jndiBinding());

         EJBMetaDataImpl metadata = new EJBMetaDataImpl(remote, home, pkClass, true, false, homeHandle);

         InvocationResponse response = marshallResponse(statefulInvocation, metadata, null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("getHomeHandle"))
      {
         HomeHandleImpl homeHandle = null;

         RemoteHomeBinding remoteHomeBinding = this.getAnnotation(RemoteHomeBinding.class);
         assert remoteHomeBinding != null : "remoteHomeBinding is null";
         homeHandle = new HomeHandleImpl(remoteHomeBinding.jndiBinding());

         InvocationResponse response = marshallResponse(statefulInvocation, homeHandle, null);
         return response;
      }
      else
      {
         return null;
View Full Code Here

Examples of org.jboss.aop.joinpoint.InvocationResponse

            // Create a new EJB2.x Proxy
            proxy = (EJBObject) proxyFactory.createProxyEjb2x((Serializable) newStatefulInvocation.getId());
         }

         StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
         InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
         return response;
      }

      // SFSB remove()
      else if (unadvisedMethod.getName().equals(Ejb2xMethodNames.METHOD_NAME_HOME_REMOVE))
      {
         try
         {
            // Attempt to remove the bean
            destroySession(statefulInvocation.getId());
         }
         catch (NoSuchEJBException e)
         {
            String invokingClassName = method.getActualClassName();
            Throwable newException = this.constructProperNoSuchEjbException(e, invokingClassName);
            throw newException;
         }

         InvocationResponse response = new InvocationResponse(null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("getEJBHome"))
      {
         EJBHome ejbHome;
         if(CurrentRemoteProxyFactory.isSet())
         {
            ejbHome = CurrentRemoteProxyFactory.get(EJB2RemoteProxyFactory.class).createHome();
         }
         else
         {
            HomeHandleImpl homeHandle = null;
  
            RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
            if (remoteBindingAnnotation != null)
               homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
  
            ejbHome = homeHandle.getEJBHome();
         }

         InvocationResponse response = marshallResponse(statefulInvocation, ejbHome, null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("getPrimaryKey"))
      {
         Object id = statefulInvocation.getId();

         InvocationResponse response = marshallResponse(statefulInvocation, id, null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("isIdentical"))
      {
         Object id = statefulInvocation.getId();
         EJBObject bean = (EJBObject) statefulInvocation.getArguments()[0];

         Object primaryKey = bean.getPrimaryKey();

         boolean isIdentical = id.equals(primaryKey);

         InvocationResponse response = marshallResponse(statefulInvocation, isIdentical, null);
         return response;
      }
      else
      {
         return null;
View Full Code Here

Examples of org.jboss.remoting.InvocationResponse

               packet = new SerializedPacket(req);              
            }
         }        
         else if (obj instanceof InvocationResponse)
         {
            InvocationResponse resp = (InvocationResponse)obj;
           
            Object param = resp.getResult();
           
            if (param instanceof ResponseSupport)
            {
               // A JBM invocation response
              
               packet = (ResponseSupport)param;
            
               if (trace) { log.trace("JBM Response"); }
            }
            else if (param instanceof List)
            {
               // List of polled Callbacks, this is how messages are delivered when using
               // polled callbacks e.g. the HTTP transport
              
               packet = new PolledCallbacksDelivery((List)param, resp.getSessionId());            
            }
            else if (param == null)
            {
               // Null response
               packet = new NullResponse();
View Full Code Here

Examples of org.jboss.remoting.InvocationResponse

      os.flush();
   }
  
   public Object getPayload()
   {
      return new InvocationResponse(sessionID, callbacks, false, null);
   }
View Full Code Here

Examples of org.jboss.remoting.InvocationResponse

                     WebServerError ex = new WebServerError((String)result);
                     return ex;
                  }
                  else if (result instanceof InvocationResponse)
                  {
                     InvocationResponse response = (InvocationResponse) result;
                     Object innerResult = response.getResult();
                     if (innerResult instanceof ServletThrowable)
                     {
                        return ((ServletThrowable) innerResult).getCause();
                     }
                     else
                     {
                        return innerResult;
                     }
                  }
                  else
                  {
                     return result;
                  }
               }
            }
         }


         // if got here, wasn't configured to not throw exception, so will throw it.

         // In this case, MicroRemoteClientInvoker will throw the exception carried by
         // the InvocationResponse.
         if (result instanceof InvocationResponse)
         {
            if ((((InvocationResponse) result).getResult()) instanceof ServletThrowable)
            {
               InvocationResponse response = (InvocationResponse) result;
               ServletThrowable st = (ServletThrowable) response.getResult();
               Throwable t = st.getCause();
               InvocationResponse ir = new InvocationResponse(response.getSessionId(),
                                                              t,
                                                              response.isException(),
                                                              response.getPayload());
               return ir;
            }
View Full Code Here

Examples of org.jboss.remoting.InvocationResponse

      return result;
   }

   private Object checkForLeasePing(HttpURLConnection conn, Object invocation, Map metadata) throws IOException
   {
      InvocationResponse response = null;
      boolean shouldLease = false;
      long leasePeriod = -1;

      if(invocation != null && invocation instanceof InvocationRequest)
      {
         InvocationRequest request = (InvocationRequest)invocation;

         Object payload = request.getParameter();
         // although a bit of a hack, this will determin if first time ping called by client.
         if(payload != null && payload instanceof String && "$PING$".equalsIgnoreCase((String)payload) && request.getReturnPayload() != null)
         {
            try
            {
               // now know is a ping request, so convert to be a HEAD method call
               conn.setDoOutput(false);
               conn.setDoInput(true);
               conn.setRequestMethod("HEAD");
               // set the remoting version
               conn.setRequestProperty(HTTPMetadataConstants.REMOTING_VERSION_HEADER, new Integer(Version.getDefaultVersion()).toString());
               // set the user agent
               conn.setRequestProperty(HTTPMetadataConstants.REMOTING_USER_AGENT, "JBossRemoting - " + Version.VERSION);
               conn.setRequestProperty(HTTPMetadataConstants.REMOTING_LEASE_QUERY, "true");
               conn.setRequestProperty("sessionId", request.getSessionId());
               conn.connect();

               //InputStream is = (conn.getResponseCode() < 400) ? conn.getInputStream() : conn.getErrorStream();
               Map headers = conn.getHeaderFields();

               if(headers != null)
               {
                  Object leasingEnabled = headers.get("LEASING_ENABLED");
                  if(leasingEnabled != null && leasingEnabled instanceof List)
                  {
                     shouldLease = new Boolean((String)((List)leasingEnabled).get(0)).booleanValue();
                  }
                  Object leasingPeriod = headers.get("LEASE_PERIOD");
                  if(leasingPeriod != null && leasingPeriod instanceof List)
                  {
                     leasePeriod = new Long((String)((List)leasingPeriod).get(0)).longValue();
                  }
               }
            }
            catch (IOException e)
            {
               log.error("Error checking server for lease information.", e);
            }

            Map p = new HashMap();
            p.put("clientLeasePeriod", new Long(leasePeriod));
            InvocationResponse innterResponse = new InvocationResponse(null, new Boolean(shouldLease), false, p);
            response = new InvocationResponse(null, innterResponse, false, null);

         }
      }

      return response;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.