Loading ...
Sorry, an error occurred while loading the content.
 

.NET Remoting - Denoting which creation method is to be called

Expand Messages
  • Oliver
    Hi, I am building a system that uses .NET Remoting. The server uses a server-activated singleton remote object. Therefore the object is instantiated by the
    Message 1 of 3 , Jun 1, 2004
      Hi,

      I am building a system that uses .NET Remoting. The server uses a
      server-activated singleton remote object. Therefore the object is
      instantiated by the remoting infrastructure in response to the first
      remote method call from a client via a proxy. According to what I
      have read the default constructor is used to create the instance. It
      is my understanding that in Eiffel there is no default constructor
      and that all methods that can be used for object creation are simply
      listed in the create clause. I have done some testing and I am
      unable to get the Remoting infrastructure to instantiate my remote
      object using a constructor from my code, as opposed to initialising
      all features to default values. I have tried using a single creation
      method called make, and that does not appear to be called at any time.
      Is there a way to denote a particular creation method as the default
      constructor for the purposes of the remoting infrastructure?

      Thanks,

      Oliver.
    • yafokou
      Hi, I am not sure I really understand what you need. But if you would like the dotnet system to create an Eiffel object for you and automatically call a
      Message 2 of 3 , Jun 1, 2004
        Hi,

        I am not sure I really understand what you need.

        But if you would like the dotnet system to create an Eiffel object
        for you and automatically call a default creation routine, then I am
        afraid it is not possible. I have not found yet how to do that.

        If you have a class SERVER in Eiffel that is located in the cluster
        remote and you want to instantiate
        an instance of this class in another .Net language say C#.
        You will have to do the following

        s: remote.Server;

        s = remote.Create.Server.Make();

        assuming make is the SERVER class creation procedure.

        I think you should consider writing a small bootstrap code in a
        native .NET language like C# to start your server.


        Guy Fokou
      • Paul Bates [ES]
        Hi Oliver, The simple answer to your question is no. There is currently no way to mark any creation method as a default constructor. I have three solutions:
        Message 3 of 3 , Jun 1, 2004
          Hi Oliver,

          The simple answer to your question is no. There is currently no way to
          mark any creation method as a default constructor.

          I have three solutions:

          First, your singleton object could host an initialization routine that
          is a once function. Post creation of the remote object proxy you can
          call that initialization routine to initialize the state of the remote
          object. The once function prevents subsequent calls to initialize from
          reinitializing the instance, so there is no need to do any special state
          checking in the client. For single-call objects, the initialization
          routine can just be a regular routine. This method of course defines the
          object type (singleton or single-call) in the remote implementation as
          appose to the client. It depends on the proposed flexibility of your
          design whether or not this is an acceptable means of instantiating and
          initializing instances.

          The second solution, which has more flexibility in terms of client
          dictation of the type of object to instantiate, is to check the remote
          object's state of initialization at the beginning of the body of a
          remote method. I personally do not like this method. It's open to
          introduction of bugs through neglect when sub-classing. And, by design,
          is flaky. I'm only suggesting it incase the external model you want to
          present is that similar to using a default constructor to instantiate
          and initialize a remote object.

          --------------------------------------------------------------

          class MY_REMOTE_OBJECT

          inherit
          I_MY_REMOTE_OBJECT
          redefine
          my_remote_method
          end

          create
          make

          feature {NONE} -- Initialization

          make
          -- Create instance
          do
          ensure
          is_initialized
          end

          feature - Basic Operations

          me_remote_method (a_string: SYSTEM_STRING) is
          -- A remote method
          do
          if not is_initialized then
          make
          end

          --| Post initialized implementation
          end

          .
          .
          .

          feature - Access

          is_initialized: BOOLEAN
          -- Is instance initialized?

          end -- MY_REMOTE_OBJECT

          --------------------------------------------------------------

          Finally, if you don't want to make any such calls or have to write
          checks, you could implement a factory remote object:

          --------------------------------------------------------------

          class MY_REMOTE_OBJECT

          inherit
          I_MY_REMOTE_OBJECT
          redefine
          my_remote_method
          end

          create
          make

          feature {NONE} -- Initialization

          make is
          -- create and initialize object
          instance
          do
          --| .
          end

          feature -- Basic Operations

          my_remote_method (a_string: SYSTEM_STRING) is
          -- remote method
          do
          --| .
          end

          .
          .
          .

          end - class MY_REMOTE_OBJECT

          --------------------------------------------------------------

          class REMOTING_FACTORY

          inherit
          I_REMOTING_FACTORY
          redefine
          my_remote_object_singleton,
          my_remote_object
          end

          feature -- Access

          my_remote_object_singleton: MY_REMOTE_OBJECT is
          -- retrieve singleton instance of
          MY_REMOTE_OBJECT
          once
          create Result.make
          end

          my_remote_object: MY_REMOTE_OBJECT is
          -- retrieve instance of
          MY_REMOTE_OBJECT
          do
          create Result.make
          end

          end -- class REMOTING_FACTORY

          --------------------------------------------------------------

          I don't see any need to create another C# bootstrap assembly and add
          another unnecessary dependency. It can all be done from within Eiffel.

          The proposed first and final options are what you would need to consider
          if you wanted to instantiate and initialize a remote object using
          external data passed to the constructor via arguments. As the remoting
          infrastructure does not support this, an initialization routine will
          need to be called after the object has been created. In that respect,
          Eiffel actually forces a consistent model.

          I hope this helps,
          Paul.

          -----Original Message-----
          From: Oliver [mailto:olivercurl@...]
          Sent: Tuesday, June 01, 2004 6:35 AM
          To: eiffel_software@yahoogroups.com
          Subject: [eiffel_software] .NET Remoting - Denoting which creation
          method is to be called

          Hi,

          I am building a system that uses .NET Remoting. The server uses a
          server-activated singleton remote object. Therefore the object is
          instantiated by the remoting infrastructure in response to the first
          remote method call from a client via a proxy. According to what I
          have read the default constructor is used to create the instance. It
          is my understanding that in Eiffel there is no default constructor
          and that all methods that can be used for object creation are simply
          listed in the create clause. I have done some testing and I am
          unable to get the Remoting infrastructure to instantiate my remote
          object using a constructor from my code, as opposed to initialising
          all features to default values. I have tried using a single creation
          method called make, and that does not appear to be called at any time.
          Is there a way to denote a particular creation method as the default
          constructor for the purposes of the remoting infrastructure?

          Thanks,

          Oliver.





          Yahoo! Groups Sponsor


          ADVERTISEMENT

          <http://rd.yahoo.com/SIG=129mhvh7f/M=295196.4901138.6071305.3001176/D=gr
          oups/S=1705007207:HM/EXP=1086183442/A=2128215/R=0/SIG=10se96mf6/*http:/c
          ompanion.yahoo.com> click here


          <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=group
          s/S=:HM/A=2128215/rand=368331887>

          _____

          Yahoo! Groups Links
          * To visit your group on the web, go to:
          http://groups.yahoo.com/group/eiffel_software/

          * To unsubscribe from this group, send an email to:
          eiffel_software-unsubscribe@yahoogroups.com
          <mailto:eiffel_software-unsubscribe@yahoogroups.com?subject=Unsubscribe>


          * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
          <http://docs.yahoo.com/info/terms/> Service.


          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.