Posts Tagged 'java&'

Jul

7

Play Framework,Java Web Applications Framework

Posted by kevin under internet, resource, technology - No Comments

The Play framework makes it easier to build Web applications with Java

A web app in 10 minutes using Play! from zenexity on Vimeo.

The Play framework is a clean alternative to bloated Enterprise Java stacks. It focuses on developer productivity and targets RESTful architectures. Play is a perfect companion to agile software development.

The Play framework’s goal is to ease web applications development while sticking with Java.

Play framework 1.0.3 documentation

Download Play Framework

Jul

13

SUN JDK 1.6.0_07 released.

Posted by kevin under other - No Comments

VisualVM

Java VisualVM is provided as part of this update release. Java VisualVM is a tool with a visual interface for viewing detailed information about Java applications while they are running on a Java Virtual Machine (JVM), and for troubleshooting and profiling these applications. Various optional tools, including Java VisualVM, are provided with Sun’s distribution of the Java Development Kit (JDK) for retrieving different types of data about running JVM software instances. Java VisualVM federates these tools to obtain data from the JVM software, then re-organizes and presents the information graphically enabling you to view different data about multiple Java applications uniformly, whether they are running locally or on remote machines. Furthermore, developers can extend Java VisualVM to add new functionality by creating and posting plugins to the tool’s built-in update center.

For more information about VisualVM, check the Product Documentation, the Project Home Page and Documentation Index.

Bug Fixes

This release contains fixes for one or more security vulnerabilities. For more information, please see Sun Alerts 238687, 238628, 238965, 238966, 238967, 238968, and 238905.

Nov

16

The Java Compiler API

Posted by kevin under technology - No Comments

The Java Compiler API
A Conversation with Peter von der Ahé
by Frank Sommers
April 3, 2007

Summary
Most developers think of the Java compiler, javac, as an unobtrusive command-line tool to invoke when you want to turn Java source code into class files. The Java Compiler API, JSR 199, released in final form last December, opens up the Java compiler to programmatic interaction as well. Artima spoke with JSR 199 spec lead and Sun engineer Peter von der Ahé about what programmatic compiler access means for developers.

Frank Sommers: Can you start by giving us a bird’s eye view of the JSR 199 API?

Peter von der Ahé: The JSR 199 Compiler API consists of three things: The first one basically allows you to invoke a compiler via the API. Second, the API allows you to customize how the compiler finds and writes out files. I mean files in the abstract sense, since the files the compiler deals with aren’t necessarily on the file system. JSR 199′s file abstraction allows you to have files in a database, and to generate output directly to memory, for example. Finally, the JSR 199 API lets you collect diagnostics from the compiler in a structured way so that you can easily transform error messages, for instance, into lines in an IDE’s editor.

Frank Sommers: How do you expect the Java Compiler API to impact developers’ work?

Peter von der Ahé: The main benefits to developers are indirect in that the JSR 199 API allows betters tools, better deployment time, and better infrastructure to exist.

For example, one of the benefits of having a compiler API is that you can make compilation part of an application-level service. Consider the case when you upload JSP code to an app server: The server has to analyze the JSP files, generate Java source code files from the JSPs, write those files out to disk, invoke an external compiler that then reads the generated Java source code files from disk, writes the class files back to disk, and then the app server needs to read those class files into memory. With the Compiler API, you can keep the compiler running in that app server, and keep all of that in memory. That can reduce deployment time, and also eliminates the startup overhead of the compiler.

To mention another example, say, you have an app server that stores most of its data in a database, and is highly optimized for database access. It is then natural to store not just the data, but also the program in a database. Before the Compiler API, you had to take the program data out of the database, put it on the file system, run the compiler as an external process, which would then have to start up, incurring a time overhead. And once you’ve generated some results, you’d have to copy those back into the database. The compiler API allows you to shortcut these steps, since it can consume files directly from the database, thus allowing better integration with the database.

Another benefit for developers is that IDEs and other developer tools can more tightly integrate with compilers. By using the JSR 199 API, you can invoke a compiler directly from within an IDE’s editor, or from build tools, such as Ant. Those tools then have a tighter control over the compiler. In an application area where compilers are used a lot, reducing the compile time significantly with the Compiler API can have a big impact.

As a result, I think the expectation from developers will be higher for tools that integrate with the compiler API. While I don’t think the Compiler API will fundamentally change how developers interact with their IDEs, it’s the combination of various subtle things the API allows that will make a lot of difference.

Frank Sommers: To what extent will that tighter compiler integration be available in the upcoming NetBeans 6.0 release?

