Refactoring of Interceptor.intercept(ActionInvocation)

2009-10-06 Thread Alex Siman

Is there any way to refactor method [intercept(ActionInvocation)] to remove
ActionInvocation parameter. It is not usable to have this parameter, because
it makes refactoring of method interceptor hard.

Instead of this:

public class SomeInterceptor extends AbstractInterceptor
{
@Override
public String intercept(ActionInvocation actionInvocation) throws 
Exception
{
oneMethod(actionInvocation);
anotherMethod(actionInvocation);
return actionInvocation.invoke();
}

public void oneMethod(ActionInvocation actionInvocation) throws 
Exception
{
// code depended on actionInvocation
}

public void anotherMethod(ActionInvocation actionInvocation) throws
Exception
{
// code depended on actionInvocation
}
}

I would like to have this one:

public class SomeInterceptor extends AbstractInterceptor
{
@Override
public String intercept() throws Exception
{
// get actionInvocation from somewhere
oneMethod();
anotherMethod();
return actionInvocation.invoke();
}

public void oneMethod() throws Exception
{
// get actionInvocation from somewhere
}

public void anotherMethod() throws Exception
{
// get actionInvocation from somewhere
}
}

-- 
View this message in context: 
http://www.nabble.com/Refactoring-of-Interceptor.intercept%28ActionInvocation%29-tp25779342p25779342.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Refactoring of Interceptor.intercept(ActionInvocation)

2009-10-06 Thread Alex Siman

Is it safe to get ActionInvocation inside of [Interceptor.intercept()] in
this way?:

ActionInvocation invocation =
ActionContext.getContext().getActionInvocation();

Alex Siman wrote:
 
 Is there any way to refactor method [intercept(ActionInvocation)] to
 remove ActionInvocation parameter. It is not usable to have this
 parameter, because it makes refactoring of method interceptor hard.
 
 Instead of this:
 
 public class SomeInterceptor extends AbstractInterceptor
 {
   @Override
   public String intercept(ActionInvocation actionInvocation) throws
 Exception
   {
   oneMethod(actionInvocation);
   anotherMethod(actionInvocation);
   return actionInvocation.invoke();
   }
   
   public void oneMethod(ActionInvocation actionInvocation) throws 
 Exception
   {
   // code depended on actionInvocation
   }
   
   public void anotherMethod(ActionInvocation actionInvocation) throws
 Exception
   {
   // code depended on actionInvocation
   }
 }
 
 I would like to have this one:
 
 public class SomeInterceptor extends AbstractInterceptor
 {
   @Override
   public String intercept() throws Exception
   {
   // get actionInvocation from somewhere
   oneMethod();
   anotherMethod();
   return actionInvocation.invoke();
   }
   
   public void oneMethod() throws Exception
   {
   // get actionInvocation from somewhere
   }
   
   public void anotherMethod() throws Exception
   {
   // get actionInvocation from somewhere
   }
 }
 
 

-- 
View this message in context: 
http://www.nabble.com/Refactoring-of-Interceptor.intercept%28ActionInvocation%29-tp25779342p25779697.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Refactoring of Interceptor.intercept(ActionInvocation)

2009-10-06 Thread Musachy Barroso
yes, although I am kind of confused about your first email.

musachy

On Tue, Oct 6, 2009 at 7:50 PM, Alex Siman aleksandr.si...@gmail.com wrote:

 Is it safe to get ActionInvocation inside of [Interceptor.intercept()] in
 this way?:

 ActionInvocation invocation =
 ActionContext.getContext().getActionInvocation();

 Alex Siman wrote:

 Is there any way to refactor method [intercept(ActionInvocation)] to
 remove ActionInvocation parameter. It is not usable to have this
 parameter, because it makes refactoring of method interceptor hard.

 Instead of this:

 public class SomeInterceptor extends AbstractInterceptor
 {
       @Override
       public String intercept(ActionInvocation actionInvocation) throws
 Exception
       {
               oneMethod(actionInvocation);
               anotherMethod(actionInvocation);
               return actionInvocation.invoke();
       }

       public void oneMethod(ActionInvocation actionInvocation) throws 
 Exception
       {
               // code depended on actionInvocation
       }

       public void anotherMethod(ActionInvocation actionInvocation) throws
 Exception
       {
               // code depended on actionInvocation
       }
 }

 I would like to have this one:

 public class SomeInterceptor extends AbstractInterceptor
 {
       @Override
       public String intercept() throws Exception
       {
               // get actionInvocation from somewhere
               oneMethod();
               anotherMethod();
               return actionInvocation.invoke();
       }

       public void oneMethod() throws Exception
       {
               // get actionInvocation from somewhere
       }

       public void anotherMethod() throws Exception
       {
               // get actionInvocation from somewhere
       }
 }



 --
 View this message in context: 
 http://www.nabble.com/Refactoring-of-Interceptor.intercept%28ActionInvocation%29-tp25779342p25779697.html
 Sent from the Struts - User mailing list archive at Nabble.com.


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





-- 
Hey you! Would you help me to carry the stone? Pink Floyd

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



Re: Refactoring of Interceptor.intercept(ActionInvocation)

