comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Multi-threaded access to a file on disk - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fc88e19bbf867357
* FYI: VTD-XML, the latest XML processing model - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ef0e44eb1dc55921
* rooms synchronization code - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/525a7e0ea2658568
* Eclipse, VE, and the MenuBar bean - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/90ef8c61f49f3a3b
* difference between java built in classes and ADT - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4258a065563ae3ae
* Java client connected to non-Java server problems - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9dcb548fa77a4b46
* runtime.getRuntim().exec(somecmd) problem with linux - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a3f83ceedc3184b0
* jni and garbage collection??? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc6f35a45fad50c5
* Java newbie: RMI woes on Linux - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/96a016c1721dc337
* JExplorer 1.0 and JNIWrapper 2.7 Released - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9b2de43c465db295
* Http to port different than 80? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/83c9369f58ffcd00
* test javamail file - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/49e12ffa7e150d55
* who uses algorithms learned in cs studies? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf
* currentThread, getContextClassLoader and get resource - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e4c0429549cea577
* Sockets and TCP Data Segments - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af31f913a137c3ea
* returning a subclass through an interface - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b62cd9cf6edaa6c4
* writing clobs using oracle thin driver - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f9dc55b5f77991a1
* Calculate Resource Usage - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9e861e05dddbabf5
  
==========================================================================
TOPIC: Multi-threaded access to a file on disk
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fc88e19bbf867357
==========================================================================

== 1 of 2 ==
Date:   Wed,   Nov 10 2004 4:46 pm
From: "Ann" <[EMAIL PROTECTED]> 


"Chris" <anon> wrote in message news:[EMAIL PROTECTED]
>
> "Steve W. Jackson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > In article <[EMAIL PROTECTED]>, "Chris" <anon> wrote:
> >
> > >:We have a web app that needs to access a very large file on disk. This
> app
> > >:will have a large number of simultaneous users. The file is too big to
> fit
> > >:entirely in memory.
> > >:
> > >:I'd really like for different threads to be able to read different
parts
> of
> > >:the file without synchronizing access. Unfortunately, RandomAccessFile
> isn't
> > >:multithreaded, because you have to call seek() and then read().
> > >:

> The difficulty is the you need to make two calls to RandomAccessFile to
read
> anything: seek(), and then read(). If you don't synchronize, then one
thread
> could seek, the next thread could seek, then thread 1 could read, and then
> thread 2 could read. Each thread would get the wrong data.
>
---
This does not sound so expensive to me -- subtract two ints
from the source file randomaccessfile.java
---
 seek(newpos);

 /* return the actual number of bytes skipped */
 return (int) (newpos - pos);
    }
---





== 2 of 2 ==
Date:   Wed,   Nov 10 2004 4:57 pm
From: "Ann" <[EMAIL PROTECTED]> 


"Ann" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Chris" <anon> wrote in message news:[EMAIL PROTECTED]
> >
> > "Steve W. Jackson" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > In article <[EMAIL PROTECTED]>, "Chris" <anon> wrote:
> > >
> > > >:We have a web app that needs to access a very large file on disk.
This
> > app
> > > >:will have a large number of simultaneous users. The file is too big
to
> > fit
> > > >:entirely in memory.
> > > >:
> > > >:I'd really like for different threads to be able to read different
> parts
> > of
> > > >:the file without synchronizing access. Unfortunately,
RandomAccessFile
> > isn't
> > > >:multithreaded, because you have to call seek() and then read().
> > > >:
>
> > The difficulty is the you need to make two calls to RandomAccessFile to
> read
> > anything: seek(), and then read(). If you don't synchronize, then one
> thread
> > could seek, the next thread could seek, then thread 1 could read, and
then
> > thread 2 could read. Each thread would get the wrong data.
> >
> ---
> This does not sound so expensive to me -- subtract two ints
> from the source file randomaccessfile.java
> ---
>  seek(newpos);
>
>  /* return the actual number of bytes skipped */
>  return (int) (newpos - pos);
>     }
> ---


OOPS! sorry, I goofed, it calls a native method to do the work.






==========================================================================
TOPIC: FYI: VTD-XML, the latest XML processing model
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ef0e44eb1dc55921
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 5:25 pm
From: "Jimmy zhang" <[EMAIL PROTECTED]> 