Peter von der Ahé: Again, it’s a combination of small things that will make NetBeans 6 look very distinct from NetBeans 5 in the editor area. For NetBeans 6.0, we completely rewired the guts of the Java source code, using the compiler to implement the editor.

That means a couple of things. For example, we expect quick NetBeans integration of whatever new languages features will be put into JDK 7. Just what those features will be, is an open issue. But once those are implemented in the compiler, we expect that most of the new language features will work in NetBeans with not too much extra work.

Another thing is that simply more information is available about your program to the editor. For example, does a method override another method? Or how many times are these methods get overridden in subclasses? If you’re editing a superclass, you can see how many classes override a specific class or method. Code completion pops up faster, and there is less overhead.

Note that the compiler integration is just a means to an end. NetBeans 6 simply has a better Java source code editor. The details of how we achieve that just means that we’re working more closely together and provide more direct access to the underlying compiler.

I keep saying NetBeans, but there are other IDEs out there. All the changes we made to the compiler are in Java SE 6, and there are more changes to come, of course, as we move along. Those are out for everybody to use. But at the moment, NetBeans 6 is the only IDE I know that uses Java 6′s compiler features directly.

Frank Sommers: Based on your description, JSR 199 is really an API around the Java compiler. How deep inside the actual compiler can you get with this API?

Peter von der Ahé: Quite deep. JSR 199 works together with the annotation processing API, JSR 269, for instance, that presents a compile-time model similar to core reflection. Just as when running a Java program you can reflect on objects and examine the structure of objects and class files, the annotation framework allows you to examine the classes the compiler is compiling. That lets you get fairly deep into the compiler data structures.

In addition, Sun is providing access to the compiler syntax tree, a feature relied on very heavily by the upcoming version of NetBeans. While this is not directly in JSR 199, we’re providing that capability in subclasses of the 199 API. At the moment, this only works on Sun’s compiler, but providing standardized access to a tree API is something we might want to consider in the future.

Before we could think of a standard way to access the compiler tree, though, we needed to have access to the tree API first. In the past, we didn’t even provide a stable API to those internal compiler structures. Instead of trying to standardize on a tree API at this stage, we made a more stable version of the API. You can say that the tree API we’re providing now is a first try in that direction. At a later stage, we’ll have to reconcile differences between various compilers, and then we will perhaps look at proposing a standard API for syntax trees.

Frank Sommers: How does parsing work in the current compiler?

Peter von der Ahé: In JSR 199, there is a construct called a compilation task. If you access the Sun subclass of that class, then you get additional utilities from that subclass. One of them is to be able to parse files. You can specify files using the file abstraction from JSR 199. If you give a parse() method files in that form, that method returns a list of abstract syntax trees. You can then run through the syntax trees and analyze them in your program.

Note that the tree API we’re exposing is not mutable—you cannot change the syntax tree. Providing a mutable API for that would involve a lot of challenges, as we learned from experience with some NetBeans-related tools, notably the Jackpot project.

The Jackpot project learned that if you don’t allow modification of trees, but instead copy trees to a new version when you want to make modifications, then you can compare the old version of a tree to a new version. If a user later decides that a modification didn’t work, you can just throw away that modification, or the copy representing that modification, and go back to the old version. That turns out to be a great way to perform undo during refactoring. Actually, what Jackpot provides goes beyond refactoring—it’s more apt to call that code re-engineering. While the compiler doesn’t directly support this, Jackpot extends the compiler’s capabilities to recover trees in that manner.

Frank Sommers: You spoke before about the Kitchen Sink project that provides an experimental playground for new Java language features. If I have an idea for a great new Java programming language feature, what steps would I have to take to implement that feature in the open-source compiler?

Peter von der Ahé: When it comes to language features, the first thing you want to do is not touch the compiler. The really important part comes from first sitting down and thinking really hard about the specification of that change. Think about how you want certain things to work. Consider the various corner cases, and how you want to solve them.

That will give you a good starting point for language features, because you want to have fairly clear ideas how the syntax should look before you start modifying especially the parser. You want to think about whether there should be new types of syntax trees in the compiler so when the parser is analyzing the new language features, it could create those trees.

Once you have a good plan for what you want to do, it should be fairly easy to modify the parser. Note that we have a hand-written parser in javac, and that the compiler relies extensively on the visitor pattern. One of the things you need to decide is whether you’ll need to extend the visitors to support your new language feature.

Whether you are reusing an existing syntax tree or adding a new one, you will know where to look for changes once you figure out which syntax tree you’re looking at. You’ll want to go through all the phases of the compiler, and see what’s going on in each area. It’s not trivial, but it’s not as daunting a task as one might think.

