Package javax.ejb

Examples of javax.ejb.EJBObject


        // Ok, now the given arg is an Handle, get it.
        Handle handle = (Handle) args[0];

        // Get the EJBObject from this handle and call the remove method.
        EJBObject ejbObject = handle.getEJBObject();

        // removing
        ejbObject.remove();
    }
View Full Code Here


         if (arg instanceof Handle)
         {
            if (arg == null)
               throw new RemoteException("Null handle");
            Handle handle = (Handle) arg;
            EJBObject ejbObject = handle.getEJBObject();
            mi.setId(ejbObject.getPrimaryKey());
         }
         else
            mi.setId(arg);

         mi.setArguments(new Object[0]);
View Full Code Here

      jndiName = binding;
   }

   public boolean isIdentical(Container container, Invocation mi)
   {
      EJBObject other = (EJBObject) mi.getArguments()[0];
      if (other == null)
         return false;
      EJBObject me;
      if (container instanceof StatelessSessionContainer)
         me = (EJBObject) getStatelessSessionEJBObject();
      else if (container instanceof StatefulSessionContainer)
         me = (EJBObject) getStatefulSessionEJBObject(mi.getId());
      else if (container instanceof EntityContainer)
View Full Code Here

      {
         return id;
      }
      else if (unadvisedMethod.getName().equals("isIdentical"))
      {
         EJBObject bean = (EJBObject) args[0];

         Object primaryKey = bean.getPrimaryKey();

         boolean isIdentical = id.equals(primaryKey);

         return isIdentical;
      }
View Full Code Here

         // Lookup the Proxy Factory in the Object Store
         StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
               StatefulSessionProxyFactory.class);
        
         // Create a new EJB2.x Proxy
         EJBObject 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"))
      {
         HomeHandleImpl homeHandle = null;

         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
         if (remoteBindingAnnotation != null)
            homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));

         EJBHome 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;
View Full Code Here

      {
         return id;
      }
      else if (unadvisedMethod.getName().equals("isIdentical"))
      {
         EJBObject bean = (EJBObject) args[0];

         Object primaryKey = bean.getPrimaryKey();

         boolean isIdentical = id.equals(primaryKey);

         return isIdentical;
      }
View Full Code Here

         StatefulContainerInvocation newStatefulInvocation = buildInvocation(
                 info, statefulInvocation);

         ProxyFactory proxyFactory = this.getProxyFactory(this.getAnnotation(RemoteBinding.class));
         BaseStatefulRemoteProxyFactory statefulRemoteProxyFactory = (BaseStatefulRemoteProxyFactory) proxyFactory;
         EJBObject proxy = (EJBObject) statefulRemoteProxyFactory.createProxyEjb21(newStatefulInvocation.getId(), null);
         StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
         InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("remove"))
      {
         try
         {
            destroySession(statefulInvocation.getId());
         }
         catch(NoSuchEJBException e)
         {
            if(log.isTraceEnabled())
               log.trace("Throwing " + e.getClass().getName(), e);
            throw new NoSuchObjectException(e.getMessage());
         }

         InvocationResponse response = new InvocationResponse(null);
         return response;
      }
      else if (unadvisedMethod.getName().equals("getEJBHome"))
      {
         HomeHandleImpl homeHandle = null;

         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
         if (remoteBindingAnnotation != null)
            homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));

         EJBHome 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;
View Full Code Here

      {
         // object has no identity
         if(id == null)
            return false;
        
         EJBObject bean = (EJBObject) args[0];

         Object primaryKey = bean.getPrimaryKey();
         if(primaryKey == null)
            return false;

         boolean isIdentical = id.equals(primaryKey);
View Full Code Here

      {
         return id;
      }
      else if (unadvisedMethod.getName().equals("isIdentical"))
      {
         EJBObject bean = (EJBObject) args[0];

         Object primaryKey = bean.getPrimaryKey();

         boolean isIdentical = id.equals(primaryKey);

         return isIdentical;
      }
View Full Code Here

      MethodInfo info = this.getAdvisor().getMethodInfo(hash);
      Method unadvisedMethod = info.getUnadvisedMethod();

      if (unadvisedMethod.getName().equals("getHandle"))
      {
         EJBObject proxy;
         if(CurrentRemoteProxyFactory.isSet())
         {
            proxy = CurrentRemoteProxyFactory.get(EJB2RemoteProxyFactory.class).create((Serializable) statefulInvocation.getId());
         }
         else
         {
            StatefulContainerInvocation newStatefulInvocation = buildInvocation(info, statefulInvocation);
  
            // Get JNDI Registrar
            JndiSessionRegistrarBase sfsbJndiRegistrar = this.getJndiRegistrar();
  
            // Determine if local/remote
            boolean isLocal = EJBLocalObject.class.isAssignableFrom(unadvisedMethod.getDeclaringClass());
  
            // Get the metadata
            JBossSessionBeanMetaData smd = this.getMetaData();
  
            // Get the appropriate JNDI Name
            String jndiName = isLocal ? smd.getLocalJndiName() : smd.getJndiName();
  
            // Find the Proxy Factory Key for this SFSB
            String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(jndiName, smd, isLocal);
  
            // Lookup the Proxy Factory in the Object Store
            StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
                  StatefulSessionProxyFactory.class);
  
            // 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;
View Full Code Here

TOP

Related Classes of javax.ejb.EJBObject

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.