|
From: Leif M. <le...@ta...> - 2003-09-25 03:08:55
|
Alex,
I am not sure that your assumption about not being able to use Sockets
and a GUI in the same service is correct. The TestWrapper example
that is shipped with version 3.0.5 of the Wrapper does both and works
just fine.
Edit wrapper.conf and set the following
wrapper.ntservice.interactive=true
at the bottom of the file. Then install the TestWrapper as a service
and start
it.
InstallTestWrapper-NT.bat
net start testwrapper
Now telnet to the machine on port 9999. When it connects, type 'R'
Must
be upper case. The Wrapper will promptly restart the JVM.. All works fine
both using localhost and from a remote machine.
The problems you are having with your users is a little more
difficult. Unless you
specify an account in the wrapper.conf file, NT services will by default
always run
as the SYSTEM user. This is also true for their child processes (Java
in this case)
So no matter how many times you check, your user is always going to be
SYSTEM. You are going to need to have an application running in the
User space
which is launched when the user logs in. This component could then
communicate to
the service using any of a number of methods.
There is not any way that I am aware of for an NT service to tell
when a user logs
in to the system. It sounds like it should be possible, but not with
the current Wrapper.
Telling when the user logs out is easy. Windows sends a logout
signal to all processes
when any user logs out. The Wrapper intercepts this and prevents the
Wrapper and its
JVM from exiting. The WrapperSimpleApp and WrapperStartStopApp classes
do not
provide a way for your java app to see this signal, but you can see it
if you use method
3, by implementing the WrapperListener interface directly. The
listener's controlEvent
method is called whenever any system signals are received. This gives
the app the
opportunity to respond.
I posted a couple of feature requests around this so I remember to
look into ways
of making it possible to tell when and who logs in.
http://sourceforge.net/tracker/index.php?func=detail&aid=812174&group_id=39428&atid=425190
http://sourceforge.net/tracker/index.php?func=detail&aid=812175&group_id=39428&atid=425190
Cheers,
Leif
ender wiggin wrote:
>Hello.
>
>First some details:
>I am working on a project involving an instant one way
>messaging on windows. Basically I am writing a
>service(SocketService) that connects with a server
>through a socket and writes to file/(some repository)
>the messages it receives. Another service(
>DesktopMessageService) reads from the files the
>messages and if it finds a new message for the CURRENT
>user it will open a frame and show it on the screen.
>The reason I use two services instead of one is
>because I read that a service either does neworking or
>it accesses the desktop or console.
> The SocketService performs well, it does indeed read
>from a socket(ServerSocket) and when contacted there
>are messages it does store them on file.
>
>The problems arise with the DesktopMessageService.I
>have yet to find a way to detect the current
>user.Basically when the pc is booted the
>DesktopMesssage starts ,tries to detect the current
>user and print to screen a message.The problem is that
>
>I cannot decect when a user loggs on to the machine.
>The current user for the DesktopService is still
>System.So if I want to print a message Hi +
>System.getProperty("user.name") , even if there is a
>user logged on it still prints Hi System , not Hi
>"Current User Name".Im also tried to restart the JVm
>periodically but the curent user is still System.
>By the way the service works fine when tested in a
>console .
>
>So my questions are, Is there a way to detect when a
>user loggs on and get his name?
>Also, is there a way to detect when a users logs off?
>
>Thanks, Alex
>
>
|