Package org.jboss.invocation

Examples of org.jboss.invocation.InvocationContext


/*     */   private static final long serialVersionUID = 4399705304832568350L;
/*     */
/*     */   public Object invoke(Invocation invocation)
/*     */     throws Throwable
/*     */   {
/*  63 */     InvocationContext ctx = invocation.getInvocationContext();
/*     */
/*  65 */     Method m = invocation.getMethod();
/*     */
/*  68 */     if (m.equals(TO_STRING))
/*     */     {
/*  70 */       return toString(ctx);
/*     */     }
/*  72 */     if (m.equals(EQUALS))
/*     */     {
/*  74 */       Object[] args = invocation.getArguments();
/*  75 */       String argsString = args[0] != null ? args[0].toString() : "";
/*  76 */       String thisString = toString(ctx);
/*  77 */       return new Boolean(thisString.equals(argsString));
/*     */     }
/*  79 */     if (m.equals(HASH_CODE))
/*     */     {
/*  81 */       return new Integer(ctx.getCacheId().hashCode());
/*     */     }
/*     */
/*  84 */     if (m.equals(GET_HANDLE))
/*     */     {
/*  86 */       String jndiName = (String)ctx.getValue(InvocationKey.JNDI_NAME);
/*  87 */       Object id = ctx.getCacheId();
/*  88 */       return new EntityHandleImpl(jndiName, id);
/*     */     }
/*  90 */     if (m.equals(GET_PRIMARY_KEY))
/*     */     {
/*  92 */       return ctx.getCacheId();
/*     */     }
/*  94 */     if (m.equals(GET_EJB_HOME))
/*     */     {
/*  96 */       return getEJBHome(invocation);
/*     */     }
/*  98 */     if (m.equals(IS_IDENTICAL))
/*     */     {
/* 100 */       Object[] args = invocation.getArguments();
/* 101 */       String argsString = args[0].toString();
/* 102 */       String thisString = toString(ctx);
/* 103 */       return new Boolean(thisString.equals(argsString));
/*     */     }
/*     */
/* 109 */     invocation.setType(InvocationType.REMOTE);
/*     */
/* 111 */     invocation.setId(ctx.getCacheId());
/* 112 */     return getNext().invoke(invocation);
/*     */   }
View Full Code Here


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

/*     */   protected static final Method IS_IDENTICAL;
/*     */
/*     */   protected EJBHome getEJBHome(Invocation invocation)
/*     */     throws NamingException
/*     */   {
/*  98 */     InvocationContext ctx = invocation.getInvocationContext();
/*  99 */     EJBHome home = (EJBHome)ctx.getValue(InvocationKey.EJB_HOME);
/*     */
/* 101 */     if (home == null)
/*     */     {
/* 103 */       String jndiName = (String)ctx.getValue(InvocationKey.JNDI_NAME);
/* 104 */       InitialContext iniCtx = new InitialContext();
/* 105 */       home = (EJBHome)iniCtx.lookup(jndiName);
/*     */     }
/* 107 */     return home;
/*     */   }
View Full Code Here

