FljpFl0p | 14 Apr 19:49
Picon
Favicon
Gravatar

User input from JConsole?

Hi, I've been trying to use your JConsole to create a simple command-line
interface. Every features is perfect, except that I still can't figure out
how to get the user input.

I tried using BufferedReader using getIn() as a parameter, but for some
reason the BufferedReader is blocked. I'm not familiar with neither
BufferReader or JConsole so I can't figure out how to fix the problem.

Can you help me fix this or give me an alternative?

Thank you

P/s: to make it easier for you to see the code, please view this URL:
http://stackoverflow.com/questions/10155782/java-how-to-read-user-input-from-beanshells-jconsole

--
View this message in context: http://beanshell.2283338.n4.nabble.com/User-input-from-JConsole-tp4557704p4557704.html
Sent from the BeanShell - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
Ryan Wexler | 8 Feb 19:06
Favicon

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: bsh.CallStack

I have been receiving this error off and on for sometime now.

Using:
jdk 1.6, bsh_2.04b

The error is difficult to reproduce because it seems random.  If I run the
same script on the same data that caused the error it never seems to
reproduce it.
This is very problematic.

I see that there is an old bug related to serialization.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4171142
Might this be related?

thanks for the help
-ryan
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
mark wilkinson | 31 Jan 13:38
Favicon

String Strangeness

Using bsh-2.0b5 embedded in JMeter-2.5.1

Trying to do a simple string assignment in a test script (test.bsh):

String rawBCString = "288/SetEntryList/7/ITSPUAT9/Home Page2/\9";

And get the following...

<snip>

bsh % source("test.bsh");
// Error: // Uncaught Exception: Method Invocation
this.interpreter.source : at Line: 14 : in file:
/bsh/commands/source.bsh : this .interpreter .source ( filename , this
.caller .namespace )

Called from method: source : at Line: 1 : in file: <unknown file> :
source ( "test.bsh" )
Target exception: Sourced file: test.bsh Token Parsing Error: Lexical
error at line 1, column 63.  Encountered: "9" (57), after :
"\"288/SetEntryList/7/ITSPUAT9/Home Page2/\\": <at unknown location>

bsh %

<snip>

Anyone got any ideas what's going on here? I think it's something to
do with escape chars but having a "9" after a "\" doesn't seem like
anything odd to me. Looks like java is taking the raw string, escaping
all the "\" chars and then barfing on the result..
(Continue reading)

J.D. Mullin | 29 Dec 23:49
Gravatar

Executing Eclipse SaveAll command from beanshell

I have a beanshell script that is run inside Eclipse via Practically Macro. I need the script to run the File
-> SaveAll command, but I'm having problems getting a reference to the ICommandService that Eclipse
provides. 

