java

How to use a ThrottlingFilter for Jetty in Restlet

I would like to configure a webservice so that once the accept queue is full the service returns 503. Currently, these requests seem to just time out. I did set paramters like maxThreads and acceptQueuesize (as described here: http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/jetty/JettyServerHelper). But the servic...

Iterating over Java Collections in Scala

I'm writing some Scala code which uses the Apache POI API. I would like to Iterate over the Rows contained in the java.util.Iterator that I get from the Sheet class. I would like to use the Iterator in a for each style loop, so I have been trying to convert it to a native Scala collection but will no luck. I have looked at the Scala Wra...

Should I use java.text.MessageFormat for localised messages without placeholders?

We are localising the user-interface text for a web application that runs on Java 5, and have a dilemma about how we output messages that are defined in properties files - the kind used by java.util.Properties. Some messages include a placeholder that will be filled using java.text.MessageFormat. For example: search.summary = Your sear...

Comparing XMLs using XMLUnit RecursiveElementNameAndTextQualifier

Hi, I am trying to compare 2 XML files using XMLUnit 1.2. I am using the RecursiveElementNameAndTextQualifier() qualifier. When changing the order of some entities order in my XML, it causes XMLUnit to pass on some cases and fail on other cases. My XML file looks like this, and I'm comparing it to a similar copy with a simple locat...

Using Spring Pitchfork to have JEE compliant code that runs in non-JEE container

I am facing the decision to abandon Java EE 5 (JEE) container to use web container instead (with Spring). According to Interface21 Spring Pitchfork allows elements of the JEE programming model to be used in Spring. Thus, I get a subset of JEE annotations inside of Spring container. Since I prefer to maintain compatibility with JEE this l...

Running a java program at the command line, what am I doing wrong?

Note I'm running windows, the path just looks like it's linus because I typed it manually and thats how I think of paths. I'm trying to run a java class That I have built to diagnose my connection to a databse, it references the oracle jdbc adaptor. When I just run it without a class path: %> java DBDiagnostics <connectionString> I ...

What CVS client for Java do you recommend?

I'm looking for a CVS client to embed in my Java application. What do you recommend? ...

Remove server.policy from sun application server

I encounter this java.lang.StackOverflowError error after deployment of the java web application (.war). If i remove the server.policy file. I will not encounter this error however it means that there will be no security. I realize that the error will occur if i include the following in server.policy which by default is included permissi...

AOP for third-party classes

I have used AOP within spring with no real problems, mainly for transaction management, for which it works a charm. My question is this... the only examples I've seen for AOP so far is to pointcut a class that you have created yourself. Is it possible to pointcut a class within a third party library, for example a database connection c...

What are your best Swing design patterns and tips?

I'm writing a GUI for an application using Swing, and in the interests of code maintenance and readability, I want to follow a consistent pattern throughout the whole system. Most of the articles and books (or at least book sections) that I've read appear to provide plenty of examples on how to create and arrange various components, but...

How to tell whether an XML document validates against a DTD or XSD?

In Java, I can validate an XML document against an XSD schema using javax.xml.validation.Validator, or against a DTD by simply parsing the document using org.xml.sax.XMLReader. What I need though is a way of programmatically determining whether the document itself validates against a DTD (i.e. it contains a <!DOCTYPE ...> statement) or ...

Disinheriting(?) / overriding .ToString to access COM Object .toString

I have a java library that I am accessing in VB.NET via COM. The objects on the java side expose non-trivial .toString methods that I need for debugging. Unfortunately, when I call .toString on the COM objects, the call is being intercepted by the Object class' .ToString function. How do I force the call to the COM-side .toString and ...

Connecting to remote URL which requires authentication using Java

How do I connect to a remote URL in Java which requires authentication. I'm trying to find a way to modify the following code to be able to programatically provide a username/password so it doesn't throw a 401. URL url = new URL(String.format("http://%s/manager/list", _host + ":8080")); HttpURLConnection connection = (HttpURLConnection)...

Adding a Pre-constructed Bean to a Spring Application Context

I am writing a class that implements the following method: public void run(javax.sql.DataSource dataSource); Within this method, I wish to construct a Spring application context using a configuration file similar to the following: <bean id="dataSource" abstract="true" /> <bean id="dao" class="my.Dao"> <property name="dataSource" r...

Implementing `hashCode()` for very simple classes

I have a very simple class with only one field member (e.g. String). Is it OK to implement hashCode() to simply return fieldMember.hashCode()? Or should I manipulate the field's hash code somehow? Also, if I should manipulate it, why is that? ...

Multiple Java installs on Windows

Can 32-bit and 64-bit Java be simultaneously installed on Vista x64? ...

Performing Optical Character Recognition on PDF's from Coldfusion using a Java or .NET Library?

I am looking to take a PDF and extract any text from it. I then want to make it available using Coldfusion's available Verity search to search the contents. Are there any libraries out there that do this quite well already? I am including Java or .NET (Java prefered) libraries in the scope since they can be called from CF. Any insigh...

Javadoc only one class in a package using Ant

I am using apache ant to generate javadoc for my project. I have a number of classes in one of my packages and I only want to show one. How do I do this? Here is my current code. <javadoc sourcepath="jig-engine/src" destdir="${target.path}/docs/javadoc/" packagenames="jig.engine.util.Vector2D" > </javadoc> (simplified for ...

What is the difference between instanceof and Class.isAssignableFrom(...)?

Which of the following is better? a instanceof B or B.class.isAssignableFrom(a.getClass()) The only difference that I know of is, when 'a' is null, the first returns false, while the second throws an exception. Other than that, do they always give the same result? ...

Modifying a set during iteration java

I'm looking to make a recursive method iterative. I have a list of Objects I want to iterate over, and then check their subobjects. Recursive: doFunction(Object) while(iterator.hasNext()) { //doStuff doFunction(Object.subObjects); } I want to change it to something like this doFunction(Object) iIterator = hashSet.iterator(); ...