views:

82

answers:

1

Firstly, please don't move to serverfault. It is indeed a programming question :-)

We are developing occasionally connected applications. These applications reside on laptop and handhelds. In my case, the application runs on a small servlet container (like jetty).

The requirement is that if the system is idle, the application should suspend itself. If the lid of the laptop is closed, then the application and the servlet container are in a suspend mode.

Are such things a feature of the OS itself or can such power awareness be built into the application? If it can be built into the application, how ?

+2  A: 

Every OS provides a set of APIs and notifications you can use and subscribe to appropriately. Windows, for example, sends a WM_POWERBROADCAST message to all windows before an power event happens. Read on it more in Power Management section at MSDN.

However you want the power-aware features in a java application, which will require you to use some sort of a JNI bridge. There's a codeproject article on detecting standby and denying the request (although denying power transitions is not possible in Windows Vista/7 any more).

macbirdie