You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashish Kulkarni <ku...@yahoo.com> on 2003/01/31 16:34:28 UTC

one desing question, Revisited

Hi,

When i was thinking about my problem, I think what i
want to do in multiple inhereteance
I want to define a class called CommonFunctions , this
call will have methods which are common, (As name
suggest)
now i have to do some thing like
public class MyAction extends Action, CommonFuntions

and public class MyDisptachAction extends
DispatchAction, CommonFuntions

By doing this i will be able to access all the methods
in the class which sybclasses MyAction or
MyDispatchAction
I know the code above is not possible to do, but i
want to do some thing like that..
So what are the ways of achieving it

=====
A$HI$H

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: one desing question, Revisited

Posted by Malik Recoing <m....@almerys.com>.
Friday, January 31, 2003 4:34 PM , Ashish Kulkarni
<ku...@yahoo.com> a écrit :
> Hi,
>
> When i was thinking about my problem, I think what i
> want to do in multiple inhereteance
> I want to define a class called CommonFunctions , this
> call will have methods which are common, (As name
> suggest)
> now i have to do some thing like
> public class MyAction extends Action, CommonFuntions
>
> and public class MyDisptachAction extends
> DispatchAction, CommonFuntions
>
> By doing this i will be able to access all the methods
> in the class which sybclasses MyAction or
> MyDispatchAction
> I know the code above is not possible to do, but i
> want to do some thing like that..
> So what are the ways of achieving it
>

As mutiple inheritance is not possible, the only alternative is to delegate.

You can do it by using a CommonFunction attribute in an MyAbstractAction
classe. All the concrete sub-classes of it can then use this attribute as an
access to the common functions. This is only interesting if you
CommonFunction instances can be differents (differently configured) for each
MyAction.

An other common way to use utility Classes via delegation is by using it as
a Singleton (look for Sigleton desing pattern) or by making all methods
(functions) static if posssible.

Malik




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: one desing question, Revisited

Posted by Matthew Meyer <mo...@charter.net>.
The interface provides both flexability in the 
delegation(aka different versions of the common funtions 
can exist), and it enforces an API.
Interfaces don't need to be logically functional objects. 
When was the last time you cast an object to Serializable 
and manipulated it?

Matt,


On Fri, 31 Jan 2003 17:23:29 +0100
  "Malik Recoing" <m....@almerys.com> wrote:
