java

Java: implementation of notification provider vs. hashCode-driven Map

I have implemented abstract generic provider for notification bunch of generic listeners E, descendants have to override notifyListener(E) with specific notification code. For backing list of listeners I choose WeakHashMap<K,V>. Listeners must be held as weak references: abstract public class NotificationProvider<E> { private Map<E...

How to use an incremented counter to provide a unique id in XSLT?

I am using XSLT to convert a very large XML document into (X)HTML. For some of the tags I am converting them to a <div>. I would like to be able to create a unique id for these tags, using an incremented integer to form part of the unique id. An example of the rule I am using is: <xsl:template match="bookcoll/book"> <div class="b...

Which is the best Java REST API - Restlet or Jersey?

Which REST API do you prefer - Jersey or Restlet? This would encompass both the client and server API-s. We really need to just pick one and kick the tires around but I was curious what the community thinks. Restlet seems simpler and better documented to me. I've had a hard time even finding decent documentation about the Jersey clie...

Using two different databases with identical hibernate mapping files

Basically the idea is to use the same hibernate mapping files for two different underlying databases. In production the underlying database is MySQL5 and for testing purposes I'd like to use Apache Derby - in order to avoid setting up and maintaining various MySQL databases for testing purposes. I hoped that just switching the DataSour...

Database not dropped in between unit test

Hello good people i came accross a weird behaviour in my test.I'm using JPA hibernate annotation with spring. let say i have an Class MyObject and it's property email is marqued @Column(name="EMAIL", length=100, unique=true) private String email; i prepare for what i need to be in the database in the setup of this class MyObjectDAOImp...

Privileged operations in netbeans mobility

I'm writing a Java ME app that will use privileged operations such as messaging. By default the user is prompted to confirm each of these operations, but I would like to run it as a background service. Documentation says to request permission in the jad file, I have done so and presume it will work on a device. However I would like to...

print query string in hibernate with parameter values

Hi Is it possible in hibernate to print generated sql queries with real values instead of question marks? How would you suggest to print queries with real values if its not possible with hibernate api? Umar ...

Web service frameworks for Java 1.4?

We want to implement web services on our Weblogic 8.1 Java 1.4 application. We want to create new server services and call services in other apps. And we need to stick with Java 1.4 (for now). Due to 1.4 we can't use frameworks like Restlet or Jersey. Are there any good web service (preferably REST) API frameworks that support Java 1...

iBatis not populating object when there are no rows found.

I am running a stored procedure that returns 2 cursors and none of them have any data. I have the following mapping xml: <resultMap id="resultMap1" class="HashMap"> <result property="firstName" columnIndex="2"/> </resultMap> <resultMap id="resultMap2" class="com.somePackage.MyBean"> <result property="unitStreetName" column="street...

OPEN MQ - Help with asynchronous

Hi guys, I'm testing open MQ for send and receive messages in my project. I have no problem to configure it to send a synchronous message, but i can't find any way in the official documentation to configure the message to be consumed 15 minutes after the producer send a message, and continue call the consumer if an error appears. offic...

Two Viewports using Java2D

This is sort of a homework question, however no expectations for code or whatever just an idea or hint towards the following problem. I have a set of cubes in 3D world coordinates and i have to display them using two projections in two separate areas, parallel and perspective. The parallel went fine, no problems there, however displayin...

Submitting FutureTasks to an Executor - why does it work ?

I have the following test code. import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.FutureTask; class MyTask extends FutureTask<String>{ @Override protected void done() { System.out.println("Done"); } public MyTask(Runnable runnable) { super(runnabl...

Finding the application support directory on OSX in java

I would like to store some files in the application support directory is there some system call to retrieve this directory? ...

Write once, run anywhere languages & Unrar for AIR

I wanted to ask if there are any other Write Once, run anywhere languages like Java or AIR. I have mostly been a Java developer up till now, and a bit of Python and recently AIR has peaked my interest as I just found out about it. Also I wanted to know if there are any unrar libraries for AIR or someway to read RAR archives with AIR, ki...

A server side component for tracking a large number of RSS & Atom feeds

I am looking for an open source component that can help me track a large number of RSS feeds (>> 10K RSS sources). I don't care about the programming language, but it should be something with a simple API where I can add or remove RSS feeds and asynchronously receive notifications every time an RSS is updated. Preferably in Java or Pyt...

Reading content of URL in java - redirect problems

When I execute the following java program, sometimes I get an empty response, sometimes I get the real (redirected) content. ByteArrayOutputStream output = new ByteArrayOutputStream(); URL url = new URL( "http://stackoverflow.com/questions/84629" ); IOUtils.copy( url.openStream(), output ); System.out.println( output.toString() ); The...

JUnit View in Eclipse on OSX Snow Leopard

I recently purchased a mac and am trying to get junit tests working on Eclipse. I am using the latest Galileo, but for some reason there is no option to "run as junit" on the tests. What am I doing wrong? There's no JUnit view panel either. However I went into the "About Eclipse" thing and it said JUnit is installed. I also port installe...

Starting a .app file from java

I need run a system call to run a .app file from java. Any ideas? ...

Removing access to System.out in java

I maintain an application which acts as a container for multiple individual programs. These programs have their own dedicated logging facility, i.e. everything they log does to a special log file. Nevertheless, application developers seem to love to throw System.out.println and e.printStackTrace calls all over, making it impossible to m...

Limitations of exposing Java web services using javax.xml.ws.Endpoint?

I am trying to expose some Java web services so that I can interoperate from C# (see this SO question). The proof of concept code below works great with WCF! My question is about the use of the javax.xml.ws.Endpoint class to publish my service: What do I forfeit by going this route instead of a full-blown application server? Is ...