It’s also possible to plug in a different parser. But then we’re not talking about a standard API any more, but about going in and making changes to the internals of the compiler—you’re off the beaten path, and things at that level may change as we change the implementation of the compiler.

Frank Sommers: The JSR 199 specs state that the compiler should generate a valid Java class. Can you modify the compiler so that you output something other than Java classes, even from Java source code? Likewise, can you modify the compiler to read in some other language and generate Java class files from that language?

Peter von der Ahé: You could probably use the compiler to read some other language, such as JavaScript, for instance, but then we get into details of our conformance rules, and what you can call Java and what you can’t call that. That’s really a legal issue that I would prefer to steer clear of.

We have discussed internally at Sun whether it would be a good idea to reuse compiler technology and implementations between the Java programming language, C++, and JavaScript, for example. One use of that would be in the NetBeans IDE. When you look at the Java programming language, C, and C++, they share to some extent certain traits. If you create a compiler that generates code in some intermediate format, as in GCC, then you can probably share some technology there, especially in the area of optimization in the back-end. However, when it comes to applications, such as IDEs, then the differences become more of a stumbling block.

In fact, such reuse was already tried, and we decided to stop doing that. You will see the benefits of not doing that once NetBeans 6 comes out, because the newly-implemented Java source code editor makes the Java editor very specific to the Java programming language. Separately, we can have a specific JavaScript editor. So it’s not as much reusing compiler technology, as it is re-using experiences.

I could imagine that if someone was writing a compiler for some scripting language to get it running on the JVM, they could reuse a few classes that make up the back-end of javac. But even then, they would have to do a lot of work, because javac is targeted only at generating class files from the Java programming language.

Frank Sommers: Sun open-sourced javac last November along with the JDK, and the JCP followed that with the final release JSR 199. Going forward, what upcoming compiler-related features are you most excited about?

Peter von der Ahé: Right now, I’m most excited about the community involvement. For example, with the Kitchen Sink project we talked about, the potential is really exciting: we have now a more open way to evaluate various language features, and see what works the best.

I’m also excited about some of the possible new language features for JDK 7 that the compiler will support. While no decisions have been formed on the exact set of new Java programming language features to ship in JDK 7, let me say that I’m very optimistic about closures, based on the proposal led by Neal Gafter. As with other new language features, it’s now possible to see how they’ll look in practice, since the open-source compiler makes it easier to build an implementation of those features.
Share Your Opinion

Have a question or opinion about the Java Compiler API? Discuss this article in the Articles Forum topic, The Java Compiler API.
Resources

JSR 199, the Java Compiler API

http://www.jcp.org/en/jsr/detail?id=199

JSR 269: Pluggable Annotation Processing API

http://www.jcp.org/en/jsr/detail?id=269

The OpenJDK Project’s javac section:

https://openjdk.dev.java.net/compiler/

The Kitchen Sink Language project:

https://ksl.dev.java.net/

Artima interviews Peter von der Ahé on the Kitchen Sink project:

http://www.artima.com/forums/flat.jsp?forum=276&thread=191274

NetBeans 6.0 Milestone builds:

http://www.netbeans.info/downloads/dev.php

Artima interviews Sun’s Tim Boudreau on upcoming NetBeans 6.0 features:

http://www.artima.com/lejava/articles/future_of_netbeans.html

Peter von der Ahé’s Blog:

http://blogs.sun.com/ahe/

Kin-Man Chung on Speed up JSP compilations in GlassFish with JSR 199 Java Compiler Interface:

http://blogs.sun.com/kchung/entry/speed_up_jsp_compilations_with

Interview with Jackpot Team Leader Tom Ball

http://www.netbeans.org/kb/articles/tom-ball-interview.html

About the author

Frank Sommers is a Senior Editor with Artima Developer. He also serves as chief editor of the IEEE Technical Committee on Scalable Computing’s newsletter, and is an elected member of the Jini Community’s Technical Advisory Committee. Prior to joining Artima, Frank wrote the Jiniology and Web services columns for JavaWorld.

Nov

16

Continuations in Java

Posted by kevin under technology - No Comments

A Conversation with Geert Bevin
by Bill Venners with Frank Sommers
March 1, 2007

Summary
Continuations refer to a functional programming technique that allows you to save the current execution state of a thread, with the possiblity of suspending and later resuming execution. Continuations have been incorporated into several Web application frameworks, including RIFE and WebWork. In this interview with Artima, RIFE project founder Geert Bevin discusses how continuations can simplify complex workflows, and how they are implemented in RIFE.
Geert Bevin is the creator of the RIFE Web application framework, and is founder of Uwyn, a Belgian consultancy. One of RIFE’s more innovative features is an implementation of continuations in pure Java, a technique especially suitable for workflow-like applications, such as Web-based forms. Bill Venners spoke with Bevin at the 2006 JavaPolis conference about how continuations can help developers simplify complex workflows.
Continuations explained