2009-10-06 Thread Alex Siman

Am I right that storing request/session related info as interceptor fields is
NOT safe due to concurrency? Such as interceptors are singletons and shared
across all concurrent requests.

Musachy Barroso wrote:
 
 yes, although I am kind of confused about your first email.
 
 musachy
 
 On Tue, Oct 6, 2009 at 7:50 PM, Alex Siman aleksandr.si...@gmail.com
 wrote:

 Is it safe to get ActionInvocation inside of [Interceptor.intercept()] in
 this way?:

 ActionInvocation invocation =
 ActionContext.getContext().getActionInvocation();

 Alex Siman wrote:

 Is there any way to refactor method [intercept(ActionInvocation)] to
 remove ActionInvocation parameter. It is not usable to have this
 parameter, because it makes refactoring of method interceptor hard.

 Instead of this:

 public class SomeInterceptor extends AbstractInterceptor
 {
       @Override
       public String intercept(ActionInvocation actionInvocation) throws
 Exception
       {
               oneMethod(actionInvocation);
               anotherMethod(actionInvocation);
               return actionInvocation.invoke();
       }

       public void oneMethod(ActionInvocation actionInvocation) throws
 Exception
       {
               // code depended on actionInvocation
       }

       public void anotherMethod(ActionInvocation actionInvocation)
 throws
 Exception
       {
               // code depended on actionInvocation
       }
 }

 I would like to have this one:

 public class SomeInterceptor extends AbstractInterceptor
 {
       @Override
       public String intercept() throws Exception
       {
               // get actionInvocation from somewhere
               oneMethod();
               anotherMethod();
               return actionInvocation.invoke();
       }

       public void oneMethod() throws Exception
       {
               // get actionInvocation from somewhere
       }

       public void anotherMethod() throws Exception
       {
               // get actionInvocation from somewhere
       }
 }



 --
 View this message in context:
 http://www.nabble.com/Refactoring-of-Interceptor.intercept%28ActionInvocation%29-tp25779342p25779697.html
 Sent from the Struts - User mailing list archive at Nabble.com.


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


 
 
 
 -- 
 Hey you! Would you help me to carry the stone? Pink Floyd
 
 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Refactoring-of-Interceptor.intercept%28ActionInvocation%29-tp25779342p25780145.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Refactoring of Interceptor.intercept(ActionInvocation)

2009-10-06 Thread Chris Pratt
What does that have to do with method parameters?  The ActionInvocation and
any local variables are thread safe.  I think the problem we're having in
helping you is none of us understand what you're trying to accomplish?  For
instance why would you be trying to refactor away parameters that are
required by an interface?
  (*Chris*)

On Tue, Oct 6, 2009 at 8:56 PM, Alex Siman aleksandr.si...@gmail.comwrote:


 Am I right that storing request/session related info as interceptor fields
 is
 NOT safe due to concurrency? Such as interceptors are singletons and shared
 across all concurrent requests.

 Musachy Barroso wrote:
 
  yes, although I am kind of confused about your first email.
 
  musachy
 
  On Tue, Oct 6, 2009 at 7:50 PM, Alex Siman aleksandr.si...@gmail.com
  wrote:
 
  Is it safe to get ActionInvocation inside of [Interceptor.intercept()]
 in
  this way?:
 
  ActionInvocation invocation =
  ActionContext.getContext().getActionInvocation();
 
  Alex Siman wrote:
 
  Is there any way to refactor method [intercept(ActionInvocation)] to
  remove ActionInvocation parameter. It is not usable to have this
  parameter, because it makes refactoring of method interceptor hard.
 
  Instead of this:
 
  public class SomeInterceptor extends AbstractInterceptor
  {
@Override
public String intercept(ActionInvocation actionInvocation) throws
  Exception
{
oneMethod(actionInvocation);
anotherMethod(actionInvocation);
return actionInvocation.invoke();
}
 
public void oneMethod(ActionInvocation actionInvocation) throws
  Exception
{
// code depended on actionInvocation
}
 
public void anotherMethod(ActionInvocation actionInvocation)
  throws
  Exception
{
// code depended on actionInvocation
}
  }
 
  I would like to have this one:
 
  public class SomeInterceptor extends AbstractInterceptor
  {
@Override
public String intercept() throws Exception
{
// get actionInvocation from somewhere
oneMethod();
anotherMethod();
return actionInvocation.invoke();
}
 
public void oneMethod() throws Exception
{
// get actionInvocation from somewhere
}
 
public void anotherMethod() throws Exception
{
// get actionInvocation from somewhere
}
  }
 
 
 
  --
  View this message in context:
 
 http://www.nabble.com/Refactoring-of-Interceptor.intercept%28ActionInvocation%29-tp25779342p25779697.html
  Sent from the Struts - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 
 
 
 
  --
  Hey you! Would you help me to carry the stone? Pink Floyd
 
  -
  To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
  For additional commands, e-mail: user-h...@struts.apache.org
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Refactoring-of-Interceptor.intercept%28ActionInvocation%29-tp25779342p25780145.html
 Sent from the Struts - User mailing list archive at Nabble.com.


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