>I Ask : "What the real apport of implementing 
>CommonFunctionInterface in
>each classes rather than just using common.aFunction() 
>where you need it ?"
>(but maintaining more code).
>
>Malik.
>
>Friday, January 31, 2003 5:17 PM , Ashish Kulkarni
><ku...@yahoo.com> a écrit :
>> Hi
>> Thanx for the all the mails, this is what i plan to do
>> public interface CommonFunctionInterface{
>>     // all my common methods;
>>    public Connection getConnection();
>>
>> }
>>
>> public class CommonFunction implements
>> CommonFunctionInterface{
>>
>>         public Connection getConnection(){
>>         // provide the implementation here
>>
>>         }
>> }
>>
>> public class MyAction extends Action implements
>> CommonFunctionInterface{
>>         private final CommonFunction common;
>>
>>         public MyAction(){
>>             common = new CommonFunction();
>>         }
>>
>>         public Connection getConnnection(){
>>                 return common.getConnection();
>>         }
>>
>> }
>>
>> public MyClass extends MyAction{
>>         // now you should inherit getConnection()
>> without problem }
>>
>>
>> Ashish
>>
>>
>> --- John Espey <je...@tallan.com> wrote:
>> > sorry, the action wouldn't pass itself, it would
>> > pass its class.
>> >
>> > -----Original Message-----
>> > From: John Espey [mailto:jespey@tallan.com]
>> > Sent: Friday, January 31, 2003 10:10 AM
>> > To: Struts Users Mailing List
>> > Subject: RE: one desing question, Revisited
>> >
>> >
>> > You could create a CommonFunctionsFactory, with a
>> > method:
>> >
>> > CommonFunctions getCommonFunctionsByClass(Class)
>> >
>> > Your action could pass itself to this call to
>> > retrieve a CommonFunctions
>> > implementation, determined by the Factory, which
>> > could look up in a
>> > properties file which implementation to create for
>> > the specified class.  You
>> > wouldn't really need to have your action implement
>> > CommonFunctions.  If you
>> > needed to modify the behavior of your
>> > CommonFunctionsImpl for a given action
>> > class, you could extend CommonFunctionsImpl, and
>> > then map the action class
>> > to that new subclass.
>> >
>> > -----Original Message-----
>> > From: Matthew Meyer [mailto:mordorian@charter.net]
>> > Sent: Friday, January 31, 2003 10:00 AM
>> > To: Struts Users Mailing List
>> > Subject: Re: one desing question, Revisited
>> >
>> >
>> > What you will want to is make your commonFunctions
>> > an
>> > interface. Next write a class to implement all of
>> > your
>> > common functions. Then Write your action extending
>> > Action
>> > and implementing your commonFunctions interface.
>> > Make your
>> > common funtions an instance variable of your action
>> > and
>> > then simply delegate all the commonFunction messages
>> > your
>> > action recieves to your commonFunction instance
>> > variable
>> > like so:
>> >      public .... method(..., ....) {
>> >         return commonFuntionInstance.method(....,
>> > ....);
>> >      }
>> > Hope this helps you out...
>> >
>> > Matt,
>> >
>> >
>> > On Fri, 31 Jan 2003 07:45:22 -0800 (PST)
>> >   Ashish Kulkarni <ku...@yahoo.com>
>> > wrote:
>> > > Hi,
>> > > I know java does not allow multiple inheritance,
>> > but I
>> > > gave that example so i can make it clear what i
>> > want
>> > > to do,
>> > > So i want to find out a work around to achieve what
>> > i
>> > > have explanned in the example
>> > > Ashish
>> > > --- Jacob Hookom <ho...@uwec.edu> wrote:
>> > > > I'm going to save you from getting flamed....
>> > java
>> > > > does not allow multiple
>> > > > inheritance.  You can only extend from a single
>> > > > Object.
>> > > >
>> > > > -Jacob
>> > > >
>> > > > > -----Original Message-----
>> > > > > From: Ashish Kulkarni
>> > > > [mailto:kulkarni_ash1312@yahoo.com]
>> > > > > Sent: Friday, January 31, 2003 9:34 AM
>> > > > > To: struts-user@jakarta.apache.org
>> > > > > Subject: one desing question, Revisited
>> > > > >
>> > > > > Hi,
>> > > > >
>> > > > > When i was thinking about my problem, I think
>> > what
>> > > > i
>> > > > > want to do in multiple inhereteance
>> > > > > I want to define a class called CommonFunctions
>> > ,
>> > > > this
>> > > > > call will have methods which are common, (As
>> > name
>> > > > > suggest)
>> > > > > now i have to do some thing like
>> > > > > public class MyAction extends Action,
>> > > > CommonFuntions
>> > > > >
>> > > > > and public class MyDisptachAction extends
>> > > > > DispatchAction, CommonFuntions
>> > > > >
>> > > > > By doing this i will be able to access all the
>> > > > methods
>> > > > > in the class which sybclasses MyAction or
>> > > > > MyDispatchAction
>> > > > > I know the code above is not possible to do,
>> > but i
>> > > > > want to do some thing like that..
>> > > > > So what are the ways of achieving it
>> > > > >
>> > > > > =====
>> > > > > A$HI$H
>> > > > >
>> > > > >
>> > __________________________________________________
>> > > > > Do you Yahoo!?
>> > > > > Yahoo! Mail Plus - Powerful. Affordable. Sign
>> > up
>> > > > now.
>> > > > > http://mailplus.yahoo.com
>> > > > >
>> > > > >
>> > > >
>> >
>> > 
>>---------------------------------------------------------------------
>> > > > > To unsubscribe, e-mail:
>> > > > struts-user-unsubscribe@jakarta.apache.org
>> > > > > For additional commands, e-mail:
>> > > > struts-user-help@jakarta.apache.org
>> > > >
>> > > >
>> > > >
>> >
>> > 
>>---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail:
>> > > > struts-user-unsubscribe@jakarta.apache.org
>> > > > For additional commands, e-mail:
>> > > > struts-user-help@jakarta.apache.org
>> > > >
>> > >
>> > >
>> > > =====
>> > > A$HI$H
>> > >
>> > > __________________________________________________
>> > > Do you Yahoo!?
>> > > Yahoo! Mail Plus - Powerful. Affordable. Sign up
>> > now.
>> > > http://mailplus.yahoo.com
>> > >
>> >
>> > 
>>---------------------------------------------------------------------
>> > > To unsubscribe, e-mail:
>> > > struts-user-unsubscribe@jakarta.apache.org
>> > > For additional commands, e-mail:
>> > > struts-user-help@jakarta.apache.org
>> > >
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> > struts-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail:
>> > struts-user-help@jakarta.apache.org
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> > struts-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail:
>> > struts-user-help@jakarta.apache.org
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> > struts-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail:
>> > struts-user-help@jakarta.apache.org
>> >
>>
>>
>> =====
>> A$HI$H
>>
>> __________________________________________________
>> Do you Yahoo!?
>> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>> http://mailplus.yahoo.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: 
>>struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: 
>>struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: 
>struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: 
>struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: one desing question, Revisited