Bill Venners: What are continuations?

Geert Bevin: A good way to think about continuations is to consider what happens when you save the state of a computer or online game. Most games allow you to halt at any time, save away the state of that game, and then start the game up again. They let you save and restart a game as many times as you like. And some games go even further: if you took a wrong turn somewhere, you can go back to a previously saved game, and take another direction.

Continuations offer a similar benefit in the context of Java Web applications. Instead of creating an external control flow as individual steps that are tied together with navigation rules or state transitions, continuations provide a much simpler model—almost as simple as if you were doing console programming in the early DOS days.

With continuations, when you need to get a response from a user, you only need to say so: the execution of the server-side process will then halt and preserve everything that is going on for that particular process. When the next request from the user comes in, the server-side process resumes exactly where it left off before. It’s just like when you save and resume a game.

Continuations free you from having to worry about where you are in the process, or what next steps you can take, or which elements of the session are entered into at what point in the execution. Continuations handle that for you automatically. Since you have all those previous continuations—saved games, as it were—when the user presses his browser’s back-button, continuations automatically handle the fact that a previous state corresponds to that back button click. That makes Web applications more usable and behave more as the users expect.

The way that works is that continuations let you save the method call stack as well as the variable stack. In the Web application context, you don’t capture everything, of course, because everything would mean capturing the startup of the servlet container and so on. What you do capture is the execution of a particular action on the server. There is a point from which you start capturing. We call that a partial continuation, because it only captures the method call stack and variable stack from a certain point onwards.
The implementation of RIFE continuations

Bill Venners: How does that work in the implementation?

Geert Bevin: Java doesn’t support this natively. The JVM does something like what I just explained internally, to be able to handle exceptions, for instance. But the VM doesn’t expose any of that data to developers.

The only way to access that information currently is to re-write the bytecode that gets loaded into the VM. What we currently do in RIFE is that at class-load time we detect pause() method calls in a class. These act as a markers. The class loader will detect these markers and then modify the bytecode to actually aggregate that information in parallel to how the JVM tracks the method call stack and variable stack.

The continuations infrastructure maintains a parallel stack that references the actual data. The mechanism is quite light, because you don’t store the actual data twice in memory: you create references to the actual stack data in building up that parallel stack. When a continuation is to be preserved, the state of that parallel stack is preserved.

The bit of overhead that occurs is the result of the fact that you typically make a deep clone of the actual data at the next continuation. This is needed because each continuation needs to be totally independent of another one. To return to the game analogy, it would be strange if potions you drank in the last saved game were also gone from earlier games—that data needs to be saved independently of earlier instances.

The only restrictions developers have in using continuations is that the data structure must be cloneable or serializable so that the infrastructure can create carbon copies of those data structures. However, even that’s not mandatory, and is only required when you want that previous state functionality to work—which is what you typically desire in a Web application to make the back button work.

People are using continuations in other application domains as well where they don’t want those previous versions around. A good example is an event-driven system where you have agents polling for state changes. When some state changes, you continue the execution. Systems like that can be heavily optimized with continuations, and people are starting to adopt RIFE continuations for event-driven systems for that reason.

In event-driven systems, when you arrive at a certain point where you need to have a trigger in order to continue, you create a continuation, and stop the execution. You don’t have any polling at all. The only thing you have is an event that wakes up all the related continuations. You can then start executing until the next point when you need to have more information available from an additional event. That creates a lot less CPU overhead, and performs much better than the alternative polling-based approach.

Bill Venners: Let me see if I can paint this picture: I am using RIFE, and a request comes into the server, and a thread gets taken out of the pool and starts handling that request. At some point, as the call goes down a call stack, that call is going to hit the starting point of your partial continuation. You’re going to start making a companion stack object of some kind. You have instrumented those classes, those controllers…

Geert Bevin: We call them elements, but in WebWork they call them actions.

Bill Venners: So those elements have been instrumented such that when there is a method call to process the request, and that method starts changing local variables, you just figure out what the local variables are and reference those from the parallel stack.

Geert Bevin: At the byte-code level, when the method pops variables from the stack, exactly the same operation will be performed on the parallel stack. We just add a piece of byte code that mimics what goes on exactly. Then, when a continuation has to be resumed, there’s a bit of added byte-code that interacts with the state of the stack, and puts all the variables in the correct location so that they are present when the executing thread passes that point. At this point, it’s as if nothing happened—execution resumed as if nothing happened.

