Problem with removeListener

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with removeListener

webdel@libero.it
look this code:
 
class test{
    Object obs = new java.util.Observer(){
            update(o, e){
                ....
            }
     };

    open(){
        myjavaclass.addObserver(obs);
        ....
    }

    close(){
          myjavaclass.deleteObserver(obs);
        ....
    }
}

i have problem with deleteObserver in myjavaclass don't remove  obs. The
problem is when the vector list in myjavaclass.deleteObserver call
remove don't find the obs because method equals don't work well between
java and beanshell.

how i do?

thank Danilo


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem with removeListener

Alexey Zinger
In the past I've seen problems stemming from lack of scope and return type in
method declarations:
hashCode() {...}
vs
public int hashCode() {...}

Can we see your implementations of hashCode() and equals(Object)?

--- webdel <[hidden email]> wrote:

> look this code:
>  
> class test{
>     Object obs = new java.util.Observer(){
>             update(o, e){
>                 ....
>             }
>      };
>
>     open(){
>         myjavaclass.addObserver(obs);
>         ....
>     }
>
>     close(){
>           myjavaclass.deleteObserver(obs);
>         ....
>     }
> }
>
> i have problem with deleteObserver in myjavaclass don't remove  obs. The
> problem is when the vector list in myjavaclass.deleteObserver call
> remove don't find the obs because method equals don't work well between
> java and beanshell.
>
> how i do?
>
> thank Danilo
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem with removeListener

webdel@libero.it
i don't have implementation of hashCode  or equals.
i don't want use this . if i add:

Object obs = new java.util.Observer(){
            update(o, e){
                ....
            }
           
       equals(o){
                print(super);
                print(o);
                print(o==super);
                print(super.equals(o));
                return true;
            }
     };

this code work but is wrong.
the output is:

- 'this' reference (XThis) to Bsh object: NameSpace: XPanelScript
(bsh.NameSpace@943b29) (isClass)  (class instance)
- XPanelScript@13b7064
- false
- false

thank very much
Danilo

P.S. now i create a work sample and post it



Alexey Zinger ha scritto:

> In the past I've seen problems stemming from lack of scope and return type in
> method declarations:
> hashCode() {...}
> vs
> public int hashCode() {...}
>
> Can we see your implementations of hashCode() and equals(Object)?
>
> --- webdel <[hidden email]> wrote:
>
>  
>> look this code:
>>  
>> class test{
>>     Object obs = new java.util.Observer(){
>>             update(o, e){
>>                 ....
>>             }
>>      };
>>
>>     open(){
>>         myjavaclass.addObserver(obs);
>>         ....
>>     }
>>
>>     close(){
>>           myjavaclass.deleteObserver(obs);
>>         ....
>>     }
>> }
>>
>> i have problem with deleteObserver in myjavaclass don't remove  obs. The
>> problem is when the vector list in myjavaclass.deleteObserver call
>> remove don't find the obs because method equals don't work well between
>> java and beanshell.
>>
>> how i do?
>>
>> thank Danilo
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
>> for problems?  Stop!  Download the new AJAX search engine that makes
>> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
>> _______________________________________________
>> Beanshell-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>>
>>    
>
>
> Alexey
> 2001 Honda CBR600F4i (CCS)
> 1992 Kawasaki EX500
> http://bsheet.sourceforge.net
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>
>
>  



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem with removeListener

Alexey Zinger
Uh, you don't wanna use hashCode() or equals(Object)?  Why?  The code works,
but is wrong?  Huh?  Maybe something's getting lost here.  Looking at the code,
here's what I'd do:

Object obs = new java.util.Observer(){
        update(o, e){
                ....
        }
           
        public boolean equals(Object o){
                // do something to really determine if the instances are equal
                // not just their references (==)
        }
       
        public int hashCode()
        {
                // Calculate a value that will be guaranteed for instances that
                // are equal to each other.  Doesn't have to be unique.
        }
};

Consult with Javadoc for the methods in question.  It contains a pretty good
explanation of how it should be implemented.  Then and only then would I worry
about whether BSH is interfering with it.  I've implemented this kind of stuff
before in BSH with no problems.

--- webdel <[hidden email]> wrote:

