From: Jan S. <st...@us...> - 2002-05-16 11:40:39
|
Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/connect In directory usw-pr-cvs1:/tmp/cvs-serv21531 Modified Files: SocketLaunchConnector.java ShmemLaunchConnector.java Log Message: First version of launching connectors. Index: SocketLaunchConnector.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/connect/SocketLaunchConnector.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** SocketLaunchConnector.java 14 Oct 2001 21:56:31 -0000 1.3 --- SocketLaunchConnector.java 16 May 2002 11:40:36 -0000 1.4 *************** *** 21,28 **** --- 21,35 ---- package net.sourceforge.javaprofiler.jpiimpl.connect; + import java.io.File; + import java.io.IOException; import java.util.Map; + import java.util.Iterator; import java.util.ResourceBundle; import net.sourceforge.javaprofiler.jpi.VirtualMachine; import net.sourceforge.javaprofiler.jpi.connect.*; + import net.sourceforge.javaprofiler.jpiimpl.VirtualMachineImpl; + import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; + import net.sourceforge.javaprofiler.jpiimpl.commun.IProfException; + import net.sourceforge.javaprofiler.jpiimpl.commun.CommunSetupSocket; /** *************** *** 36,47 **** /** ! * Launches the VM and connects to it through socket. */ ! public VirtualMachine connect(Map arguments) throws IllegalConnectorArgumentsException, ConnectingException { ! //PENDING ! return null; } /** * Returns the transport mechanism used by this connector to establish * connections with a target VM. --- 43,143 ---- /** ! * Returns the arguments accepted by this Connector and their default values. ! * The keys of the returned map are string argument names. The values are ! * {@link Connector.Argument} containing information about the argument ! * and its default value. ! * ! * @return the map associating argument names with argument information ! * and default value. */ ! public Map defaultArguments() { ! Map args=super.defaultArguments(); ! Connector.Argument arg; ! arg=new StringArgumentImpl(false, bundle.getString("Port"), ! bundle.getString("PortDesc"), "port"); ! arg.setValue(""); ! args.put(arg.name(), arg); ! return args; } /** + * Launches the VM and connects to it through socket. + */ + public VirtualMachine connect(Map args) throws IllegalConnectorArgumentsException, ConnectingException { + String quote=null; + String launcher=null; + String options=null; + String clazz=null; + String arguments=null; + String settings=null; + String workdir=null; + int port=-1; + Iterator iter=args.keySet().iterator(); + while (iter.hasNext()) { + Connector.Argument arg=(Connector.Argument)args.get(iter.next()); + if ("port".equals(arg.name())) { + if (arg.isValid(arg.value())) { + port=((Connector.IntegerArgument)arg).intValue(); + } + } + if ("quote".equals(arg.name())) { + if (arg.isValid(arg.value())) { + quote=((Connector.StringArgument)arg).value(); + } + } + if ("launcher".equals(arg.name())) { + if (arg.isValid(arg.value())) { + launcher=((Connector.StringArgument)arg).value(); + } + } + if ("options".equals(arg.name())) { + if (arg.isValid(arg.value())) { + options=((Connector.StringArgument)arg).value(); + } + } + if ("class".equals(arg.name())) { + if (arg.isValid(arg.value())) { + clazz=((Connector.StringArgument)arg).value(); + } + } + if ("arguments".equals(arg.name())) { + if (arg.isValid(arg.value())) { + arguments=((Connector.StringArgument)arg).value(); + } + } + if ("settings".equals(arg.name())) { + if (arg.isValid(arg.value())) { + settings=((Connector.StringArgument)arg).value(); + } + } + if ("workdir".equals(arg.name())) { + if (arg.isValid(arg.value())) { + workdir=((Connector.StringArgument)arg).value(); + } + } + } + StringBuffer command=new StringBuffer(); + command.append(quote).append(launcher).append(quote).append(' ').append(options).append(" -Xrunprofiler:"); + if (port!=-1) { + command.append("commun_port=").append(port).append(','); + } + command.append(settings).append(' ').append(clazz).append(' ').append(arguments); + Process proc=null; + try { + proc=Runtime.getRuntime().exec(command.toString(), null, new File(workdir)); + } catch (IOException e) { + throw new IllegalConnectorArgumentsException(bundle.getString("ERR_IOEXCEPTION"), ""); + } + // PENDING port==-1 + IProf iprof=new IProf(new CommunSetupSocket(CommunSetupSocket.CLIENT_MODE, "localhost", port)); + try { + iprof.run(); + } catch (IProfException ipe) { + throw new ConnectingException(bundle.getString("ERR_CONNECT")+ipe); + } + return new VirtualMachineImpl(iprof, proc); + } + + /** * Returns the transport mechanism used by this connector to establish * connections with a target VM. *************** *** 88,91 **** --- 184,190 ---- /* * $Log$ + * Revision 1.4 2002/05/16 11:40:36 stolis + * First version of launching connectors. + * * Revision 1.3 2001/10/14 21:56:31 stolis * Connectors updated. Index: ShmemLaunchConnector.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/connect/ShmemLaunchConnector.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ShmemLaunchConnector.java 14 Oct 2001 21:56:31 -0000 1.3 --- ShmemLaunchConnector.java 16 May 2002 11:40:36 -0000 1.4 *************** *** 21,28 **** --- 21,35 ---- package net.sourceforge.javaprofiler.jpiimpl.connect; + import java.io.File; + import java.io.IOException; import java.util.Map; + import java.util.Iterator; import java.util.ResourceBundle; import net.sourceforge.javaprofiler.jpi.VirtualMachine; import net.sourceforge.javaprofiler.jpi.connect.*; + import net.sourceforge.javaprofiler.jpiimpl.VirtualMachineImpl; + import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; + import net.sourceforge.javaprofiler.jpiimpl.commun.IProfException; + import net.sourceforge.javaprofiler.jpiimpl.commun.CommunSetupShMem; /** *************** *** 34,45 **** public class ShmemLaunchConnector extends LaunchConnector { public static ResourceBundle bundle=ResourceBundle.getBundle("net.sourceforge.javaprofiler.jpiimpl.bundle"); ! /** ! * Launches the VM and connects to it through shared memory. */ ! public VirtualMachine connect(Map arguments) throws IllegalConnectorArgumentsException, ConnectingException { ! //PENDING ! return null; ! } /** --- 41,139 ---- public class ShmemLaunchConnector extends LaunchConnector { public static ResourceBundle bundle=ResourceBundle.getBundle("net.sourceforge.javaprofiler.jpiimpl.bundle"); ! /** ! * Launches the VM and connects to it through socket. */ ! public VirtualMachine connect(Map args) throws IllegalConnectorArgumentsException, ConnectingException { ! String quote=null; ! String launcher=null; ! String options=null; ! String clazz=null; ! String arguments=null; ! String settings=null; ! String workdir=null; ! String shmem=null; ! Iterator iter=args.keySet().iterator(); ! while (iter.hasNext()) { ! Connector.Argument arg=(Connector.Argument)args.get(iter.next()); ! if ("shmem".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! shmem=((Connector.StringArgument)arg).value(); ! } ! } ! if ("quote".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! quote=((Connector.StringArgument)arg).value(); ! } ! } ! if ("launcher".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! launcher=((Connector.StringArgument)arg).value(); ! } ! } ! if ("options".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! options=((Connector.StringArgument)arg).value(); ! } ! } ! if ("class".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! clazz=((Connector.StringArgument)arg).value(); ! } ! } ! if ("arguments".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! arguments=((Connector.StringArgument)arg).value(); ! } ! } ! if ("settings".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! settings=((Connector.StringArgument)arg).value(); ! } ! } ! if ("workdir".equals(arg.name())) { ! if (arg.isValid(arg.value())) { ! workdir=((Connector.StringArgument)arg).value(); ! } ! } ! } ! StringBuffer command=new StringBuffer(); ! command.append(quote).append(launcher).append(quote).append(' ').append(options).append(" -Xrunprofiler:"); ! command.append("commun_shmem_id=").append(shmem).append(','); ! command.append(settings).append(' ').append(clazz).append(' ').append(arguments); ! Process proc=null; ! try { ! proc=Runtime.getRuntime().exec(command.toString(), null, new File(workdir)); ! } catch (IOException e) { ! throw new IllegalConnectorArgumentsException(bundle.getString("ERR_IOEXCEPTION"), ""); ! } ! // PENDING port==-1 ! IProf iprof=new IProf(new CommunSetupShMem(shmem, 256*1024)); ! try { ! iprof.run(); ! } catch (IProfException ipe) { ! throw new ConnectingException(bundle.getString("ERR_CONNECT")+ipe); ! } ! return new VirtualMachineImpl(iprof, proc); ! } ! ! /** ! * Returns the arguments accepted by this Connector and their default values. ! * The keys of the returned map are string argument names. The values are ! * {@link Connector.Argument} containing information about the argument ! * and its default value. ! * ! * @return the map associating argument names with argument information ! * and default value. ! */ ! public Map defaultArguments() { ! Map args=super.defaultArguments(); ! Connector.Argument arg; ! arg=new StringArgumentImpl(false, bundle.getString("Shmem"), ! bundle.getString("ShmemDesc"), "shmem"); ! arg.setValue(""); ! args.put(arg.name(), arg); ! return args; ! } /** *************** *** 88,91 **** --- 182,188 ---- /* * $Log$ + * Revision 1.4 2002/05/16 11:40:36 stolis + * First version of launching connectors. + * * Revision 1.3 2001/10/14 21:56:31 stolis * Connectors updated. |