/*     */   protected static final Method REMOVE_OBJECT;
/*     */
/*     */   public Object invoke(Invocation invocation)
/*     */     throws Throwable
/*     */   {
/* 115 */     InvocationContext ctx = invocation.getInvocationContext();
/*     */
/* 117 */     Method m = invocation.getMethod();
/*     */
/* 120 */     if (m.equals(TO_STRING))
/*     */     {
/* 122 */       return ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home";
/*     */     }
/* 124 */     if (m.equals(EQUALS))
/*     */     {
/* 127 */       Object[] args = invocation.getArguments();
/* 128 */       String argsString = args[0] != null ? args[0].toString() : "";
/* 129 */       String thisString = ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home";
/* 130 */       return new Boolean(thisString.equals(argsString));
/*     */     }
/* 132 */     if (m.equals(HASH_CODE))
/*     */     {
/* 134 */       return new Integer(hashCode());
/*     */     }
/*     */
/* 138 */     if (m.equals(GET_HOME_HANDLE))
/*     */     {
/* 140 */       return new HomeHandleImpl((String)ctx.getValue(InvocationKey.JNDI_NAME));
/*     */     }
/*     */
/* 143 */     if (m.equals(GET_EJB_META_DATA))
/*     */     {
/* 145 */       return ctx.getValue(InvocationKey.EJB_METADATA);
/*     */     }
/* 147 */     if (m.equals(REMOVE_BY_HANDLE))
/*     */     {
/* 150 */       EJBObject object = ((Handle)invocation.getArguments()[0]).getEJBObject();
/*     */
/* 154 */       object.remove();
/*     */
/* 157 */       return Void.TYPE;
/*     */     }
/* 159 */     if (m.equals(REMOVE_BY_PRIMARY_KEY))
/*     */     {
/* 162 */       if (((EJBMetaData)ctx.getValue(InvocationKey.EJB_METADATA)).isSession()) {
/* 163 */         throw new RemoveException("Session beans cannot be removed by primary key.");
/*     */       }
/*     */
/* 168 */       Object id = invocation.getArguments()[0];
/*     */
View Full Code Here

/*     */   private static final long serialVersionUID = -8807189798153718350L;
/*     */
/*     */   public Object invoke(Invocation invocation)
/*     */     throws Throwable
/*     */   {
/*  63 */     InvocationContext ctx = invocation.getInvocationContext();
/*  64 */     Method m = invocation.getMethod();
/*     */
/*  67 */     if (m.equals(TO_STRING))
/*     */     {
/*  69 */       return toString(ctx);
/*     */     }
/*  71 */     if (m.equals(EQUALS))
/*     */     {
/*  73 */       Object[] args = invocation.getArguments();
/*  74 */       String argsString = args[0] != null ? args[0].toString() : "";
/*  75 */       String thisString = toString(ctx);
/*  76 */       return new Boolean(thisString.equals(argsString));
/*     */     }
/*  78 */     if (m.equals(HASH_CODE))
/*     */     {
/*  82 */       return new Integer(hashCode());
/*     */     }
/*     */
/*  85 */     if (m.equals(GET_HANDLE))
/*     */     {
/*  87 */       return new StatelessHandleImpl((String)ctx.getValue(InvocationKey.JNDI_NAME));
/*     */     }
/*     */
/*  90 */     if (m.equals(GET_PRIMARY_KEY))
/*     */     {
/*  92 */       throw new RemoteException("Call to getPrimaryKey not allowed on session bean");
View Full Code Here

/*     */   private static final long serialVersionUID = -4333233488946091285L;
/*     */
/*     */   public Object invoke(Invocation invocation)
/*     */     throws Throwable
/*     */   {
/*  62 */     InvocationContext ctx = invocation.getInvocationContext();
/*     */
/*  64 */     Method m = invocation.getMethod();
/*     */
/*  67 */     if (m.equals(TO_STRING))
/*     */     {
/*  69 */       return toString(ctx);
/*     */     }
/*  71 */     if (m.equals(EQUALS))
/*     */     {
/*  73 */       Object[] args = invocation.getArguments();
/*  74 */       String argsString = args[0] != null ? args[0].toString() : "";
/*  75 */       String thisString = toString(ctx);
/*  76 */       return new Boolean(thisString.equals(argsString));
/*     */     }
/*  78 */     if (m.equals(HASH_CODE))
/*     */     {
/*  80 */       return new Integer(ctx.getCacheId().hashCode());
/*     */     }
/*     */
/*  83 */     if (m.equals(GET_HANDLE))
/*     */     {
/*  85 */       int objectName = ((Integer)ctx.getObjectName()).intValue();
/*  86 */       String jndiName = (String)ctx.getValue(InvocationKey.JNDI_NAME);
/*  87 */       Invoker invoker = ctx.getInvoker();
/*  88 */       Object id = ctx.getCacheId();
/*  89 */       return new StatefulHandleImpl(objectName, jndiName, invoker, ctx.getInvokerProxyBinding(), id, ctx.getValue("InvokerID"));
/*     */     }
/*     */
/*  97 */     if (m.equals(GET_EJB_HOME))
/*     */     {
/*  99 */       return getEJBHome(invocation);
/*     */     }
/* 101 */     if (m.equals(GET_PRIMARY_KEY))
/*     */     {
/* 103 */       throw new RemoteException("Call to getPrimaryKey not allowed on session bean");
/*     */     }
/* 105 */     if (m.equals(IS_IDENTICAL))
/*     */     {
/* 107 */       Object[] args = invocation.getArguments();
/* 108 */       String argsString = args[0].toString();
/* 109 */       String thisString = toString(ctx);
/* 110 */       return new Boolean(thisString.equals(argsString));
/*     */     }
/*     */
/* 116 */     invocation.setType(InvocationType.REMOTE);
/*     */
/* 119 */     invocation.setId(ctx.getCacheId());
/*     */
/* 121 */     return getNext().invoke(invocation);
/*     */   }
View Full Code Here

/*  81 */     return createProxy(id, targetName, invoker, jndiName, proxyBindingName, interceptorClasses, loader, ifaces, null);
/*     */   }
/*     */
/*     */   public Object createProxy(Object id, ObjectName targetName, Invoker invoker, String jndiName, String proxyBindingName, ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces, HashMap ctx)
/*     */   {
/*     */     InvocationContext context;
/*     */     InvocationContext context;
/* 100 */     if (ctx != null)
/* 101 */       context = new InvocationContext(ctx);
/*     */     else
/* 103 */       context = new InvocationContext();
/* 104 */     Integer nameHash = new Integer(targetName.hashCode());
/* 105 */     context.setObjectName(nameHash);
/* 106 */     context.setCacheId(id);
/* 107 */     if (jndiName != null) {
/* 108 */       context.setValue(InvocationKey.JNDI_NAME, jndiName);
/*     */     }
/* 110 */     if (invoker == null)
/* 111 */       throw new RuntimeException("Null invoker given for name: " + targetName);
/* 112 */     context.setInvoker(invoker);
/* 113 */     if (proxyBindingName != null) {
/* 114 */       context.setInvokerProxyBinding(proxyBindingName);
/*     */     }
/*     */
/* 117 */     boolean wantIClientAccess = false;
/* 118 */     for (int n = 0; (!wantIClientAccess) && (n < interceptorClasses.size()); n++)
/*     */     {
View Full Code Here

  
   // 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

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.