> i don't have implementation of hashCode  or equals.
> i don't want use this . if i add:
>
> Object obs = new java.util.Observer(){
>             update(o, e){
>                 ....
>             }
>    
>        equals(o){
> print(super);
> print(o);
> print(o==super);
> print(super.equals(o));
> return true;
>    }
>      };
>
> this code work but is wrong.
> the output is:
>
> - 'this' reference (XThis) to Bsh object: NameSpace: XPanelScript
> (bsh.NameSpace@943b29) (isClass)  (class instance)
> - XPanelScript@13b7064
> - false
> - false
>
> thank very much
> Danilo
>
> P.S. now i create a work sample and post it
>
>
>
> Alexey Zinger ha scritto:
> > In the past I've seen problems stemming from lack of scope and return type
> in
> > method declarations:
> > hashCode() {...}
> > vs
> > public int hashCode() {...}
> >
> > Can we see your implementations of hashCode() and equals(Object)?
> >
> > --- webdel <[hidden email]> wrote:
> >
> >  
> >> look this code:
> >>  
> >> class test{
> >>     Object obs = new java.util.Observer(){
> >>             update(o, e){
> >>                 ....
> >>             }
> >>      };
> >>
> >>     open(){
> >>         myjavaclass.addObserver(obs);
> >>         ....
> >>     }
> >>
> >>     close(){
> >>           myjavaclass.deleteObserver(obs);
> >>         ....
> >>     }
> >> }
> >>
> >> i have problem with deleteObserver in myjavaclass don't remove  obs. The
> >> problem is when the vector list in myjavaclass.deleteObserver call
> >> remove don't find the obs because method equals don't work well between
> >> java and beanshell.
> >>
> >> how i do?
> >>
> >> thank Danilo
> >>
> >>
> >> -------------------------------------------------------
> >> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> >> for problems?  Stop!  Download the new AJAX search engine that makes
> >> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> >> _______________________________________________
> >> Beanshell-users mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >>
> >>    
> >
> >
> > Alexey
> > 2001 Honda CBR600F4i (CCS)
> > 1992 Kawasaki EX500
> > http://bsheet.sourceforge.net
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com 
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> > for problems?  Stop!  Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> > _______________________________________________
> > Beanshell-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >
> >
> >  
>
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem with removeListener

Alexey Zinger
In reply to this post by webdel@libero.it
Most likely because in BeanShell, you were inheriting XThis implementations of
those methods rather than ObjectObserver's.  But this is just a theory on my
part.

--- webdel <[hidden email]> wrote:

