Skip to content

Commit

Permalink
added Windows command scripts --fixes BYTEMAN-193
Browse files Browse the repository at this point in the history
  • Loading branch information
adinn committed Feb 20, 2012
1 parent 3ff1710 commit c751033
Show file tree
Hide file tree
Showing 5 changed files with 657 additions and 0 deletions.
133 changes: 133 additions & 0 deletions bin/bmcheck.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
@echo off
@rem -----------------------------------------------------------------------------------
@rem
@rem JBoss, Home of Professional Open Source
@rem Copyright 2009-11, Red Hat and individual contributors
@rem by the @authors tag. See the copyright.txt in the distribution for a
@rem full listing of individual contributors.
@rem
@rem This is free software; you can redistribute it and/or modify it
@rem under the terms of the GNU Lesser General Public License as
@rem published by the Free Software Foundation; either version 2.1 of
@rem the License, or (at your option) any later version.
@rem
@rem This software is distributed in the hope that it will be useful,
@rem but WITHOUT ANY WARRANTY; without even the implied warranty of
@rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@rem Lesser General Public License for more details.
@rem You should have received a copy of the GNU Lesser General Public
@rem License along with this software; if not, write to the Free
@rem Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@rem 02110-1301 USA, or see the FSF site: http://www.fsf.org.
@rem
@rem @authors Kenji Suzuki
@rem
@rem batch which type checks a byteman rule set
@rem
@rem usage: bmcheck [-cp classpath]* [-p package]* [-v] script1 . . . scriptN
@rem
@rem -----------------------------------------------------------------------------------
if "%OS%" == "Windows_NT" setlocal

@rem set byteman environment
call "%~dp0\bmsetenv.bat"
if %ERRORLEVEL% == 1 goto exitBatch

set CP=%BYTEMAN_JAR%
set PACKAGES=
set VERBOSE=
@rem for debugging purposes we will also pass through sys prop defines
set DEFINES=
@rem include application classes upplied via -cp flag and check for -v flag

@rem ===================================================================================
@rem start parse args section.
@rem ===================================================================================
:startArgsLoop

set ARG=%~1

@rem if there are no arguments, or not an option.
if "%ARG%" == "" goto endArgsLoop
if not "%ARG:~0,1%" == "-" goto endArgsLoop

if "%ARG%" == "-cp" goto addClasspass
if "%ARG%" == "-p" goto addPackage
if "%ARG%" == "-v" goto setVerbose
if "%ARG:~0,2%" == "-D" goto addDefine

goto showUsage

:addClasspass
set CP=%CP%;%~2
shift
shift
goto startArgsLoop

:addPackage
shift
set ARG=%~1
if "%ARG%" == "" goto showUsage
set PACKAGES=%PACKAGES% -p %ARG%
shift
goto startArgsLoop

:setVerbose
set VERBOSE=-v
shift
goto startArgsLoop

:addDefine
set DEFINES=%DEFINES% %ARG%
shift
goto startArgsLoop

:endArgsLoop
if "%~1" == "" goto showUsage
@rem ===================================================================================
@rem end parse args section.
@rem ===================================================================================


@rem ===================================================================================
@rem start parse file section.
@rem ===================================================================================
set error=0
:startFileLoop

@rem if there are no arguments.
if "%~1" == "" goto endFileLoop

@rem extract file attribute, and validate.
SET A=%~a1
if not "%A:~0,1%" == "-" goto showInvalidFileMessage

set FILES=%FILES% "%~1"

shift
goto startFileLoop

:showInvalidFileMessage
set error=1
echo %~1 is not a readable file
shift
goto startFileLoop

:endFileLoop
if %error% == 1 goto exitBatch
@rem ===================================================================================
@rem end parse file section.
@rem ===================================================================================


@rem Execute java program.
java %BYTEMAN_JAVA_OPTS% -classpath "%CP%" %DEFINES% org.jboss.byteman.test.TestScript %PACKAGES% %VERBOSE% %FILES%


