4 Replies Latest reply on May 25, 2006 2:37 PM by upankar

    How to know if a bean instance is accessed by a local or rem

    upankar

      Hi,
      Is there a way in stateful bean instance to know if it is being accessed by a local or remote client at present ? Two ways to know are - one when u have different arguments create() methods in their local and remote home interface, and secondly if u declare methods of different names or args in their local and remote interfaces. But my situation is both home have same zero arg create() method, and the both home and remote have same arg methods of same names. Given this, when one of the method of the interface is invoked, is there way to know whether the bean instance is currently serving a local or remote EJB object ? The SessionContext object always returns not-null EJBObject and EJBLocalObject if the bean instance implements both local and remote interfaces. This is probably becoz same bean instance when created is capable of serving both a local or remote EJB object. Any idea will be highly appreciated.

        • 1. Re: How to know if a bean instance is accessed by a local or
          drabbit

          This is an interesting question, but I doubt there is a solution to it. You might want to go one step back and post what you need to know this information for. If it is merely for logging and to check if calls are local or remote, you could just write an interceptor that logs the invocation type.

          dirk

          • 2. Re: How to know if a bean instance is accessed by a local or
            upankar

            Well ! i am actually trying to simulate streaming behaviour in a session bean. As we know IO streams are not serilizable and hence can not be used in EJB method return types, I am trying to put together a generic framework which can simulate the streaming behaviour. I got pretty successful in it and got it to working. But the framework needs to identify the client type. If local, it directly returns the stream instance to client (since no serialization is done here, hence no issues), but if remote it returns the simulated stream instance to client which then retrieves data from actual underneath stream instance that resides on server. As of now, i am handling this with different create methods in local and remote home to know if the bean instance is serving a remote or local client.

            But this is a redundant workaround. I would like to have some thing more concrete and generic.

            • 3. Re: How to know if a bean instance is accessed by a local or
              bhupendra.yaduvenshi

              If ur issue is performance than plz don't worry beacaz when u deploy ur client & server on same jvm & ur ejb component is worked as a local intefcae.Only difference is in cas eof remote it is used only pass by value but no stub skeleton created.it means it will behave like a local interface.If any confision than let me know

              • 4. Re: How to know if a bean instance is accessed by a local or
                upankar

                Performace is definitely one thing. But more than that, i am just curious to know if there is a straightforward way to getting to know the access type (local or remote) in the bean instance.