> yes, but i wan't understand why the analog code used without equals or
> hashCode work in java and don't work in bsh?
>
>
> thank you
> very much
>
> Danilo
>
>
> Alexey Zinger ha scritto:
> >> Uh, you don't wanna use hashCode() or equals(Object)?  Why?  The code
> >> works,
> >> but is wrong?  Huh?  Maybe something's getting lost here.  Looking at
> >> the code,
> >> here's what I'd do:
> >>
> >> Object obs = new java.util.Observer(){
> >>     update(o, e){
> >>         ....
> >>     }
> >>             public boolean equals(Object o){
> >>         // do something to really determine if the instances are
> >> equal         // not just their references (==)
> >>     }
> >>    
> >>     public int hashCode()
> >>     {
> >>         // Calculate a value that will be guaranteed for instances that
> >>         // are equal to each other.  Doesn't have to be unique.
> >>     }
> >> };
> >>
> >> Consult with Javadoc for the methods in question.  It contains a
> >> pretty good
> >> explanation of how it should be implemented.  Then and only then
> >> would I worry
> >> about whether BSH is interfering with it.  I've implemented this kind
> >> of stuff
> >> before in BSH with no problems.
> >>
> >> --- webdel <[hidden email]> wrote:
> >>
> >>  
> >>> i don't have implementation of hashCode  or equals.
> >>> i don't want use this . if i add:
> >>>
> >>> Object obs = new java.util.Observer(){
> >>>             update(o, e){
> >>>                 ....
> >>>             }
> >>>                    equals(o){
> >>>         print(super);
> >>>         print(o);
> >>>         print(o==super);
> >>>         print(super.equals(o));
> >>>         return true;
> >>>         }
> >>>      };
> >>>
> >>> this code work but is wrong.
> >>> the output is:
> >>>
> >>> - 'this' reference (XThis) to Bsh object: NameSpace: XPanelScript
> >>> (bsh.NameSpace@943b29) (isClass)  (class instance)
> >>> - XPanelScript@13b7064
> >>> - false
> >>> - false
> >>>
> >>> thank very much
> >>> Danilo
> >>>
> >>> P.S. now i create a work sample and post it
> >>>
> >>>
> >>>
> >>> Alexey Zinger ha scritto:
> >>>    
> >>>> In the past I've seen problems stemming from lack of scope and
> >>>> return type
> >>>>      
> >>> in
> >>>    
> >>>> method declarations: hashCode() {...}
> >>>> vs
> >>>> public int hashCode() {...}
> >>>>
> >>>> Can we see your implementations of hashCode() and equals(Object)?
> >>>>
> >>>> --- webdel <[hidden email]> wrote:
> >>>>
> >>>>        
> >>>>> look this code:
> >>>>>  
> >>>>> class test{
> >>>>>     Object obs = new java.util.Observer(){
> >>>>>             update(o, e){
> >>>>>                 ....
> >>>>>             }
> >>>>>      };
> >>>>>
> >>>>>     open(){
> >>>>>         myjavaclass.addObserver(obs);
> >>>>>         ....
> >>>>>     }
> >>>>>
> >>>>>     close(){
> >>>>>           myjavaclass.deleteObserver(obs);
> >>>>>         ....
> >>>>>     }
> >>>>> }
> >>>>>
> >>>>> i have problem with deleteObserver in myjavaclass don't remove  
> >>>>> obs. The problem is when the vector list in
> >>>>> myjavaclass.deleteObserver call remove don't find the obs because
> >>>>> method equals don't work well between java and beanshell.
> >>>>>
> >>>>> how i do?
> >>>>>
> >>>>> thank Danilo
> >>>>>
> >>>>>
> >>>>> -------------------------------------------------------
> >>>>> This SF.net email is sponsored by: Splunk Inc. Do you grep through
> >>>>> log
> >>>>>        
> >>> files
> >>>    
> >>>>> for problems?  Stop!  Download the new AJAX search engine that makes
> >>>>> searching your log files as easy as surfing the  web.  DOWNLOAD
> >>>>> SPLUNK!
> >>>>>
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 
> >>>>>
> >>>>> _______________________________________________
> >>>>> Beanshell-users mailing list
> >>>>> [hidden email]
> >>>>> https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >>>>>
> >>>>>            
> >>>> Alexey
> >>>> 2001 Honda CBR600F4i (CCS)
> >>>> 1992 Kawasaki EX500
> >>>> http://bsheet.sourceforge.net
> >>>>
> >>>> __________________________________________________
> >>>> Do You Yahoo!?
> >>>> Tired of spam?  Yahoo! Mail has the best spam protection around
> >>>> http://mail.yahoo.com
> >>>>
> >>>> -------------------------------------------------------
> >>>> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> >>>>      
> >>> files
> >>>    
> >>>> for problems?  Stop!  Download the new AJAX search engine that makes
> >>>> searching your log files as easy as surfing the  web.  DOWNLOAD
> >>>> SPLUNK!
> >>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
>
> >>>>
> >>>> _______________________________________________
> >>>> Beanshell-users mailing list
> >>>> [hidden email]
> >>>> https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >>>>
> >>>>
> >>>>        
> >>>    
> >>
> >>
> >> Alexey
> >> 2001 Honda CBR600F4i (CCS)
> >> 1992 Kawasaki EX500
> >> http://bsheet.sourceforge.net
> >>
> >> __________________________________________________
> >> Do You Yahoo!?
> >> Tired of spam?  Yahoo! Mail has the best spam protection around
> >> http://mail.yahoo.com
> >>
> >> -------------------------------------------------------
> >> This SF.net email is sponsored by: Splunk Inc. Do you grep through
> >> log files
> >> for problems?  Stop!  Download the new AJAX search engine that makes
> >> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> >> _______________________________________________
> >> Beanshell-users mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >>
> >>
> >>  
> >
> >
>
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users