Better, Faster XML Processing with VTD-XML

http://www.devx.com/xml/Door/7050






==========================================================================
TOPIC: rooms synchronization code
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/525a7e0ea2658568
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 5:30 pm
From: The Abrasive Sponge <[EMAIL PROTECTED]> 

tri wrote:
> Hi,
> 
> I am looking for java code which implements rooms synchronization for
> a Queue for a class project.  I'd like to reuse so I can save time on
> implementing it.
> 
> Does anyone know where I can get this?
> 
> This paper has the ideas I am talking about but leaves out some
> things.
> 
> http://www.cs.brown.edu/courses/cs176/room.pdf
> 
> Thank You,
> 
> Tri


I'd say do it from scratch and have fun!  That's what an education is 
for. :)

Anyways, so Brown CS Dept is java based?





==========================================================================
TOPIC: Eclipse, VE, and the MenuBar bean
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/90ef8c61f49f3a3b
==========================================================================

== 1 of 2 ==
Date:   Wed,   Nov 10 2004 7:57 pm
From: [EMAIL PROTECTED] (Ted Holden) 



Anybody have any idea why the swing Jmenubar item doesn't seem to work
(windows 2000)  in the Eclipse visual editor?






== 2 of 2 ==
Date:   Wed,   Nov 10 2004 10:52 pm
From: [EMAIL PROTECTED] (Ted Holden) 

I was looking at that one the wrong way, sorry.  It works.:

>Anybody have any idea why the swing Jmenubar item doesn't seem to work
>(windows 2000)  in the Eclipse visual editor?
>
>
>





==========================================================================
TOPIC: difference between java built in classes and ADT
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4258a065563ae3ae
==========================================================================

== 1 of 3 ==
Date:   Wed,   Nov 10 2004 8:10 pm
From: Kenneth <[EMAIL PROTECTED]> 

Hal Rosser wrote:
> Because we can.
> 
> "Kenneth" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
>>What is the difference between java built in classes such as java.util.*
>>and ADT implementations.   Why would you ever need to implement
>>something that is already written for you?
>>
>>k
> 
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004
> 
> 
So they're just options?



== 2 of 3 ==
Date:   Thurs,   Nov 11 2004 1:07 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Kenneth wrote:

> What is the difference between java built in classes such as java.util.* 
> and ADT implementations.   Why would you ever need to implement 
> something that is already written for you?

Other implementations might be more efficient, have more features, or be 
superior
in some other way.



== 3 of 3 ==
Date:   Thurs,   Nov 11 2004 1:11 am
From: "Tony Morris" <[EMAIL PROTECTED]> 


"Kenneth" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> What is the difference between java built in classes such as java.util.*
> and ADT implementations.   Why would you ever need to implement
> something that is already written for you?
>
> k

The core collections classes are implementations of ADTs.
Some argue that they are not as good as they should be - so they rewrite
them.
Others rewrite them as a learning exercise, such as a student at a tertiary
institution.

-- 
Tony Morris
http://xdweb.net/~dibblego/






==========================================================================
TOPIC: Java client connected to non-Java server problems
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9dcb548fa77a4b46
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 8:32 pm
From: Esmond Pitt <[EMAIL PROTECTED]> 

Unless the VB server knows about Unicode it would make more sense to use 
Input/OutputStreams rather than Readers & Writers.





==========================================================================
TOPIC: runtime.getRuntim().exec(somecmd) problem with linux
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a3f83ceedc3184b0
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 8:59 pm
From: Andrew Thompson <[EMAIL PROTECTED]> 

> On Tue, 09 Nov 2004 16:58:26 GMT, Andrew Thompson wrote:

>> On 9 Nov 2004 08:46:24 -0800, wex wrote:
>> 
>>> The code i use to start it is:
>> 
>> Sorry wex, not interested.  Not until you show some sign of 
>> paying close attention to advice.  

** wex - Via email. **
>I recently posted a thread titled "runtime.getRuntim().exec(somecmd) 
> problem with linux" in the java programmer forum.  Andrew - I didn't 
> want to post this in the java forum cause it has no place there.  

