mirror of https://github.com/mchr3k/org.intrace
Deleted files
This commit is contained in:
parent
b4b5fa58de
commit
d180ca0814
|
|
@ -1,101 +0,0 @@
|
|||
package org.intrace.client.cui;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.tools.attach.VirtualMachine;
|
||||
import com.sun.tools.attach.VirtualMachineDescriptor;
|
||||
|
||||
/**
|
||||
* Command line agent loader.
|
||||
*/
|
||||
public class AgentLoader
|
||||
{
|
||||
/**
|
||||
* Cmd line tool.
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
BufferedReader readIn = new BufferedReader(new InputStreamReader(System.in));
|
||||
String inLine = "";
|
||||
while (!"quit".equals(inLine))
|
||||
{
|
||||
System.out.print("Enter command [attach/quit]: ");
|
||||
inLine = readIn.readLine();
|
||||
|
||||
if ("attach".equals(inLine))
|
||||
{
|
||||
attachToVM(readIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void attachToVM(BufferedReader xiReadIn)
|
||||
{
|
||||
try
|
||||
{
|
||||
listProcIDs();
|
||||
System.out.print("Choose VM: ");
|
||||
String inLine = xiReadIn.readLine();
|
||||
if (!"".equals(inLine))
|
||||
{
|
||||
VirtualMachine vm = VirtualMachine.attach(inLine);
|
||||
System.out.println("Attached to: " + vm.id());
|
||||
|
||||
while (!"done".equals(inLine))
|
||||
{
|
||||
System.out.print("Enter command [load/done]: ");
|
||||
inLine = xiReadIn.readLine();
|
||||
|
||||
if ("load".equals(inLine))
|
||||
{
|
||||
loadAgent(xiReadIn, vm);
|
||||
}
|
||||
}
|
||||
vm.detach();
|
||||
System.out.println("Detatched from: " + vm.id());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadAgent(BufferedReader xiReadIn, VirtualMachine vm) throws Exception
|
||||
{
|
||||
System.out.print("Enter path to agent jar (blank for windows default): ");
|
||||
String agentPath = xiReadIn.readLine();
|
||||
String defaultAgentPath = "../TestProject/lib/traceagent.jar";
|
||||
if ("".equals(agentPath))
|
||||
{
|
||||
agentPath = defaultAgentPath;
|
||||
}
|
||||
System.out.println("Agent Options");
|
||||
System.out.println("Leave blank for default: [regex-dcl.*");
|
||||
System.out.println("After loading you can only enabled/disable trace");
|
||||
System.out.print("Enter agent options: ");
|
||||
String agentOptions = xiReadIn.readLine();
|
||||
String defaultAgentOpt = "[regex-dcl.*";
|
||||
if ("".equals(agentOptions))
|
||||
{
|
||||
agentOptions = defaultAgentOpt;
|
||||
}
|
||||
vm.loadAgent(agentPath, agentOptions);
|
||||
System.out.println("Loaded agent into: " + vm.toString());
|
||||
}
|
||||
|
||||
private static void listProcIDs()
|
||||
{
|
||||
System.out.println("============== Begin List ==============");
|
||||
List<VirtualMachineDescriptor> vmList = VirtualMachine.list();
|
||||
for (VirtualMachineDescriptor vm : vmList)
|
||||
{
|
||||
System.out.println(vm.displayName() + ":" + vm.id());
|
||||
}
|
||||
System.out.println("============== End List ==============");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
package org.intrace.client.gui;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
public class ConnectionDetails
|
||||
{
|
||||
private final ExecutorService asyncExecutor = Executors.newSingleThreadExecutor(); // @jve:decl-index=0:
|
||||
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
|
||||
private Text addressText = null;
|
||||
private Text portText = null;
|
||||
private Label addressLabel = null;
|
||||
private Label portLabel = null;
|
||||
private Button connectButton = null;
|
||||
private Label statusLabel = null;
|
||||
private ConnectionDetails instanceRef = this; // @jve:decl-index=0:
|
||||
|
||||
public void open()
|
||||
{
|
||||
createSShell();
|
||||
sShell.open();
|
||||
Display display = Display.getDefault();
|
||||
while (!sShell.isDisposed())
|
||||
{
|
||||
if (!display.readAndDispatch())
|
||||
display.sleep();
|
||||
}
|
||||
display.dispose();
|
||||
}
|
||||
|
||||
public void show()
|
||||
{
|
||||
sShell.setVisible(true);
|
||||
sShell.setFocus();
|
||||
}
|
||||
|
||||
public void hide()
|
||||
{
|
||||
sShell.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes sShell
|
||||
*/
|
||||
private void createSShell()
|
||||
{
|
||||
GridData gridData11 = new GridData();
|
||||
gridData11.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER;
|
||||
gridData11.widthHint = 400;
|
||||
GridData gridData2 = new GridData();
|
||||
gridData2.widthHint = 400;
|
||||
GridData gridData1 = new GridData();
|
||||
gridData1.widthHint = 400;
|
||||
GridData gridData = new GridData();
|
||||
gridData.grabExcessHorizontalSpace = true;
|
||||
gridData.widthHint = 200;
|
||||
gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER;
|
||||
GridLayout gridLayout = new GridLayout();
|
||||
gridLayout.numColumns = 2;
|
||||
sShell = new Shell(SWT.CLOSE | SWT.TITLE | SWT.MIN);
|
||||
sShell.setText("Trace Client");
|
||||
sShell.setLayout(gridLayout);
|
||||
sShell.setSize(new Point(475, 126));
|
||||
sShell.addShellListener(new org.eclipse.swt.events.ShellAdapter()
|
||||
{
|
||||
public void shellClosed(org.eclipse.swt.events.ShellEvent e)
|
||||
{
|
||||
asyncExecutor.shutdownNow();
|
||||
sShell.dispose();
|
||||
}
|
||||
});
|
||||
addressLabel = new Label(sShell, SWT.NONE);
|
||||
addressLabel.setText("Address:");
|
||||
addressText = new Text(sShell, SWT.BORDER);
|
||||
addressText.setText("localhost");
|
||||
addressText.setLayoutData(gridData1);
|
||||
portLabel = new Label(sShell, SWT.NONE);
|
||||
portLabel.setText("Port:");
|
||||
portText = new Text(sShell, SWT.BORDER);
|
||||
portText.setText("9123");
|
||||
portText.setLayoutData(gridData2);
|
||||
@SuppressWarnings("unused")
|
||||
Label filler = new Label(sShell, SWT.NONE);
|
||||
connectButton = new Button(sShell, SWT.NONE);
|
||||
connectButton.setText("Connect");
|
||||
connectButton.setLayoutData(gridData);
|
||||
Label filler1 = new Label(sShell, SWT.NONE);
|
||||
filler1.setText("Status:");
|
||||
statusLabel = new Label(sShell, SWT.WRAP | SWT.LEFT);
|
||||
statusLabel.setText("Enter Details Above");
|
||||
statusLabel.setLayoutData(gridData11);
|
||||
connectButton.addMouseListener(new org.eclipse.swt.events.MouseAdapter()
|
||||
{
|
||||
public void mouseUp(org.eclipse.swt.events.MouseEvent e)
|
||||
{
|
||||
String host = addressText.getText();
|
||||
String port = portText.getText();
|
||||
connectToAgent(host, port);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void connectToAgent(final String host, final String port)
|
||||
{
|
||||
if (host.length() == 0)
|
||||
{
|
||||
sShell.getDisplay().asyncExec(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
statusLabel.setText("Please enter an address");
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (port.length() == 0)
|
||||
{
|
||||
sShell.getDisplay().asyncExec(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
statusLabel.setText("Please enter a port");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sShell.getDisplay().asyncExec(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
statusLabel.setText("Connecting...");
|
||||
asyncExecutor.execute(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Socket socket = new Socket();
|
||||
String statusMessage;
|
||||
try
|
||||
{
|
||||
socket.connect(new InetSocketAddress(host, Integer.valueOf(port)));
|
||||
statusMessage = "Connected";
|
||||
sShell.getDisplay().asyncExec(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
hide();
|
||||
TraceWindow traceWindow = new TraceWindow(instanceRef, socket);
|
||||
traceWindow.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
statusMessage = e.toString();
|
||||
}
|
||||
final String statusMessageRef = statusMessage;
|
||||
sShell.getDisplay().asyncExec(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
statusLabel.setText(statusMessageRef);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
package org.intrace.client.gui;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.intrace.agent.AgentConfigConstants;
|
||||
import org.intrace.output.trace.TraceConfigConstants;
|
||||
|
||||
public class ParsedSettingsData
|
||||
{
|
||||
public final String classRegex;
|
||||
public final boolean instrEnabled;
|
||||
public final boolean saveTracedClassfiles;
|
||||
public final boolean verboseMode;
|
||||
public final boolean allowJarsToBeTraced;
|
||||
|
||||
public final boolean entryExitEnabled;
|
||||
public final boolean branchEnabled;
|
||||
public final boolean argsEnabled;
|
||||
public final boolean stdOutEnabled;
|
||||
public final boolean fileOutEnabled;
|
||||
public ParsedSettingsData(Map<String, String> settingsMap)
|
||||
{
|
||||
classRegex = settingsMap.get(AgentConfigConstants.CLASS_REGEX);
|
||||
|
||||
if ("true".equals(settingsMap.get(AgentConfigConstants.TRACING_ENABLED)))
|
||||
{
|
||||
instrEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
instrEnabled = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(AgentConfigConstants.SAVE_TRACED_CLASSFILES)))
|
||||
{
|
||||
saveTracedClassfiles = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveTracedClassfiles = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(AgentConfigConstants.VERBOSE_MODE)))
|
||||
{
|
||||
verboseMode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
verboseMode = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(AgentConfigConstants.ALLOW_JARS_TO_BE_TRACED)))
|
||||
{
|
||||
allowJarsToBeTraced = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
allowJarsToBeTraced = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(TraceConfigConstants.ENTRY_EXIT)))
|
||||
{
|
||||
entryExitEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
entryExitEnabled = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(TraceConfigConstants.BRANCH)))
|
||||
{
|
||||
branchEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
branchEnabled = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(TraceConfigConstants.ARG)))
|
||||
{
|
||||
argsEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
argsEnabled = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(TraceConfigConstants.STD_OUT)))
|
||||
{
|
||||
stdOutEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
stdOutEnabled = false;
|
||||
}
|
||||
|
||||
if ("true".equals(settingsMap.get(TraceConfigConstants.FILE_OUT)))
|
||||
{
|
||||
fileOutEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileOutEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
package org.intrace.output.trace;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class NetworkTraceThread implements Runnable
|
||||
{
|
||||
private final ServerSocket networkSocket;
|
||||
private final BlockingQueue<String> outgoingTrace = new LinkedBlockingQueue<String>(100);
|
||||
private Set<NetworkTraceThread> set;
|
||||
|
||||
public NetworkTraceThread(ServerSocket networkSocket)
|
||||
{
|
||||
this.networkSocket = networkSocket;
|
||||
}
|
||||
|
||||
public void start(Set<NetworkTraceThread> set)
|
||||
{
|
||||
this.set = set;
|
||||
|
||||
Thread networkThread = new Thread(this);
|
||||
networkThread.setDaemon(true);
|
||||
networkThread.setName("Network-Trace");
|
||||
networkThread.start();
|
||||
}
|
||||
|
||||
private void stop()
|
||||
{
|
||||
try
|
||||
{
|
||||
networkSocket.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Throw away
|
||||
}
|
||||
set.remove(this);
|
||||
System.out.println("## Network Trace Disconnected");
|
||||
}
|
||||
|
||||
public void queueTrace(String traceLine)
|
||||
{
|
||||
try
|
||||
{
|
||||
outgoingTrace.put(traceLine);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
// Throw away
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Socket traceSendingSocket;
|
||||
try
|
||||
{
|
||||
traceSendingSocket = networkSocket.accept();
|
||||
try
|
||||
{
|
||||
ObjectOutputStream traceWriter = new ObjectOutputStream(traceSendingSocket.getOutputStream());
|
||||
while (true)
|
||||
{
|
||||
String traceLine = outgoingTrace.take();
|
||||
traceWriter.writeObject(traceLine);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
traceSendingSocket.close();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue