This content has been marked as final.
Show 3 replies
-
1. Re: To get Event when Jboss is called for shutdown
alesj Feb 25, 2008 5:37 AM (in response to svsubramanyam007)You can provide your own impl of the Server interface.
e.g. extend the current ServerImpl and override shutdown method to hook in your behavior.
See ServerLoader usage in Main and ServerImpl for more details. -
2. Re: To get Event when Jboss is called for shutdown
alesj Feb 25, 2008 5:47 AM (in response to svsubramanyam007)Or, there is already a nice hook provided for you.
In the form of Bootstrap interface - see AbstractServerImpl.// Do the bootstraps in reverse order for (Bootstrap bootstrap : startedBootstraps) { Thread.currentThread().setContextClassLoader(bootstrap.getClass().getClassLoader()); try { bootstrap.shutdown(this); } catch (Throwable t) { log.warn("Error shutting down bootstrap: " + bootstrap, t); } }
Simply implement your behavior in some Bootstrap impl, and add this bean to bootstrap-beans.xml.
It will get automatically picked up by ServerImpl, and added to the list of all bootstraps. -
3. Re: To get Event when Jboss is called for shutdown
alesj Feb 25, 2008 5:51 AM (in response to svsubramanyam007)"svsubramanyam007" wrote:
I want to get event when jboss is called for shutdown.When i was walking through code i was not able to understand ..how to get event when it is about to shutdown...can anyone help me in understanding...whether it is possible to get event.
What's there to understand, it's a simple event/listener pattern:// Send a notification that server stop is initiated Notification msg = new Notification(STOP_NOTIFICATION_TYPE, this, 2); sendNotification(msg); List currentList; synchronized (lock) { currentList = listenerList; } final int size = currentList.size(); for (int i = 0; i < size; i++) { ListenerInfo li = (ListenerInfo) currentList.get(i); if (li.filter == null || li.filter.isNotificationEnabled(notification)) { try { this.handleNotification(li.listener, notification, li.handback); } catch (Exception e) { trace("sendNotification", "exception from listener: " + e); } } }