Posted by Malik Recoing <m....@almerys.com>.
I Ask : "What the real apport of implementing CommonFunctionInterface in
each classes rather than just using common.aFunction() where you need it ?"
(but maintaining more code).

Malik.

Friday, January 31, 2003 5:17 PM , Ashish Kulkarni
<ku...@yahoo.com> a écrit :
> Hi
> Thanx for the all the mails, this is what i plan to do
> public interface CommonFunctionInterface{
>     // all my common methods;
>    public Connection getConnection();
>
> }
>
> public class CommonFunction implements
> CommonFunctionInterface{
>
>         public Connection getConnection(){
>         // provide the implementation here
>
>         }
> }
>
> public class MyAction extends Action implements
> CommonFunctionInterface{
>         private final CommonFunction common;
>
>         public MyAction(){
>             common = new CommonFunction();
>         }
>
>         public Connection getConnnection(){
>                 return common.getConnection();
>         }
>
> }
>
> public MyClass extends MyAction{
>         // now you should inherit getConnection()
> without problem }
>
>
> Ashish
>
>
> --- John Espey <je...@tallan.com> wrote:
> > sorry, the action wouldn't pass itself, it would
> > pass its class.
> >
> > -----Original Message-----
> > From: John Espey [mailto:jespey@tallan.com]
> > Sent: Friday, January 31, 2003 10:10 AM
> > To: Struts Users Mailing List
> > Subject: RE: one desing question, Revisited
> >
> >
> > You could create a CommonFunctionsFactory, with a
> > method:
> >
> > CommonFunctions getCommonFunctionsByClass(Class)
> >
> > Your action could pass itself to this call to
> > retrieve a CommonFunctions
> > implementation, determined by the Factory, which
> > could look up in a
> > properties file which implementation to create for
> > the specified class.  You
> > wouldn't really need to have your action implement
> > CommonFunctions.  If you
> > needed to modify the behavior of your
> > CommonFunctionsImpl for a given action
> > class, you could extend CommonFunctionsImpl, and
> > then map the action class
> > to that new subclass.
> >
> > -----Original Message-----
> > From: Matthew Meyer [mailto:mordorian@charter.net]
> > Sent: Friday, January 31, 2003 10:00 AM
> > To: Struts Users Mailing List
> > Subject: Re: one desing question, Revisited
> >
> >
> > What you will want to is make your commonFunctions
> > an
> > interface. Next write a class to implement all of
> > your
> > common functions. Then Write your action extending
> > Action
> > and implementing your commonFunctions interface.
> > Make your
> > common funtions an instance variable of your action
> > and
> > then simply delegate all the commonFunction messages
> > your
> > action recieves to your commonFunction instance
> > variable
> > like so:
> >      public .... method(..., ....) {
> >         return commonFuntionInstance.method(....,
> > ....);
> >      }
> > Hope this helps you out...
> >
> > Matt,
> >
> >
> > On Fri, 31 Jan 2003 07:45:22 -0800 (PST)
> >   Ashish Kulkarni <ku...@yahoo.com>
> > wrote:
> > > Hi,
> > > I know java does not allow multiple inheritance,
> > but I
> > > gave that example so i can make it clear what i
> > want
> > > to do,
> > > So i want to find out a work around to achieve what
> > i
> > > have explanned in the example
> > > Ashish
> > > --- Jacob Hookom <ho...@uwec.edu> wrote:
> > > > I'm going to save you from getting flamed....
> > java
> > > > does not allow multiple
> > > > inheritance.  You can only extend from a single
> > > > Object.
> > > >
> > > > -Jacob
> > > >
> > > > > -----Original Message-----
> > > > > From: Ashish Kulkarni
> > > > [mailto:kulkarni_ash1312@yahoo.com]
> > > > > Sent: Friday, January 31, 2003 9:34 AM
> > > > > To: struts-user@jakarta.apache.org
> > > > > Subject: one desing question, Revisited
> > > > >
> > > > > Hi,
> > > > >
> > > > > When i was thinking about my problem, I think
> > what
> > > > i
> > > > > want to do in multiple inhereteance
> > > > > I want to define a class called CommonFunctions
> > ,
> > > > this
> > > > > call will have methods which are common, (As
> > name
> > > > > suggest)
> > > > > now i have to do some thing like
> > > > > public class MyAction extends Action,
> > > > CommonFuntions
> > > > >
> > > > > and public class MyDisptachAction extends
> > > > > DispatchAction, CommonFuntions
> > > > >
> > > > > By doing this i will be able to access all the
> > > > methods
> > > > > in the class which sybclasses MyAction or
> > > > > MyDispatchAction
> > > > > I know the code above is not possible to do,
> > but i
> > > > > want to do some thing like that..
> > > > > So what are the ways of achieving it
> > > > >
> > > > > =====
> > > > > A$HI$H
> > > > >
> > > > >
> > __________________________________________________
> > > > > Do you Yahoo!?
> > > > > Yahoo! Mail Plus - Powerful. Affordable. Sign
> > up
> > > > now.
> > > > > http://mailplus.yahoo.com
> > > > >
> > > > >
> > > >
> >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail:
> > > > struts-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> > > > struts-user-help@jakarta.apache.org
> > > >
> > > >
> > > >
> >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > > struts-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> > > > struts-user-help@jakarta.apache.org
> > > >
> > >
> > >
> > > =====
> > > A$HI$H
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail Plus - Powerful. Affordable. Sign up
> > now.
> > > http://mailplus.yahoo.com
> > >
> >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > > struts-user-help@jakarta.apache.org
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
>
>
> =====
> A$HI$H
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: one desing question, Revisited

