1 Reply Latest reply on Jun 16, 2004 5:06 PM by Carlos Cajina

    getEJBLocalObject

    sanjewad Newbie

      Hi I am using JBoss 3.2.3 and I have written a proxy class to invoke ejb methods.

      public Object invoke(Object ejbObjectName, String methodName, Object[] parms)
      Iam invoking the method above because I have the Localobject with me when I call the invoke method.

      my parms include LocalObject parameter types as well.
      implementation inside the invoke method says

      Class[] parmClass = new Class[parms.length];
      for (int i=0;i<parms.length;i++)
      parmClass=parms.getClass();

      but it does not covert to real type because it returns a proxy class.
      how can I get the actual EJBLocalObject cladd from the parm object.

      -----------
      invoke methos is here.

      public Object invoke(Object ejbObjectName, String methodName, Object[] parms){
      Object result = null;
      try {
      Class[] parmClass = new Class[parms.length];
      for (int i=0;i<parms.length;i++)
      parmClass=parms.getClass();

      //System.out.println(parms.);
      Method bizMethod = ejbObjectName.getClass().getMethod(methodName,parmClass);

      /*Now call the desired method on it
      */
      result = bizMethod.invoke(ejbObjectName, parms);
      } catch (Exception e) {
      System.err.println("Caught an exception in invoke method.");
      }
      return result;
      }

        • 1. Re: getEJBLocalObject
          Carlos Cajina Newbie

          I think that what you're tryin' to do is implemented in the examples from the Professional Struts Applications book... you might want to look @ the source code from the book and pay special attention to the ServiceLocator pattern implementation.

          Good Luck!

          PS: you can also try the EJBHomFactory Pattern from the EJB Design Patterns book (free download @ TheServerSide)