Re: newFixedThreadPool in struts2

2018-02-09 Thread Martin Gainty
in struts this is accomplished implementing
 org.apache.struts2.interceptor.createSessionInterceptor
configured in interceptor-ref name in struts-config.xml


 action name="someAction" class="com.examples.SomeAction"
 * interceptor-ref name="createSession"/

afterwards you can access the HttpServletRequest:

HttpServletRequest req=ServletActionContext.getServletContext().getRequest()

HttpSession session=req.getSession();

get all the params from session you need


HTH

Martin
__




From: Emi 
Sent: Friday, February 9, 2018 4:02 PM
To: Struts Users Mailing List
Subject: Re: newFixedThreadPool in struts2

Hello Yasser,
> You can write your own listener by implementing HttpSessionListener
> and call shutdown in it's `sessionDestroyed` method. Please see [1].
> [1] http://www.myjavarecipes.com/tag/session-timeout-handling-in-java/
Session timeout handling in Java | My Java 
Recipes
www.myjavarecipes.com
Hi Reader, Recently I got requirement from customer that how much time user is 
spending on web application. Requirement is simple, for this we just need to 
record ...



In HttpSessionListener, it seems that there are no session attributes
anymore. So, there is no way for me to do the following in the listener
class:

fixPool = session.getAttribute('fixpool_name');
fixPool.shutdown();

So, the only possible way is through springframework config, right?

Thanks a lot.


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



Re: Lang

2018-02-09 Thread Martin Gainty
Buenas Noches

your implementation of AbstractBeanProvider needs to supply 
struts-messages_es.properties

in WEB-INF/classes/org/apache/struts2 folder


if you have no impl of AbstractBeanProvider use 
org.apache.struts2.config.DefaultBeanSelectionProvider

