ラベル Java の投稿を表示しています。 すべての投稿を表示
ラベル Java の投稿を表示しています。 すべての投稿を表示

9/23/2011

Introduction of CookieSessionFilter

CookieSessionFilter is a servlet filter which stores session data into the client cookie for Java based web applications.

In using CookieSessionFilter, session replication becomes unnecessary for multiplexing of application servers. You'll be able to make and manage multiplexing environment more easily.

It provides HttpSession interface. So any modification in your application is not necessary. Probably, you'll be able to use it with not so large cost.

See details about CookieSessionFilter at:
http://amateras.sourceforge.jp/site/cookie-session-filter/usage.html

10/01/2010

Java Standard EL Functions 1.1.1 is available!

We released Java Standard EL Functions (JSEL) ver 1.1.1.

JSEL provides standard JSP-EL functions for web application development such as escaping HTML tags, URL encoding and formatting Date or Number. You can use it with many web frameworks which use JSP as view technologies.

Here is the list of new features in this release:

  • New functions to print message to JSP by log level
  • New functions to test whether log level is enabled

You can print message if the log log level is enabled using functions such as log:printDebug().

${log:printDebug('DEBUG level is enabled.')}

And also you can test whether log level is enabled using log:isDebugEnabled().

<c:if test="${log:isDebugEnabled()}">
  DEBUG level is enabled.
</c:if>

Please see the TLDDoc to know details of available functions.

6/15/2010

Mirage 1.0.3 Released

Mirage 1.0.3 is now available!

Mirage is a simple SQL centric database access library. See the following URL to know about Mirage:

Here is the list of changes in this release:

  • Iteration search per a record using cursor.
  • Stored procedure / function support.
  • BugFix about SqlManager#insertEntity().

Please see also my past entries about new features in Mirage 1.0.3.

I wish that Mirage helps your development. Enjoy!

6/03/2010

Mirage supports stored procedure/function

The next version of Mirage will support stored procedure/function. We added new methods to call them to SqlManager in the SVN trunk.

Here is an example to call stored function in Mirage:

// Creates parameter object which give to stored function
GetCountParam param = new GetCountParam();
param.deptId = 1;
...
// Calls a stored function and get a result value.
Long count = sqlManager.call(Long.class, "get_emp_count", param);

Fields of the parameter class has annotation such as @In, @Out, @InOut and @ResultSet. These annotations mean parameter type.

If the function returns ResultSet, use SqlManager#callForList() instead of SqlManager#call().

Please wait for the next release of Mirage!

5/09/2010

Large results processing in Mirage

The next release of Mirage is 1.0.3. It contains some new features. Today, I write about iteration search which is one of them.

SqlManager#getResultList() creates all entity instances and returns a list which contains them. If SQL returns a large result, it causes OutOfMemory.

In these case, you should use SqlManager#iterate() instead of SqlManager#getResultList().

Integer result = sqlManager.iterate(
  Book.class,
  new IterationCallback<Book, Integer>() {

    private int result;

    @Override public Integer iterate(Book entity) {
      result = result + entity.price;
      return result;
    }

  },
  SQL_PREFIX + "SqlManagerImplTest_selectBooks.sql");

SqlManager#iterate() accepts IterationCallback and invoke it per record. The return value of SqlManager#iterate() is a last returned value from IterationCallback.

Iteration search would be available in Mirage 1.0.3.

5/08/2010

Mirage 1.0.2 Released!

Mirage 1.0.2 is now available!

Mirage is a simple SQL centric database access library. See the following URL to know about Mirage:

1.0.2 is a maintenance release. Here is the list of changes in this release:

  • Dependency to Spring Framework and Guice became optional.
  • Dependency to the pached OGNL changed to OGNL 2.7.3.
  • BugFix about BLOB support.

BLOB support in 1.0.1 does not work because it contains a serious bug. This bug was fixed in 1.0.2 and dependencies was reviewed and modified to minimum.

And also Mirage with Apache Click example is released. You can get it from the download page.

I wish that Mirage helps your development. Enjoy!

5/02/2010

Mirage and Apache Click Example

I started to make a sample application to use Mirage with Apache Click.

This sample application has not been completed yet. However you can checkout source code from the following URL using Subversion.

You can build a war file using Maven. Please execute following commands in command prompt.

$ svn co http://svn.sourceforge.jp/svnroot/amateras/mirage/trunk/mirage-click-example/
$ cd mirage-click-example
$ mvn package

Then you can find mirage-click-example.war in the /target directory.

Put it into the application server such as Tomcat and access http://localhost:8080/mirage-click-example/ using your browser.

Mirage 1.0.1 Released!

Mirage is a simple SQL centric database access library. Today, I've just released Mirage 1.0.1. It's already available.

See the following URL to know about Mirage:

Here is the list of new features in this release:

  • Use java.util.logging instead of slf4j / logback to remove them from dependency.
  • Simple example and documentation for Google Guice integration.
  • It's possible to specify a transient property by transient modifier instead of @Transient annotation.
  • Add new method SqlManager#findEntity(Class clazz, Object... id)
  • Add new method SqlManager#getCount(String sqlPath[, Object param])
  • ValueType interface to add custome value type support
  • BLOB support

Mirage is still not enough to use in complex systems. So we would improve it as much as possible soon.

4/20/2010

Mirage: Simple SQL Centric DB Access Library

Today, I released Mirage ver 1.0.0.

