Different handlers for ejb Timer - ejb

I'm trying to set different handlers for different types of tasks created via TimerService , ejb.
I need to figure out a way where I can create a schedule tasks with extra information including the handler type so when a timeout occurs different handlers should be fired according to the timer identification.

Eventually the solution to the problem as i tried to explain is by adding Serialized handler, which is set when you create a timer event.
after you set a handler you can get it from the timer object, so when a timeout occurs we can execute an action according to the relevant handler.

Related

Servlet Initialization Listener

I am trying to identify when a servlet is initilazed (not the init() method called), when container try to load an individual servlet ? Or, any mechanism which keeps track of servlet initialized / destroyed / pending to load.
I am aware of the ServletContextListner, which invoked on application start & shutdown. But, I am looking for kind of listener, which probably trigger on individual servlet load / destroy event.
So, scenario would be like :
/Servlet1
/Servlet2
An listener which trigger on servlet1 load and then for Servlet2.
I guess this is the listener you are looking for .You want to know each time a request comes in, so that you can log it.
javax.servlet.ServletRequestListener . Following are the methods requestInitialized requestDestroyed

Symfony2 Handler vs Listener what the difference?

I need to create listener or handler to provide some actions for AccessDenied exception.
I've looked some sources of standard handlers and listeners, so looks like they can be use for same task.
I also read this:
What's the difference between Event Listeners & Handlers in Java?
JavaScript - What's the difference between event handlers & listener?
Using Symfony2's AccessDeniedHandlerInterface
But only difference I've seen - that handlers often use for handle exceptions.
So, what the real difference between handler and listener in Symfony ?
Listeners are registered and called when an event occurs. Observer or PubSub patterns are used.
The Handler is more of a strategy pattern that delegates implementation details to class. Which can then be substituted. (composition over inheritance)
The patterns could maybe be interchangeable in some cases, and it's more the intention of the code that calls for one or the other then.

ASP.NET global.asax usage

When to use and not to use global.asax file in asp.net application? I heard that you should use that file only at a pinch.
The Global.asax file is used to implement application and session level events, such as:
Application_Init - fired when an application first initializes
Application_Start - fired when the application first starts
Application_End - the final event fired when the application ends or times out
Session_Start - fired the first time a user’s session is started
Application_BeginRequest - fired with each new request
Application_EndRequest - fired when the application ends
Application_AuthenticateRequest - the event indicates that a request is ready to be authenticated.
Application_Error - fired when an unhandled error occurs within the application
Session_End - fired whenever a single user Session ends or times out.
Implementing these handlers can all be legitimate uses of the global.asax. For example, the Application_Error event handler typically logs any global errors, and the Application_End event handler typically contains application cleanup logic. These are good uses of the Global.asax. Use them whenever necessary, and don't be afraid if the file grows.
However, I have seen cases where developers have added all sorts of global methods to the global.asax that are indeed un-justified. For example, keep business logic related to a particular domain object inside the object itself rather than in the global.asax. If you find methods in the Global.asax that shouldn't be there refactor the work into the right location.
global.asax is a HTTPModule. All requests go through the global.asax and other modules before they reach your page handlers. Use this to perform certain tasks on your request or response, like url routing, global error handlign etc.
If you need something special to happen on Application start/end or Session start/end, or globally handle exceptions you could use it to map the events in the Apllication and Session life cycles.

Logging of long/unusual page execution time automatically in ASP.NET

I'd like to implement some kind of automatic "logging" in my ASP.NET MVC application when a page execution (incl. database calls etc.) takes longer than 3 seconds, and then gather some 'circumstantial evidence', e.g. which action was called, what the parameters were, session information etc. so I can then store that info for review/send it via email and so forth.
How could I do this, preferably on a global level without editing/adding code to each of my many controller actions?
BeginRequest and EndRequest in global.asax is the most basic way, record a start and end time then log from there. Another (more reusable) way may be to create your own custom provider such as demonstrated on MSDN
Start by looking at the global.asax methods that hook into the following events:
-- Application_BeginRequest
-- Application_EndRequest
Record the time in the fist, compare it to current time in the last - if it's too long log it. You can probably get the action etc from the HttpContext.Current.

Handle fault event in mx.data.DataService while background sync?

We are using objects that at times need to sync up with the server via
the mx.data.DataService, The problem is in case of explicit method
invocation over the dataservice object we are able to trap the fault
events using the fault handlers.
The problem arises when dataservice is sync'ing the object in
background. In case of a fault event (such as session timeout or
server down) the error is not trapped via the fault handler added on
the dataservice using the addEventListener(FaultEvent.FAULT).
Any suggestions on how to trap the fault events generated via
background sync invocations of the DataService?
Try DataServiceFaultEvent.FAULT instead of FaultEvent.FAULT

Resources