Command List for L2PNodeLauncher Interactive Mode - mohamedalsherif/SampleWebService GitHub Wiki
This tutorial gives some examples to the interactive Command Line tool of the LAS2peer project. In the previous tutorial L2pNodeLauncher-Commands we introduced the commands related to the current LAS2peer launched node. This tutorial shows the power of the command line tool and what else can be done with it.
On an open node in the interactive mode you can type the help
command to get all possible commands printed on the console. We will explain some intersting commands here in detail and give some possible usage scenarios.
Creating local variables using the assigment operator is one of the basic commands needed. You can basically assign a variable to any object in the available libraries.
user = i5.las2peer.security.UserAgent.createUserAgent("Pass")
The object can also be basic java object:
a = new java.lang.Integer ('5')
For example to be used for function calls that take Integer parameters.
You can also call methods on those objects exactly as you would do that in java code using the "." notation.
A call to the method setLogin of the UserAgent object would look like this on the console :
user.setLoginName("NewName")
The bind command
When you start a Node using the L2pNodeLauncher class as explained in the Step-by-Step-Service-Deployment-Tutorial, the bound object is automatically set to that L2pNodeLauncher Object and you are able to directly call methods from the command line on that specific object as was shown in L2pNodeLauncher-Commands. However the command line tool gives you the option to change the bound object to a different one by using the bind
command and hence directly call methods on the new bound object.
The list command
The list
command just prints all accessible methods of the bound object including their parameter list.
Using the bind
command for example, one can bind the previously declared User Agent with the command bind user
. After that a call to the command list
would list all accessible methods on that UserAgent object. This can be seen in the following screenshot.
The package command
The package
command gives you the option to add a prefix for all class relevant operations on the command line. This can be useful if you are willing to create multiple agents on the command line and would rather avoid writing i5.las2peer.security everytime. In this scenario a command would look like this package i5.las2peer.security
. The following screenshot shows this case with creating a Service Agent.
After using the package
command you may like to remove the package prefix and go back to the default (empty) package prefix, to do that you would call the package
command without parameters.
The print and the printStackTrace commands
The print
command can be used to print the values of multiple local variables. The printStackTrace
command is useful to understand the cause of an exception.