:exitBatch
if "%OS%" == "Windows_NT" endlocal
exit /b

:showUsage
echo usage: bmcheck [-cp classpath]* [-p package]* [-v] script1 . . . scriptN
goto exitBatch
87 changes: 87 additions & 0 deletions bin/bminstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
@echo off
@rem -----------------------------------------------------------------------------------
@rem
@rem JBoss, Home of Professional Open Source
@rem Copyright 2009-11, Red Hat and individual contributors
@rem by the @authors tag. See the copyright.txt in the distribution for a
@rem full listing of individual contributors.
@rem
@rem This is free software; you can redistribute it and/or modify it
@rem under the terms of the GNU Lesser General Public License as
@rem published by the Free Software Foundation; either version 2.1 of
@rem the License, or (at your option) any later version.
@rem
@rem This software is distributed in the hope that it will be useful,
@rem but WITHOUT ANY WARRANTY; without even the implied warranty of
@rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@rem Lesser General Public License for more details.
@rem You should have received a copy of the GNU Lesser General Public
@rem License along with this software; if not, write to the Free
@rem Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@rem 02110-1301 USA, or see the FSF site: http://www.fsf.org.
@rem
@rem @authors Kenji Suzuki
@rem
@rem batch which can be used to install the Byteman agent into
@rem a JVM which was started without the agent. This provides an
@rem alternative to using the -javaagent java command line flag
@rem
@rem usage: bminstall [-p port] [-h host] [-b] [-Dname[=value]]* pid
@rem pid is the process id of the target JVM
@rem -h host selects the host name or address the agent listener binds to
@rem -p port selects the port the agent listener binds to
@rem -b adds the byteman jar to the bootstrap classpath
@rem -Dname=value can be used to set system properties whose name starts with "org.jboss.byteman."
@rem expects to find a byteman agent jar in BYTEMAN_HOME
@rem
@rem -----------------------------------------------------------------------------------
if "%OS%" == "Windows_NT" setlocal

if "%~1" == "" goto showUsage

@rem set byteman environment
call "%~dp0\bmsetenv.bat"
if %ERRORLEVEL% == 1 goto exitBatch

@rem the Install class is in the byteman-install jar
if exist "%BYTEMAN_HOME%\lib\byteman-install.jar" goto okInstallJar
echo "Cannot locate byteman install jar"
goto exitBatch

:okInstallJar
set BYTEMAN_INSTALL_JAR=%BYTEMAN_HOME%\lib\byteman-install.jar

@rem we also need a tools jar from JAVA_HOME
if not "%JAVA_HOME%" == "" goto okJavaHome
echo please set JAVA_HOME
goto exitBatch

:okJavaHome

if exist "%JAVA_HOME%\lib\tools.jar" goto okTools
echo Cannot locate tools jar
goto exitBatch

:okTools
set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar

@rem exception avoidance; java.lang.UnsatisfiedLinkError: no attach in java.library.path
if exist "%JAVA_HOME%\jre\bin" set PATH=%PATH%;%JAVA_HOME%\jre\bin

@rem allow for extra java opts via setting BYTEMAN_JAVA_OPTS
@rem attach class will validate arguments
java %BYTEMAN_JAVA_OPTS% -classpath "%BYTEMAN_INSTALL_JAR%;%TOOLS_JAR%" org.jboss.byteman.agent.install.Install %*

:exitBatch
if "%OS%" == "Windows_NT" endlocal
exit /b

:showUsage
echo usage: bminstall [-p port] [-h host] [-b] [-Dname[=value]]* pid
echo pid is the process id of the target JVM
echo -h host selects the host name or address the agent listener binds to
echo -p port selects the port the agent listener binds to
echo -b adds the byteman jar to the bootstrap classpath
echo -Dname=value can be used to set system properties whose name starts with "org.jboss.byteman."
echo expects to find a byteman agent jar in BYTEMAN_HOME
goto exitBatch
Loading

0 comments on commit c751033

Please sign in to comment.