Package org.jboss.invocation

Examples of org.jboss.invocation.InvocationContext


  
   // Inner classes -------------------------------------------------
  
   static String getProxyFamilyName(Invocation invocation) throws Exception
   {
      InvocationContext ctx = invocation.invocationContext;
      Invoker invoker = ctx.getInvoker();
     
      // HACK!  Get the proxy family name via reflection. 
      // Works for the known InvokerProxyHA impls
      Method m = invoker.getClass().getDeclaredMethod("getProxyFamilyName", new Class[]{});
      String proxyFamilyName = (String) m.invoke(invoker, new Object[] {});
View Full Code Here


    * @throws Throwable    Any exception or error thrown while processing.
    */
   public Object invoke(Invocation invocation)
      throws Throwable
   {
      InvocationContext ctx = invocation.getInvocationContext();
     
      Method m = invocation.getMethod();
     
      // Implement local methods
      if (m.equals(TO_STRING))
      {
         return toString(ctx);
      }
      else if (m.equals(EQUALS))
      {
         Object[] args = invocation.getArguments();
         String argsString = args[0] != null ? args[0].toString() : "";
         String thisString = toString(ctx);
         return new Boolean(thisString.equals(argsString));
      }
      else if (m.equals(HASH_CODE))
      {
         return new Integer(ctx.getCacheId().hashCode());
      }
      // Implement local EJB calls
      else if (m.equals(GET_HANDLE))
      {
         int objectName = ((Integer) ctx.getObjectName()).intValue();
         String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME);
         Invoker invoker = ctx.getInvoker();
         Object id = ctx.getCacheId();
         return createHandle(objectName, jndiName, invoker, id, ctx);
      }
      else if (m.equals(GET_EJB_HOME))
      {
         return getEJBHome(invocation);
      }
      else if (m.equals(GET_PRIMARY_KEY))
      {
         throw new RemoteException("Call to getPrimaryKey not allowed on session bean");
      }
      else if (m.equals(IS_IDENTICAL))
      {
         Object[] args = invocation.getArguments();
         String argsString = args[0].toString();
         String thisString = toString(ctx);
         return new Boolean(thisString.equals(argsString));
      }
      // If not taken care of, go on and call the container
      else
      {
         // It is a remote invocation
         invocation.setType(InvocationType.REMOTE);
        
         // On this entry in cache
         invocation.setId(ctx.getCacheId());
        
         return getNext().invoke(invocation);
      }
   }
View Full Code Here

      // It is a home invocation
      invocation.setType(InvocationType.HOME);

      // Create an invocation context for the invocation
      InvocationContext ctx = new InvocationContext();
      invocation.setInvocationContext(ctx);
     
      // Get the invoker to the target server (cluster or node)

      // Ship it
View Full Code Here

    */
   public Object invoke(Invocation invocation)
      throws Exception
   {
      Object returnValue = null;
      InvocationContext ctx = invocation.getInvocationContext();
      String methodName = invocation.getMethod().getName();
      if( methodName.equals("doSomethingSlowly") )
      {
         returnValue = sendRecvJMS(invocation);
      }
      else
      {
         // Get the
         Invoker invoker = ctx.getInvoker();
         returnValue = invoker.invoke(invocation);
         // If this is a remove close the jms connection
         if( methodName.equals("remove") )
         {
            try
View Full Code Here

      if (failureType != null)
      {
         inv.setValue("FAILURE_TYPE", failureType);
      }

      InvocationContext ctx = new InvocationContext();
      ctx.setInvoker(invoker);
      inv.setInvocationContext(ctx);
     
      return inv;
   }
View Full Code Here

    */
   public Object invoke(Invocation invocation)
      throws Throwable
   {
      Object result = null;
      InvocationContext ctx = invocation.getInvocationContext();
      retry = true;
      int retryCount = 0;
      while( retry == true )
      {
         Interceptor next = getNext();
View Full Code Here

   }
  
   protected EJBHome getEJBHome(Invocation invocation) throws NamingException
   {
      // Look to the context for the home
      InvocationContext ctx = invocation.getInvocationContext();
      EJBHome home = (EJBHome) ctx.getValue(InvocationKey.EJB_HOME);
      // If there is no home use the legacy lookup method
      if( home == null )
      {
         String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME);
         InitialContext iniCtx =  new InitialContext();
         home = (EJBHome) iniCtx.lookup(jndiName);
      }
      return home;
   }
View Full Code Here

   * @throws Throwable    Any exception or error thrown while processing.
   */
   public Object invoke(Invocation invocation)
      throws Throwable
   {
      InvocationContext ctx = invocation.getInvocationContext();
     
      Method m = invocation.getMethod();
     
      // Implement local methods
      if (m.equals(TO_STRING))
      {
         return ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home";
      }
      else if (m.equals(EQUALS))
      {
         // equality of the proxy home is based on names...
         Object[] args = invocation.getArguments();
         String argsString = args[0] != null ? args[0].toString() : "";
         String thisString = ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home";
         return new Boolean(thisString.equals(argsString));
      }
      else if (m.equals(HASH_CODE))
      {
         return new Integer(this.hashCode());
      }
     
      // Implement local EJB calls
      else if (m.equals(GET_HOME_HANDLE))
      {
         return new HomeHandleImpl(
         (String)ctx.getValue(InvocationKey.JNDI_NAME));
      }
      else if (m.equals(GET_EJB_META_DATA))
      {
         return ctx.getValue(InvocationKey.EJB_METADATA);
      }
      else if (m.equals(REMOVE_BY_HANDLE))
      {
         // First get the EJBObject
         EJBObject object =
         ((Handle) invocation.getArguments()[0]).getEJBObject();
        
         // remove the object from here
         object.remove();
        
         // Return Void
         return Void.TYPE;
      }
      else if (m.equals(REMOVE_BY_PRIMARY_KEY))
      {
         // Session beans must throw RemoveException (EJB 1.1, 5.3.2)
         if(((EJBMetaData)ctx.getValue(InvocationKey.EJB_METADATA)).isSession())
            throw new RemoveException("Session beans cannot be removed " +
            "by primary key.");
        
         // The trick is simple we trick the container in believe it
         // is a remove() on the instance
View Full Code Here

      // It is a home invocation
      invocation.setType(InvocationType.HOME);

      // Create an invocation context for the invocation
      InvocationContext ctx = new InvocationContext();
      invocation.setInvocationContext(ctx);
     
      // Get the invoker to the target server (cluster or node)

      // Ship it
View Full Code Here

   protected void bindProxy() throws Exception
   {
      try
      {
         // Create a stack from the description (in the future) for now we hardcode it
         InvocationContext context = new InvocationContext();

         context.setObjectName(jmxNameHashInteger);
         context.setValue(InvocationKey.JNDI_NAME, jndiBinding);
         // The behavior for home proxying should be isolated in an interceptor FIXME
         context.setInvoker(homeInvoker);
         context.setValue(InvocationKey.EJB_METADATA, ejbMetaData);
         context.setInvokerProxyBinding(invokerMetaData.getName());
        
         if(container.getSecurityManager() != null)
         {
            String secDomain = container.getSecurityManager().getSecurityDomain();
            context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain);
         }
        
         ClientContainer client = null;
         EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container;
         Class[] ifaces = {pfc.getHomeClass(), Class.forName("javax.ejb.Handle")};
         if( includeIClientIface )
         {
            ifaces = new Class[] {IClientContainer.class, pfc.getHomeClass(),
                           Class.forName("javax.ejb.Handle")};
            client = new ClientContainerEx(context);
         }
         else
         {
            client = new ClientContainer(context);
         }
         loadInterceptorChain(homeInterceptorClasses, client);

         // Create the EJBHome
         this.home = (EJBHome) Proxy.newProxyInstance(
               // Class loader pointing to the right classes from deployment
               pfc.getHomeClass().getClassLoader(),
               // The classes we want to implement home and handle
               ifaces,
               // The home proxy as invocation handler
               client);

         // Create stateless session object
         // Same instance is used for all objects
         if(ejbMetaData.isStatelessSession() == true)
         {
            // Create a stack from the description (in the future) for now we hardcode it
            context = new InvocationContext();

            context.setObjectName(jmxNameHashInteger);
            context.setValue(InvocationKey.JNDI_NAME, jndiBinding);
            // The behavior for home proxying should be isolated in an interceptor FIXME
            context.setInvoker(beanInvoker);
            context.setInvokerProxyBinding(invokerMetaData.getName());
            context.setValue(InvocationKey.EJB_HOME, home);
           
            if(container.getSecurityManager() != null)
            {
               String secDomain = container.getSecurityManager().getSecurityDomain();
               context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain);
            }

            Class[] ssifaces = {pfc.getRemoteClass()};
            if( includeIClientIface )
            {
View Full Code Here

TOP

Related Classes of org.jboss.invocation.InvocationContext

Copyright © 2018 www.massapicom. 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.