[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objects versus proxies



On Fri, 07 Jul 2000, Charles Benett wrote:
> Hi!
> 
> Falko Braeutigam wrote:
> 
> > On Thu, 06 Jul 2000, Charles Benett wrote:
> > > Hi!
> > >
> > > I'm getting a ClassCastException which doesn't make sense. Basically I
> > > have one database object which creates database objects of two other
> > > classes and then passes on of these to the other as a parameter of a
> > > method. The method call throws a ClassCastException referencing the
> > > Proxy for the parameter.
> > >
> > > OK. I have an object, dbObj1, with a default constructor and a method.
> > > The client app calls createObject(dbObj1) and then the method.
> > >  Method is like this:
> > > blah, blah
> > > try {
> > > Interface2 varDbObj2 = (Interface2)
> > > database().createObject(class_DbObj2);
> > > varDbObj2.someMethod_update(); // no params
> > >
> > > Interface3 varDbObj3 = (Interface3)
> > > database().createObject(class_DbObj3);
> > > varDbObj3.init_update(String, String); // so the strings become
> > > persistent members of the dbObj3
> > >
> > > varDbObj2.add_update(varDbObj3); // throws UnexpectedException
> > > }
> > >
> > > The UnexpectedException is: ClassCastException class_DbObj3_Proxy
> > > at class_DbObj2_Proxy.add_update
> > > at class_DbObj1.Method
> > >
> > > The the add method is:
> > > public void add_update(Interface3 anObj) {
> > > someCollection.add(obj);
> > > // other stuff
> > > }
> > >
> > > But class_DbObj3, varDbObj3 and classDbObj3_Proxy all implement
> > > Interface 3, so why do I get a class cast exception?
> >
> > Hmmm.. so far I don't see the problem. Can you please send the full stack traces
> > (with line numbers, if possible) from the client _and_ the server plus the
> > source code of the generated proxy? (-ks tells opp to keep sources)
> >
> 
> Unfortuneatly I'd changed the code to work around this before I got your email. I
> tried putting together a simple example - but it works! Rats.
> If I find the problem again, I'll let you know.
> Looks likes its something funky my end.
> 
> >
> > BTW: your type names are somewhat confusing. Why don't you just follow the
> > naming conventions of the samples and the tutorial? They help to produce
> > readable and maintainable code and help other (ozone) programmers to
> > understand what you have done.
> 
> Oh,those aren't the real names! I use, e.g. Car (for interface) and CarPDO (for
> persistent data objects). I think CarImpl isn't very helpful. All it suggests is
> that it implements some interface Car. What I really want to know is that its a
> persistent data object, as opposed to an EJB, a javabean or any other type of
> object.
Yes, good point. In environments where different types of (persistent) business
objects exists, *PDO is more clear than *Impl indeed. What do you guys think
about Persistent Data Objects?


Falko
-- 
______________________________________________________________________
Falko Braeutigam                         mailto:falko@softwarebuero.de
softwarebuero m&b (SMB)                    http://www.softwarebuero.de