java

Can Spring initialize "non-bean" fields?

I have initialized a java.util.logging.Logger bean and now want to add a Handler which I've also created a bean for. The trouble is the Logger method is called addHandler instead of something like setHandler. How can I inject the handler into the logger? Do I need to wrap Logger in a Spring-friendly bean class? EDIT If someone can...

What do REFRESH and MERGE mean in terms of databases?

Hi all. I'm curious and need to find this answer quick. Google won't help much. The Java Persistece API has these properties that tell the framework to cascade operations on associated entities: CascadeType.PERSIST CascadeType.DELETE CascadeType.MERGE CascadeType.REFRESH I know what the first two mean: when I persist object A which h...

What is the best way to create a Java Servlet or JSP that optionally includes content depending on URL parameters

I want to create a JSP page or servlet that will work in 2 ways. A user visits their own profile page: http//something.com/profile/ Or they visit their friends page: http://something.com/profile/FriendsName They could also visit their own page through an explicit URL like: http://something.com/profile/YourName I have a servlet-mapp...

Print regex matches in java

So I have an IP address as a string. I have this regex (\d{1-3})\.(\d{1-3})\.(\d{1-3})\.(\d{1-3}) How do I print the matching groups? Thanks! ...

Why all java methods are implicitly overridable?

In C++, I have to explicitly specify 'virtual' keyword to make a member function 'overridable', as there involves an overhead of creating virtual tables and vpointers, when a member function is made overridable (so every member function is implicitly not overridable for performance reasons). It also allows a member function to be hidde...

Problem with FOP Image scaling in Java

Okay, so here's my problem: We use FOP for creating "pretty" report output. We use the pdf option if the user wants a file, AWT for previewing, and the -print option for printing them. We are using FOP 0.25.x, which I fully recognize is not the newest version, but upgrading to 0.95 appears to be a non-trivial task that I don't necessa...

Is there a Java Open source Library for parsing Excel 2007 Files?

Is there a Java Open source Library for parsing Excel 2007 Files? ...

In XStream is there a better way to marshall/unmarshall List<Object>'s in JSON and Java

I'm using XStream and JETTISON's Stax JSON serializer to send/receive messages to/from JSON javascripts clients and Java web applications. I want to be able to create a list of objects to send to the server and be properly marshalled into Java but the format that XStream and JSON expect it in is very non-intuitive and requires our javas...

Tomcat: Implementing java.security.Principal

I am trying to create a custom realm in Tomcat. My problem is that there is a SessionAttributeListener as part of the framework which checks to see if any object added to the session is serializable, and if it isn't it causes problems... like invalidating the session. Because org.apache.catalina.realm.GenericPrincipal is not serializab...

How to access remote flash Shared Objects from php or java?

Are there any php (preferably) or java libraries that allow to retrieve remote flash shared objects? Something equal to: connection = new NetConnection(); connection.connect("rtmp://example.com/test"); var testdb_so = SharedObject.getRemote("testdb_so", connection.uri, true); ... Thanks. ...

Smooth lines in OpenGL

I'm trying to a draw a more-or-less smooth multi-segment line in OpenGL. However I find that if the line is over a thickness about 3 then the joins between the segments are not seamless. They sometimes have gaps between them. Is there a good way of making these joins smooth and gapless? I'm looking for something like the equivalent of Ba...

Passing a backing bean instance as parameter for another backing bean method

Hey, After the user fills my backing bean with info through the forms, I want to process the instance in Java code (such as JAXB marshalling). So at the moment i'm doing this like so: <% OtherBean.method(myBackingBean); %> which is - if i'm right - not quite an up to date solution :) So how can I make this happen in a 'better' way? ...

How to deal with inept management

A project I was working on has finished, so I've been moved on to some new tasking at my employer. The previous work was very agile, small team, progress over procedure, etc etc. So anyway, the new project I'm on - I find myself confused on how to deal with management. They have no real understanding of object oriented programing , cu...

Is there a Log4J Layout/Formatter that prunes Stack Traces for exceptions?

I'm looking for a Log4J Layout/Formatter that helps me prune stack-traces in exceptions a little better than the defaults. That the stack-execution is somewhere below main() is quite obvious and unnecessary for me to know, and that the exception occurred deeply within some other library is really nothing I can do too much about. What I ...

How do I Save the Heap (Dump to a File) in Eclipse?

Hi Guys! I'm getting this error when I run or debug my GA/AI from MyEclipse: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space eclipse.ini looks like this: -showsplash com.genuitec.myeclipse.product --launcher.XXMaxPermSize 256m -vmargs -Xms128m -Xmx512m -Duser.language=en -XX:PermSize=128M -XX:MaxPermSize=256M...

How can I add an element to a lazily-loaded collection in Hibernate without causing the collection to load?

What it says on the tin; I want to modify a collection in Hibernate without forcing the collection to load, since it is a large volume of data (~100,000 records, monotonically increasing). Right now, I add an element to this list by calling getEvents ().add (newEvent) which, of course, causes events to be populated. Here's the mapping...

JUnit theory for hashCode/equals contract

The following class serve as generic tester for equals/hashCode contract. It is a part of a home grown testing framework. What do you think about? How can I (strong) test this class? It is a good use of Junit theories? The class: @Ignore @RunWith(Theories.class) public abstract class ObjectTest { // For any non-null refere...

JTree connecting lines in Substance

Using the new version of the substance look and feel for Java, the connecting lines in a typical JTree are not drawn (parent - child lines). In the official forum in java.net someone asked the same thing and the answer of the developer for this is that it was a choice based on the newer UI's and there is no plan to implement the option ...

How can I get a java.io.InputStream from a java.lang.String?

I have a String that I want to use as an InputStream. In Java 1.0, you could use java.io.StringBufferInputStream, but that has been @Deprecrated (with good reason--you cannot specify the character set encoding): This class does not properly convert characters into bytes. As of JDK 1.1, the preferred way to create a stream from ...

Java overloading vs overwriting

Hi I just want to make sure I have these concepts right. Overloading in java means that you can have a constructor or a method with different number of arguments or different data types. i.e public void setValue(){ this.value = 0; } public void setValue(int v){ this.value = v; } How about this method? Would it still be consider...