User Guide

8  Version API changes

8.1.0  Changes from 1.1 to 1.2

The main changes for 1.2 are all additions to the APIs in 1.1, mainly to support static queries.

 

  8.1.1  Index Interfaces

The Index interface has two new methods:

  • addQuery(String name, IndexQuery, query)
  • getQuery(String name)
These methods are for use with adding static queries to the relevant Index. See 3.1.12  Specifying named queries in the config file for more detail.

In order to support the parameterisation of queries two methods have also been added to the IndexQuery interface. These are:

  • setParameter(int position, Object value)
  • setParameter(String name, Object value)
However, only EJB3 format queries currently support parameters.

 

  8.1.2  Query Classes

In 1.1, the complex query concrete class was com.jofti.query.Query. This represented the default SQL format query language. In 1.2 and above, the addition of EJB format queries, and to allow easier integration of other query types in future versions, the Query class has been deprecated and developers should use either the SQLQuery class or the EJBQuery class. Both classes implement IndexQuery, the base interface for Queries. Please see the User Guide for details of these changes. It is not anticipated that these classes will change again in future versions.

 

8.2.0  Changes from 1.0 to 1.1

There are some minor changes to the APIs for Jofti from 1.0. The changes are centered on the Index and IndexCache interfaces for the actual Indexes, and the IndexManager, from which Indexes are obtained.

 

  8.2.1  Index Interfaces

Version 1.0 originally had an Interface called IndexedCache that was the base interface for the Indexes. This inteface implemented a method query(). The interface has been replaced with the Index interface which also implements only the query() method.

The second change is that the previous interface for Index contained put(),get() and remove methods. These have been removed from this Interface and moved to a new Interface called IndexCache. This interface extends the new Index interface and includes the put(),get() and remove() methods.

So the changes are illustrated below. Previously, for a wrapper usage of a Cache you would have called:


Index index = (Index)manager.addIndexedCache(config,new HashMap());

// now do get(), put() stuff

index.put("testKey", "test value");

This is now:

Map cache = new HashMap();
IndexCache index =  (IndexCache) manager.addIndex(config,cache);
index.put("testKey", "test value");

Map results = index.query(new MatchQuery("test value"));

You can see that the change is to use an IndexCache interface rather than the Index interface as the put,get methods have moved to this interface. The query method is still available on the Index interface, which IndexCache extends.

If you are using a listener adapter(which was not available in 1.0), you should use:
// assume we a Cache implementation that supports listeners
Cache cache = ....;

Index index =  manager.addIndex(config,cache);

cache.put("testKey", "test value");

Map results = index.query(new MatchQuery("test value"));

Notice how the Index interface has only the query method available and the puts are directly performed on the Cache (the index is populated via callbacks in this case). See the User Guide for more information.

 

  8.2.2  Obtaining an Index

In 1.0, the two main methods for obtaining an Index were addIndexedCache(...) and getIndex(String indexName). The first set of methods has now been split up into addIndex, which returns Index and addIndexCache, which also returns Index. The difference in these methods is that the addIndex, does not attempt to instantiate a Cache, whereas the latter one will. This is to better separate the creation Listener and wrapper type Indexes in Jofti.
Further details on this are outlined in the User Guide.

Similarly, the getIndex method is now called getIndexCache(...) as this method is generally used to obtain preconfigured Indexes, although it can be used to return listener Indexes that have been added as listeners. Further details on this are also outlined in the User Guide.

Features

  • Multi Cache support
  • Transaction support
  • Type aware searching
  • Configurable property indexing
  • Indexing/searching by interfaces
  • Support for Dynamic Proxies
  • Support for primitve attributes
  • Support for Collections and Arrays
  • String prefix searching
  • Simple query language