| Finding memory leak in big app |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- Write object array to CSVI'm trying to write an object array to a CSV file. I can't seem to get
to the actual instances, rather than the reference. I can use
ObjectOutputStream and writeObject to handle writing to a bin file, but
am stuck on CSV.
fos = new FileOutputStream("asg3out.bin");
ObjectOutputStream out = new ObjectOutputStream(fos);
if (quitornot.compareToIgnoreCase("q") == 0) {
for (int cnt4 = 0; (requests[cnt4] != null); cnt4++) {
requests[cnt4].Display();
System.out.println();
out.writeObject(requests[cnt4]);
out.close();
}// end for loop
cnt++;
} //end if statement
Thanks for any help offered
- 5
- Gomez, Inc - Lexington, MA - JAVA DEVELOPER Needed**TO APPLY**
Please e-mail a formal resume to email***@***.com and include salary
requirements. Local candidates only please. No agencies at this
time.
Title: Senior Software Engineer
Skills: Java Swing API HTTP UI
Location: Lexington, MA
Job description:
Gomez, Inc., the leading provider of Web Application Experience
Management solutions, is seeking a Senior Software Engineer to develop
and maintain a critical component of Gomez's performance monitoring
technology.
Job Description:
In this role, you will own development and maintenance of the Gomez
Script Recorder, a core component of our website performance
monitoring service. You will be required to work closely with other
developers and members of the product management team to implement
requirements and support the product. Success in this role requires
strong attention to detail, a flair for developing solid user
interfaces, and superb communication skills both internally and
externally to the company.
The ideal candidate should have a strong background in the required
technology, experience solving complicated problems on predictable
timelines, and a commitment to maintaining high quality code through
best practices.
Job Responsibilities:
* Serve as primary developer for the application, working closely with
engineering and product management to refine and implement product
requirements
* Assist QA by helping define test plans, building unit tests, etc.
* Maintain compatibility with the latest version of Gomez's monitoring
agent
* Participate in customer support issues, engaging customers directly
if needed
Job Requirements:
* Academic background in computer science or equivalent
* Several years of Java language experience
* Java Swing API experience, the stronger the better
* Deep knowledge of core web technologies, particularly HTTP and
Javascript
* Windows platform experience desired, particularly COM
* User Interface design experience a plus
* Excellent communication skills; flexibility and a strong attention
to detail a must
* Ability to work independently and as a team member
Travel required: none
Telecommute: no
- 5
- Bit Manipulation in JavaHello,
I am new to working with the bit operators in java and need to
implement an algorightm and was hoping to get some guidance to address
the questions or url to material that may help.
1) I am starting out a byte array of lenght 20.
2) Next I need to determin the offsetbits, which are supposed to to be
the low order 4 bits of byte[19]. How do I determine this?
3)How do I convert this value in to an Int ?
Thanks in advance for your help.
Leslie
- 5
- J2EE vs J2SE vs JDK?Hello. I am new to Java. I would like to be able to create both Java
applets and Applications, and I want to try to use the Netbeans IDE.
There seem to be many different versions of Java on Sun's site, and I
am confused about what I really need.
Can you tell me the difference between J2EE, J2SE, and JDK?
Why does J2EE want to install a server on my machine?
Why does the option to create new applications disappear from the
Netbeans Create New Project window?
Netbeans doesn't seem to want to create applets separately from an
unrelated web appication. Any idea why? How do I use it to just
create a regular applet?
Thanks!
- 5
- static funtionsHello
i have some simple question reguarding static functions:
If i have some class that implements a static function that is called
from many places inside the app would every call have to wait for
termination of a previous call to that static function?
The function is not defined as synchronized.
If not, how is this realized in java? I mean if i understood it right
static functions are functions of the class not of any object so this
function should not be present more than once in memory right? Would i
overwrite the functionstate if i'd call the function eg. from more
threads?
_thanks for your info in advance
PS: the function does some DB calls in a tomcat app where some thousend
people call the function within short time and i'd like to avoid the
waiting, so i thought of changing the function to be nonstatic but
first i'd like to understand how static functions work :)
- 6
- Tips for backporting Java 1.6 classes into Java 1.5? I'm writing a Swing app, and I wanted a way to filter certain rows out
of a JTable. I search Sun's API to see if they had any facilities for doing
this, and I while I couldn't find such an API for 1.5, there is one for 1.6:
javax.swing.RowFilter
(http://download.java.net/jdk6/docs/api/javax/swing/RowFilter.html)
So I have a bit of a dilemma here. I don't want to have to "wait" for
1.6 to come out. I don't want to actually use a beta version of 1.6 (forcing
my clients to do the same). But I don't want to implement this functionality
myself, only to have to re-architecture my app when 1.6 does come out and we
want to switch to the official API.
The solution I've come up with is to write a class which implements the
same interface as Sun's javax.swing.RowFilter class, with the hope that the
interface won't change significantly when 1.6 is finally released. Then,
hopefully, when 1.6 does come out, the changes require to switch from my
implementation to Sun's implementation should be relatively minor (the
method signatures will be the same, and hopefully my interpretation of the
semantics will be close enough to the actual semantics that no bugs will
surface).
Is this the right approach, or is there a better way?
- Oliver
- 6
- recieve emailHi all,
I have googled around to look for recieving posts in this group by
email but not succeeded. Anyone know how to do it ?
thanks
- 6
- Taglib to build smart html tablesHello,
I need to build smart html tables (with sortable columns, merged cells,
pictures, different colors and fonts, etc -- all the kind of stuff html &
javascript allow).
I recall I've seen here a post a while ago of such an impressive component,
but I can't find it. :-(
Do you know such components ?
Thanks.
- 8
- 9
- Struts life cycleI have a question about "Struts life cycle".
I have a form with some data fields, I loaded them from database, and
I want
change them and strored to database.
When I run ***Action.do (controller for this form) forward to JSP
(view).
When execute JSP in server, made ***ActionForm object.
I submit data from JSP to ***Action.do (controller) and in execute()
method I store new data in database ...
I don't know where place that data from database (default data for
form) load from database and stored in ***ActionForm object.
pls, tell me about life cycle for this simple form.
- 9
- JPogressBar does not update UIHi,
i would like to show a JProgessBar during a longer process. I can show
it, but I cannot get the JProgressBar to update the UI, so it just
appears and at the end it disappears again, but it's not changed in the
meantime.
Example code, JProgressBar in JDialog, Java 1.4.2:
public class DialogProgressBar extends JDialog {
private JProgressBar jpb;
public DialogProgressBar(String title, java.awt.Frame owner, boolean
modal) {
super(owner, title, modal);
jpb = new JProgressBar();
jpb.setStringPainted(true);
this.getContentPane().add(jpb, java.awt.BorderLayout.CENTER);
setSize(300,50);
}
public JProgressBar getProgressBar() {
return jpb;
}
}
and that's how I use the Dialog/JProgressBar.
...
DialogProgressBar pb = new DialogProgressBar("Titel", dialog, false);
...
public void actionPerformed(ActionEvent aE) {
...
else if(cmd.equals("mniSynchronize")) {
int selectedRows = 3;
pb.getProgressBar().setMinimum(0);
pb.getProgressBar().setValue(0);
pb.getProgressBar().setMaximum(selectedRows);
pb.setVisible(true);
for(int i=0;i<selectedRows;i++) {
switch(i) {
case 1: pb.getProgressBar().setString("file001");
storeFiletype001();
break;
case 2: pb.getProgressBar().setString("file002");
storeFiletype002();
break;
case 3: pb.getProgressBar().setString("file003");
storeFiletype003();
break;
}
pb.getProgressBar().setValue(i+1);
}
pb.setVisible(false);
}
}
Thanks,
Aloys
- 12
- Class, Class, where is the ClassIs there a reference somewhere which lists which classes are in which
.jar files?
For instance, if I want to use HTTPServlet, which jar file is it in (I
know where it is, just an example...)?
All the API docs give the package name, but where is the package?
TKS!!
- 12
- A better looking JTableI want to create a JTable that emulates the appearance of native tables
on Windows and OSX. In particular, if the panel that a table is in is
taller than the size of the table (due to the table only having a few
rows), I want the extra space in the table to be filled with empty
cells, so that the table fills the whole panel.
This behaviour is present in most native apps I've seen that use tables.
A good example is the iTunes songs list.
My specific scenario is that I have a table which may contain only 1
row, or may contain as many as 50 (typically it contains 2 or 3 rows).x
I want to display this table in a pane that is resizable.
This means that the table may have a lot of extra veritcal space,
relative to the rows being displayed. I want it to fill the unused,
lower part of the pane with empty cells as the pane is made larger (and
when it is first drawn).
Is there a simple way to do this, or do I need to create a custom JTable
class to paint the table as described?
Any suggestions will be much appreciated.
Rob
- 14
- Math.IEEEremainder vs. %Today I encountered some code using Math.IEEEremainder to calculate the
remainder of two ints, for a simple pagination calculation. I normally
would just use %, but I'm wondering if anyone knows of a specific
reason to use Math.IEEEremainder for this type of calculation instead.
- 16
- [junit] Disabling OutputHi,
I have several test cases where I want the output to be displayed when I run
the TestRunner class as a stand-alone app. But, I also want to run a test
suite within an application of mine, but have the System output disabled...
is there a way in the JUnit API to disable the text that is displayed?
Thanks
|
| Author |
Message |
Big D

