Index: [Article Count Order] [Thread]

Date:  Fri, 22 Mar 2002 22:19:57 +1200
From:  Holden Glova <dsafari@xtra.co.nz>
Subject:  [webricken:76] Re: soaplet confusion saga
To:  webricken@notwork.org
Message-Id:  <20020322101440.DINL20246.mta3-rme.xtra.co.nz@there>
In-Reply-To:  <000801c1d186$a478af40$85222fc0@sarion.co.jp>
References:  <000801c1d186$a478af40$85222fc0@sarion.co.jp>
X-Mail-Count: 00076

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 22 Mar 2002 21:47, NAKAMURA, Hiroshi wrote:
> Hi, Holden,
>
> I'm sorry but I misunderstood the problem.
>
> > From: Holden Glova [mailto:dsafari@xtra.co.nz]
> > Sent: Friday, March 22, 2002 6:37 PM
> >
> > > Hmm.  Instance of Proxy is created by SOAP4R unmarshaller,
> > > isn't it?  The SOAP4R unmarshaller allocates new object
> > > without calling user's initialize and set its instance
> > > variables.  Your Proxy#initialize is not called.  So the
> > > method 'name' is not on your method list.
> >
> > Not sure I fully understand - my proxy initialize method must
> > be getting
> > called because the correct data is stored in the name
> > attribute. Also, when I
> > do a #type#to_s on the object coming back it is of type
> > RAA::Proxy which is
> > my class, no?
>
> Yes.  But if the object was created by SOAP4R,
> your Proxy#initialize was not called.  SOAP4R set
> @name using instance_eval.
>
> Is the Proxy object really sent back from the server side?
> Your server side method is something like
>
>   def search_for_entry_index
>     proxy = RAA::Proxy.new( [ :name ] )
>     proxy.name = [ "name1", "name2" ... ]
>     return proxy
>   end
>
> no? ... (*)

Very close NaHi! Server method looks like this:
  def search_for_entry_names(name)
    storage_handle = StorageUtils.get_storage_handle
    entry_indexes = 			
RAA::PersistenceMechanism.new.search_for_entry_indexes(name, storage_handle)
    
    ProxyFactory.create_many(entry_indexes, :name)
  end

entry_indexes is an array of EntryIndex objects which are merely data 
transfer objects. This array then gets passed to the ProxyFactory to make me 
proxies that only have a name field. Here is the code for that.

class ProxyFactory


  #
  # Creates a proxy object with the data from the supplied object for
  # the requested attributes.
  #
  # Returns a Proxy
  #  
  def ProxyFactory.create(object, *attributes)
    proxy = Proxy.new(attributes)		# Makes my Proxy object

    attributes.each do |attribute|
      value = object.send(attribute)
      setter = attribute.id2name + '='
      proxy.send(setter, value)
    end

    proxy
  end
  
  
  #
  # Creates a list of proxy objects with the data supplied from a list objects
  # for the requested attributes
  #
  # Returns an Array of Proxy objects
  #
  def ProxyFactory.create_many(objects, *attributes)
    proxies = []
    
    objects.each do |object|
      proxy = ProxyFactory.create(object, *attributes)
      proxies << proxy
    end
    
    proxies
  end
  
end

I hope this adds some clarity to my problem - thanks.

- -- 
Signed,
Holden Glova
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8mwVO+mF116Lw2cQRAtogAKCIxx39raOcaHtpYuZAru6jGVCpagCfaMuR
Cjl/nnaVkLuJw3vTIWN6VH4=
=+0d9
-----END PGP SIGNATURE-----