Posted by Ashish Kulkarni <ku...@yahoo.com>.
Hi
Thanx for the all the mails, this is what i plan to do
public interface CommonFunctionInterface{
    // all my common methods;
   public Connection getConnection();

}

public class CommonFunction implements
CommonFunctionInterface{

        public Connection getConnection(){
        // provide the implementation here

        }
}

public class MyAction extends Action implements
CommonFunctionInterface{
        private final CommonFunction common;

        public MyAction(){
            common = new CommonFunction();
        }

        public Connection getConnnection(){
                return common.getConnection();
        }

}

public MyClass extends MyAction{
        // now you should inherit getConnection()
without problem }


Ashish


--- John Espey <je...@tallan.com> wrote:
> sorry, the action wouldn't pass itself, it would
> pass its class.
> 
> -----Original Message-----
> From: John Espey [mailto:jespey@tallan.com]
> Sent: Friday, January 31, 2003 10:10 AM
> To: Struts Users Mailing List
> Subject: RE: one desing question, Revisited
> 
> 
> You could create a CommonFunctionsFactory, with a
> method:
> 
> CommonFunctions getCommonFunctionsByClass(Class)
> 
> Your action could pass itself to this call to
> retrieve a CommonFunctions
> implementation, determined by the Factory, which
> could look up in a
> properties file which implementation to create for
> the specified class.  You
> wouldn't really need to have your action implement
> CommonFunctions.  If you
> needed to modify the behavior of your
> CommonFunctionsImpl for a given action
> class, you could extend CommonFunctionsImpl, and
> then map the action class
> to that new subclass.
> 
> -----Original Message-----
> From: Matthew Meyer [mailto:mordorian@charter.net]
> Sent: Friday, January 31, 2003 10:00 AM
> To: Struts Users Mailing List
> Subject: Re: one desing question, Revisited
> 
> 
> What you will want to is make your commonFunctions
> an
> interface. Next write a class to implement all of
> your
> common functions. Then Write your action extending
> Action
> and implementing your commonFunctions interface.
> Make your
> common funtions an instance variable of your action
> and
> then simply delegate all the commonFunction messages
> your
> action recieves to your commonFunction instance
> variable
> like so:
>      public .... method(..., ....) {
>         return commonFuntionInstance.method(....,
> ....);
>      }
> Hope this helps you out...
> 
> Matt,
> 
> 
> On Fri, 31 Jan 2003 07:45:22 -0800 (PST)
>   Ashish Kulkarni <ku...@yahoo.com>
> wrote:
> >Hi,
> >I know java does not allow multiple inheritance,
> but I
> >gave that example so i can make it clear what i
> want
> >to do,
> >So i want to find out a work around to achieve what
> i
> >have explanned in the example
> >Ashish
> >--- Jacob Hookom <ho...@uwec.edu> wrote:
> >> I'm going to save you from getting flamed....
> java
> >> does not allow multiple
> >> inheritance.  You can only extend from a single
> >> Object.
> >>
> >> -Jacob
> >>
> >> | -----Original Message-----
> >> | From: Ashish Kulkarni
> >> [mailto:kulkarni_ash1312@yahoo.com]
> >> | Sent: Friday, January 31, 2003 9:34 AM
> >> | To: struts-user@jakarta.apache.org
> >> | Subject: one desing question, Revisited
> >> |
> >> | Hi,
> >> |
> >> | When i was thinking about my problem, I think
> what
> >> i
> >> | want to do in multiple inhereteance
> >> | I want to define a class called CommonFunctions
> ,
> >> this
> >> | call will have methods which are common, (As
> name
> >> | suggest)
> >> | now i have to do some thing like
> >> | public class MyAction extends Action,
> >> CommonFuntions
> >> |
> >> | and public class MyDisptachAction extends
> >> | DispatchAction, CommonFuntions
> >> |
> >> | By doing this i will be able to access all the
> >> methods
> >> | in the class which sybclasses MyAction or
> >> | MyDispatchAction
> >> | I know the code above is not possible to do,
> but i
> >> | want to do some thing like that..
> >> | So what are the ways of achieving it
> >> |
> >> | =====
> >> | A$HI$H
> >> |
> >> |
> __________________________________________________
> >> | Do you Yahoo!?
> >> | Yahoo! Mail Plus - Powerful. Affordable. Sign
> up
> >> now.
> >> | http://mailplus.yahoo.com
> >> |
> >> |
> >>
>
>---------------------------------------------------------------------
> >> | To unsubscribe, e-mail:
> >> struts-user-unsubscribe@jakarta.apache.org
> >> | For additional commands, e-mail:
> >> struts-user-help@jakarta.apache.org
> >>
> >>
> >>
>
>---------------------------------------------------------------------
> >> To unsubscribe, e-mail:
> >> struts-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail:
> >> struts-user-help@jakarta.apache.org
> >>
> >
> >
> >=====
> >A$HI$H
> >
> >__________________________________________________
> >Do you Yahoo!?
> >Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> >http://mailplus.yahoo.com
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> >struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail:
> >struts-user-help@jakarta.apache.org
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


