|
From: Daniel W. <ma...@gm...> - 2009-12-04 15:15:37
|
Hello, is it possible to stop a Windows service before the computer enters standby? my application is polling hardware via an virtual com port. every time the computer wakes up the service is up and running again. but the com port is blocked by another app instance. i know this is not entirely related to the wrapper. but for now i have no idea how to solve my problem. any hints? regards |
|
From: Leif M. <le...@ta...> - 2009-12-11 16:52:08
|
Daniel, Sorry for the delay. The Wrapper actually supports Windows POWER events and will fire events in the JVM to give your application a chance to respond to them. Please see the WrapperServiceControlEvent class in javadocs for details on the events that can be processed. http://wrapper.tanukisoftware.org/doc/english/javadocs.html?org/tanukisoftware/wrapper/event/WrapperServiceControlEvent.html The various events can be handled by passing a WrapperEventListener instance to the WrapperManager.addWrapperEventListener(...) method. Please take a look at the Javacocs for details and let me know how it works for you or if you have any questions getting things working. Cheers, Leif On Sat, Dec 5, 2009 at 12:15 AM, Daniel Weinand <ma...@gm...> wrote: > Hello, > > is it possible to stop a Windows service before the computer enters standby? > my application is polling hardware via an virtual com port. every time the computer > wakes up the service is up and running again. but the com port is blocked by another > app instance. > > i know this is not entirely related to the wrapper. but for now i have no idea > how to solve my problem. any hints? > > regards |
|
From: Daniel W. <ma...@gm...> - 2010-02-20 14:31:29
|
So, the problem finaly needs to be fixed. Haven't worked a while with the wrapper and the service it controls. In the previous mail you told me to use a WrapperServiceControlEvent. For my service i'm using method 4 because the app/service can run as configurable jar. But now i have no idea how to integrate or act on wrapper events. Basically i need the wrapper to stop the service if a standby/hibernate request is coming in. when the system is resuming normal operation the wrapper should restart the service. This should solve my com port issues. Can this be configured in my wrapper.conf or how can i listen to the events, because my app doesn't and should not know anything about the wrapper. Any advice is appreciated. regards Daniel Leif Mortenson schrieb: > Daniel, > Sorry for the delay. The Wrapper actually supports Windows POWER > events and will fire events in the JVM to give your application a > chance to respond to them. Please see the WrapperServiceControlEvent > class in javadocs for details on the events that can be processed. > > http://wrapper.tanukisoftware.org/doc/english/javadocs.html?org/tanukisoftware/wrapper/event/WrapperServiceControlEvent.html > > The various events can be handled by passing a WrapperEventListener > instance to the WrapperManager.addWrapperEventListener(...) method. > Please take a look at the Javacocs for details and let me know how it > works for you or if you have any questions getting things working. > > Cheers, > Leif > > > On Sat, Dec 5, 2009 at 12:15 AM, Daniel Weinand <ma...@gm...> wrote: > >> Hello, >> >> is it possible to stop a Windows service before the computer enters standby? >> my application is polling hardware via an virtual com port. every time the computer >> wakes up the service is up and running again. but the com port is blocked by another >> app instance. >> >> i know this is not entirely related to the wrapper. but for now i have no idea >> how to solve my problem. any hints? >> >> regards >> > > |
|
From: Leif M. <le...@ta...> - 2010-02-23 17:24:45
|
Daniel,
Sorry for the delay. This currently requires that some code be
written in the Java Application. The good news though is that you
can easily create a simple "wrapper" class between the
WrapperSimpleApp class, and the main class of your executable jar.
You will need to look in the Manifest file of your executable jar to
get its main class as you will not be able to use it as an executable
jar. Set up the Wrapper using Method #1 (WrapperSimpleApp) and
specify the helper class below as its first parameter. Then hard
code the fully qualified main class of your jar file in the end of the
helper class's main method.
By doing this, the WrapperSimpleApp will start up this helper class,
it will do what it needs to do to restart when the system is resumed.
Then it calls your main class to start up your application as usual.
This helper class will cause the Wrapper to restart the JVM when the
system is resumed rather than when it suspends. ( If you restart it
just before suspending then you may not get the results you want
depending how far along the restart gets before the system actually
suspends. You may be able to make this work if you specify a long
restart delay (wrapper.restart.delay=30) to make sure the JVM does not
get relaunched before the system is fully suspended. It should then
start back up when the system is resumed. )
Please give this a try and let me know how it works for you.
I have added a feature to our TODO list to make the Wrapper stop the
JVM before the system is suspended, and then start it back up after it
resumes. This will be done in the Wrapper itself to let you avoid
having to write code. It won't make it into the next release however.
Cheers,
Leif
---
/*
* javac -classpath ..\lib\wrapper.jar;..\lib\wrappertest.jar *.java
*/
import org.tanukisoftware.wrapper.WrapperManager;
import org.tanukisoftware.wrapper.event.WrapperEvent;
import org.tanukisoftware.wrapper.event.WrapperEventListener;
import org.tanukisoftware.wrapper.event.WrapperServiceControlEvent;
import org.tanukisoftware.wrapper.test.Main;
public class HibernateRestartTest
implements WrapperEventListener
{
private static HibernateRestartTest m_app;
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
HibernateRestartTest()
{
}
/*---------------------------------------------------------------
* WrapperEventListener Methods
*-------------------------------------------------------------*/
public void fired( WrapperEvent event )
{
System.out.println( "Received event: " + event );
if ( event instanceof WrapperServiceControlEvent )
{
WrapperServiceControlEvent scEvent = (WrapperServiceControlEvent)event;
switch ( scEvent.getServiceControlCode() )
{
case WrapperManager.SERVICE_CONTROL_CODE_POWEREVENT_SUSPEND:
System.out.println( " The system is about to be suspended. Let
this happen here." );
break;
case WrapperManager.SERVICE_CONTROL_CODE_POWEREVENT_POWERSTATUSCHANGE:
System.out.println( " There was a power status change." );
break;
case WrapperManager.SERVICE_CONTROL_CODE_POWEREVENT_RESUMESUSPEND:
case WrapperManager.SERVICE_CONTROL_CODE_POWEREVENT_RESUMEAUTOMATIC:
System.out.println( " There system was resumed. Trigger a
restart to let the JVM reinitialize." );
WrapperManager.restartAndReturn();
break;
default:
System.out.println( " Got an unhandled power event: " +
scEvent.getServiceControlCode() );
break;
}
}
}
/*---------------------------------------------------------------
* Main Method
*-------------------------------------------------------------*/
public static void main( String[] args )
{
System.out.println( "Start" );
m_app = new HibernateRestartTest();
WrapperManager.addWrapperEventListener( m_app,
WrapperEventListener.EVENT_FLAG_SERVICE );
// Replace the following with your main class.
org.tanukisoftware.wrapper.test.BackgroundThreads.main( args );
}
}
---
On Sat, Feb 20, 2010 at 11:30 PM, Daniel Weinand <ma...@gm...> wrote:
> So, the problem finaly needs to be fixed. Haven't worked a while with
> the wrapper and the service it controls.
> In the previous mail you told me to use a WrapperServiceControlEvent.
> For my service i'm using method 4 because
> the app/service can run as configurable jar. But now i have no idea how
> to integrate or act on wrapper events.
>
> Basically i need the wrapper to stop the service if a standby/hibernate
> request is coming in. when the system is
> resuming normal operation the wrapper should restart the service. This
> should solve my com port issues.
>
> Can this be configured in my wrapper.conf or how can i listen to the
> events, because my app doesn't and
> should not know anything about the wrapper. Any advice is appreciated.
>
> regards
>
> Daniel
>
> Leif Mortenson schrieb:
>> Daniel,
>> Sorry for the delay. The Wrapper actually supports Windows POWER
>> events and will fire events in the JVM to give your application a
>> chance to respond to them. Please see the WrapperServiceControlEvent
>> class in javadocs for details on the events that can be processed.
>>
>> http://wrapper.tanukisoftware.org/doc/english/javadocs.html?org/tanukisoftware/wrapper/event/WrapperServiceControlEvent.html
>>
>> The various events can be handled by passing a WrapperEventListener
>> instance to the WrapperManager.addWrapperEventListener(...) method.
>> Please take a look at the Javacocs for details and let me know how it
>> works for you or if you have any questions getting things working.
>>
>> Cheers,
>> Leif
>>
>>
>> On Sat, Dec 5, 2009 at 12:15 AM, Daniel Weinand <ma...@gm...> wrote:
>>
>>> Hello,
>>>
>>> is it possible to stop a Windows service before the computer enters standby?
>>> my application is polling hardware via an virtual com port. every time the computer
>>> wakes up the service is up and running again. but the com port is blocked by another
>>> app instance.
>>>
>>> i know this is not entirely related to the wrapper. but for now i have no idea
>>> how to solve my problem. any hints?
>>>
>>> regards
|