Package org.jboss.invocation

Examples of org.jboss.invocation.InvocationContext


    * Create an EJBObject proxy for a stateful session given its session id.
    */
   public Object getStatefulSessionEJBObject(Object id)
   {
      // Create a stack from the description (in the future) for now we hardcode it
      InvocationContext context = new InvocationContext();

      context.setObjectName(jmxNameHashInteger);
      context.setCacheId(id);
      context.setValue(InvocationKey.JNDI_NAME, jndiBinding);
      context.setInvoker(beanInvoker);
      log.debug("seting invoker proxy binding for stateful session: " + invokerMetaData.getName());
      context.setInvokerProxyBinding(invokerMetaData.getName());
      context.setValue(InvocationKey.EJB_HOME, home);
      context.setValue("InvokerID", Invoker.ID);

      if(container.getSecurityManager() != null)
      {
         String secDomain = container.getSecurityManager().getSecurityDomain();
         context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain);
      }
     
      ClientContainer client;
      if( includeIClientIface )
      {
View Full Code Here


         result = null;
      }
      else
      {
         // Create a stack from the description (in the future) for now we hardcode it
         InvocationContext context = new InvocationContext();

         context.setObjectName(jmxNameHashInteger);
         context.setCacheId(id);
         context.setValue(InvocationKey.JNDI_NAME, jndiBinding);
         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);
         }
        
         ClientContainer client;
         if( includeIClientIface )
         {
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))
      {
         // We base the stateless hash on the hash of the proxy...
         // MF XXX: it could be that we want to return the hash of the name?
         return new Integer(this.hashCode());
      }
      // Implement local EJB calls
      else if (m.equals(GET_HANDLE))
      {
         return new StatelessHandleImpl(
               (String)ctx.getValue(InvocationKey.JNDI_NAME));
      }
      else if (m.equals(GET_PRIMARY_KEY))
      {
         throw new RemoteException("Call to getPrimaryKey not allowed on session bean");
      }
View Full Code Here

    */
   public Object createProxy(Object id, ObjectName targetName,
      Invoker invoker, String jndiName, String proxyBindingName,
      ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces, HashMap ctx)
   {
      InvocationContext context;
      if (ctx != null)
         context = new InvocationContext(ctx);
      else
         context = new InvocationContext();
      Integer nameHash = new Integer(targetName.hashCode());
      if (log.isTraceEnabled())
      {
         log.trace("Target name " + targetName + " and corresponding hash code" +  nameHash);
      }     
      context.setObjectName(nameHash);
      context.setCacheId(id);
      if( jndiName != null )
         context.setValue(InvocationKey.JNDI_NAME, jndiName);

      if( invoker == null )
         throw new RuntimeException("Null invoker given for name: " + targetName);
      context.setInvoker(invoker);
      if( proxyBindingName != null )
         context.setInvokerProxyBinding(proxyBindingName);

      // If the IClientContainer interceptor was specified, use the ClientContainerEx
      boolean wantIClientAccess = false;
      for(int n = 0; wantIClientAccess == false && n < interceptorClasses.size(); n ++)
      {
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

    * @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))
      {
         String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME);
         Object id = ctx.getCacheId();
         return new EntityHandleImpl(jndiName, id);
      }
      else if (m.equals(GET_PRIMARY_KEY))
      {
         return ctx.getCacheId();
      }
      else if (m.equals(GET_EJB_HOME))
      {
         return getEJBHome(invocation);
      }
      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
      {
         // We are a Remote invocation
         invocation.setType(InvocationType.REMOTE);
         // We pertain to this ID (represented by cache ID)
         invocation.setId(ctx.getCacheId());
         return getNext().invoke(invocation);
      }
   }
View Full Code Here

  private static final long serialVersionUID = 3049140179377045637L;
  int key;

  public TestInvocation(String serializationType, Object value)
  {
    InvocationContext context = new InvocationContext();
    context.setValue("SERIALIZATION_TYPE",serializationType);
    Invocation invocation = new Invocation();
   
    // Contextual information for the interceptors
    invocation.setInvocationContext(context);
    invocation.setObjectName("This is a test only");
    invocation.setMethod(TestInvocation.class.getMethods()[0]);
    invocation.setArguments(new Object[]{value});
     
    invocation.setValue(InvocationKey.INVOKER_PROXY_BINDING,
                          context.getInvokerProxyBinding(),
                          PayloadKey.AS_IS);
   
    this.invocation = new MarshalledInvocation(invocation);
    key = new Random().nextInt();
  }
