I'm trying to set up a code that will behave in one way if the spring request area is available, and another way if the specified area is not available.
This application is a web application, but there are some JMX triggers and scheduled tasks (i.e. quartz) that also trigger calls.
eg.
@Named
class MySingletonBean{
@Inject
private MyRequestScopedBean myRequestScopedBean;
public void someMethod(){
if(){
myRequestScopedBean.invoke();
}else{
}
}
}
Assuming it myRequestScopedBeanhas a request scope.
I know that this can be done with try- catcharound the call myRequestScopedBean, for example:
@Named
class MySingletonBean{
@Inject
private MyRequestScopedBean myRequestScopedBean;
public void someMethod(){
try{
myRequestScopedBean.invoke();
}catch(Exception e){
}
}
}
but this seems really awkward, so I wonder if anyone knows about the elegant spring way of polling something to see if beans are available with the request.
Many thanks!