|
Posted: 2003-12-13 4:38:00 |
Top |
java-programmer, Finding memory leak in big app
I have an application that uses a lot of memory (up to a gig) and I'm
trying to track a memory leak. The problem is that all of the tools I've
found can't handle such large heap sizes. They generally just run out of
memory themselves.
The bulk of the memory is taken up by double[] and char[], but I need to
know who owns these arrays so I can see why there are so many of them. Is
there any tool that will let me track object ownership, or just give me a
useful heap dump that I can parse myself?
I'm running this on red hat advanced server 4 proc/8gig ram.
I can work with any jdk that's version 1.4.0_01 or higher.
Thanks
|
| |
|
| |
 |
Jose Rubio

|
Posted: 2003-12-13 12:04:00 |
Top |
java-programmer >> Finding memory leak in big app
Have you taken a look at JProbe? http://www.quest.com/jprobe/
Jose
"Big D" <email***@***.com> wrote in message
news:email***@***.com...
> I have an application that uses a lot of memory (up to a gig) and I'm
> trying to track a memory leak. The problem is that all of the tools I've
> found can't handle such large heap sizes. They generally just run out of
> memory themselves.
>
> The bulk of the memory is taken up by double[] and char[], but I need to
> know who owns these arrays so I can see why there are so many of them. Is
> there any tool that will let me track object ownership, or just give me a
> useful heap dump that I can parse myself?
>
> I'm running this on red hat advanced server 4 proc/8gig ram.
>
> I can work with any jdk that's version 1.4.0_01 or higher.
>
> Thanks
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Error Installing Jboss ServerHi,
I am trying to install Jboss application server on linux. When I ran sh
run.sh from Jboss Bin Directory, It gave me the following
messages/Errors.
JBoss Bootstrap Environment
JBOSS_HOME: /home/cabig/jboss-4.0.2
JAVA: /usr/java/j2sdk1.4.2_11/bin/java
JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh
CLASSPATH:
/home/cabig/jboss-4.0.2/bin/run.jar:/usr/java/j2sdk1.4.2_11/lib/tools.jar
=========================================================================
Failed to boot JBoss:
java.lang.ClassNotFoundException: org.jboss.system.server.ServerImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at
org.jboss.system.server.ServerLoader.createServer(ServerLoader.java:271)
at
org.jboss.system.server.ServerLoader.load(ServerLoader.java:253)
at org.jboss.Main.boot(Main.java:187)
at org.jboss.Main$1.run(Main.java:463)
at java.lang.Thread.run(Thread.java:534)
Kindly let me know what the error is ? How to solve this ?
Appreciate your Help,
Thanks
shan
- 2
- To getenv or not getenvI'm using 1.4.2 for some commecial development. I was just about to set
a property and pass it on the command line when I noticed that System.getenv is
not deprecated in 1.5.0. So is it bad form to use a deprecated 'getenv'
in 1.4.2 given its new lease of life in 1.5.0??
Being 'allowed' to use getenv would make certain parts of the program
more expressive.
Cheers,
Lordy
- 3
- [ANNOUNCE] DataDirect Technologies Releases DataDirect XQuery to Simplify XML and Relational Data Integration[ANNOUNCE] BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies
(http://www.datadirect.com), the software industry leader in
standards-based components for connecting applications to data and an
operating unit of Progress Software Corporation, today announced the
release of DataDirect XQuery(TM), the first embeddable component for
XQuery that is modeled after the XQuery API for Java(TM) (XQJ).
Developers can download a free trial of DataDirect XQuery today at:
http://www.datadirect.com/downloads/registration/xquery/index.ssp
"Internet developers typically spend much of their time creating and
restructuring XML, using data from many sources, generally including
relational data. This task is much too tedious in most environments.
Using DataDirect XQuery, which is based on the W3C's XML Query
(XQuery), simplifies the programming task significantly, solving the
same problems with much less code," said Jonathan Robie, Program
Manager for DataDirect XQuery and an editor of the W3C XQuery
specification. "Using DataDirect XQuery means that your applications
can run on any Java platform, accessing data from the major relational
databases, using any Web server or application server, or using no
server at all. And DataDirect XQuery performs quite well, even when
your query creates large XML results."
DataDirect XQuery supports all major relational databases, including
Oracle, Microsoft SQL Server 2000, IBM DB2, and Sybase, on any Java
platform, allowing developers to query XML, relational databases, or a
combination of the two. Query results can be used for XML-based data
exchange, XML-driven Web sites, and other applications that require or
leverage the power of XML. DataDirect XQuery provides IT professionals
with a highly productive, powerful, simple, and standards-based
approach to XML and relational data integration.
Simplifying XML and Relational Data Integration
DataDirect XQuery simplifies XML and relational data integration by
providing developers with an XQuery implementation that offers greater
productivity, performance and interoperability for building
standards-based data integration applications, and here's how:
?Productivity: Web services, Web sites, data integration, and
publishing are just a few examples of the many types of applications
that need data from many sources, including relational and XML. For the
first time, DataDirect XQuery enables developers to easily process both
XML and relational data using industry-standard XQuery. DataDirect
XQuery simplifies application development by reducing the amount of
code developers write and maintain to use XML and relational data
together. The result: reduced application complexity, shorter
development cycles and more powerful applications - all based on the
current W3C XQuery standard yet to be finalized.
?Performance: DataDirect XQuery optimizes and mediates query
performance when accessing relational data. DataDirect XQuery is
designed to move the minimum amount of data out of the database - for
example, XQuery code is converted to SQL statements which are executed
on the database server - thus providing the best performance possible.
?Interoperability: It's easy to embed DataDirect XQuery in
applications: it does not require any other product or application
server, it has no server of its own, it is not tied to a specific
vendor database or database version, and it is based on the current
version W3C XQuery and XQuery API for Java (XQJ) standards yet to be
finalized. Application developers can write one easy-to-maintain
application, regardless of the databases and versions they are using -
Oracle, DB2, Microsoft SQL Server, or Sybase. This approach results in
more extensible and interoperable applications which are insulated from
the frequent database updates and changes in the database vendor tools.
"In the past, our web-based XML Human Resources applications generated
and sent XML data using data stored in an Oracle database," said Mark
Zimmerman, VP of IT, at Gevity, a leading provider of employee
management solutions. "We found DataDirect XQuery to be fast, scalable,
and reliable. And because DataDirect XQuery allows us to leave the data
access code in the middle tier, and not tied to a specific database,
our application is insulated from any changes in the back end,
improving application interoperability. Overall, we're very pleased
with DataDirect XQuery."
"Most XQuery implementations either work only with XML files in memory,
or are bound to a particular database or application server - these are
serious restrictions if your organization or partners have different
databases, require scalability, or need to integrate with legacy data,"
said Jerry King, Vice President of the XML Products Group at DataDirect
Technologies. "DataDirect XQuery is the first and only product that
truly makes your XQuery just as portable as your XML - you can use it
on any Java platform, with any major relational database, and it
integrates seamlessly with your Java applications using an industry
standard query language and processing API. DataDirect XQuery is a
quantum leap forward in data integration technology, providing
developers with more power, performance and interoperability than ever
before, and developers can download and try it out today."
Availability
DataDirect XQuery is available today. For more information, please
contact Nancy Vodicka at 919-461-4326, or visit our Web site at
www.datadirect.com/xquery. Developers can also download the DataDirect
XQuery for a free 15-day trial at:
http://www.datadirect.com/downloads/registration/xquery/index.ssp
About DataDirect Technologies
DataDirect Technologies is focused on standards-based data
connectivity, enabling software developers to quickly develop and
deploy business applications across all major databases and platforms.
DataDirect Technologies offers the most comprehensive, proven line of
data connectivity components available anywhere. Developers worldwide
at more than 250 leading independent software vendors and thousands of
corporate IT departments rely on DataDirect?products to connect their
applications to an unparalleled range of data sources using
standards-based interfaces such as ODBC, JDBC and ADO.NET. Developers
also depend on DataDirect to radically simplify complex data
integration projects using XML products based on the emerging XQuery
and XQJ standards. DataDirect Technologies is an operating unit of
Progress Software Corporation, a US$300+ million global software
industry leader. Headquartered in Bedford, Mass., DataDirect
Technologies can be reached on the Web at www.datadirect.com or by
phone at +1-800-876-3101.
DataDirect and DataDirect XQuery are trademarks or registered
trademarks of DataDirect Technologies Corp. in the U.S. and other
countries. Java and all Java based marks are trademarks or registered
trademarks of Sun Microsystems, Inc. in the U.S. and in other
countries. Any other trademarks contained herein are the property of
their respective owner
Contact:
DataDirect Technologies
Nancy Vodicka, 919-461-4326
email***@***.com
- 4
- javadoc -linkoffline helpHowdy All!
I am trying to issue a javadoc command with the following linkoffline
option:
-linkoffline http://java.sun.com/j2se/1.4.1/docs/api
C:/java/j2sdk1.4.1_01/docs/api
Both the file path and the url are valid, but I find the generated
links are of the form:
file:///E:/phd/semiInterface/doc/http://java.sun.com/j2se/1.4.1/docs/api/java/lang/reflect/Method.html
Can anyone advise how I can make this work?
Thanks for any help!
Rob
:)
- 5
- Referencing enclosing class from inner classHi everyone,
I'm trying to understand inner classes, but came across the following
problem. If I define two types (one is an inner class), and each type
has a method with the same name, is there a way that I can call the
enclosing instance's method from within an instance of the inner class?
I'm guessing that (as per the example pasted below) the getValue()
methods aren't overloaded or overridden because the two classes don't
participate in super-class/sub-class OO relationship. I'd be grateful
for any insight.
Thanks,
Jonathan
public class EnclosingClass {
private int _value = 100;
private class InnerClass
{
public int getValue()
{
return _value * 2;
}
public void println()
{
System.out.println(getValue()); //<-- inner
System.out.println(getText()); //<-- enclosing
}
}
public int getValue()
{
return _value;
}
public String getText()
{
return "hello!";
}
public static void main(String[] args)
{
// create an instance of both classes and call the println method of
the inner class
new EnclosingClass().new InnerClass().println();
}
}
- 6
- redirect problemHi everyone,
I have a problem, I am connectin to a lotus notes database to download
a file (using URLConnection)
...gbp.nsf/agWebLAL?OpenAgent&UNID=A9D19EDE65447DF5C1256F2000465E87
The thing is lotus notes doesn't give the filename, it redirects me to
something first, then downloads the filename..
Does anyone know of a way on how I can get the final url (the place
where I am being redirected), filename and mimetype
Thanks!
- 7
- Zip file directory creation problemWhile extracting zip files I've come accross a strange error. I use the
code below to check if the directory exists and create it if necessary. The
problem is that it works for most zip files but I have a few zip files that
do not properly extract using this code.
What seems to be happening is the variable e is referencing a ZipEntry that
is a directory but it is not being recognized as a directory in the code.
So I get the following debug info printed:
Extracting AuthorizedDBProject.zip to: D:\zips\AuthorizedDBProject
D:\zips\AuthorizedDBProject\AuthorizedDBProject\AuthorizedDBProject.jpx (The
system cannot find the path specified)
The ZipEntry is: AuthorizedDBProject/AuthorizedDBProject.jpx but
AuthorizedDBProject is not being created before extracting
AuthorizedDBProject.jpx.
Any pointers, suggestions will be appreciated.
Code:
________________
//location - a base directory to extract all the files
try {
in = new BufferedInputStream ( new FileInputStream ( _file ) );
zin = new ZipInputStream ( in );
ZipEntry e;
while ( ( e = zin.getNextEntry () ) != null ) {
File entryPath = new File ( location.toString () + File.separator +
e.getName ());
if ( e.isDirectory () ) {
if ( !entryPath.exists()) {
if(entryPath.mkdir()){
System.out.println (entryPath + " does not exist,
creating..." );
}else{
System.out.println (entryPath + " does not exist and there was
a problem creating it!!!" );
}
}
continue;
}
System.out.println(e.getName() + " is NOT a directory");
System.out.println ( "Extracting: " + e.getName() + " to " +
entryPath );
out = new FileOutputStream ( entryPath );
byte[] b = new byte[ 512 ];
int len = 0;
while ( ( len = zin.read ( b ) ) != -1 ) {
out.write ( b , 0 , len );
}
out.close ();
}
extracted = true;
} catch ( FileNotFoundException ex ) {
System.out.println ( ex.getMessage () );
} catch ( IOException io ) {
System.out.println ( io.getMessage () );
} finally {
if ( out != null ) {
try {
out.close ();
} catch ( IOException ex1 ) {
System.out.println ( ex1.getMessage () );
}
}
...
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
- 8
- casting from int to byte problemit looks like I have a strange problem.
I have a small class with several byte 'properties'
and I put a values into them from int values casting them to byte..
but for some values (like 143), casting result (with (byte)) is -113???
it's the same with 147 casted to -109...
and it should be a byte value (means, there should be no negative values)..
value is lowered for 256
why?
did I missed something?
- 9
- coordinating eventsHi there,
I'm having difficulty trying to coordinate the sequence of events for
populating a JTree with data received from a server app. I'm so-o-o-o close
and yet no banana! It's proving to be very tricky processing. I could use
some help in trying to make this work properly. Perhaps you may understand
better as to why my efforts are being thwarted by the either the JTree
object or its DefaultTreeModel?
Here's the setup:
1) I have a server app that, when requested from the client app, will
provide a child count on any given directory node on the server. Also, it
will serve up the names of each child node for any given node upon request.
2) The client app contains a JTree object that I'm trying to initially
populate with the root node. Subsequently, the plan is to dynamically
populate any directory node in the JTree whenever the treeWillExpand( ... )
event is triggered as the user tries to expand on a node.
3) Throughout my code I have a number of System.out.println( ... )
statements so that I can see what sequence of events are taking place as the
client app makes requests to the server and receives replies back from the
server. Also, some println(...) statements in some key methods which you'll
see.
4) The sequence of events is supposed to go like so:
i) root node is created
ii) as the root node is passed as a parameter when creating the JTree
object
the getChildCount( ) method of the root node [type DefaultTreeNode
extends DefaultMutableTreeNode ]
is called.
public int getChildCount()
{
if (!hasChildren)
{
defineChildNodes();
}
return(super.getChildCount());
}
iii) Since the root node initially has no children, getChildCount( )
then calls the method
defineChildNodes( ).
protected void defineChildNodes()
{
hasChildren = true;
ref.requestChildCountFromServer(this);
}
As you can see, defineChildNodes( ) simply sets the flag
hasChildren to true then
calls a method requestChildCountFromServer(this) which exists in a
class called Response
referred here by the variable "ref". Also in the Response class
there exists the method
populateTree( ) which initially created the root node and JTree
objects:
protected void populateTree(String NodeName)
{
//System.out.println("Entering populatTree() method");
//This could take a while, so change the cursor icon
//ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try
{
String separator = "";
if(ref.serverOS.equals("Windows"))
separator = "\\";
else
separator = "/";
rootNode = new DefaultTreeNode(NodeName, true, separator);
expandingNode = rootNode;
String rootPath = getLeadingPath(ref.rootPath);
rootNode.setLeadingPath(rootPath);
rootNode.setResponseReference(this);
jTree1 = new JTree(rootNode);
jTree1.setRootVisible(true);
jTree1.setShowsRootHandles(true);
jTree1.collapseRow(0);
MouseListener popupListener = new PopupListener(ref);
jTree1.addMouseListener(popupListener);
//Listen to our own expand/collapse events to keep the labels in
sync
jTree1.addTreeWillExpandListener(this);
}
catch(Exception e){System.out.println("Exception in populateTree()
method"); e.printStackTrace();return;}
....
....
}
iv) The requestChildCountFromServer( ) method then makes a request to
the server app for
the child count for the root node.
v) I have a separate thread running that listens for all responses
from the server
called ResponseListener. In its run( ) method I have the
following code:
else if(connected == ref.ref.SENDING_CHILDCOUNT)
{
System.out.println("Received message: ReceivingChildCount");
ref.expandingNode.numChildren = input.readInt();
//expandingNode.setReceivedChildCount(true);
ref.ref.imageLabel.setIcon(ref.ref.blank);
ref.ref.textLabel.setText("");
}
When the root node was originally created I set a reference to it
using a variable
named expandingNode. Here you can see that the root node's
instance variable
named numChildren is set to a value read in by the DataInputStream
object
named input.
vi) The requestChildCountFromServer( ) method in turn calls another
method in the
Response class named RequestChildrenFromServer(String path).
RequestChildrenFromServer(String path) method requests from the
server the names
of all the child nodes for the root node.
vii) ResponseListener then receives a response from the server:
else if(connected == ref.ref.SENDING_TREE_DATA)
{
System.out.println("Received message: SendingTreeData");
ref.expandingNode.TreeDataIncoming = true;
ref.expandingNode.ReceiveChildrenFromServer(input);
ref.ref.imageLabel.setIcon(ref.ref.blank);
ref.ref.textLabel.setText("");
}
Here you can see that the root nodes method named
ReceiveChildrenFromServer(input) is then called
while passing it a reference to the DataInputStream so that the
method can
read in the names of the child nodes as they come in over the
wire.
viii) The root node's method ReceiveChildrenFromServer(input) then
begins receiving the
names of each child node, creates a new DefaultTreeNode object
for each child node
and adds it to the root node, seen below:
protected void ReceiveChildrenFromServer(DataInputStream input)
{
System.out.println("Entering ReceiveChildrenFromServer()");
DefaultTreeNode child = null;
String name = "";
try
{
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
//System.out.println("numChildren = " + numChildren);
int nodeType = 0;//default
//iterate through each of the children as they come in
//from the server.
for(int i = 0; i < numChildren; i++)
{
name = input.readUTF(); //get the name
System.out.println("child node: " + name);
child = new DefaultTreeNode(name); //create a new
child node
//determine if this node is a directory
//or a file. Empty directories are denoted
//as having (nodeType == -1)
nodeType = input.readInt();
//System.out.println("node type: " + nodeType);
if(nodeType == 0)
{
//Since a file is a leaf node
//we won't be needing to continue
//reading in nodes for it.
child.setResponseReference(ref);
child.setAllowsChildren(false);
child.setHasChildren(false);
child.setLeadingPath(getWholeServerPath());
if(ref.ref.serverOS.equals("Windows"))
child.setSeparator("\\");
else
child.setSeparator("/");
}
else if(nodeType == -1)
{
child.setResponseReference(ref);
child.setAllowsChildren(true); //It's an empty
directory
child.setHasChildren(false);
child.setLeadingPath(getWholeServerPath());
if(ref.ref.serverOS.equals("Windows"))
child.setSeparator("\\");
else
child.setSeparator("/");
}
else
{
child.setResponseReference(ref);
child.setAllowsChildren(true); //It's a directory
with child nodes
child.setHasChildren(true);
child.setLeadingPath(getWholeServerPath());
if(ref.ref.serverOS.equals("Windows"))
child.setSeparator("\\");
else
child.setSeparator("/");
}
this.insert(child,i);
}//end for loop
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}//end try
catch(IOException ioe){ioe.printStackTrace();}
catch(NullPointerException npe){npe.printStackTrace();}
}//end method
IT IS HERE THAT I RUN INTO PROBLEMS!!!!
All the code you see compiles fine. What I found annoying is that, at
run-time, the sequence of events were as I depict them here until I start
reading in the names of the childnodes with the
ReceiveChildrenFromServer(...) method. While it is going through its for
loop, mysteriously the method getChildCount( ) is called again, which in
turn calls defineChildNodes( ), which in turn calls
requestChildCountFromServer(...), which interrupts the processing of the for
loop in ReceiveChildrenFromServer(...) . Here is the read out from the
console to prove it:
***************************************
Entering requestChildCountFromServer
waiting for response...
checking...
Received message: ReceivingChildCount
checking...
got ChildCount: 26 <<<Root node has 26 child nodes
Entering RequestChildrenFromServer()
path is: C:\JavaProjects
Finished calling server for children
Received message: SendingTreeData
Entering ReceiveChildrenFromServer()
checking for tree data ...
child node: AssignmentServer <<<<ReceiveChildrenFromServer(...)
method begins reading in names
child node: AssignmentSubmitter
child node: Borland
child node: ClientServerJTreeProject
child node: DBJavaBean
child node: DirAdmin.bak
Entering requestChildCountFromServer <<<This method is called by
defineChildNodes( ) which was
called by getChildCount( )
waiting for response...
checking...
checking...
Node Expanding.
checking...
checking...
got ChildCount: 0 <<< Don't know
why this is reading zero. It should be 26
child node: DirectoryAdministratorProject <<<For loop from
ReceiveChildrenFromServer(...) method
resumes reading in names
child node: EZSmtp
child node: Icon Editor
child node: images
child node: IniFileProject
child node: J2exe
child node: JCalculator
child node: JGridProject
child node: JSlideShow
child node: MSSTextEditorProject
child node: MySQL_JDBC
child node: PersonalNetSearchProject
child node: Print_Preview
child node: PropertiesFileAccessExample
child node: Sample_EBusiness
child node: SharewareProject
child node: SystemTreeProject
child node: TestProgram
child node: Thread_Pooling
child node: ZeroG
Received message: ReceivingChildCount
*****************************************
Ultimately, I wind up with a root node being displayed in the JTree that
only has maybe five or six child nodes displayed when there should be 26
child nodes.
For further clarity here are the methods requestChildCountFromServer(...)
and RequestChildrenFromServer(...):
public void requestChildCountFromServer(DefaultTreeNode node)
{
System.out.println("Entering requestChildCountFromServer");
String name = "";
try
{
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
output.writeInt(ref.PATH);
output.flush();
output.writeUTF(node.getWholeServerPath());
output.flush();
output.writeInt(ref.REQUEST_CHILD_COUNT);
output.flush();
System.out.println("waiting for response...");
timer1 = new ChildCountTimer(node);
timer1.start();
timer1.join();
System.out.println("got ChildCount: " + node.numChildren);
if(node.numChildren > 0)
{
//NodeExpanding = false; //reset
RequestChildrenFromServer(node.getWholeServerPath());
//Set up TreeDataTimer so that we know we have a
//response from the server.
timer2 = new TreeDataTimer(node);
timer2.start();
timer2.join();
}
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
catch(InterruptedException ie){}
catch(IOException ioe){ioe.printStackTrace();}
catch(NullPointerException npe){npe.printStackTrace();}
}
protected void RequestChildrenFromServer(String path)
{
System.out.println("Entering RequestChildrenFromServer()");
//Request Children from server
try
{
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
output.writeInt(ref.PATH);
output.flush();
System.out.println("path is: " + path);
output.writeUTF(path);
output.flush();
//Sending REQUEST_CHILDREN should cause a response
//from the server: SENDING_TREE_DATA
output.writeInt(ref.REQUEST_CHILDREN);
output.flush();
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
catch(IOException ioe){ioe.printStackTrace();}
System.out.println("Finished calling server for children");
}
I realize this post is rather lengthy, however, I didn't know how else to
explain my dilemma with this project. If you need more information, just
ask.
Please advise,
Alan
- 10
- JSTL & Source Code
JavaScript and CSS programmers have for years, been looking for the
"holy grail", i.e., the ability to hide source code.
Take at look at www.dice.com, do a job search then view source.....
nothing there except JSTL noatation per below:
-------------------------- start -------------------------------------
<!--
* $RCSfile: abbreviated.jsp,v $
* $Author: duket $
* $Date: 2005/06/15 13:36:17 $
-->
<!-- START JSTL_INITIALIZATION -->
<!-- FINISH JSTL_INITIALIZATION -->
------------------------ end -----------------------------------------
Was not aware that a fringe benefit of JSTL was the ability to hide
html source code. How secure is this? Can someone hack it to get the
html source?
I'm one of those Java/JavaScript/CSS programmers that has created
graphics with CSS on Web pages and would like to keep the code
private. I have found a crude way but I like the above better.
Thanks
- 11
- how to add double key listenerhi,
i want to catch the key event when SHIFT+TAB are pressed simultaneously
to shift focus to the previous focusable component. the key event is
caught on a JComboBox. if somebody knows the code to do so plz post it.
thanx in advance.
- 12
- slow axis performance vs JAX-RPC?hi..
i've been mainly using axis framework for webservices becouse it's
simpler, how ever i was told it's the slowers implementions of them
all, are there any non-commercial frameworks ? simple to use? (and
production ready not beta).
- 13
- How to Fail at Software DevelopmentHello,
The book "How to Fail at Software Develoopment" is about all the
strange and funny things people do in the name of developing software.
I worked in software development for over 20 years and found silly
things that were being done in the name of software development were
being repeated again and again. As a matter of fact, most things that
cause software projects to fail are forever being repeated. And you
can spot the symptoms if you know what to look for.
Most people running software projects don't have much software
experience, so their inventions are usually not new. They rediscover
the same mistakes over and over again. It turned out to be a book of
very funny scenarios--some I lived through, and some were lived
through by others.
Those who don't know the history of software failure are doomed to
repeat it. You can find the book on Amazon or wherever.
Arthur Griffith
"How to Fail at Software Development"
http://www.anchorpointbooks.com
- 14
- Certification is a must in MNCs,the comming Future.Certification is a mark of excellence that you carry with you
everywhere you go.
Integer is a authorised testing center for .Net, Java, J2EE, Testing
etc..... for the clients like Microsoft, Sun, IBM, Exin, Lotus and
many more...
We offer certifications on:
Microsoft
Sun Microsystem
Adobe Systems
Cognos
Comptia
CWNP
EMC2
Enterasys Networks
Exin
Help Desk Institute
Huawei
IBM
Juniper Networks
and many more...
For more details Visit: http://www.integerblr.com
For Registration: http://www.integerblr.com/registration/thomsonprometric.asp
Regards
Ramesh
- 15
- difference between endorsed and lib folders?hi..
can somone please explain to me what is the difference between the
endorsed and lib folders in common folder in tomcat? i tried reading
the documentation but i couldn't figure it out.
|
|
|