=====
A$HI$H

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: one desing question, Revisited

Posted by John Espey <je...@tallan.com>.
sorry, the action wouldn't pass itself, it would pass its class.

-----Original Message-----
From: John Espey [mailto:jespey@tallan.com]
Sent: Friday, January 31, 2003 10:10 AM
To: Struts Users Mailing List
Subject: RE: one desing question, Revisited


You could create a CommonFunctionsFactory, with a method:

CommonFunctions getCommonFunctionsByClass(Class)

Your action could pass itself to this call to retrieve a CommonFunctions
implementation, determined by the Factory, which could look up in a
properties file which implementation to create for the specified class.  You
wouldn't really need to have your action implement CommonFunctions.  If you
needed to modify the behavior of your CommonFunctionsImpl for a given action
class, you could extend CommonFunctionsImpl, and then map the action class
to that new subclass.

-----Original Message-----
From: Matthew Meyer [mailto:mordorian@charter.net]
Sent: Friday, January 31, 2003 10:00 AM
To: Struts Users Mailing List
Subject: Re: one desing question, Revisited


What you will want to is make your commonFunctions an
interface. Next write a class to implement all of your
common functions. Then Write your action extending Action
and implementing your commonFunctions interface. Make your
common funtions an instance variable of your action and
then simply delegate all the commonFunction messages your
action recieves to your commonFunction instance variable
like so:
     public .... method(..., ....) {
        return commonFuntionInstance.method(...., ....);
     }