The second problem is how to arrive at the point to resume a continuation. You want to skip over code that you don’t want to execute. That’s easily done in byte code, because you can maintain a tableswitch in byte code that allows you to jump to a particular location. You can create a unique label for each continuation point, jump to that label in the switch table, and then you know exactly what the stack for that label of variables was. You can restore that stack, and continue executing from that point on.

I should mention that there are several ways to use continuations. In Web development you are mostly interested in pause(), which means you arrive at a particular point, and want to continue from where you left off.

A second possibility is a call-answer continuations. With call-answer, you have a method call that calls another element or action. An example is in creating modal dialogs. Suppose you have a delete screen where you ask the user, “Do you really want to delete this entity?” You want to make sure that’s want they really want to do. You pause the execution of the original intent, which was to delete that entity, and start another action. If the user presses “Yes,” that will result in a true variable as a response to the original execution. The delete action will then receive the true or false answer from the call and continue execution from where it left off.

A third possibility is step-back continuations. That allows you to easily step back to a previous continuation without having to use a browser’s back button. You typically use this in wizards, when you want to provide a back button on the form itself and not rely on the browser’s back button. For that, we rely on the previous snapshots. That’s why we have three different method calls: pause(), call(), and stepback(); and not just one yield() method.

Bill Venners: When I call one of those methods, how do you go back? Do you throw an exception?

Geert Bevin: We throw an Error because almost nobody catches errors until the point where the Web framework starts to execute that action. Control goes back to the initial execution point that catches the error, and then we know exactly where we need to continue from. The continuations manager will then be consulted to make sure that the required continuation is stored away and is available for re-use afterwards, when the next request comes in.

Each continuation has its own unique ID that has been preserved either through a hidden parameter or a query string parameter. When that ID comes in, the Web framework finds out that continuation ID, fetches the corresponding continuation data from the continuations manager, knows that it has to restore that continuation, and jumps over the code to restore the specified continuation.
Continuation IDs

Bill Venners: I’d like to understand the mechanics of how that ID comes back from the client. Is it in the URL?

Geert Bevin: You have unique IDs for each individual continuation step. They can come back in any way, even in an email message event. Suppose you have a system where a confirmation email is sent to make sure the person really is who he says he is, and a reply is expected within a certain time-frame, say within thirty minutes.

You just send that ID as a query parameter in the confirmation URL the user has to click. When that ID comes in, it is looked up in the continuation manager, which then resumes the execution of the continuation referenced by that ID. If the user doesn’t access that URL within thirty minutes, the continuation corresponding to that ID will be flushed away automatically by the continuation manager and that code can’t be resumed anymore.

I want to stress that in the continuation programming style, everything is a continuation. You’ve got snapshots at each individual step of execution. By putting in those method calls, such as pause(), you indicate one specific location you’re interested in.

To make that practical, the code that leads up to that method call has access to the unique ID of the upcoming snapshot. Because you know what that unique ID is going to be, you can already add that ID to a form as a hidden parameter. If that ID was not available in advance of the start of the continuation, you would not be able to add that ID to a form: when execution hits that pause() method call, it stops. Everything you need to show the user must already have been sent through the output stream of the servlet container.

Bill Venners: Is it the continuation manager that manages those IDs completely separate from the session? If so, how do I replicate the continuation manager’s state, if I want to have stateful fail-over?

Geert Bevin: Currently, we’re working on one solution, and that’s using Terracotta DSO, which is open-source now. I’m collaborating with Jonas Bonér to make RIFE continuations work seamlessly with Terracotta DSO. We’re still tackling a problem that’s not related to continuations per se, but to RIFE. As a framework, RIFE is extremely dynamic. For example our template classes are usually created on the fly. Terracotta has to have access to all the class files to be able to replicate the data. So we’re still figuring out a mechanism for how we can do that with run-time generated classes. We’re expecting to finish that work very soon.
The usefulness of continuations

Bill Venners: The general continuations selling point is that continuations provide a simpler programming model to make a loop: If there are 28 steps to a process, and you want to be able to go back and forth between those steps, continuations promise to make that easier. Without them, you have to have a state transition diagram, and for each of those 28 steps possibly a controller, too. But how often are loops really that complicated? How useful are continuations in practice?

Geert Bevin: It really depends on the kind of Web sites you’re building. For a public Web site with pages that people just read most the time, you don’t need continuations. There is no point. But if you’ve got what I call islands of functionality—a transactional process a user has to go through—and that only can complete when the user finished all the steps, continuations make that extremely easy to program. Examples are a checkout process, a questionnaire, wizards, stuff like that.