Netiquette and asking smart questions has everything to do 
with the forum, I'll discuss it here.

> But you need to be told - 

Join the queu.

>..don't be a dick.  If you don't want to help people ..

What makes you say that?  Because I criticised *you*?

> ..openly then please don't help, but don't go downtalking people 
> cause no matter how impressed you are with yourself, and yes it 
> is pretty obvious,  you are you aren't the king of java or the king 
> of the forums.  Cmon man don't be an ass just cause you have some knowledge.  
>  

Don't be an ass just because you get criticised for asking a 
clueless, time-wasting question.

I have no intention of allowing this community to become infested
with waves of noobs who ask vague questions, tell us code that is
'something like' the actual code they are using, and cannot follow 
simple instructions.

My way of doing things works both for me and the many, many people who 
*do* appreciate the help.  I have no intention of changing my posting
technique.  If you are having a problem with that, that is something 
you need to take care of at your end.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==========================================================================
TOPIC: jni and garbage collection???
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc6f35a45fad50c5
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 10:38 pm
From: Gordon Beaton <[EMAIL PROTECTED]> 

On Wed, 10 Nov 2004 13:45:47 -0800, John McClain wrote:
> The problem I am having is this:
> When I run the webapp and call powerbuilder functions through JNI
> and PowerBuilder Native Interface code (a c++ .dll), it works for a
> while, but then hangs. The pattern I have found to be consistent is
> that it hangs when I wait a little while before making my next
> function call (via a jsp calling a servlet calling JNI code). And
> here is the question - Why is my native codes' state being changed
> or removed, and what would do that? Yes, I am cleaning up after
> myself in the Native code
> 
> Does Garbage collection affect the loaded JNI code?

No, but that would depend how you define "affect" I suppose. Any Java
objects you create or access from your native code are subject to the
same reachability rules as objects created and accessed from Java
code. Anything you allocate with traditional native mechanisms (e.g.
malloc()) is immune to garbage collection.

One small difference is that the garbage collector doesn't know about
objects you no longer hold references to until you leave the current
context, i.e. when you return from the native method or call
PopLocalFrame().

> Is there some way to test / profile this ?
> 
> A general question - Is the native code loaded into the JVM address
> space or does it reside outside of the JVM?

Your code does exist in the same address space as the JVM, but the
garbage collector is not interested in anything but Java objects. 

>From your description of the problem, I'd say there is an error in
your native code. Look for stray pointers, uninitialized variables,
buffer overflows, or general pointer misuse, etc. Whenever native code
is part of the equation, hangs, crashes and other kinds of erratic
behaviour are rarely, if ever, caused by anything else.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e




==========================================================================
TOPIC: Java newbie: RMI woes on Linux
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/96a016c1721dc337
==========================================================================

== 1 of 2 ==
Date:   Wed,   Nov 10 2004 10:57 pm
From: Gordon Beaton <[EMAIL PROTECTED]> 

On 10 Nov 2004 20:22:02 -0800, Andy wrote:
> I don't have a firewall. But I am wondering if rmiregistry is actually
> listening.

That's easy enough to check. 

Use "netstat -l" to see all listening sockets. If you have sufficient
priviliges, "netstat -lp" or "lsof -i" will also show you which
process owns each socket.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e



== 2 of 2 ==
Date:   Thurs,   Nov 11 2004 1:37 am
From: Nigel Wade <[EMAIL PROTECTED]> 

Andy wrote:

