comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * store whole InputStream in a String - 13 messages, 5 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9 * Passing Large Size Data over Network - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3be58fc6ae618b13 * Garbage Collector Tuning? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/313c67ac36428c3 * Print help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d8e2a798b4dcd983 * How does tomcat re-start?? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a5012cc45e447b79 * Calling Overridden Methods without super - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b323ca46ffc0fc37 * xdoclet and session bean - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4da091f393c1f57f * System.ext() - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6008bc2e14d4e02e * Build using Ant gets Stuck - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/81c38a47dd409f6a * help with JDBC - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a4767f119aa3583b * question about Object.clone - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/86e64c7b7efb3866 ========================================================================== TOPIC: store whole InputStream in a String http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9 ========================================================================== == 1 of 13 == Date: Sat, Sep 11 2004 10:27 am From: "Mike Schilling" <[EMAIL PROTECTED]> "Paul Lutus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > ak wrote: > >>> Can I write all contents of an InputStream to a String at once? >>> >>> something like >>> >>> String a = inputStream.readAll(); >>> >> sure: >> >> public String readAll(InputStream inputStream) { >> ByteArrayOutputStream bout = new ByteArrayOutputStream(); >> byte [] buffer = new byte[1024]; >> while(true) { >> int len = inputStream.read[buffer]; >> if(len < 0) { >> break; >> } >> bout.write(buffer, 0, len); >> } > > ??? Please consider the following, and avoid constructions like > "while(true)" and "break" when possible: > > int len; > > while((len = inputStream.read[buffer]) > 0) { > bout.write(buffer, 0, len); > } > I find the other version clearer, myself. The nesting of method call and test in the while statement is too much information in one line, and it's unfortunate to declare len outside the loop that it's only used inside of. == 2 of 13 == Date: Sat, Sep 11 2004 11:00 am From: Paul Lutus <[EMAIL PROTECTED]> Mike Schilling wrote: > > "Paul Lutus" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> ak wrote: >> >>>> Can I write all contents of an InputStream to a String at once? >>>> >>>> something like >>>> >>>> String a = inputStream.readAll(); >>>> >>> sure: >>> >>> public String readAll(InputStream inputStream) { >>> ByteArrayOutputStream bout = new ByteArrayOutputStream(); >>> byte [] buffer = new byte[1024]; >>> while(true) { >>> int len = inputStream.read[buffer]; >>> if(len < 0) { >>> break; >>> } >>> bout.write(buffer, 0, len); >>> } >> >> ??? Please consider the following, and avoid constructions like >> "while(true)" and "break" when possible: >> >> int len; >> >> while((len = inputStream.read[buffer]) > 0) { >> bout.write(buffer, 0, len); >> } >> > > I find the other version clearer, myself. You can't be serious. The original arrangement has two control structures where only one is needed. Also, both "while(true)" and "break" are frowned upon in any case where they are not required. They are not particularly good examples of structure programming. A while() clause should actually perform a test, not be added as a patch to create a loop that must later be broken out of, by force, using break. > The nesting of method call and > test in the while statement is too much information in one line, 1. A for-loop typically contains one additional piece of information (three instead of two items as in my example). Want to object to that also? 2. Compared to the original, this version is simpler to read and interpret. It is also better coding practice -- it doesn't misuse while(). > and it's > unfortunate to declare len outside the loop that it's only used inside of. I could instead have said: for (int len = inputStream.read[buffer]); len > 0;) { } But this replaces one arbitrary choice with another, and uses a for clause in a place where it is not the ideal choice. In any case, writing "while(true)" simply builds a perpetual loop that requires "break" to terminate, creating the illusion of appropriate usage. -- Paul Lutus http://www.arachnoid.com == 3 of 13 == Date: Sat, Sep 11 2004 11:37 am From: "Vincent Lascaux" <[EMAIL PROTECTED]> > 1. A for-loop typically contains one additional piece of information > (three > instead of two items as in my example). Want to object to that also? Although I agree with you for the while loop, I don't think that this is a good example. A for loop should always be that kind (I think): for(T i = start; i<end; i++) (where T could be int, Iterator...) There is only few information here: start and end, and assuming you are always using the for loop that way, you get use to it and understand easily the statement > I could instead have said: > > for (int len = inputStream.read[buffer]); len > 0;) { > } And this is the example of what not to do. First I'm not sure it would compile, then it should be for(int len = inputStream.read(buffer); len>0; len = inputStream.read(buffer)) { //... } And this is too much... ;) -- Vincent == 4 of 13 == Date: Sat, Sep 11 2004 1:02 pm From: Paul Lutus <[EMAIL PROTECTED]> Vincent Lascaux wrote: >> 1. A for-loop typically contains one additional piece of information >> (three >> instead of two items as in my example). Want to object to that also? > > Although I agree with you for the while loop, I don't think that this is a > good example. A for loop should always be that kind (I think): > > for(T i = start; i<end; i++) > (where T could be int, Iterator...) No. The third field is optional. If T is an iterator, one might want to: for(T i = start; i.hasNext();) { something q = i.next(); } Which makes it exactly like my example. The third clause in the for-loop construct is optional and one sees code shaped this way regularly. > > There is only few information here: start and end, and assuming you are > always using the for loop that way, you get use to it and understand > easily the statement But a typical use is not the only acceptable use. > >> I could instead have said: >> >> for (int len = inputStream.read[buffer]); len > 0;) { >> } > > And this is the example of what not to do. Quite false. It is entirely appropriate and a common coding practice. > First I'm not sure it would > compile, I compiled it, then posted it. You could do the same. > then it should be > for(int len = inputStream.read(buffer); len>0; len = > inputStream.read(buffer)) { What? No wonder you think there's something wrong. Your example is broken (it discards the first block of input), mine is not. > //... > } > > And this is too much... ;) Yes, if you take my working example and render it unworkable, then it won't work. -- Paul Lutus http://www.arachnoid.com == 5 of 13 == Date: Sat, Sep 11 2004 1:14 pm From: "ak" <[EMAIL PROTECTED]> int len = inputStream.read[buffer]; while(len > 0) { bout.write(buffer, 0, len); len = inputStream.read[buffer]; } or for(int len = inputStream.read[buffer]; len > 0;) { bout.write(buffer, 0, len); len = inputStream.read[buffer]; } -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader == 6 of 13 == Date: Sat, Sep 11 2004 1:26 pm From: Paul Lutus <[EMAIL PROTECTED]> ak wrote: > int len = inputStream.read[buffer]; > while(len > 0) { > bout.write(buffer, 0, len); > len = inputStream.read[buffer]; > } A maintenance nightmare. This is an example of the kind of coding practice that drives software administrators up the wall. Always avoid this silly construction, the kind that uses two identical lines of code to avoid a little thought. Summary: Never write two identical lines of code when you can instead write one. > or > > for(int len = inputStream.read[buffer]; len > 0;) { > bout.write(buffer, 0, len); > len = inputStream.read[buffer]; > } Same nightmare, different pillow. -- Paul Lutus http://www.arachnoid.com == 7 of 13 == Date: Sat, Sep 11 2004 2:45 pm From: "Mike Schilling" <[EMAIL PROTECTED]> "Paul Lutus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Mike Schilling wrote: > >> >> "Paul Lutus" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> ak wrote: >>> >>>>> Can I write all contents of an InputStream to a String at once? >>>>> >>>>> something like >>>>> >>>>> String a = inputStream.readAll(); >>>>> >>>> sure: >>>> >>>> public String readAll(InputStream inputStream) { >>>> ByteArrayOutputStream bout = new ByteArrayOutputStream(); >>>> byte [] buffer = new byte[1024]; >>>> while(true) { >>>> int len = inputStream.read[buffer]; >>>> if(len < 0) { >>>> break; >>>> } >>>> bout.write(buffer, 0, len); >>>> } >>> >>> ??? Please consider the following, and avoid constructions like >>> "while(true)" and "break" when possible: >>> >>> int len; >>> >>> while((len = inputStream.read[buffer]) > 0) { >>> bout.write(buffer, 0, len); >>> } >>> >> >> I find the other version clearer, myself. > > You can't be serious. The original arrangement has two control structures > where only one is needed. Also, both "while(true)" and "break" are frowned > upon in any case where they are not required. They are not particularly > good examples of structure programming. I am entirely serious. > > A while() clause should actually perform a test, not be added as a patch > to > create a loop that must later be broken out of, by force, using break. > >> The nesting of method call and >> test in the while statement is too much information in one line, > > 1. A for-loop typically contains one additional piece of information > (three > instead of two items as in my example). Want to object to that also? They're nicely punctuated.. > > 2. Compared to the original, this version is simpler to read and > interpret. > It is also better coding practice -- it doesn't misuse while(). > >> and it's >> unfortunate to declare len outside the loop that it's only used inside >> of. > > I could instead have said: > > for (int len = inputStream.read[buffer]); len > 0;) { > } > > But this replaces one arbitrary choice with another, and uses a for clause > in a place where it is not the ideal choice. And it's wrong :-) It reads from the stream only once, rather than each time through the loop. You need len = inputStream.read[buffer] as the iteration clause. > > In any case, writing "while(true)" simply builds a perpetual loop that > requires "break" to terminate, creating the illusion of appropriate usage. You make a lot of absolute assertions. I disagree with many of them. I'm not sure what that leaves us to discuss. == 8 of 13 == Date: Sat, Sep 11 2004 2:46 pm From: "Mike Schilling" <[EMAIL PROTECTED]> "Paul Lutus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >> then it should be >> for(int len = inputStream.read(buffer); len>0; len = >> inputStream.read(buffer)) { > > What? No wonder you think there's something wrong. Your example is broken > (it discards the first block of input), mine is not. No, try it. That loop is entirely correct. Yours only reads from the stream once. == 9 of 13 == Date: Sat, Sep 11 2004 4:02 pm From: "Vincent Lascaux" <[EMAIL PROTECTED]> >> for(T i = start; i<end; i++) >> (where T could be int, Iterator...) > > No. The third field is optional. If T is an iterator, one might want to: > > for(T i = start; i.hasNext();) { > something q = i.next(); > } Yes... I would actually have voted for something like for(Iterator i = start; i.hasNext(); i.next()) { something q = i.current(); } The C# and C++ STL iterators work like that (well, same idea), and I am more used to reading a for statement with an "inc" as a third "parameter" >>> I could instead have said: >>> >>> for (int len = inputStream.read[buffer]); len > 0;) { >>> } >> >> And this is the example of what not to do. > > Quite false. It is entirely appropriate and a common coding practice. Actually, all the while loop could be written as a for loop (while(cond) { body; } is like for(;cond;) { body; }, with the benefit for the second version to have a smiley in it). So I think you have to make a rule for where to use while and where to use for. I would reserve the for statement for an iteration over a limited number of elements, like an array or the numbers from 0 to 100 for example. To me it is important to find in a for statement a starting value, an ending value and an incrementation. Else I would prefer using a while loop. But my "what not to do" was probably too strong (apologize for that). I feel it more unreadable than the while((len = inputStream.read(buffer))>0) { }. I really think a while statement should be used in that case. My "what not to do" was also here because I feel your code doesnt act as intended (see further). >> First I'm not sure it would >> compile, > > I compiled it, then posted it. You could do the same. It dont manage to compile it. I'm using Java 1.4.2... maybe it's the reason? Has a new version of the language introduced something with more closing parenthesis than opening ones? If so, I don't like it :P >> then it should be >> for(int len = inputStream.read(buffer); len>0; len = >> inputStream.read(buffer)) { > > What? No wonder you think there's something wrong. Your example is broken > (it discards the first block of input), mine is not. I think that for(Init; Cond; Inc) { Body; } is equivalent to { Init; while(Cond) { Body; Inc; } } So my loop is equivalent to { int len = inputStream.read(buffer); while(len>0) { /* Body */ len = inputStream.read(buffer); } } To me it doesnt look like any block of input is discarded by that. If I understand your code (I am not sure I do), and if it is equivalent to for(int len = inputStream.read(buffer); len>0; ) { /* Body */ } then it is equivalent to { int len = inputStream.read(buffer); while(len>0) { /* Body */ } } Since /*Body*/ is not supposed to change len, you have an infinite loop (for a non empty inputStream) -- Vincent == 10 of 13 == Date: Sat, Sep 11 2004 4:03 pm From: "ak" <[EMAIL PROTECTED]> > > int len = inputStream.read[buffer]; > > while(len > 0) { > > bout.write(buffer, 0, len); > > len = inputStream.read[buffer]; > > } > > A maintenance nightmare. This is an example of the kind of coding practice > that drives software administrators up the wall. Always avoid this silly > construction, the kind that uses two identical lines of code to avoid a > little thought. there is nothing wrong if len initialized with same code as incremented. > Summary: Never write two identical lines of code when you can instead write > one. even if this one line looks ugly? -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader == 11 of 13 == Date: Sat, Sep 11 2004 4:10 pm From: "ak" <[EMAIL PROTECTED]> > > int len = inputStream.read[buffer]; > > while(len > 0) { > > bout.write(buffer, 0, len); > > len = inputStream.read[buffer]; > > } > > A maintenance nightmare. This is an example of the kind of coding practice > that drives software administrators up the wall. Always avoid this silly > construction, the kind that uses two identical lines of code to avoid a > little thought. > > Summary: Never write two identical lines of code when you can instead write > one. > ok, what is with folowing, also nightmare? int len; do { len = inputStream.read[buffer]; if(len > 0) { bout.write(buffer, 0, len); } }while(len > 0); or better: int len; do { len = inputStream.read[buffer]; writeBuffer(buffer, len, bout); } private static void writeBuffer(byte [] buffer, int len, OutputStream out) { if(len > 0) { out.write(buffer, 0, len); } } -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader == 12 of 13 == Date: Sat, Sep 11 2004 7:33 pm From: "Tony Morris" <[EMAIL PROTECTED]> I'm waiting for someone to notice in this thread, as I thought it was inevitable, but to no avail. Take a closer look at the following line of code that I keep seeing posted: int len = inputStream.read[buffer]; Side Note: I'm with Paul Lutus all the way so far, but then, I'm more of a "purist" than most. -- Tony Morris http://xdweb.net/~dibblego/ == 13 of 13 == Date: Sat, Sep 11 2004 7:41 pm From: "Mike Schilling" <[EMAIL PROTECTED]> "Tony Morris" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Side Note: I'm with Paul Lutus all the way so far, but then, I'm more of a > "purist" than most. You like infinite for loops? :-) ========================================================================== TOPIC: Passing Large Size Data over Network http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3be58fc6ae618b13 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 10:33 am From: Kevin McMurtrie <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, YU <[EMAIL PROTECTED]> wrote: > Hello! > There is one problem which has been causing me much trouble. > (Perhaps I haven't got enough exp on app development in Java) > In a network environment, we have to develop a system to transmit > large size data (several hundred MB). When using RMI, or J2EE, or > other distributed framework, how can this be done? Thanks! > > YU Just use a socket. Put gzip input and output streams around it if it's compressible data. ========================================================================== TOPIC: Garbage Collector Tuning? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/313c67ac36428c3 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 11:13 am From: Kevin McMurtrie <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, "Will Hartung" <[EMAIL PROTECTED]> wrote: > Anyone have any good tips on this? I've read the stuff on the Sun site, and > it's not the clearest in addressing the problem we're having. > > The problem manifested itself when we tweaked a parameter on our Weblogic > container that boosted the number of Entity Beans we were caching. > > Our first cut ran out of memory, and that's fine. > > So, we doubled the memory from 512MB to 1G. > > Now, what we're discovering is that when the total heap hits about 70%, the > JVM stops doing regular GC's and instead always does FULL GC's. > > Here's an example: > > 49361.470: [GC 697385K->383772K(1038336K), 0.3217450 secs] > 49718.707: [Full GC 712796K->343806K(1038336K), 9.3212136 secs] > 50100.223: [GC 672830K->350047K(1038336K), 0.1127042 secs] > 50602.456: [GC 679070K->355207K(1038336K), 0.1818174 secs] > 51805.160: [GC 684230K->356492K(1038336K), 0.1795301 secs] > 53811.129: [GC 685515K->361465K(1038336K), 0.1690929 secs] > 54881.216: [GC 690489K->364970K(1038336K), 0.1771471 secs] > 55140.403: [GC 693992K->375349K(1038336K), 0.3487647 secs] > 55489.379: [Full GC 704372K->388449K(1038336K), 8.0318241 secs] > 56094.146: [Full GC 717473K->401236K(1038336K), 7.9995729 secs] > 56584.954: [Full GC 730260K->409971K(1038336K), 7.8904020 secs] > 57313.878: [Full GC 738995K->375909K(1038336K), 9.7734903 secs] > > Once it crossed that 700MB mark, it was always doing the Full GC's. > (Although it crossed 700MB earlier). > > Any ideas which knob to turn that can prevent that/delay that? There's no > reason it should be using Full GC's at that point (that I can think off). > > We understand where and how the memory is being used, it's the actual GC > behavior we are curious about. > > Any thoughts appreciated. > > Best regards, > > Will Hartung > ([EMAIL PROTECTED]) Some of the garbage collectors degrade over time due to incorrect self-tuning. The incremental collector is completely broken. At some point it will fail because it stops adjusting heap sizes or the tenuring threshold drops to zero. Either way it does full GCs and slows to a halt. This collector has been removed from Java 1.5. The CMS collector (-XX:+UseConcMarkSweepGC -XX:+UseParNewGC) in Java 1.4.2_05 and later works well long-term. Just don't drive the free space to zero or you'll get a deadlock. The tenuring threshold degrades to zero from poor self-tuning but that's not a major problem with this collector. Self-tuning otherwise works well. The collection threshold (-XX:CMSInitiatingOccupancyFraction) should be adjusted to make use of large heaps. I haven't done official long-term stress testing on the other collectors, though I think I've seen the default collector go bad while running Eclipse. CMS is probably the most appropriate for a web server. Turn on the other GC debug options to see more about what's happening: verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintTenuringDistribution ========================================================================== TOPIC: Print help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d8e2a798b4dcd983 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 1:17 pm From: "neo" <[EMAIL PROTECTED]> Hi, I'm new in Java technology and I'm using Eclipse which is helping me a lot, by far the best IDE available. I make GUIs just that easy like Visual Basic, I wonder if there is a tool to make reports for print documents, a graphic tool where I can define page borders, headers and footers, etc. If not, please tell me what Classes must I use and give me the easiest way to make visual reports Thank you very much in advance ========================================================================== TOPIC: How does tomcat re-start?? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a5012cc45e447b79 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 1:30 pm From: "Mr. Steve R. Burrus" <[EMAIL PROTECTED]> Yes, that's my question for this newsgroup, how do I go about getting the version 5.5.0 of Tomcat to reload its' context exactly??? I have tried everything short of flying to the moon :) to get it to do this for me. ========================================================================== TOPIC: Calling Overridden Methods without super http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b323ca46ffc0fc37 ========================================================================== == 1 of 2 == Date: Sat, Sep 11 2004 2:05 pm From: [EMAIL PROTECTED] (Yakov) As a workaround, add to the subclass a method public void callParent(boolead shouldIcallSuper){ this.callSuper = shouldIcallSuper; } And here's the foo() in the subclass: foo(){ if (callSuper){ super.foo(); }else{ // your current code } } Regards, Yakov == 2 of 2 == Date: Sat, Sep 11 2004 4:16 pm From: Frank <[EMAIL PROTECTED]> On 10 Sep 2004 08:45:33 -0700, Marco <[EMAIL PROTECTED]> wrote: > Can I call the overridden version of an object's foo() method > outside that object's class, without using super? EG: > > class MainProgram { > public static void main(String[] args) { > Beta b = new Beta(); > > // I want to invoke Alpha.foo() but on the Beta instance. > // I want to cancel the dynamic binding that makes Beta.foo() > // get called instead > // b.super.foo() <---- obviously doesn't compile > } > } > > class Alpha { > public void foo() { System.out.println("inside Alpha.foo()"); } > } > > class Beta extends Alpha { > public void foo() { System.out.println("inside Beta.foo()"); } > } > > Is this possible? > Marco There are some other responses here, but I've noticed most people have said no, but the answer is actually yes (sorta): change class Beta extends Alpha { public void foo() { System.out.println("inside Beta.foo()"); } public void origionalFoo() { super.foo(); } } then your main method reads: Beta b=new Beta(); b.origionalFoo(); HTH -Frank ========================================================================== TOPIC: xdoclet and session bean http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4da091f393c1f57f ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 5:18 pm From: William Zumwalt <[EMAIL PROTECTED]> I'm trying to figure out why I'm getting the exceptions thrown below. I'm using XDoclet and there's something about using about using local interface extending EJBLocalObject that I'm not understand though I think I'm doing. Any help much appreciated. --- my session bean file --- /** * @ejb.bean * name="comps/RegisterDevice" * type="Stateless" * jndi-name="ejb/comps/RegisterDevice" * primkey-field="id" * display-name="Register Device Bean" * * @ejb.home * extends="javax.ejb.EJBHome" * remote-class="com.comps.management.ejb.session.RegisterDeviceHome" * local-extends="javax.ejb.EJBLocalHome" * * @ejb.interface * extends="javax.ejb.EJBObject" * remote-class="com.comps.management.ejb.session.RegisterDevice" * local-extends="javax.ejb.EJBLocalObject" */ public class RegisterDeviceBean implements SessionBean { private SessionContext context = null; public void setSessionContext(SessionContext ctx) { context = ctx; } public void unsetSessionContext() throws EJBException { context = null; } /** * @throws CreateException * * @ejb.create-method */ public void ejbCreate() throws CreateException { } public void ejbPostCreate() { } public void ejbRemove() throws EJBException { } public void ejbActivate() throws EJBException { } public void ejbPassivate() throws EJBException { } public void ejbLoad() throws EJBException { } public void ejbStore() throws EJBException { } /** * @ejb.interface-method */ public boolean registerDevice() { return true; } } --- server output --- 19:11:30,702 WARN [verifier] EJB spec violation: Bean : comps/RegisterDevice Section: 7.10.7 Warning: The local interface must extend the javax.ejb.EJBLocalObject interface. 19:11:30,702 WARN [verifier] EJB spec violation: Bean : comps/RegisterDevice Method : public abstract boolean registerDevice() throws RemoteException Section: 7.10.7 Warning: The methods in the local interface must not include java.rmi.RemoteException in their throws clause. 19:11:30,703 WARN [verifier] EJB spec violation: Bean : comps/RegisterDevice Method : public abstract void remove() throws RemoteException, RemoveException Section: 7.10.7 Warning: The methods in the local interface must not include java.rmi.RemoteException in their throws clause. 19:11:30,703 WARN [verifier] EJB spec violation: Bean : comps/RegisterDevice Method : public abstract Object getPrimaryKey() throws RemoteException Section: 7.10.7 Warning: The methods in the local interface must not include java.rmi.RemoteException in their throws clause. 19:11:30,703 WARN [verifier] EJB spec violation: Bean : comps/RegisterDevice Method : public abstract EJBHome getEJBHome() throws RemoteException Section: 7.10.7 Warning: The methods in the local interface must not include java.rmi.RemoteException in their throws clause. 19:11:30,705 WARN [verifier] EJB spec violation: Bean : comps/RegisterDevice Method : public abstract Handle getHandle() throws RemoteException Section: 7.10.7 Warning: The methods in the local interface must not include java.rmi.RemoteException in their throws clause. 19:11:30,705 WARN [verifier] EJB spec violation: Bean : comps/RegisterDevice Method : public abstract boolean isIdentical(EJBObject) throws RemoteException Section: 7.10.7 Warning: The methods in the local interface must not include java.rmi.RemoteException in their throws clause. ========================================================================== TOPIC: System.ext() http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6008bc2e14d4e02e ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 6:44 pm From: Andrew Thompson <[EMAIL PROTECTED]> On Sat, 11 Sep 2004 15:58:41 +0200, steph wrote: > Is the any way to prevent a class to do a System.exit() <sscce> import java.awt.*; import java.awt.event.*; public class NoExit extends Frame implements ActionListener { Button frameLaunch = new Button("Frame"), exitLaunch = new Button("Exit"); public NoExit() { super("Launcher Application"); SecurityManager sm = new ExitManager(); System.setSecurityManager(sm); setLayout(new GridLayout(0,1)); frameLaunch.addActionListener(this); exitLaunch.addActionListener(this); add( frameLaunch ); add( exitLaunch ); pack(); setSize( getPreferredSize() ); } public void actionPerformed(ActionEvent ae) { if ( ae.getSource()==frameLaunch ) { TargetFrame tf = new TargetFrame(); } else { System.exit(-3); } } public static void main(String[] args) { NoExit ne = new NoExit(); ne.setVisible(true); } } class TargetFrame extends Frame { static int x=0, y=0; TargetFrame() { super("Close Me!"); add(new Label("Hi!")); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent we) { System.out.println("Bye!"); System.exit(0); } }); pack(); setSize( getPreferredSize() ); setLocation(++x*10,++y*10); setVisible(true); } } class ExitManager extends SecurityManager { public void checkExit(int status) { if (status > -2) { throw( new SecurityException() ); } } } </sscce> As I suspected, restricting permissions in an unsigned app running locally is child's play, but rewidenning them is a bit more tricky. I tried storing a reference to the original securitymanager, so I could swap back to it to allow the main app to exit, but that threw SecurityExceptions, hence the kludgy exit stategy. The security manager throws an exception for any exit code > -2, so we call System.exit(-3) in our main app to end the VM. HTH -- Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology ========================================================================== TOPIC: Build using Ant gets Stuck http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/81c38a47dd409f6a ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 7:19 pm From: "Tony Morris" <[EMAIL PROTECTED]> Have you tried narrowing it down? "Divide and conquer" is your friend. -- Tony Morris http://xdweb.net/~dibblego/ ========================================================================== TOPIC: help with JDBC http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a4767f119aa3583b ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 6:54 pm From: steve <[EMAIL PROTECTED]> On Sun, 12 Sep 2004 00:34:27 +0800, Ebrahim wrote (in article <[EMAIL PROTECTED]>): > "Steve Cassidy" <[EMAIL PROTECTED]> wrote in message > news:<[EMAIL PROTECTED]>... >> "Ebrahim" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> hi guys .. I am using Oracle : JDBC driver to connect to an oracle >>> It gives the Exception ResultSet.next() was not called . >>> BEsides why should ResultSet.Next() be called in the first place ?? >> >> rs.next() reads a row from the database into the ResultSet. When you first >> create a ResultSet with statement.executeQuery() or similar, the cursor >> into >> the ResultSet is initially positioned at the start, before the first row. >> Your first call to rs.next() reads the first row - you have to call it even >> if your query returns only one row. Until you've called this you can't >> retrieve any values, as there aren't any loaded to retrieve. > > thx for clearing that doubt !!! > > could you also help me with the following : > i need to enter values into my Oracle db in chinese . For this I need > to set up the Oracle DB in chinese . Since I work for a company , they > might not allow me to change the charset for the entire database to > UTF-8 but rather only for a specific schema . Can you help me with > this ?? Do you know of any other way by which I can enter data in > Chinese/Japanese in an ORacle DB ?? > > Ebrahim B O.K here we go again. you need to read up on oracle multi character support, it has improved since UTF-8 (see the rather long running thread i18n'ed characters set in DBMS and tables) in this new group. you can support any multi byte language, chinese/japanese in an oracle database. if using oracle , YOU MUST ensure your Schema represents the character encoding data you are entering into it. ( yes you CAN get away with sticking multibyte data into a normal clob/varchar2) but be aware on pl/sql string functions, if you use the wrong encoding ( by sticking multibyte into single byte tablespace) you will SERIOUSLY mess up the string functions , and the text indexing functions. if you heed to get 1 character or a bunch of characters. also oracle will try to do character tanslation between the database & the client. however if you like to live dangerously, loose upgradeability and don't mind loosing string indexing ( or your job): you can try the following: 1. get your java app to input ALL the asian text. Build a binary storage area. delimit the asian text (somehow), concat the resulting Objects insert your "asian" Objects into a binary staging area. write the staging area to oracle & store it in a BLOB ( binary large object) ( oracle will not index or try to do character translation, do not use a CLOB) when you need the asian text , get the BLOB from the database, unpack the data, & display it on your screen. ( do not try to get smart , and realize that you can use java in the database to "serialize objects", then try to call the server code from the client java, to serialize the data , to & from the database, if you do the overhead will buy your database) Be aware that you are fooling yourself & the database , by doing the above. ( if you have to add fields/remove fields from your data, or make fields longer/smaller, then you better be sure your packing/unpacking routines are smart enough) steve ========================================================================== TOPIC: question about Object.clone http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/86e64c7b7efb3866 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 7:40 pm From: "Tony Morris" <[EMAIL PROTECTED]> "jeep" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > If you can't change the class in question, tough luck > In fact, you still have one chance, but it will be a bit harder : the > reflection api (java.lang.reflect.*) > Reflection doesn't allow you to change a class, only inspect it. Perhaps you were thinking of bytecode enhancment? -- Tony Morris http://xdweb.net/~dibblego/ ======================================================================= 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 ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> <a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