public void register(ContainerBuilder builder, LocatableProperties props) {

...find your way to LocalizedTextUtil.addDefaultResourceBundle to add in your 
_es properties:


LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages_es");
loadCustomResourceBundles(props);

in org/apache/struts2/default.properties point struts.custom.i18n.resources to 
your properties:
struts.custom.i18n.resources=struts_messages_es

i will leave org/apache/struts2/struts-messages_es.properties as ejercicio de 
traducción

Un Saludo desde Nueva Inglaterra
Martín
__



From: Deborah White 
Sent: Friday, February 9, 2018 12:47 PM
To: Struts Users Mailing List
Subject: Lang

I have this:



It doesn't seem to like lang=es

Help?

CONFIDENTIALITY NOTICE: This communication with its contents may contain 
confidential and/or legally privileged information. It is solely for the use of 
the intended recipient(s). Unauthorized interception, review, use or disclosure 
is prohibited and may violate applicable laws including the Electronic 
Communications Privacy Act. If you are not the intended recipient, please 
contact the sender and destroy all copies of the communication.


Re: newFixedThreadPool in struts2

2018-02-09 Thread Dave Weis
It's still accessible:

public void sessionCreated(HttpSessionEvent hse) {
final HttpSession session = hse.getSession();

logger.debug("session created");

session.setAttribute(KEY,  new Clickstream());


}

public void sessionDestroyed(HttpSessionEvent hse) {
final HttpSession session = hse.getSession();

logger.debug("session destroyed");

}




On Fri, Feb 9, 2018 at 3:02 PM, Emi  wrote:

> Hello Yasser,
>
>> You can write your own listener by implementing HttpSessionListener and
>> call shutdown in it's `sessionDestroyed` method. Please see [1]. [1]
>> http://www.myjavarecipes.com/tag/session-timeout-handling-in-java/
>>
> In HttpSessionListener, it seems that there are no session attributes
> anymore. So, there is no way for me to do the following in the listener
> class:
>
> fixPool = session.getAttribute('fixpool_name');
> fixPool.shutdown();
>
> So, the only possible way is through springframework config, right?
>
> Thanks a lot.
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


Re: newFixedThreadPool in struts2

2018-02-09 Thread Emi

Hello Yasser,
You can write your own listener by implementing HttpSessionListener 
and call shutdown in it's `sessionDestroyed` method. Please see [1]. 
[1] http://www.myjavarecipes.com/tag/session-timeout-handling-in-java/
In HttpSessionListener, it seems that there are no session attributes 
anymore. So, there is no way for me to do the following in the listener 
class:


fixPool = session.getAttribute('fixpool_name');
fixPool.shutdown();

So, the only possible way is through springframework config, right?

Thanks a lot.


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



Re: newFixedThreadPool in struts2

2018-02-09 Thread Emi


Firstly you should decide what do you like about life-time of that 
thread pool without being worry about calling shutdown. All your 
examples have solutions to call shutdown which I described below... 
Please read below
[Try1] . By springframe work setup ThreadPool . In action class, 
use fixedPool   Future f1 = fixedPool.submit(() -> { 
...actions such as send email, etc });   So,  there will be NO 
shutdown in action class  fixedPool.shutdown();  will be 
maintained by spring config?
You can set your bean `destroy-method` and call shutdown in that 
method. e.g. init-method="initPool" destroy-method="shutdownPool">
[Try2] . Each user login session create one fixedPool . When user 
logout, fixedPool.shutdown()   What about if users do not call 
logout action. Where and how the fixedPool to be shutdown?   Is 
there a way to auto shutdown after period of time?
You can write your own listener by implementing HttpSessionListener 
and call shutdown in it's `sessionDestroyed` method. Please see [1]. 
[1] http://www.myjavarecipes.com/tag/session-timeout-handling-in-java/
I will try1 which can be used/shared by all login users or 2 used by 
per login user session then.
set session as it's life-time, then it seems you still simply can use 
that spring bean with `scope` set to `session`.
session scope can be a bad choice if your "...actions such as send 
email, etc" take too long to being completed because user can log out 
or session can being expired in the middle of their executions!
For users logout action, I could try to check based on future.get() to 
help users know there are processes still running.


For session expired, this is not clear to me. In web.xml, 
session-timeout=60 for example. Users will be considered auto-logout 
only if users have not use any features(no active actions) for more than 
60 mins.


If there are sub-threads submitted by action class(struts2 is 
thread-safe, I could consider the action class as a main thread?), and 
if sub-threads have not completed, wouldn't web.xml consider there are 
still active actions?


So, wouldn't it be that user-session auto-expired only when:
(1) users have not use any features and
(2) All sub-threads submitted by users through action classes have completed

If I misunderstood threads usage in struts2 framework, please kindly 
correct me.


Thanks a lot.





Lang

2018-02-09 Thread Deborah White
I have this:



It doesn't seem to like lang=es

Help?

CONFIDENTIALITY NOTICE: This communication with its contents may contain 
confidential and/or legally privileged information. It is solely for the use of 
the intended recipient(s). Unauthorized interception, review, use or disclosure 
is prohibited and may violate applicable laws including the Electronic 
Communications Privacy Act. If you are not the intended recipient, please 
contact the sender and destroy all copies of the communication.


Re: newFixedThreadPool in struts2

2018-02-09 Thread Yasser Zamani


On 2/8/2018 8:51 PM, Emi wrote:
>> Firstly you should decide what do you like about life-time of that
>> thread pool without being worry about calling shutdown. All your
>> examples have solutions to call shutdown which I described below...
>> Please read below
>>> [Try1] . By springframe work setup ThreadPool . In action class, use
>>> fixedPool   Future f1 = fixedPool.submit(() -> { ...actions
>>> such as send email, etc });   So,  there will be NO shutdown in
>>> action class  fixedPool.shutdown();  will be maintained by
>>> spring config?
>> You can set your bean `destroy-method` and call shutdown in that
>> method. e.g. > init-method="initPool" destroy-method="shutdownPool">
>>> [Try2] . Each user login session create one fixedPool . When user
>>> logout, fixedPool.shutdown()   What about if users do not call logout
>>> action. Where and how the fixedPool to be shutdown?   Is there a way
>>> to auto shutdown after period of time?
>> You can write your own listener by implementing HttpSessionListener
>> and call shutdown in it's `sessionDestroyed` method. Please see [1].
>> [1] http://www.myjavarecipes.com/tag/session-timeout-handling-in-java/
> Thank you very much Yasser. The information are very helpful!
> 
> I will try1 which can be used/shared by all login users or 2 used by per
> login user session then.
> 

You're welcome :)

I rethought and if you decided to set session as it's life-time, then it
seems you still simply can use that spring bean with `scope` set to
`session`.

But session scope can be a bad choice if your "...actions such as send
email, etc" take too long to being completed because user can log out or
session can being expired in the middle of their executions!

Sincerely,
Yasser.