You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mu...@aol.com on 2009/06/25 14:23:30 UTC

Re: Exceptions thrown by constructor different from those thown by execute() ?

 I am with the devs on this one -- typically the constructor of an object whose life cycle is managed by 
the framework is off limits -- you wouldn't write code to throw exceptions from a servlet or
EJB etc.
Chris

 

-----Original Message-----
From: Wes Wannemacher <we...@wantii.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Tue, Jun 23, 2009 9:03 am
Subject: Re: Exceptions thrown by constructor different from those thown by  execute() ?










On Tue, Jun 23, 2009 at 8:50 AM, Jim Kiley<jh...@summa-tech.com> wrote:
[...]
> From a philosophical perspective, though -- no clue, I don't have a lot of
> insight into why the devs make all the decisions they make.
>
[...]

The decisions I make are usually heavily weighted by how impressed
girls will be :)

I would go against adding security via exceptions thrown by a
constructor. In the default ObjectFactory for xwork, the flow for
creating instances of classes is pretty easy to follow. The exception
handling is deferred to callers (as evidenced by the various "throws
Exception" qualifiers on the methods). The main reason I would be
against it is that you aren't the one calling "new" on the classes. I
can appreciate what you are trying to do, so file a JIRA and when we
have time to investigate, we could probably implement it, but to solve
your problem, the best bet is an interceptor.

-Wes

-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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




 


Re: Exceptions thrown by constructor different from those thown by execute() ?

Posted by mu...@aol.com.
I see your point that there has to be some design to handle? that contingency
(exceptions coming from the constructor) but with so many opportunities for
us to do things via interceptors I would let the framework have a total monopoly
on the constructors. 

Essentially we (application developers) should be into
how the action behaves rather than how it comes into being.

But I do see your point that for completeness there has to be some definite
behavior that takes place if the exception is thrown.
Chris


-----Original Message-----
From: Jan T. Kim <j....@uea.ac.uk>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thu, Jun 25, 2009 9:05 am
Subject: Re: Exceptions thrown by constructor different from those thown by execute() ?



Dear Chris,

On Thu, Jun 25, 2009 at 08:23:30AM -0400, musomesa@aol.com wrote:
> 
>  I am with the devs on this one -- typically the constructor of an object 
whose life cycle is managed by 
> the framework is off limits -- you wouldn't write code to throw exceptions 
from a servlet or
> EJB etc.

I agree that from an EJB provider's angle its quite possible to argue
that session bean's constructors shouldn't throw exceptions. From an
application assembler's perspective, though, I'd expect that a global
exception mapping would handle all exceptions of the specified class,
regardless of whether they are thrown by constructors or other methods
(and regardless of whether the exception is considered legitimate or
reasonable).

Best regards, Jan

> 
>  
> 
> -----Original Message-----
> From: Wes Wannemacher <we...@wantii.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Tue, Jun 23, 2009 9:03 am
> Subject: Re: Exceptions thrown by constructor different from those thown by  
execute() ?
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Tue, Jun 23, 2009 at 8:50 AM, Jim Kiley<jh...@summa-tech.com> wrote:
> [...]
> > From a philosophical perspective, though -- no clue, I don't have a lot of
> > insight into why the devs make all the decisions they make.
> >
> [...]
> 
> The decisions I make are usually heavily weighted by how impressed
> girls will be :)
> 
> I would go against adding security via exceptions thrown by a
> constructor. In the default ObjectFactory for xwork, the flow for
> creating instances of classes is pretty easy to follow. The exception
> handling is deferred to callers (as evidenced by the various "throws
> Exception" qualifiers on the methods). The main reason I would be
> against it is that you aren't the one calling "new" on the classes. I
> can appreciate what you are trying to do, so file a JIRA and when we
> have time to investigate, we could probably implement it, but to solve
> your problem, the best bet is an interceptor.
> 
> -Wes
> 
> -- 
> Wes Wannemacher
> Author - Struts 2 In Pr
actice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
>  
> 

-- 
 +- Jan T. Kim -------------------------------------------------------+
 |             email: j.kim@uea.ac.uk                                 |
 |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

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



Re: Exceptions thrown by constructor different from those thown by execute() ?

Posted by Wes Wannemacher <we...@wantii.com>.
On Thu, Jun 25, 2009 at 9:05 AM, Jan T. Kim<j....@uea.ac.uk> wrote:
>
> I agree that from an EJB provider's angle its quite possible to argue
> that session bean's constructors shouldn't throw exceptions. From an
> application assembler's perspective, though, I'd expect that a global
> exception mapping would handle all exceptions of the specified class,
> regardless of whether they are thrown by constructors or other methods
> (and regardless of whether the exception is considered legitimate or
> reasonable).
>
> Best regards, Jan
>

I'm with you here, I plan on making this work in 2.1.8 (or at least
trying really hard). You will be hard-pressed to find people to agree
that throwing exceptions in your constructor as a way of enforcing
security is the right thing to do, *but* "global-exception-mappings"
is an ambiguous feature name, unless we are catching exceptions during
access and creation. So, although I don't quite agree with your
design, I still agree that it is something we should change... (Is
that a political explanation or what?)

-Wes

-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

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


Re: Exceptions thrown by constructor different from those thown by execute() ?

Posted by "Jan T. Kim" <j....@uea.ac.uk>.
Dear Chris,

On Thu, Jun 25, 2009 at 08:23:30AM -0400, musomesa@aol.com wrote:
> 
>  I am with the devs on this one -- typically the constructor of an object whose life cycle is managed by 
> the framework is off limits -- you wouldn't write code to throw exceptions from a servlet or
> EJB etc.

I agree that from an EJB provider's angle its quite possible to argue
that session bean's constructors shouldn't throw exceptions. From an
application assembler's perspective, though, I'd expect that a global
exception mapping would handle all exceptions of the specified class,
regardless of whether they are thrown by constructors or other methods
(and regardless of whether the exception is considered legitimate or
reasonable).

Best regards, Jan

> 
>  
> 
> -----Original Message-----
> From: Wes Wannemacher <we...@wantii.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Tue, Jun 23, 2009 9:03 am
> Subject: Re: Exceptions thrown by constructor different from those thown by  execute() ?
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Tue, Jun 23, 2009 at 8:50 AM, Jim Kiley<jh...@summa-tech.com> wrote:
> [...]
> > From a philosophical perspective, though -- no clue, I don't have a lot of
> > insight into why the devs make all the decisions they make.
> >
> [...]
> 
> The decisions I make are usually heavily weighted by how impressed
> girls will be :)
> 
> I would go against adding security via exceptions thrown by a
> constructor. In the default ObjectFactory for xwork, the flow for
> creating instances of classes is pretty easy to follow. The exception
> handling is deferred to callers (as evidenced by the various "throws
> Exception" qualifiers on the methods). The main reason I would be
> against it is that you aren't the one calling "new" on the classes. I
> can appreciate what you are trying to do, so file a JIRA and when we
> have time to investigate, we could probably implement it, but to solve
> your problem, the best bet is an interceptor.
> 
> -Wes
> 
> -- 
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
>  
> 

-- 
 +- Jan T. Kim -------------------------------------------------------+
 |             email: j.kim@uea.ac.uk                                 |
 |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*

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