View Full Code Here

/*     */   protected void bindProxy()
/*     */     throws Exception
/*     */   {
/*     */     try
/*     */     {
/* 384 */       InvocationContext context = new InvocationContext();
/*     */
/* 386 */       context.setObjectName(this.jmxNameHashInteger);
/* 387 */       context.setValue(InvocationKey.JNDI_NAME, this.jndiBinding);
/*     */
/* 389 */       context.setInvoker(this.homeInvoker);
/* 390 */       context.setValue(InvocationKey.EJB_METADATA, this.ejbMetaData);
/* 391 */       context.setInvokerProxyBinding(this.invokerMetaData.getName());
/*     */
/* 393 */       ClientContainer client = null;
/* 394 */       EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer)this.container;
/* 395 */       Class[] ifaces = { pfc.getHomeClass(), Class.forName("javax.ejb.Handle") };
/* 396 */       if (this.includeIClientIface)
/*     */       {
/* 398 */         ifaces = new Class[] { IClientContainer.class, pfc.getHomeClass(), Class.forName("javax.ejb.Handle") };
/*     */
/* 400 */         client = new ClientContainerEx(context);
/*     */       }
/*     */       else
/*     */       {
/* 404 */         client = new ClientContainer(context);
/*     */       }
/* 406 */       loadInterceptorChain(this.homeInterceptorClasses, client);
/*     */
/* 409 */       this.home = ((EJBHome)Proxy.newProxyInstance(pfc.getHomeClass().getClassLoader(), ifaces, client));
/*     */
/* 419 */       if (this.ejbMetaData.isStatelessSession() == true)
/*     */       {
/* 422 */         context = new InvocationContext();
/*     */
/* 424 */         context.setObjectName(this.jmxNameHashInteger);
/* 425 */         context.setValue(InvocationKey.JNDI_NAME, this.jndiBinding);
/*     */
/* 427 */         context.setInvoker(this.beanInvoker);
/* 428 */         context.setInvokerProxyBinding(this.invokerMetaData.getName());
/* 429 */         context.setValue(InvocationKey.EJB_HOME, this.home);
/*     */
/* 431 */         Class[] ssifaces = { pfc.getRemoteClass() };
/* 432 */         if (this.includeIClientIface)
/*     */         {
/* 434 */           ssifaces = new Class[] { IClientContainer.class, pfc.getRemoteClass() };
View Full Code Here

/* 549 */     return this.statelessObject;
/*     */   }
/*     */
/*     */   public Object getStatefulSessionEJBObject(Object id)
/*     */   {
/* 558 */     InvocationContext context = new InvocationContext();
/*     */
/* 560 */     context.setObjectName(this.jmxNameHashInteger);
/* 561 */     context.setCacheId(id);
/* 562 */     context.setValue(InvocationKey.JNDI_NAME, this.jndiBinding);
/* 563 */     context.setInvoker(this.beanInvoker);
/* 564 */     log.debug("seting invoker proxy binding for stateful session: " + this.invokerMetaData.getName());
/* 565 */     context.setInvokerProxyBinding(this.invokerMetaData.getName());
/* 566 */     context.setValue(InvocationKey.EJB_HOME, this.home);
/* 567 */     context.setValue("InvokerID", Invoker.ID);
/*     */     ClientContainer client;
/*     */     ClientContainer client;
/* 570 */     if (this.includeIClientIface)
/*     */     {
/* 572 */       client = new ClientContainerEx(context);
View Full Code Here

/*     */     {
/* 607 */       result = null;
/*     */     }
/*     */     else
/*     */     {
/* 612 */       InvocationContext context = new InvocationContext();
/*     */
/* 614 */       context.setObjectName(this.jmxNameHashInteger);
/* 615 */       context.setCacheId(id);
/* 616 */       context.setValue(InvocationKey.JNDI_NAME, this.jndiBinding);
/* 617 */       context.setInvoker(this.beanInvoker);
/* 618 */       context.setInvokerProxyBinding(this.invokerMetaData.getName());
/* 619 */       context.setValue(InvocationKey.EJB_HOME, this.home);
/*     */       ClientContainer client;
/*     */       ClientContainer client;
/* 622 */       if (this.includeIClientIface)
/*     */       {
/* 624 */         client = new ClientContainerEx(context);
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.