Kilim is a message-passing framework for Java that provides ultra-lightweight threads and facilities for fast, safe, zero-copy messaging between these threads.
It consists of a bytecode postprocessor (a "weaver"), a run time library with buffered mailboxes (multi-producer, single consumer queues) and a user-level scheduler and a type system that puts certain constraints on pointer aliasing within messages to ensure interference-freedom between threads.
http://www.malhar.net/sriram/kilim/index.html
Tags: API
ItsNat: Natural Ajax
ItsNat: Natural Ajax. Component Based Java Web Application Framework
ItsNat is an innovative open source Java AJAX Component based Web Framework, it offers a natural approach to modern web development.
Why natural? ItsNat leverages the old tools to build the new AJAX based Web 2.0 applications: pure (X)HTML and pure Java W3C DOM!
ItsNat is server centric using a unique approach called TBITS, "The Browser Is The Server". ItsNat simulates a Universal W3C Java Browser at the server, with ItsNat the server mimics the behavior of a web browser, containing a W3C DOM Level 2 node tree and receiving W3C DOM Events.
Core features
ItsNat provides many more (core) features:
- Client to server synchronization
- Web-continuations ("continue" events)
- User defined event types
- Timers
- Long running server tasks
- COMET without special application servers
- DOM utils (to simplify DOM manipulation)
- Resolution of ${} based variables in markup
- ElementCSSInlineStyle support in the server
- Automatic page remote/view control of other users/sessions!!
- XML generation
- Non-HTML namespaces support like pure SVG with AJAX and SVG embedded in XHTML
- JavaScript generation utilities
- Events fired by the server sent to the client simulating user actions for instance to test the view from the server
- Custom pretty URLs
- Previous/forward document navigation (pull and push referrers with back/forward button support
- Degraded modes (AJAX disabled and JavaScript disabled modes)
- ...
Tags: API
Apache Rampart
Apache Rampart is a security module for Axis 2. It secures SOAP messages according to specifications in the WS-Security stack. Rampart implements the following specifications:
- WS - Security 1.1
- WS - Secure Conversation
- WS - Security Policy - 1.2
- WS - Trust
Apache Rampart can be downloaded from http://ws.apache.org/rampart/download.html.
Tags: API
Change the last modified date of a file or directory.
The setLastModified method of file class can be used for changing the last modified time of a directory or a file.
import java.io.File;
import java.util.Date;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the source file/directory
File file = new File("d:\\temp\\test.txt");
// Get the current time
long time = new Date().getTime();
// Change the last modified time.
file.setLastModified(time);
}
}
Tags: java.io
Moving a file or directory in Java
The renameTo method of file class can be used for moving a file or directory to another destination.
import java.io.File;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the source file/directory
File file = new File("d:\\temp\\test.txt");
// Create the destination file/directory.
File destintation = new File("d:\\temp\\dir\\test.txt");
// Move the file
boolean status = file.renameTo(destintation);
System.out.println("Moving status - "+status);
}
}
Tags: java.io
Renaming a file in Java
The renameTo method of file class can be used for renaming a file or directory.
import java.io.File;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the source file/directory
File file = new File("d:\\temp\\test.txt");
// Create the destination file/directory.
File destintation = new File("d:\\temp\\test1.text");
// Rename the file.
boolean status = file.renameTo(destintation);
System.out.println("Renaming status - "+status);
}
}
Tags: java.io
Creating a directory with sub directory
The mkdirs method of file class is used for creating a direcory and sub directories in Java
import java.io.File;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the directory
File file = new File("d:\\temp\\dir\\subdir");
// Create directory and sub directories.
boolean status = file.mkdirs();
System.out.println("Directory creation status - "+status);
}
}
Tags: java.io
Create a directory using java
The mkdir method of file class is used for creating a new directory in java.
import java.io.File;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the directory
File file = new File("d:\\temp\\dir");
// Create directory
boolean status = file.mkdir();
System.out.println("Directory creation status - "+status);
}
}
Tags: java.io
Creating a FileFilter
We need to implement the FileFilter class for creating a file filter. The FileFilter interface contains only one method accept(File). This method is used for checking whether a file should be included or excluded.
import java.io.File;
import java.io.FilenameFilter;
/**
*
* A file filter.
*
*/
class TextFileFilter implements FileFilter {
/**
* Pattern would contain the extension of
* the file.
*/
private String pattern;
/**
* Initializes the pattern.
*
* Provide the file extension to filter.
*
* @param pattern
*/
public TextFileFilter(String pattern){
this.pattern = pattern;
}
public boolean accept(File pathname) {
return pathname.getName().endsWith(this.pattern);
}
}
}
To invoke the above FileFilter create an object of the TextFileFilter class like
TextFileFilter filter = new TextFileFilter("txt");
The argument to TextFileFilter will be the extension of the file we need to include.
Tags: java.io
List all the contents of a directory according to a filter.
The list method of File class can be used for listing all the contents of a directory according to a filter.
import java.io.File;
import java.io.FilenameFilter;
/**
* File class examples
*/
public class FileExample {
public static void main(String[] args){
// Create file object representing the directory
File file = new File("d:\\temp");
// Create a FilenameFilter for filtering all the text files.
FileFilter filter = new FileFilter("txt");
// List the contents of the directory.
String contents[] = file.list(filter);
// Loop through the array and display the file/directory names.
for (int i = 0; i < contents.length; i++) {
System.out.println(contents[i]);
}
}
}
/**
*
* A file filter.
*
*/
class FileFilter implements FilenameFilter{
/**
* Pattern would contain the extension of
* the file.
*/
private String pattern;
/**
* Initializes the pattern.
*
* Provide the file extension to filter.
*
* @param pattern
*/
public FileFilter(String pattern){
this.pattern = pattern;
}
public boolean accept(File dir, String name) {
return name.endsWith(this.pattern);
}
}
The above examples filters out all the non text files from the directory. The list method returns an array of file names that matches the filter. But if we want an array of File objects instead of file names we should use listFiles method instead of list method.
Tags: java.io