With continuations, you just program the process steps in Java, use the native Java control statements, and then put the pause() method calls whenever you need interaction from the user.

The additional benefit, which sort of blows people away when I demonstrate it, is that you can debug you flows with a regular Java debugger. You can set your breakpoints within your implementation and step through to see exactly what happens. You can set watches, breakpoints, conditional breakpoints, logging breakpoints, everything just works. When you have very complex flows, you can benefit from all the tools you’ve used to using to debug the Web application flow.

Continuations also provide a natural way to solve the double-submit problem: In transactional processes, such as a check-out process, you don’t want a submission—an order, for instance—to pass through a second time.

Continuations solve that easily. You typically have a continuation tree. Most of the time that will just be a linear succession. But if people press the back button and follow another trail, you have a tree. At the end of the process, you know which tree you’re in. When that transactional process finished and the order has been placed, you just remove the tree.

When a person presses the submit button again, or pushes the back button, or does anything with the previous state, that will just not work, because you can’t resume a continuation that’s no longer there. Then you can show a message such as, “Please start a new order.” There is no longer a risk of re-doing that processing. It’s supposed to be transactional and occur only once.

Bill Venners: Is there a method call in the API to say “Start a tree?” If I start a tree at some point, and they back out past the start of that tree, and then go forward again so they are not part of that same tree, how do I know what to delete?

Geert Bevin: As long as you’re resuming a previous continuation, our implementation keeps track of all the relationships. If you don’t resume from a previous continuation, then you just start at the beginning: that will be a new checkout process, because the user will not be in the middle of something.

For each execution thread, there is a thread-local variable for the active continuation. You can just walk through data structures to figure out all the related continuations and their siblings. In the case of the check-out process, you walk through and delete the whole tree at the same time. There is a static removeContextTree() method on what we call ContinuationContext class.
Continuations in Jetty

Bill Venners: Jetty provides some kind of continuations framework, too. How does that compare with RIFE’s?

Geert Bevin: Jetty does what I’d call request-thread parking. Instead of tying up a socket on your servlet container for a long-lived operation—an asynchronous operation, for example—Jetty frees that socket up with some kind of a continuation, and re-activates that thread again when the result arrives.

Jetty’s mechanism is similar to the event-based programming model I was talking about earlier. The benefit is that you free up resources while you’re doing the calculation. What Jetty does can be implemented with continuations, but are not real continuations. Jetty doesn’t need to capture the state of a continuation, it doesn’t need to be in the middle of a method and capture everything that surrounds that execution. Jetty just has to resume another servlet execution thread, and know where to pick up execution.

Bill Venners: You mean the thread is in a wait state, and doesn’t get released?

Geert Bevin: I can’t remember exactly what the Jetty code does, but I know that it does just what is needed for that use-case. I know that Joe Walker has been trying to use that to add continuations to DWR and has had problems because it really didn’t provide everything that was needed.
Standardizing continuations

Bill Venners: In your talk, you mentioned about a possible JSR proposal, a way to standardize continuations. Can you tell us more about that?

Geert Bevin: There are already several implementations and approaches to continuations, depending on the use-case. There is an Apache Commons project, JavaFlow. There is JauVM that layers another VM on top of the JVM to support tail-calls and continuations. Given that there are all these efforts, it’s important to standardize the API from a library and framework developer’s standpoint.

That means standardizing on an interface to capture that local variable stack and execution stack. Since the JVM doesn’t implement that yet, any implementation underneath is very targeted to your problem domain. Longer-term, the JVM would ideally open that access up.

The approach is to create a JSR to provide continuations functionality with a common API that will initially be implemented through simulated layers, as we’re doing it now with bytecode re-writing in RIFE. When developers show enough interest in it, we can create a push to add to the JVM what is needed. To propose additions to the JVM now would be premature.

At all the conference talks I’ve been giving, I have a lot developers come up to me, saying that they want to use continuations, but can’t, because the current implementations require an alternate library that does bytecode re-writing, something they would never be able to get into their projects. Having a common API that has been standardized through a JSR would make it much easier for them to use continuations as part of their working tool set.

I started to write a draft for the JSR proposal in November. That draft is available on a Wiki at http://rifers.org/continuations/jsr. There are already comments that resulted in changes to the Wiki text, and a lot of people in the Web development space have committed to be part of the initial expert group, if the JSR is accepted. For example, Patrick Lightbody of WebWork, Joe Walker from DWR, Alexandru Popescu who created the software behind the InfoQ Web site.
Trying out RIFE continuations

Bill Venners: So if I want to try this out, what do I do and where do I go?