> Nigel Wade <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
>> Andy wrote:
>> 
>> > I am a java newbie and was trying my hand at RMI. I have an interface,
>> > a server implementing that interface and a utility class with "public
>> > static void main" to register the server class. I also have a client,
>> > which calls the server using Naming.lookup(...) and calls methods on
>> > it.
>> > Of course, before binding the server I start the rmiregistry on my
>> > local machine, without specifying the port and by specifying the
>> > following option:
>> > 
>> >  -J-Djava.security.policy=E:\mydir\...\rmiserver.policy
>> > 
>> > Later, when I try to register the server, the registration fails with
>> > an access denied error on localhost:1099.
>> > 
>> > The policy file I am using is simple:
>> > 
>> > grant{
>> >  permission java.security.AllPermissions;
>> > };
>> > 
>> > Any pointers would be greatly appreciated.
>> > 
>> > IMP: I am facing this problem on my Linux box. Whereas on my Windows,
>> > a similar program runs without cribs. (No advocacy meant for Windows.)
>> > 
>> > Cheers,
>> > Andy
>> 
>> E:\mydir\...\rmiserver.policy
>> is a very strange Linux pathname. 
>> 
> 
> LOL ... admittedly so.
> 
>> Try without any security policy. I find this works ok on Linux for
>> testing/development purposes.
>> 
>> Do you have a firewall on the Linux box? Is it enabled, and does it allow
>> connections to port 127.0.0.1:1099? Is the rmiregistry actually listening
>> on 1099?
> 
> I don't have a firewall. But I am wondering if rmiregistry is actually
> listening. How would you start the rmiregistry on Linux. From DOS I
> did this:
> 
> start rmiregistry -J-Djava.security.policy=E:\mydir\...\rmiserver.policy
> 
> 
> From Linux, I did this:
> rmiregistry -J-Djava.security.policy=/root/.../rmiserver.policy &
> 
> I have j2sdk1.4.2 and gcj both installed. Could that cause any
> problems. I have rmiregistry and all these binaries in two different
> places (due to the different installations). I guess the ones being
> called are from j2sdk1.4.2.

Yes, they can cause problems. In fact your mentioning this reminds me I had
a very similar problem on this system with gcj, java, RMI and rmiregistry.
The gcj package has an rmiregistry binary which appears in the path so is
most likely getting started by the simple rmiregistry command. Make sure
you run the Sun JDK rmiregistry with an explicit path, or, better still,
completly remove gcj.

-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK 
E-mail :    [EMAIL PROTECTED] 
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555




==========================================================================
TOPIC: JExplorer 1.0 and JNIWrapper 2.7 Released
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9b2de43c465db295
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 12:06 am
From: [EMAIL PROTECTED] (Eugene Toporov) 


