Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/commun In directory usw-pr-cvs1:/tmp/cvs-serv25507 Added Files: BAD_COMMAND_Exception.java BAD_DATA_TYPE_Exception.java BAD_INFO_ID_Exception.java BAD_INFO_TYPE_Exception.java BAD_OBJ_ID_Exception.java Buffer.java Commun.java COMMUN_Exception.java CommunSetup.java CommunSetupShMem.java CommunSetupSocket.java CommunShMem.java CommunSocket.java IProf.java IProfException.java UNKNOWN_Exception.java Log Message: Content of src2 directory moved into the new location. --- NEW FILE: BAD_COMMAND_Exception.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Bad command exception. This exception is raised when a request for ** specified objID is not possible (eg. when you try (in one call to ** getAll() or getChanged()) to gain threads where concrete method was ** called and you have method's objId only). ** ** @author Marek Przeczek */ public class BAD_COMMAND_Exception extends IProfException {}; /* * $Log: BAD_COMMAND_Exception.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: BAD_DATA_TYPE_Exception.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Bad objID type exception. This exception is raised when used ID is ** of different type than specified (eg. when an object has statistic ** data about memory profiling only and someone tries to gain cpu ** profiling data from it). ** ** @see BAD_INFO_TYPE_Exception ** ** @author Marek Przeczek */ public class BAD_DATA_TYPE_Exception extends IProfException {}; /* * $Log: BAD_DATA_TYPE_Exception.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: BAD_INFO_ID_Exception.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Bad infoID exception. This exception is raised when used ID is not ** an infoID of an object (eg. when objID is used as an infoID, this ** exception can be raised). ** ** @see BAD_OBJ_ID_Exception ** ** @author Marek Przeczek */ public class BAD_INFO_ID_Exception extends IProfException {}; /* * $Log: BAD_INFO_ID_Exception.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: BAD_INFO_TYPE_Exception.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Bad infoID type exception. This exception is raised when type of ** infoID is bad (eg. infoID exists but is of different type than ** specified). ** ** An example: when trying to gain information about method (eg. with ** infoId = 1), getInfo( 1, METHOD_INFO) must be called. METHOD_INFO ** specifies the type of information, in this case information about ** method. If another info type is specified, BAD_INFO_TYPE_Exception ** will be raised. ** ** @see BAD_DATA_TYPE_Exception ** ** @author Marek Przeczek */ public class BAD_INFO_TYPE_Exception extends IProfException {}; /* * $Log: BAD_INFO_TYPE_Exception.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: BAD_OBJ_ID_Exception.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Bad objectID exception. This exception is raised when used ID is not ** an objID of an object (eg. when an ID to which no object exists is ** used, this exception is raised). ** ** @see BAD_INFO_ID_Exception ** ** @author Marek Przeczek */ public class BAD_OBJ_ID_Exception extends IProfException {}; /* * $Log: BAD_OBJ_ID_Exception.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: Buffer.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** I/O buffer. This class implements an input/output buffer ** needed during communication between profiler dynamic library ** and Java. Same class (of the same name and functionality) exists ** in the dynamic library side - but it is more complicated and flexible ** than this one. ** ** @see Commun ** ** @author Marek Przeczek */ public class Buffer { /// internal buffer private byte[] _buf; /// size of buffer private int _size; /// Default constructor. public Buffer() { _size = 0; _buf = null; } /** Constructor. This constructor constructs Buffer object using data ** from another buffer. The data are copied to this newly created ** Buffer object. ** ** @param buf buffer (an array of bytes) ** @param size size of buffer 'buf' */ public Buffer( byte[] buf, int size) { _size = size; _buf = new byte[_size]; copyBuffer( _buf, buf, _size); } /** Use existing buffer. This method replaces internal buffer by ** the given one. No copy is created, the buffer 'buf' is used as ** an internal buffer. ** ** @param buf buffer (an array of bytes) ** @param size size of buffer 'buf' */ public Buffer useBuffer( byte[] buf, int size) { _size = size; _buf = buf; return this; } /** Get buffer. This method returns a reference ** to buffer data. ** ** @return reference to buffer */ public byte[] getBuffer() { return _buf;} /** Get size of data. This method returns size ** of data stored in buffer. ** ** @return size of data */ public int getSize() { return _size;} /** Clear buffer. It truncates buffer to zero length, ** everything stored in the buffer will be lost. */ public void clear() { _size = 0; _buf = null; } /** Put integer into buffer. By this method you can insert Java ** integer into buffer (of bytes). ** ** @param c integer ** ** @return this Buffer object ** ** @see getInt(), getLong(), getString() */ public Buffer putInt( int c) { _buf = copyBuffer( new byte[_size+4], _buf, _size); _size = _size+4; for( int i = 0; i < 4; i++) { _buf[_size-1-i] = (byte)(c & 0x000000FF); c >>= 8; } return this; } /** Get integer from buffer. This method grabs Java integer located ** at position 'offset' from the buffer. ** ** @param offset position in the buffer ** ** @return grabbed integer ** ** @see putInt(), getLong(), getString() */ public int getInt( int offset) { int c = 0; for( int i = 0; i < 4; i++) { c <<= 8; int cc = _buf[offset+i]; c += cc; if( cc < 0) c += 256; } return c; } /** Get long integer from buffer. This method grabs Java long ** integer located at position 'offset' from the buffer. ** ** @param offset position in the buffer ** ** @return grabbed long integer ** ** @see putInt(), getInt(), getString() */ public long getLong( int offset) { long hi = getInt( offset); int lo = getInt( offset+4); return (hi << 32)+lo; } /** Get string from buffer. This method grabs Java string located ** at position 'offset' from the buffer. In the buffer string is ** stored as C string (text + terminating null). ** ** @param offset position in the buffer ** ** @return grabbed string ** ** @see putInt(), getInt(), getLong() */ public String getString( int offset) { int pos = offset; while( _buf[pos] != 0) pos++; return new String( _buf, offset, pos-offset); } /** Copy buffer. It only copies source buffer to destination one. ** Destination buffer must be of sufficient size, no check is ** done. ** ** @param dest destination ** @param src source ** @param sz size of source buffer ** ** @return reference to destination buffer */ private byte[] copyBuffer( byte[] dest, byte[] src, int sz) { if( src != null) System.arraycopy( src, 0, dest, 0, sz); return dest; } }; /* * $Log: Buffer.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: Commun.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Communication. This is a standard interface for all communication ** classes. Whole communication is done thru an instance of this ** interface implementation. ** ** @see CommunSocket, CommunShMem ** ** @author Marek Przeczek */ public interface Commun { /** Initialization of communication. This method should ** initialize the communication, it means to make a connection ** with opposite side. ** ** @return false (failed); ** true (ok, initialized) */ public boolean initialize(); /** Read data. This method is used to read data ** from communication channel (socket, shmem etc.) to buffer. ** ** @param b reference to Buffer object ** ** @return reference to this Commun object ** ** @see write() */ public Commun read( Buffer b); /** Write data. This method is used to write data ** from buffer to communication channel (socket, shmem etc.). ** ** @param b reference to Buffer object ** ** @return reference to this Commun object ** ** @see read() */ public Commun write( Buffer b); /** Failure indication. Use this method if you want to know ** the last operation was successful or not. ** ** @return false (last operation was successful); ** true (last operation failed) */ public boolean hasFailed(); /** Stop communication. Is stops communication and closes ** communication channel. */ public void stopCommun(); }; /* * $Log: Commun.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: COMMUN_Exception.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Exception. This exception is raised when a communication failed ** (eg. when server falls down during communication). ** ** @author Marek Przeczek */ public class COMMUN_Exception extends IProfException {}; /* * $Log: COMMUN_Exception.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: CommunSetup.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Communication setup. Other classes holding setup data are inherited ** from this abstract class. ** ** @see CommunSetupSocket, CommunSetupShMem ** ** @author Marek Przeczek */ public abstract class CommunSetup { /// type of communication - sockets public static final int COMMUN_SOCKET = 0; /// type of communication - shared memory public static final int COMMUN_SHMEM = 1; /// type of communication public int communType; /** Default constructor. Socket communication is used by default. */ public CommunSetup() { this( COMMUN_SOCKET); } /** Constructor. It sets type of communication. ** 'communType' argument can take one of the following values: ** #COMMUN_SOCKET or #COMMUN_SHMEM. ** ** @param communType type of communication */ public CommunSetup( int communType) { this.communType = communType; } }; /* * $Log: CommunSetup.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: CommunSetupShMem.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Shared memory communication setup. This class contains setup data ** for shared memory communication. ** ** @see CommunSetup, CommunSetupSocket ** ** @author Marek Przeczek */ public class CommunSetupShMem extends CommunSetup { /// shared memory name (identifier) - 3 characters public String shmemId = new String( "com"); /// shared memory size - in bytes public int shmemSize = 256*1024; /// Default constructor. public CommunSetupShMem() { super( COMMUN_SHMEM); } /** Constructor. It takes setup from given parameters. ** ** @param shmemId shared memory name (identifier) - 3 chars only ! ** @param shmemSize shared memory size - in bytes */ public CommunSetupShMem( String shmemId, int shmemSize) { super( COMMUN_SHMEM); this.shmemId = new String( shmemId); this.shmemSize = shmemSize; } }; /* * $Log: CommunSetupShMem.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: CommunSetupSocket.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Socket communication setup. This class contains setup data ** for socket communication. ** ** @see CommunSetup, CommunSetupShMem */ public class CommunSetupSocket extends CommunSetup { /// connect mode - server public static final int SERVER_MODE = 0; /// connect mode - client public static final int CLIENT_MODE = 1; /// connect mode (client by default) public int connectMode = CLIENT_MODE; /// hostname (used when connect mode is set to 'client') public String hostname = new String( "127.0.0.1"); /// TCP port (where server should listen or where client should connect to) public int port = 25595; /// Default constructor. public CommunSetupSocket() { super( COMMUN_SOCKET); } /** Constructor. It takes setup from given parameters. ** 'connectMode' argument can take one of the following values: ** #SERVER_MODE or #CLIENT_MODE. ** ** @param connectMode connect mode ** @param hostname hostname ** @param port port */ public CommunSetupSocket( int connectMode, String hostname, int port) { super( COMMUN_SOCKET); this.connectMode = connectMode; this.hostname = new String( hostname); this.port = port; } }; /* * $Log: CommunSetupSocket.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: CommunShMem.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Shared memory communication. This class implements shared memory ** communication and offers the user of this class the standard ** communication interface. Implementation is system dependent ** (so it is different on WIN32 and UNIX systems). It should be ** faster then using sockets. Because Java has no support for shared ** memory, JNI is used. ** ** @see CommunSocket, Commun ** ** @author Marek Przeczek */ public class CommunShMem implements Commun { /// 8 bytes long pointer to data private long data = 0; /** Constructor. Creates shared memory block and ** needed semaphores for communication. If semaphores ** or shared memory block already exist, they are used. ** ** @param shmemId shared memory identifier (3 characters long only) ** @param shmemSize shared memory size ** ** @see construct() */ public CommunShMem( String shmemId, int shmemSize) { construct( shmemId, shmemSize);} /** Constructor. Because JNI does not allow native constructors, ** this native method picks constructor's function over. ** ** @param shmemId shared memory identifier (3 characters long only) ** @param shmemSize shared memory size ** ** @see CommunShMem() */ private native void construct( String shmemId, int shmemSize); /** Finalize. It deattaches and destroys shared memory, destroys ** semaphores. See Java Language Reference for more information. */ protected native void finalize(); /** Initialization of communication. This method does nothing, ** it always returns true. ** ** @return true (ok, initialized) */ public boolean initialize() { return true;} /** Read data. This method is used to read data ** from communication channel (shmem) to buffer. ** ** @param b reference to Buffer object ** ** @return reference to this Commun object ** ** @see write() */ public native Commun read( Buffer b); /** Write data. This method is used to write data ** from buffer to communication channel (shmem). ** ** @param b reference to Buffer object ** ** @return reference to this Commun object ** ** @see write() */ public native Commun write( Buffer b); /** Failure indication. Use this method if you want to know ** the last operation was successful or not. ** ** @return false (last operation was successful); ** true (last operation failed) */ public native boolean hasFailed(); /** Stop shared memory communication. It stops communication, ** locks/unlocks semaphores and leaves them in consistent state. */ public native void stopCommun(); /** Static initializer. It loads native class (stored in dynamic ** library) to the memory. */ static { System.loadLibrary( "CommunShMem"); } }; /* * $Log: CommunShMem.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: CommunSocket.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ import java.io.*; import java.lang.*; import java.net.*; /** Socket communication. This class implements TCP/IP socket ** communication and offers the user of this class the standard ** communication interface.This class stands a server or client out. ** ** @see CommunShMem, Commun ** ** @author Marek Przeczek */ public class CommunSocket implements Commun { /// connect mode (0 = server, 1 = client) private int _connectMode; /** Hostname. It is used only when connectMode is set ** to 'client' (1); it contains target host's name. */ private String _host; /** Port number. When connectMode is set to 'server' (0), ** it contains port number, where server listens for new ** connections; when connectMode is set to 'client' (1), ** it contains target host's port number. */ private int _port; /// failure indicator private boolean _failed = false; /// socket private Socket _sock; /// input stream private BufferedInputStream _in; /// output stream private BufferedOutputStream _out; /// internal buffer for binary data private Buffer _buf = (new Buffer()).useBuffer( new byte[4], 4); /** Constructor. It initializes server for listening ** on given port (if connectMode is set to 'server'). ** If connectMode is set to 'client', this class connects ** to the target specified by 'host' and 'port' arguments. ** ** @param connectMode mode (0 = as server, 1 = as client) ** @param host target host (if connectMode is set to 'client') ** @param port port number */ public CommunSocket( int connectMode, String host, int port) { _connectMode = connectMode; _host = new String( host); _port = port; } /** Initialization of communication. This method initializes ** socket communication - waits for client and makes a connection. ** Once a client is connected to this server, another client ** has no possibility to connect. If used in client mode, it tries ** to connect to server. ** ** @return false (failed); ** true (ok, client connected) */ public boolean initialize() { try { if( _connectMode == 0) { // server ServerSocket sock = new ServerSocket( _port); sock.setSoTimeout( 0); _sock = sock.accept(); sock.close(); } else _sock = new Socket( _host, _port); _in = new BufferedInputStream( _sock.getInputStream()); _out = new BufferedOutputStream( _sock.getOutputStream()); } catch( Exception e) { return _failed = true; } return true; } /** Read data. This method is used to read data ** from communication channel (socket) to buffer. ** ** @param b reference to Buffer object ** ** @return reference to this Commun object ** ** @see write() */ public Commun read( Buffer b) { try { int rc = _in.read( _buf.getBuffer(), 0, 4); if( _failed = (rc < 4)) return this; int size = _buf.getInt( 0); if( size == 0) { b.clear(); return this; } byte[] nbuf = new byte[size]; int pos = 0; while( size != 0) { rc = _in.read( nbuf, pos, size); if( _failed = (rc < 0)) return this; pos += rc; size -= rc; } b.useBuffer( nbuf, pos); } catch( Exception e) { _failed = true; } return this; } /** Write data. This method is used to write data ** from buffer to communication channel (socket). ** ** @param b reference to Buffer object ** ** @return reference to this Commun object ** ** @see read() */ public Commun write( Buffer b) { _buf.clear(); _buf.putInt( b.getSize()); try { _out.write( _buf.getBuffer(), 0, 4); _out.write( b.getBuffer(), 0, b.getSize()); _out.flush(); } catch( Exception e) { _failed = true; } return this; } /** Failure indication. Use this method if you want to know ** the last operation was successful or not. ** ** @return false (last operation was successful); ** true (last operation failed) */ public boolean hasFailed() { return _failed;} /** Stop socket communication. It stops socket communication - ** closes input/output streams and socket. */ public void stopCommun() { try { _in .close(); _out.close(); _sock.close(); } catch( Exception e) { _failed = true; } } }; /* * $Log: CommunSocket.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: IProf.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. [...1209 lines suppressed...] ** ** @see getInfo(), getData(), getAll() */ public synchronized LinkedList getChanged( int objId, int seqType) throws COMMUN_Exception, BAD_OBJ_ID_Exception, BAD_COMMAND_Exception, UNKNOWN_Exception { return getChangedOrAll( F_GET_CHANGED, objId, seqType); } }; /* * $Log: IProf.java,v $ * Revision 1.1 2001/10/14 22:08:56 stolis * Content of src2 directory moved into the new location. * */ --- NEW FILE: IProfException.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Exception. All custom exceptions raised by IProf class should be ** inherited from this class, so it should be very easy to catch ** exceptions belonging to IProf class. ** ** @see BAD_COMMAND_Exception, BAD_DATA_TYPE_Exception, ** BAD_INFO_ID_Exception, BAD_INFO_TYPE_Exception, ** BAD_OBJ_ID_Exception, COMMUN_Exception, UNKNOWN_Exception ** ** @author Marek Przeczek */ public class IProfException extends Exception {}; --- NEW FILE: UNKNOWN_Exception.java --- package net.sourceforge.javaprofiler.jpiimpl.commun; /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ /** Unknown exception. This exception is raised when a failure cannot ** be recognised, the only thing we know is that it happened in IProf ** class. ** ** @author Marek Przeczek */ public class UNKNOWN_Exception extends IProfException {}; |