Geert Bevin: The RIFE project Web site has more information, especially in the RIFE examples section. Two of those examples are especially dedicated to continuations [Editor's note: examples 4 and 8]. There are also videos in the theater section of the site that provide more examples.

In the coming weeks, I will be updating the standalone RIFE Continuations library to have the same capabilities as the framework itself provides. Developers will then be able to try it out in situations that don’t involve Web application development.
Share Your opinion

Have a question or opinion about Continuations in Java? Discuss this article in the Articles Forum topic, Continuations in Java.
Resources

The RIFE project home page:

http://www.rifers.org/

About the author

Bill Venners is president of Artima.

Nov

16

Compass : Java Search Engine Framework

Posted by kevin under resource - 1 Comment

Compass is a first class open source Java Search Engine Framework, enabling the power of Search Engine semantics to your application stack decoratively. Built on top of the amazing Lucene Search Engine, Compass integrates seamlessly to popular development frameworks like Hibernate and Spring. It provides search capability to your application data model and synchronizes changes with the datasource. With Compass: write less code, find data quicker.

As of version 0.8, Compass also provides a Lucene Jdbc Directory implementation, allowing storing Lucene index within a database for both pure Lucene applications and Compass enabled applications. Note, when using Compass, using a database as the index storage requires only updating configuration settings.>>Reference Documentation

Nov

16

Java BluePrints Solutions Catalog

Posted by kevin under technology - 1 Comment

AJAX uses JavaScript in an HTML page to make asynchronous calls to the server from which the page loaded and fetch an XML document from a server-side component asynchronously. Upon completion of a request JavaScript may update or modify the Document Object Model (DOM) of the HTML page based on the resulting XML document. Only the affected portions of the HTML DOM are are re-rendered in the HTML page. The term Asynchronous JavaScript and XML has emerged recently to describe this interaction model.

For a detailed explanation of AJAX, please see Using AJAX with the J2EE platform. If you are new to AJAX, we recommend that you read that document before reading the following solutions.

Note that AJAX is an emerging technology, and hence the solutions presented here are likely to change as best practices emerge.

This category presents some solutions for using AJAX when developing Web applications with the J2EE platform:

  • Auto-Complete: Provide a simplifed means of data navigation as the user enters a request in an HTML form.
  • Progress Bar: Track the progress on the client of a server-side operation without refreshing the HTML page.
  • Progress Bar JSF: Track the progress on the client of a server-side operation without refreshing the HTML page, presented as a JSF component.
  • Realtime Form Validation: Perform server-side validation of form data in an HTML page without refreshes.
  • Refreshing Data: Provide up to date data to the an HTML page.

From:https://bpcatalog.dev.java.net/nonav/ajax/index.html

Nov

16

Apache Lucene (JAVA) v2.1 released

Posted by kevin under news, technology - No Comments

The Apache Lucene Project has released the version 2.1 of Apache Lucene (JAVA). This release has many improvements since release 2.0, including new features, performance improvements, bug fixes, etc. 详细信æ¯è¯·çœ‹ï¼š CHANGES.txt
Apache Lucene 2.1 includes index format changes that are not readable by older versions of Lucene. Lucene 2.1 can both read and update older Lucene indexes. Adding to an index with an older format will cause it to be converted to the newer format.

Binary and source distributions are available here.

Nov

16

Better SQLExceptions in Java 6

Posted by kevin under technology - No Comments

Welcome to the 138th edition of The Java(tm) Specialists’ Newsletter, where we will look at new features of JDBC 4 that will help you to understand what went wrong with your database queries. I remember cornering Mark Hapner in 1999 when he visited Cape Town and presenting this problem to him. Mark Hapner was the architect for the first JDBC version and went on to architect J2EE and EJB. At the time, there was no easy solution to this problem.

Better SQLExceptions in Java 6

Many years ago, I mentioned in a newsletter that when a SQLException occurs, we do not necessarily know what went wrong. It could be a temporary failure or a permanent fault. The SQL could contain a syntax error (permanent fault) or the database could be rebooting (temporary fault). I promised to write up a newsletter on how to solve this, but never got round to it.

Previously, these faults could be determined by looking at the SQLState contained in the exception. However, I thought that the JDBC driver should do this analysis and give me more specific information about what went wrong.

In JDBC 4.0, which ships as part of JDK 6, we now have a solution that will make it easier to write robust code for communicating with the database.

Instead of just having a single SQLException telling us that there is “a problem”, we have three new subclasses, namely SQLNonTransientException, SQLTransientException and SQLRecoverableException. These sub-exceptions are called “categorised exceptions”. It can now be possible, if the driver supports JDBC 4, to decide whether we should retry immediately, retry later or give up altogether.

Read more here

Nov

15

froglogic Releases Automated Java GUI Testing Tool Squish/Java

Posted by kevin under resource, technology - 2 Comments

Hamburg, Germany – 2007-01-31 froglogic GmbH today announced the first release of Squish/Java. Squish/Java is a new edition of the powerful, automated GUI testing framework Squish. This new edition features the automatic creation and execution of tests for Java Swing, AWT, SWT RCP/Eclipse applications.
Squish is the leading, cross-platform and cross-browser automated GUI testing tool for applications based on a variety of GUI technologies such as Trolltech’s Qt library, Web/HTML/Ajax, Tk, Four J’s Genero and XView.

The new Squish/Java edition is based on the recently released version 3.1 of Squish and takes advantage of its mature testing framework while adding support for the standard Java GUI technologies Swing, AWT, SWT and Eclipse Rich Client Platform. Java classes, functions and fields are dynamically exposed as script interfaces in Squish thus enabling the development of sophisticated automated tests.

“We are very excited about this new release which is already in use by first customers. With Squish/Java we cover another major GUI technology after already supporting technologies such as the Qt toolkit and HTML and Ajax Web applications. This will further strengthen our leading position in the cross-platform GUI testing market”, said Reginald Stadlbauer, CEO and co-founder of froglogic.

Squish offers a versatile testing framework with a choice of popular test scripting languages (Python, JavaScript, Tcl and Perl) extended by test-specific functions, open interfaces, add-ons, integrations into test management systems, an IDE that supports the creation and debugging of tests and a set of command line tools facilitating fully automated test runs.

Similar to preexisting Squish editions, tests for Java applications can be automatically recorded or written manually. Using Squish Spy, verification and synchronization points can be inserted as easily as in every other edition by visually exploring the structure of a Java application.

Squish/Java packages are available now. If you are interested in evaluating Squish/Java, or any other Squish edition, please visit http://www.froglogic.com/evaluate or contact squish@froglogic.com. For more information, visit http://squish.froglogic.com.

About froglogic
froglogic GmbH is a software company based in Hamburg, Germany. Their flagship product is Squish, the market-leading automated testing tool for GUI applications based on Qt, Tk or XView and for HTML/Ajax-based web applications running in different web browsers. froglogic also offers services in the areas QA/automated testing and Qt C++ programming and consulting. More about froglogic at http://www.froglogic.com.

Nov

15

Java News Predictions for 2007

Posted by kevin under resource, technology - No Comments

Here are my top ten predictions for Java in 2007…

10. NetBeans IDE Platform will be divided into NetBeans Enterprise Edition, Standard (or Desktop) Edition, and Mobile (or Micro) Edition. NetBeans will continue to gain market share against Eclipse, but Eclipse will maintain a slim market share lead by year’s end.

9. JBoss Seam framework will become nearly as popular as Spring Framework, in terms of market share, adoption, etc.

8. Hibernate has matured, and will likely be “retired†by Red Hat JBoss; but it will remain the de-facto industry standard for Persistence engines until broader frameworks Spring and JBoss Seam persistence offerings take hold. Technology to watch: Apache OpenJPA.

7. Java Web frameworks consolidation: the winners will at least start to emerge in JRuby (Ruby on Rails on JVM), Grails, JSF/Apache MyFaces, and Struts Action Framework 2.0. Technologies to watch: Java Web Parts and maybe RIFE.

6. Java EE 6 alpha code drop will take place at/around JavaOne; and will be offered under GPL license initially in incubator.

5. Sun’s Jini, OpenSolaris, GlassFish, and NetBeans will become official Apache projects, while Java.net will remain the incubator for nascent open source Java projects from Sun.

4. IBM acquires Interface21 and the Spring Framework; will create super enterprise development and deployment framework stack with Spring Framework (w/scripting extensions using Groovy/Grails), Apache Geronimo, and, of course, Eclipse. May lead to a commercial version as well as open source community edition.

3. Sun will acquire the rights to Java.org through acquisition, and use this as their primary portal to all things open source Java, mostly nascent open source Java projects and RSS feeds to their other more mature projects on Apache.org.

2. Oracle merges with/acquires Red Hat (includes JBoss) as the “dance†has already begun with Oracle Linux which is based on Red Hat Linux, past Oracle-JBoss interest and discussions, etc.

And number…

1. HP looking to be relevant again, beyond printers, may acquire/merge with BEA Systems, Inc. which would give them top-down, top-notch complete software solution stack to bundle with their servers. HP currently does NOT have an in-house software stack solution like IBM, Sun, etc. This may also give HP access to a broader and more appropriate customer base…

We’ll see. Enjoy the New Year!