Hope this helps you out...

Matt,


On Fri, 31 Jan 2003 07:45:22 -0800 (PST)
  Ashish Kulkarni <ku...@yahoo.com> wrote:
>Hi,
>I know java does not allow multiple inheritance, but I
>gave that example so i can make it clear what i want
>to do,
>So i want to find out a work around to achieve what i
>have explanned in the example
>Ashish
>--- Jacob Hookom <ho...@uwec.edu> wrote:
>> I'm going to save you from getting flamed.... java
>> does not allow multiple
>> inheritance.  You can only extend from a single
>> Object.
>>
>> -Jacob
>>
>> | -----Original Message-----
>> | From: Ashish Kulkarni
>> [mailto:kulkarni_ash1312@yahoo.com]
>> | Sent: Friday, January 31, 2003 9:34 AM
>> | To: struts-user@jakarta.apache.org
>> | Subject: one desing question, Revisited
>> |
>> | Hi,
>> |
>> | When i was thinking about my problem, I think what
>> i
>> | want to do in multiple inhereteance
>> | I want to define a class called CommonFunctions ,
>> this
>> | call will have methods which are common, (As name
>> | suggest)
>> | now i have to do some thing like
>> | public class MyAction extends Action,
>> CommonFuntions
>> |
>> | and public class MyDisptachAction extends
>> | DispatchAction, CommonFuntions
>> |
>> | By doing this i will be able to access all the
>> methods
>> | in the class which sybclasses MyAction or
>> | MyDispatchAction
>> | I know the code above is not possible to do, but i
>> | want to do some thing like that..
>> | So what are the ways of achieving it
>> |
>> | =====
>> | A$HI$H
>> |
>> | __________________________________________________
>> | Do you Yahoo!?
>> | Yahoo! Mail Plus - Powerful. Affordable. Sign up
>> now.
>> | http://mailplus.yahoo.com
>> |
>> |
>>
>---------------------------------------------------------------------
>> | To unsubscribe, e-mail:
>> struts-user-unsubscribe@jakarta.apache.org
>> | For additional commands, e-mail:
>> struts-user-help@jakarta.apache.org
>>
>>
>>
>---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:
>> struts-user-help@jakarta.apache.org
>>
>
>
>=====
>A$HI$H
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>http://mailplus.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail:
>struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail:
>struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: one desing question, Revisited

Posted by John Espey <je...@tallan.com>.
You could create a CommonFunctionsFactory, with a method:

CommonFunctions getCommonFunctionsByClass(Class)

Your action could pass itself to this call to retrieve a CommonFunctions
implementation, determined by the Factory, which could look up in a
properties file which implementation to create for the specified class.  You
wouldn't really need to have your action implement CommonFunctions.  If you
needed to modify the behavior of your CommonFunctionsImpl for a given action
class, you could extend CommonFunctionsImpl, and then map the action class
to that new subclass.

-----Original Message-----
From: Matthew Meyer [mailto:mordorian@charter.net]
Sent: Friday, January 31, 2003 10:00 AM
To: Struts Users Mailing List
Subject: Re: one desing question, Revisited


