java

How do you robustly implement a REST service that retrieves DB records then purges them before returning ?

Scenario Imagine a REST service that returns a list of things (e.g. notifications) Usage A client will continually poll the REST service. The REST service retrieves records from the database. If records are available, they are converted into JSON and returned to the client. And at the same time, the retrieved records are purged from the...

JAVA - Validation in JTable

I am trying to validate a cell in the JTable as soon as the data is entered. I want to make sure that say the correct code is entered in the code column. Could anyone let me know how to do this please? Thanks ...

Tool for validating generics in Java <1.5

Is there a tool that would allow me to check use of generic collections in code that must be compilable with Java 1.4? I would imagine example code as: Map/*<String, Integer>*/ map = new HashMap(); map.put("abc", new Integer(3)); // ok map.put("def", "ghi"); // warning EDIT: Unfortunately the build process is "set in stone" to use J...

Spring security pre-authentication for development mode

While developing an application it's quite useful to be able to quickly login as different users, with different roles, to see how the application presents itself. Typing usernames and entering password is no fun, and a waste of time. What I'd like to do is: add a page/panel with a list of available usernames; clicking on a username w...

Standard Entitlements Model

I am currently building a Java financial application that I need to add entitlements to, and was wondering what approaches people have taken to solve this problem, and whether there are any third party Java libraries that people would recommend. Currently I have a number of users that can be broadly categorised into roles (e.g. "trader"...

Identifying last loop when using for each

I want to do something different with the last loop iteration when performing 'foreach' on an object. I'm using Ruby but the same goes for C#, Java etc. list = ['A','B','C'] list.each{|i| puts "Looping: "+i # if not last loop iteration puts "Last one: "+i # if last loop iteration } The output desired is equivalent to: ...

Why does ExecutorService deadlock when performing HashMap operations?

When running the following class the ExecutionService will often deadlock. import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ExecutorTest { p...

weblogic startup problem

hi i am using weblogic 8.1 with myeclipse 6.0 when i am trying to run weblogic server it asking for config.xml in mydomain directory and i am trying to boot with default configuration than it throwing exception "Exception raised: 'weblogic.management.configuration.ConfigurationException: Passwords do not match, unable to generate defau...

signed applet gives AccessControlException: access denied, when calling from javascript

I have an easy self-signed an applet (done with keytool and the jarsigner): public class NetAppletLauncher extends JApplet { private static final long serialVersionUID = 1L; public void init() { exec("notepad c:/hello.txt"); } public void exec(String command) { try { // launch EXE and grab stdin/stdout and stderr Proc...

Problem with Showing Records in Jtable

I am using DefaultTable Model for showing my records in Jtable.But there is a problem like in the picture.When i load jtable its showing like LJava.lang.Object type. NOT in string..How can i solve this. Here is my codes ; EntityManagerFactory emf = Persistence.createEntityManagerFactory("SwingDenemePU"); EntityManager em = emf.createEn...

how to send an image file over network using socket channel

I have created server program which will send an image file to the client. My program works fine if the image is of 512 byte. But it does nit work fine for large file. In this case i am not getting the exact image that i am supposed to get. means my recovered image is in some improper manner. So how to solve this problem I am using jav...

adding jar files in netbeans rmic tag

I am using rmic in netbeans to generate stub and skeleton files.Herewith I have provided the tag, I'm using in "build.xml" in netbeans 6.5 <rmic base="${build.classes.dir}" classname="packageName.RmiServerClassName"/> "RmiServerClassName" class is using some external jar files.I already have added the external jar files by using Proje...

JTextArea alignment

any method available to place the JTextArea to the right of the JPanel?? ...

Inheriting and encapsulating collection classes in Java

Suppose I have the following types of data: class Customer { String id; // unique OtherCustData someOtherData; } class Service { String url; // unique OtherServiceData someOtherData; } class LastConnection { Date date; OtherConnData someOtherData; // like request or response } Now I need to remember when each of the cust...

SOAP API C# or Java for pre-made XMLs

Is there any SOAP API that receives pre-made XMLS and wrap them with SOAP envelope (put the XML in the SOAP body/header as needed)? I need the functionality of wrapping up XMLs with SOAP envelope directly without any object model manipulations (like SAAJ do). 10, O'shea ...

Web form data structure alternatives

Once I created a form builder where user could select any number of fields for a web form. The tool then produced a code snippet which user could copy in the JSP. The submitted form data was stored as a key-value pairs in the DB, so basically just two columns were required for the form specific data. If I remember right, the processing ...

STXXL equivalent in Java

I'm searching a collection framework designed for huge datasets in Java that behaves transparently, like STXXL does for C++. It should transparently swap to disk, but in a much more efficient manner than plain OS-based VM swapping. A StringBuffer/String drop-in replacement would be a big plus. ...

Why is the "terminal speed" of a native linux telnet client 0,0 when spawned from Java (and how can I fix it)?

I'm unable to login to an HPUX host using telnet when the telnet process is created by a Java program. When I telnet to the HPUX host from the command line (from bash), I am able to login and use the session. When I spawn the telnet process from Java, something strange happens. I am prompted for the username and submit it. I also get t...

Problem retrieving properties file from webapp in tomcat

Hi, I've developed a web application that worked fine in JBoss 4. Now, I need to make it work in Tomcat 6, but I'm having trouble to access some properties file. I use the following code to read read these files: InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(fileName); if (is == null) { ...

how to setup log4j to specific file for each error / warning/ info (in grails)

Hi, I am little bit confuse about log4j in grails. I need to log info into info.log, error into error.log and warning into warning.log if possible, all the files (info,warning and error) should be placed into web-app/ so that i can do check via internet (vpn) can someone help me to do that ? ...