application server, just without the "web" part...

A

Andreas Leitgeb

Essentially my application is a couple of separate command-line
utilities, called from users with shell-access (or from unix
shell scripts).

Startup-time still isn't exactly Java's strong point, and often
enough in my situation the startup time is by far the "longest
pole in the tent".
Adding option -Xshareclasses improved things, but not enough.

I'd like to consider some kind of application server, that would
run the actual java-code of any number of jobs (of one user) in one
jvm, and with an "interface", that would only allow that one user to
start new jobs.

Does something like this already exist?

PS: the actual jobs need to be in Java, because they need certain
Java-libraries for their work. The server would know all relevant
classes beforehand.
 
M

markspace

Does something like this already exist?


ClassName.main( "arguments" );

?

After you add the Jar file to your app server's classpath, of course.

Output could be a little weird, depending on how your sever handles
stdout. Most of the output will likely end up in the log file.

Not sure what else...
 
S

Stefan Ram

Andreas Leitgeb said:
I'd like to consider some kind of application server, that would
run the actual java-code of any number of jobs (of one user) in one
jvm, and with an "interface", that would only allow that one user to
start new jobs.

I don't know the meaning of »user« in Java. Maybe you want:

java.lang.System.getProperty( "user.name" ).equals( "user0" )

? Otherwise, you could use a normal Web/REST-server and a local
socket (127.0.0.1) with appropriate IP checks/firewalls.
 
S

Stefan Ram

I don't know the meaning of »user« in Java. Maybe you want:
java.lang.System.getProperty( "user.name" ).equals( "user0" )

Oh, I now see that this does not work across server boundaries!

To grant server access only to user user0, create a file
that is writeable only by the server process and readable
only by that user user0. The server writes a text to that
file and then the user must pass this text to the server
API. As soon as such a call is received, a new text can be
written to that file.
 
A

Arne Vajhøj

Essentially my application is a couple of separate command-line
utilities, called from users with shell-access (or from unix
shell scripts).

Startup-time still isn't exactly Java's strong point, and often
enough in my situation the startup time is by far the "longest
pole in the tent".
Adding option -Xshareclasses improved things, but not enough.

I'd like to consider some kind of application server, that would
run the actual java-code of any number of jobs (of one user) in one
jvm, and with an "interface", that would only allow that one user to
start new jobs.

Does something like this already exist?

PS: the actual jobs need to be in Java, because they need certain
Java-libraries for their work. The server would know all relevant
classes beforehand.

Why not run beanshell and run the classes from that.

$ java -cp wherebshis:whereyourstuffis bsh.Interpreter
bsh% somepackage.SomeClass.main(null);
bsh% somepackage.SomeOtherClass.main(null);

Arne
 
J

Joerg Meier

bsh% somepackage.SomeClass.main(null);
bsh% somepackage.SomeOtherClass.main(null);

It seems to me that would break the vast majority of Java applications,
which tend to start with something like "if (args.length > 0) ...".

Liebe Gruesse,
Joerg
 
A

Andreas Leitgeb

Ok, I noticed from the replies that my posting was apparently
unclear in ways I didn't anticipate...

First of all, the "server" was meant as a process on the same
host, not as a separate machine.

Second, The server is supposed to handle multiple processes in
parallel (as threads), separating them (and each's static fields)
by use of separate classloaders. (I thought that would be implicit
by referring to "application server", but obviously it wasn't)

Thanks anyway for the answers so far.

PS: I already caught the drift, though, that what I need is a
bit further off mainstream than I feared it would be.
 
A

Andreas Leitgeb

Leif Roar Moldskred said:
One possible solution is to have a program that scans a given
directory (say, ~/.javaTriggers) which only that user has write access
to.

I hoped for unix domain sockets or named pipes, if the server can
handle those.
If the utilities need to write output to stdOut, it gets a little
trickier, but you can finagle your way around that too.

I'll probably need to multiplex it into the communication channel...

I hoped I wouldn't need to start from zero, though.

Thanks, anyway.
 
A

Andreas Leitgeb

Why not run beanshell and run the classes from that.
$ java -cp wherebshis:whereyourstuffis bsh.Interpreter
bsh% somepackage.SomeClass.main(null);
bsh% somepackage.SomeOtherClass.main(null);

I googled and found http://www.beanshell.org/javadoc/bsh/Interpreter.html
I'm not yet sure if this will help me with separating multiple
jobs running at the same time, but it might help me in my process
of incrementally implementing what I need.

Thanks!

PS: for the other F'up: of course I would not pass null for args...
I'd definititely have something sensible to pass instead.
 
A

Arne Vajhøj

It seems to me that would break the vast majority of Java applications,
which tend to start with something like "if (args.length > 0) ...".

Yeah. new String[0] would be a bit nicer than null.

Arne
 
A

Arne Vajhøj

I googled and found http://www.beanshell.org/javadoc/bsh/Interpreter.html
I'm not yet sure if this will help me with separating multiple
jobs running at the same time, but it might help me in my process
of incrementally implementing what I need.

Now I am confused.

You worry about the JVM startup time - implying that it is
somewhat significant compared to job run time.

But you want to run multiple jobs in parallel - implying that
jobs run for a long time.

Am I missing something?

Arne
 
A

Andreas Leitgeb

Arne Vajhøj said:
Now I am confused.

You worry about the JVM startup time - implying that it is
somewhat significant compared to job run time.
But you want to run multiple jobs in parallel - implying that
jobs run for a long time.

There are short jobs, long jobs eventually spawning short
jobs while running.

In principle I could distinguish them beforehand and only
use bean-shell for the short ones (running them serialized).

However, I'm not sure if I can correctly predict it in
all cases, so I'm looking for a general solution that
won't require me to distinguish.
 
J

Jeff Higgins

There are short jobs, long jobs eventually spawning short
jobs while running.

In principle I could distinguish them beforehand and only
use bean-shell for the short ones (running them serialized).

However, I'm not sure if I can correctly predict it in
all cases, so I'm looking for a general solution that
won't require me to distinguish.

It's starting to sound like OSGI to me.
OSGI Standard Services
<http://en.wikipedia.org/wiki/OSGi#Services>

Or even a Business Process Management platform | framework
 
A

Andreas Leitgeb

Luuk said:

Thanks for the cascade of Karaf links :)

It's not quite what I was looking for, and I saw, that I have to
refine my requirements until I really know what I need. As it seems,
an "application server" is much more than what I need, as it also
has the concept of deploying and undeploying code dynamically.

I'll probably only need to deal with unix domain sockets (not
internet sockets) for starting applications and interacting with
them, and I'll need to learn how to deal with classloaders, taking
care not to accidentally load certain classes too early (thus into
the system classloader). I could probably learn that from karaf
but I expect to learn it easier somewhere else.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top