What you will want to is make your commonFunctions an
interface. Next write a class to implement all of your
common functions. Then Write your action extending Action
and implementing your commonFunctions interface. Make your
common funtions an instance variable of your action and
then simply delegate all the commonFunction messages your
action recieves to your commonFunction instance variable
like so:
     public .... method(..., ....) {
        return commonFuntionInstance.method(...., ....);
     }
Hope this helps you out...

Matt,


On Fri, 31 Jan 2003 07:45:22 -0800 (PST)
  Ashish Kulkarni <ku...@yahoo.com> wrote:
>Hi,
>I know java does not allow multiple inheritance, but I
>gave that example so i can make it clear what i want
>to do,
>So i want to find out a work around to achieve what i
>have explanned in the example
>Ashish
>--- Jacob Hookom <ho...@uwec.edu> wrote:
>> I'm going to save you from getting flamed.... java
>> does not allow multiple
>> inheritance.  You can only extend from a single
>> Object.
>>
>> -Jacob
>>
>> | -----Original Message-----
>> | From: Ashish Kulkarni
>> [mailto:kulkarni_ash1312@yahoo.com]
>> | Sent: Friday, January 31, 2003 9:34 AM
>> | To: struts-user@jakarta.apache.org
>> | Subject: one desing question, Revisited
>> |
>> | Hi,
>> |
>> | When i was thinking about my problem, I think what
>> i
>> | want to do in multiple inhereteance
>> | I want to define a class called CommonFunctions ,
>> this
>> | call will have methods which are common, (As name
>> | suggest)
>> | now i have to do some thing like
>> | public class MyAction extends Action,
>> CommonFuntions
>> |
>> | and public class MyDisptachAction extends
>> | DispatchAction, CommonFuntions
>> |
>> | By doing this i will be able to access all the
>> methods
>> | in the class which sybclasses MyAction or
>> | MyDispatchAction
>> | I know the code above is not possible to do, but i
>> | want to do some thing like that..
>> | So what are the ways of achieving it
>> |
>> | =====
>> | A$HI$H
>> |
>> | __________________________________________________
>> | Do you Yahoo!?
>> | Yahoo! Mail Plus - Powerful. Affordable. Sign up
>> now.
>> | http://mailplus.yahoo.com
>> |
>> |
>>
>---------------------------------------------------------------------
>> | To unsubscribe, e-mail:
>> struts-user-unsubscribe@jakarta.apache.org
>> | For additional commands, e-mail:
>> struts-user-help@jakarta.apache.org
>>
>>
>>
>---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:
>> struts-user-help@jakarta.apache.org
>>
>
>
>=====
>A$HI$H
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>http://mailplus.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail:
>struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail:
>struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: one desing question, Revisited

Posted by Matthew Meyer <mo...@charter.net>.
What you will want to is make your commonFunctions an 
interface. Next write a class to implement all of your 
common functions. Then Write your action extending Action 
and implementing your commonFunctions interface. Make your 
common funtions an instance variable of your action and 
then simply delegate all the commonFunction messages your 
action recieves to your commonFunction instance variable 
like so:
     public .... method(..., ....) {
        return commonFuntionInstance.method(...., ....);
     }
Hope this helps you out...

Matt,


On Fri, 31 Jan 2003 07:45:22 -0800 (PST)
  Ashish Kulkarni <ku...@yahoo.com> wrote:
