I am using javaeventing to write an even driven shell to access a database. So, my use case is:
- open up the shell in command line.
- Now, the shell connects to database and listens for the command coming in.
- when it gets a command, it executes it and gives back the required output.
Now, how can I avoid while(!exit){ //do stuff }
kind of loop here? How to use Java eventing correctly?
The straight forward way can be:
while(!exit)
{
exit = myClass.execute("command"); //when command is exit, return true.
}
But, I am looking if java eventing can give a better solution.
Update1:
Here is what I am trying to implement:
1 My application is a shell (like mongodb shell) to try out a key-value database.
2 The simple code:
init(); //Initialize the connection with database
while(!exit)
{
//exit = myClass.execute("put(5)"); //This returns false
exit = myClass.execute("exit"); //returns true, i.e. the user wants to exit the shell
}
Now, here I do not see the use of java eventing and I solved my problem, can you please tell me, HOW java eventing will come in picture here? I want the user to trigger the event.