We announce the release of first version of JExplorer
(http://www.jniwrapper.com/jexplorer.jsp). This release addresses many
important issues that we have received during the Beta period of the
product.

We would like to thank everyone who sent us the feedback for JExplorer
Betas and patiently waited for the release.

Also, along with JExplorer we issue the important release of
JNIWrapper 2.7, in which we have fixed several major problems and
added some features.

Check the What's New page (http://www.jniwrapper.com/whatsnew.jsp) to
see the detailed list of changes in both products.

What's coming next
==================
JNIWrapper for Mac OS X: The product is on the final testing phase and
shortly we will introduce the Beta version for your evaluation.

JNIWrapper 3.0: In JNIWrapper 3.0 we're planing to introduce many
useful features, such as a Java code generation by *.H file, Java COM
server registration and many others.

What's New in JExplorer 1.0
---------------------------
1. Changes since Beta 3:
   - Listening the browser navigation events, such as downloadBegin,
downloadCompleted, progressChanged, etc., using a
NavigationEventListener listener(s);
   - Listening the browser status events, such as statusTextChanged,
titleChanged, etc., using a StatusEventListener listener(s);
   - Handling the browser events, such as beforeNavigate, newWindow,
windowClosing, etc., using a WebBrowserEventsHandler handler;
   - Getting and setting HTML content with the WebBrowser.getContent
and WebBrowser.setContent methods accordingly;
   - Executing a Java script, using the WebBrowser.executeScript
method and handling script errors, using a ScriptErrorListener
listener;
   - Creating the context-dependent Java menus in the Browser
component, using the ContextMenuProvider;
   - Disabling browser error dialogs, using the WebBrowser.setSilent
method;
   - The DomRobot was also greatly improved: added methods for
simulating user actions, such as click and mouseOver; added ability to
produce various DOM events; added various methods for decoration
elements;
   - Greatly improved the implementation of the WebBrowser.waitReady
method;
   - Improved speed of DOM wrappers.
2. Fixes: a number of fixes in multiple classes were made improving
stability of the Browser component and DOM wrappers.

What's New in JNIWrapper 2.7 for Windows
----------------------------------------
1. Fixes:
   - Fixed the problem with passing of some int parameters to the
native function calls.
   - Fixed the several problems in the Variant class; now it correctly
handles the Pointer parameters and correctly stores parameters of
VarType.VT_BYREF type.
   - Fixed the problem in the OleMessageLoop class, when it reported
sometimes the "Failed to post thread message" message.
   - Codegen: fixed code generation problem for the methods, which
returns Variant result in wrappers for dispinterfaces.
   - WinPack: fixed the problem with initialization in the StartupInfo
class.
2. Changes since version 2.6:
   - Changed the invokeAndWait and invokeMethod methods of the
OleMessageLoop class. Now these methods may throw InterruptedException
or InvocationTargetException exception (when it occurs), like it does
the SwingUtilities.invokeAndWait method.
   - Codegen: added the ability to generate property getters/setters
for dispinterface properties.
   - WinPack: added the new shell folder customization feature for
setting/getting a folder icon.

JNIWrapper Team
http://www.jniwrapper.com





==========================================================================
TOPIC: Http to port different than 80?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/83c9369f58ffcd00
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 12:33 am
From: "Andy" <[EMAIL PROTECTED]> 


> 1. Use menu Tools/Internet Options and navigate to the Advanced tab in the
> resulting dialog box
> 2. In the HTTP 1.1 settings area make sure both http 1.1 checkboxes are
> unchecked
> 3. Hit OK to accept the changes
> 4. Try to use IE to navigate the URL you provided. If this fails then the
> server doesn't accept HTTP 1.0
> 5. If this works then start again and ensure the http 1.1 checkboxes are
> checked and try again
> 6. If this works then your server accepts http 1.1 & http 1.0

I've tried this, and both protocols work.

> If both HTTP 1.0 & 1.1 work then you could try using the Jakarta
HttpClient
> library to see if it's a 'bug' in the Java library ?

I've tried this too, but I don't really understand how to post my query. How
do I post it to the server?







==========================================================================
TOPIC: test javamail file
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/49e12ffa7e150d55
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 12:50 am
From: "yihan" <[EMAIL PROTECTED]> 

Hello,
I added mail.jar and activation.jar into CLASSPATH, and compile msgsend.java 
successfully. But
 when I input
[prompt] java msgsend -o [EMAIL PROTECTED] -M SMTP.Server [EMAIL PROTECTED]
under dos. SMTP.Server is replaced by 130.232.80.15 (My mail server IP). It 
comes error:
Execption in thread "main" java.lang.NoClassDefFoundError: 
javax/mail/Message

Can anybody tell me how to solve it? Thank you.

Zhao 






==========================================================================
TOPIC: who uses algorithms learned in cs studies?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 1:27 am
From: Thomas Weidenfeller <[EMAIL PROTECTED]> 

bebop o'saurus wrote:
> for people who read my first post and jumped to the conclusion that i was 
> some wide-eyed, naive cs student seeking sagely advise on how to deal with 
> an algorithm class, you have guessed wrong. and if you think i am whining 
> about having to take a "useless algorithm class", you have guessed wrong. 
> i'm not asking for advice and i'm not a student.

Oh sure. And since you don't feel the need to tell us who or what you 
are, we are free to come up with our own conclusions. You seem to have a 
problem with that. Well, your problem. If you don't consider us worthy 
to some background information, we make up our own. You definitively are 
one of the people who seek an opinion but can't stand any response which 
is not in line with their expectation. Not the first time, as a quick 
search on Google reveals.

/Thomas




==========================================================================
TOPIC: currentThread, getContextClassLoader and get resource
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e4c0429549cea577
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 1:17 am
From: Oscar kind <[EMAIL PROTECTED]> 

Gleb <[EMAIL PROTECTED]> wrote:
> When I run my app application compilied in class-files everything is
> allright, but when I put it in jar-file url becomes null. Jar-file
> contains my classes and all third-party classes plus config.xml in the
> root of jar-file. The most strange thing is that when I run
> URL url = 
> Thread.currentThread().getContextClassLoader().getResource("config.xml");
> from the mthod of my class config.xml is available. So basically
> config.xml is richable from my class but not from hird-party class
> withing one jar-file. I've tried to put config.xml into different
> directories withing jar-file without success.
> Could be any particular detailes about this third-party class
> implementation? Or any reason why ContextClassLoader behaves
> differently in my class and third-party class? I really don't have any
> ideas any more :(.

AFAIK, this is a classloader issue. At leats it sounds that way. This is
what I think is happening:

When you're using class files directly, there is only one classloader for
all files. Thus the config.txt is available from the library.

When you package the stuff, your classloader has a complete path, but each
library has its own classloader. Thus the library cannot find config.txt
anymore, because that classloader cannot find it.


If my assessment of the situation is correct (I'm not entirely certain),
then it's a design flaw in the library.

You could solve this by adding "." to the Class-Path header in the
manifest of the library jar file, and place config.txt in the current
directory.

Is possible however, a better solution would be to add a configuration
method to the library that takes a Properties object instead of reading a
configuration file.


-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2




==========================================================================
TOPIC: Sockets and TCP Data Segments
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af31f913a137c3ea
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 2:44 am
From: Lawrence Kirby <[EMAIL PROTECTED]> 

On Thu, 11 Nov 2004 00:20:53 -0800, Pete Mainwaring wrote:

...

> Thanks Chris and Gordon for your replies. I had a feeling that I was
> going to get the answer that it can't be done. I'd already had a dig
> around for any other ways of doing it, for example, as you say, it
> could be done in C (using tcpsend I think).

Fundamentally it can't be done in any language because the issue is not
language related, it is the nature of TCP which simulates a reliable byte
stream, not a sequence of messages/records. It may be that you can use
"typical" TCP stack implementation characteristics to get each message
sent in a separate packet most of the time, but that's only going to
happen if you can be sure that the previous packet has been sent on the
network (and not subsequently lost causing a retransmit) before you supply
the next. Then there's the receiver side. If another packet is received
before the reader application gets the first then the TCP stack will pass
as much data as it can when the application does perform a read, i.e. data
from both messages if it can and maybe partial data from the second.

Your problem is that the receiver application is making invalid
assumptions about TCP and is ending up with race conditions. The only real
solution is to fix the receiver application. Using some sort of message
pacing (ick) i.e. a minimum time interval between writing messages might
improve the situation you have (i.e. make "losing" the race less likely)
but it isn't a real solution.

Lawrence




==========================================================================
TOPIC: returning a subclass through an interface
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b62cd9cf6edaa6c4
==========================================================================

== 1 of 2 ==
Date:   Thurs,   Nov 11 2004 2:53 am
From: "Andy Fish" <[EMAIL PROTECTED]> 


"John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Andy Fish wrote:
>
>> I am writing an API call which returns an object of type X. In my code, I 
>> build an object which is of type Y - a subclass of X.
>>
>> I'm worried that if I return the object Y, the caller will be able to use 
>> reflection or a debugger to find out about the extra properties of Y. Is 
>> this concern valid or is there something inherent that stops him doing 
>> this?
>
> Pretty much nothing prevents such analysis.  On the other hand, nothing 
> prevents a user from digging Y.class out of your jar and running it 
> through javap, either.  As to whether or not the concern is _valid_, I'd 
> say you need to make a good case for why the caller must *at all costs* be 
> prevented from doing what you describe before I would accept the concern 
> as valid.
>
>> assuming my concern is valid, I need to make a "clone" of Y but for the 
>> clone to be a superclass (i.e. X). Is there any clever way of doing this?
>
> Construct and return an X in the first place?  I don't see the point of an 
> object that is not an X, but yet is indistinguishable from one despite 
> scrutiny.
>
>> The class X only contains public immutable properties and has no methods 
>> so there is no need to deep copy.
>
> I hope you don't mean that X exposes its fields to the world.  As long as 
> access to its properties goes through accessor methods you have a great 
> deal of flexibility, including a variety of ways to accomplish some of the 
> things I imagine you might be trying to do.  Before I make any specific 
> recommendation, however, I need to know what things you actually are 
> trying to do.  (I have a vivid imagination. :-) )
>

OK, here's a sample. The API returns a PersonDTO (Data Transfer Object). to 
do this, it gets a rich, functional 'person' object (meant for internal use 
only) from the business services and copies the information into the DTO.

PersonDTO getPersonDetails (int personId) {
    PersonObject p = BusinessServices.GetPerson(personId);
    PersonDetails pd = new PersonDetails();
    pd.firstName = p.firstName;
    pd.lastName = p.lastName;
    pd.AddressLine1 = p.AddressLine1;
   ... etc etc
    return pd;
}

now, if PersonObject was a subclass of PersonDTO, I wouldn't have to copy 
all the fields; I could just return p. However, there are some properties of 
PersonObject I definitely don't want the caller to know about.

Andy


>
> John Bollinger
> [EMAIL PROTECTED] 





== 2 of 2 ==
Date:   Thurs,   Nov 11 2004 3:34 am
From: "Stefan Schulz" <[EMAIL PROTECTED]> 

On Thu, 11 Nov 2004 10:53:10 GMT, Andy Fish <[EMAIL PROTECTED]>  
wrote:

>
> OK, here's a sample. The API returns a PersonDTO (Data Transfer Object).  
> to
> do this, it gets a rich, functional 'person' object (meant for internal  
> use
> only) from the business services and copies the information into the DTO.
>
> PersonDTO getPersonDetails (int personId) {
>     PersonObject p = BusinessServices.GetPerson(personId);
>     PersonDetails pd = new PersonDetails();
>     pd.firstName = p.firstName;
>     pd.lastName = p.lastName;
>     pd.AddressLine1 = p.AddressLine1;
>    ... etc etc
>     return pd;
> }
>
> now, if PersonObject was a subclass of PersonDTO, I wouldn't have to copy
> all the fields; I could just return p. However, there are some  
> properties of
> PersonObject I definitely don't want the caller to know about.

I'd use a Decorator that implements PersonDTO, but denies any further
operations. This will (of course) not be debug-proof, but the attacker
might just as well look at the Info while your new object is constructed,
so you will not achive 100% security in any case.


-- 

Whom the gods wish to destroy they first call promising.




==========================================================================
TOPIC: writing clobs using oracle thin driver
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f9dc55b5f77991a1
==========================================================================

== 1 of 2 ==
Date:   Thurs,   Nov 11 2004 4:16 am
From: "Cookie Monster" <[EMAIL PROTECTED]> 

Hi,

I have a problem with the oracle thin driver writing clobs greater then 4000
chars.  Basically using the oci driver the following java code works fine:

PreparedStatement statement;
  Reader bodyReader = null;
  try {
   bodyReader = new StringReader(parameter.toString());
   statement.setCharacterStream(1,bodyReader,parameter.toString().length());
  } catch (Exception e) {
   e.printStackTrace();
   throw new SQLException("Failed to set text field.");
  }

But when using with the thin driver nothing gettings written to the clob.
Does anyone know a solution to this problem where I can use the thin driver
for writing clobs??

Thanks,
Steve.





== 2 of 2 ==
Date:   Thurs,   Nov 11 2004 4:56 am
From: Sudsy <[EMAIL PROTECTED]> 

Cookie Monster wrote:
<snip>
> But when using with the thin driver nothing gettings written to the clob.
> Does anyone know a solution to this problem where I can use the thin driver
> for writing clobs??

Such a common problem that I wrote an article about it. You can find it here:
<http://www.sudsy.net/technology/clobs.html>

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.





==========================================================================
TOPIC: Calculate Resource Usage
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9e861e05dddbabf5
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 5:03 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Bob Rivers wrote:
> How do I calculate memory and cpu usage?
> 
> Memory is "simple": I could use a profiler and see the objects created
> and their size. Am I right?
> 
> And what about cpu? Does it have a cientific method to calculate cpu
> usage, or only empirical one

Empirical observations is what science is all about. And how is looking
at a heap profiler not empirical?

> (looking into the process table - lunix
> top, or windows task manager)?

Profilers show CPU usage as well as memory, but usually expressed as
percentage of execution time an application spends in that particular
method. After all, profilers are for finding performance bottlenecks,
not for giving measurements.

Measurements are done with benchmarks. You just call whatever you want
to measure a few thousand (or a few million, or whatever) times,
see how long it takes and divide by the number of calls.



=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to