>Hi,
>I know java does not allow multiple inheritance, but I
>gave that example so i can make it clear what i want
>to do,
>So i want to find out a work around to achieve what i
>have explanned in the example
>Ashish
>--- Jacob Hookom <ho...@uwec.edu> wrote:
>> I'm going to save you from getting flamed.... java
>> does not allow multiple
>> inheritance.  You can only extend from a single
>> Object.
>> 
>> -Jacob
>> 
>> | -----Original Message-----
>> | From: Ashish Kulkarni
>> [mailto:kulkarni_ash1312@yahoo.com]
>> | Sent: Friday, January 31, 2003 9:34 AM
>> | To: struts-user@jakarta.apache.org
>> | Subject: one desing question, Revisited
>> | 
>> | Hi,
>> | 
>> | When i was thinking about my problem, I think what
>> i
>> | want to do in multiple inhereteance
>> | I want to define a class called CommonFunctions ,
>> this
>> | call will have methods which are common, (As name
>> | suggest)
>> | now i have to do some thing like
>> | public class MyAction extends Action,
>> CommonFuntions
>> | 
>> | and public class MyDisptachAction extends
>> | DispatchAction, CommonFuntions
>> | 
>> | By doing this i will be able to access all the
>> methods
>> | in the class which sybclasses MyAction or
>> | MyDispatchAction
>> | I know the code above is not possible to do, but i
>> | want to do some thing like that..
>> | So what are the ways of achieving it
>> | 
>> | =====
>> | A$HI$H
>> | 
>> | __________________________________________________
>> | Do you Yahoo!?
>> | Yahoo! Mail Plus - Powerful. Affordable. Sign up
>> now.
>> | http://mailplus.yahoo.com
>> | 
>> |
>>
>---------------------------------------------------------------------
>> | To unsubscribe, e-mail:
>> struts-user-unsubscribe@jakarta.apache.org
>> | For additional commands, e-mail:
>> struts-user-help@jakarta.apache.org
>> 
>> 
>>
>---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:
>> struts-user-help@jakarta.apache.org
>> 
>
>
>=====
>A$HI$H
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>http://mailplus.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: 
>struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: 
>struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: one desing question, Revisited

Posted by Ashish Kulkarni <ku...@yahoo.com>.
Hi,
I know java does not allow multiple inheritance, but I
gave that example so i can make it clear what i want
to do,
So i want to find out a work around to achieve what i
have explanned in the example
Ashish
--- Jacob Hookom <ho...@uwec.edu> wrote:
> I'm going to save you from getting flamed.... java
> does not allow multiple
> inheritance.  You can only extend from a single
> Object.
> 
> -Jacob
> 
> | -----Original Message-----
> | From: Ashish Kulkarni
> [mailto:kulkarni_ash1312@yahoo.com]
> | Sent: Friday, January 31, 2003 9:34 AM
> | To: struts-user@jakarta.apache.org
> | Subject: one desing question, Revisited
> | 
> | Hi,
> | 
> | When i was thinking about my problem, I think what
> i
> | want to do in multiple inhereteance
> | I want to define a class called CommonFunctions ,
> this
> | call will have methods which are common, (As name
> | suggest)
> | now i have to do some thing like
> | public class MyAction extends Action,
> CommonFuntions
> | 
> | and public class MyDisptachAction extends
> | DispatchAction, CommonFuntions
> | 
> | By doing this i will be able to access all the
> methods
> | in the class which sybclasses MyAction or
> | MyDispatchAction
> | I know the code above is not possible to do, but i
> | want to do some thing like that..
> | So what are the ways of achieving it
> | 
> | =====
> | A$HI$H
> | 
> | __________________________________________________
> | Do you Yahoo!?
> | Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> | http://mailplus.yahoo.com
> | 
> |
>
---------------------------------------------------------------------
> | To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> | For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


=====
A$HI$H

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: one desing question, Revisited

Posted by Jacob Hookom <ho...@uwec.edu>.
I'm going to save you from getting flamed.... java does not allow multiple
inheritance.  You can only extend from a single Object.

-Jacob

| -----Original Message-----
| From: Ashish Kulkarni [mailto:kulkarni_ash1312@yahoo.com]
| Sent: Friday, January 31, 2003 9:34 AM
| To: struts-user@jakarta.apache.org
| Subject: one desing question, Revisited
| 
| Hi,
| 
| When i was thinking about my problem, I think what i
| want to do in multiple inhereteance
| I want to define a class called CommonFunctions , this
| call will have methods which are common, (As name
| suggest)
| now i have to do some thing like
| public class MyAction extends Action, CommonFuntions
| 
| and public class MyDisptachAction extends
| DispatchAction, CommonFuntions
| 
| By doing this i will be able to access all the methods
| in the class which sybclasses MyAction or
| MyDispatchAction
| I know the code above is not possible to do, but i
| want to do some thing like that..
| So what are the ways of achieving it
| 
| =====
| A$HI$H
| 
| __________________________________________________
| Do you Yahoo!?
| Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
| http://mailplus.yahoo.com
| 
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org