The service locator generally uses PlatformUI which doesn't seem accessible inside beanscript. I've
also tried getSite() per the Eclipse Services help (http://tinyurl.com/c9o8a9g). It's unclear to me if
I will be able to access these inside a beanscript.

I end up getting the error "Typed variable declaration : Command not found: getSite()" or "Attempt to
resolve method: getWorkbench() on undefined variable or class name: PlatformUI"

Any pointers?

TIA,
J.D.

import org.eclipse.swt.custom.StyledText;
import org.eclipse.jface.text.IFindReplaceTarget;

import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.ui.commands.ICommandService;

		try
		{
			// Save all editors first
			ICommandService service = (ICommandService) getSite().getService(ICommandService.class);
			console.writeln("service is " + service.toString());
(Continue reading)

Rathna Kumar | 10 Nov 12:31
Picon

Reg. Non-English string literal in Java code

Hi,
I am using bean shell interpreter to execute Java code.
If any string literal in Java code has non-English characters
(say, Russian) then such characters becomes garbled when
the interpreter is executing the code.
Is there a way to support internationalization during
bean shell interpreter execution of Java code ?

Usage of bean shell interpreter
Interpreter interpreter = new Interpreter();
interpreter.eval(javaCode);

Content of javaCode
ArrayList aList = new ArrayList();
aList.add("<RussianCharsHere>");
aList.add("<RussianCharsHere>");

Any help is appreciated.

Thanks
Rathna Kumar R
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
Michael Pitoniak | 6 Aug 00:51
Picon
Favicon

Re: (no subject)

Save your money and time.. http://xp2600amd.free.fr/com.page.php?esiyahooID=82e8
 		 	   		  
------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
David Lee | 26 Jun 13:56

Re: Loading .java Files

Ok you are using "eval".  The terminology ".java" confused me.
You are loading  a "beanshell" file  not a "java" file.  Although they are
often similar.

If you want to invoke a non-static method in a class you do it the same way
in beanshell as you do in java.
you need to instantiate the class to invoke the method.

    new Foo().bar()

I dont think you can do this with BSHMethod.invoke()
(You can with eval)

My prefered method of executing bsh from within java is to use the Interface
methods.
 e.g.
     (ICampaignScript) mInterpreter.getInterface(ICampaignScript.class);

then you can call bsh methods directly via the interface.

but again this only calls 'top level' methods.   To create classes and call
them you need to run eval() or to expose a top level method which calls
them.
I dont know of any way directly from the java API to do it.

----------------------------------------
David A. Lee
dlee@...
http://www.xmlsh.org

(Continue reading)

spring | 26 Jun 12:50
Picon

Loading .java Files

Hi,

when I load a complete .java File, the global namespace has no methods:

public class Foo() {
  void bar() {
    //
  }
}

When I load this, the namespace has the method bar():

//public class Foo() {
  void bar() {
    //
  }
//}

Is this a bug or by design?

Thank you

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
Gena Batsyan | 21 Mar 16:11
Picon

Trivial question about initial script sourced automatically for every JConsole.

Hi everybody!

I've got a small probably trivial problem with beanshell
I'm trying to embed beanshell into my application by doing simple
bsh.Interpreter i = new bsh.Interpreter();
i.eval("desktop()");

what I'm trying to do is to source an initial file into the interpreter 
so that the stuff defined therein is available immediately in any shell 
created in the desktop, and it just does not work.

I've tried different things
1) before/after evaling desktop() in the code above I tried 
i.source("/pathto/boot.bsh");
2) modified makeWorkspace() command in the distribution so that
this.interpreter = new Interpreter( console );
+ this.interpreter.source("/pathto/boot.bsh");

the functions defined in /pathto/boot.bsh are simply not there.
However if i do source("/pathto/boot.bsh"); within the shell (in the 
desktop), everything is fine.

It's pretty annoying pasting this every time, I would appreciate if 
anyone would have a suggestion...

Thanks in advance!

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
(Continue reading)

Picon
Favicon

Thread BLOCKED using BS in Multi threads

Hi all,

I am having an issue when running multiple BS at the same type in
different threads in the same JVM.

Almost all the treads are getting into BLOCKED state due to some
synchronized code in Class.forName.

As a result the time of operation is much longer.

I have noticed that it happens mainly when the scripts are using
"source" to load other scripts.

Each threads have his own engine.

Any suggestion ?

Thanks

Fred

Thread dump:

"Scheduler-collector-SnmpCollector(MC.CA-30.4.31.162
[248]-0:0:0:0:0:0:0:0 [64]" prio=3 tid=0x012aa400 nid=0x4c waiting for
monitor entry [0x9457e000]

   java.lang.Thread.State: BLOCKED (on object monitor)

        at java.lang.Class.forName0(Native Method)
(Continue reading)

David | 20 Oct 12:43

Re: very simple doubt - declaring a method in the Interpreter

  i.eval("

int addTwoNumbers( int a, int b ) {
     return a + b;
} " )

David A. Lee
dlee@...
http://www.xmlsh.org

On 10/19/2010 11:00 PM, Leonardo K. Shikida wrote:
> Hi
>
> from the quickstart guide, I saw that I can declare methods just like this
>
> int addTwoNumbers( int a, int b ) {
>      return a + b;
> }
>
> sum = addTwoNumbers( 5, 7 );  // 12
> and I saw I can declare variables and evaluate expressions using the
> Interpreter just like this
>
> import bsh.Interpreter;
>
> Interpreter i = new Interpreter();  // Construct an interpreter
> i.set("foo", 5);                    // Set variables
> i.set("date", new Date() );
>
> Date date = (Date)i.get("date");    // retrieve a variable
(Continue reading)


Gmane