Mirage is a simple SQL centric database access library. It has a following two features:

  • 2WaySQL
    The main feature of Mirage is 2WaySQL. This makes plain old SQL template, and it is executable using any SQL client tools because parameters and conditions are written as SQL comment.
  • SQL less Update
    Generally, update processing are simpler than search processing. However, especially, large INSERT SQL brings us the considerable pain. In the Mirage, you can insert / update / delete records using entity class (without SQL).

The main feature of Mirage is 2WaySQL. This makes plain old SQL template. See the following example:

SELECT * FROM BOOK
/*BEGIN*/
  WHERE
  /*IF author != null */
        AUTHOR = /*author*/'Naoki Takezoe'
  /*END*/
  /*IF minPrice != null */
    AND PRICE >= /*minPrice*/20
  /*END*/
  /*IF maxPrice != null */
    AND PRICE <= /*maxPrice*/100
  /*END*/
/*END*/
ORDER BY BOOK_ID ASC

Mirage processes this SQL template and executes it using PreparedStatement at runtime. And this SQL template is exacutable even it is on SQL client tools such as SQL*Plus(Oracle) or psql(PostgreSQL). So it makes easy to test SQL.

See details about Mirage at our web site. I would also talk about Mirage in this blog.

4/18/2010

Java Standard EL Functions 1.1.0 is available!

We released Java Standard EL Functions (JSEL) ver 1.1.0.

JSEL provides standard JSP-EL functions for web application development such as escaping HTML tags, URL encoding and formatting Date or Number. You can use it with many web frameworks which use JSP as view technologies.

Here is the example to JSEL usage:

<%@ taglib uri="http://amateras.sf.jp/functions" prefix="f" %>
...
<%-- Escape HTML tags --%>
${f:h(value)}
<%-- URL encode --%>
${f:u(value)}

JSEL provides many usable EL functions. Please check our web site to know details about JSEL.

7/26/2009

Utility to use JDO easily on Google App Engine

We can use JDO to access BigTable on Google App Engine for Java.

However JDO PersistenceManager and Query object are so complex. So I wrote an utility to use JDO easily. For example, you can search entities as follows instead of JDO Query object.

List entries = JdoUtil.from(Entry.class)
  .filter("userId == ?")
  .ordering("updateDate desc")
  .range(0, 20)
  .getResultList(userId); 

No need to cast result objects and Query#declareParameters() also.

I would like to provide this utility in the part of my NikoNiko Framework (NikoNiko means Smile in Japanese). NikoNiko Framework supports both standard JavaEE web development and Google App Engine for Java. It's small and lightweight. It would be suitable for the small web application development.

4/03/2009

Empire-db: Type-safe query builder

I found a new database access framework named Empire-db in the Apache Incubator.

A most important feature of Empire-db which I think is a type-safe query builder. See a following example from Empire-db's web site.

// Create a command object
DBCommand cmd = db.createCommand();
// Select columns
cmd.select(EMP.EMPLOYEE_ID);
cmd.select(EMP.LASTNAME.append(", ").append(EMP.FIRSTNAME).as("NAME"));
cmd.select(DEP.NAME.as("DEPARTMENT"));
// Join tables
cmd.join  (DEP.DEPARTMENT_ID, EMP.DEPARTMENT_ID);
// Set constraints
cmd.where(EMP.LASTNAME.likeUpper("Foo%"));
cmd.where(EMP.RETIRED.is(false));
// Set order
cmd.orderBy(EMP.LASTNAME);
cmd.orderBy(EMP.FIRSTNAME); 
This feature is very useful at the software development projects which face many changes of database schema. Because compilation errors are caused by changes of database schema. We can fix these errors completely and surely soon.

6/24/2008

memcached in Java

I'm looking for memcached client library for Java. Then I found two libraries.
memcached client for java
memcached client for java is simple and synchronous mamcached client libraries. This is easy to use but not support CAS commands.
spymemcached
spymemcached supports asynchronous processing and CAS commands. Updating cache is high-speed. However implementation is very complex.
I think that many web applications don't require asynchronous cache processing. So I think mamcached client for java is better solution.

3/09/2008

OVal: The simple validation framework for Java

OVal is the simple validation framework for Java. You can specify validation rules using annotations.

public class Person {
  @NotNull
  public String name;
}

Usage:

Validator v = new Validator();

Person p = new Person();
for(ConstraintViolation error: v.validate(p)){
  System.out.println(error.getMessage());
}
OVal can switch validation rules by profiles.
public class Person {
  @NotNull(profiles={"profile1"})
  public String name;
  
  @NotNull(profiles={"profile1", "profile2"})
  public String email;
}

Switch profiles like following:

// Enable all profiles
v.enableAllProfiles();
// Enable a specified profile
v.enableProfile("profile1");

// Disable all profiles
v.disableAllProfiles();
// Disable a specified profile
v.disableProfile("profile1");

2/21/2008

JSONIC - simple json encoder/decoder for java

JSONIC is a simple JSON encoder / decoder for Java made in Japan. We can get JSONIC from http://sourceforge.jp/projects/jsonic/files/. The use of JSONIC is very easy.

import net.arnx.jsonic.JSON;

// POJO to JSON
String text = JSON.encode(new Hoge());

// JSON to POJO
Hoge hoge = JSON.decode(text, Hoge.class); 

JSONIC can handle POJO's public fields as property well and it also encode / decode java.util.Map and java.util.List.

I recommend JSONIC if you have to handle JSON in Java. It would be a best choice.