XINS also contains in the org.xins.common package, a set of classes that could be useful for the implementation of your API.
Note also that the following APIs are distributed with all XINS
applications: HTTPCore,
HTTPClient,
commons
logging, commons codec,
Log4j
API, json, logdoc, and xmlenc. You can then use
these APIs without adding any dependency
element in the
impl.xml
file.
Spec package
The spec package is located in org.xins.common.spec (javadoc). This
package contains classes that provide information on the specification
of the API. You can get the specification from the client side by
using capi.getAPISpecification()
and from the
server side using api.getAPISpecification()
.
The method will return a APISpec
object from
which you will be able to get all the specification of the API. You
can get information sush as the list of the functions, the type of a
parameter in a function, the error code returned by a function.
HTTPServiceCaller
The org.xins.common.http.HTTPServiceCaller (javadoc) is a class that is used to get information from a URL. This class also supports load-balancing and fail-over via the GroupDescriptor such as the XINSServiceCaller does. This class has a call method that requires a HTTPCallRequest as input where you can specify the method to call the URL, the parameters of the URL and the behaviour for the fail-over, and this call returns a HTTPCallResult where you can get the returned text as String, byte[] or as InputStream as well as the HTTP code returned.
ExpiryFolder
The org.xins.common.collections.expiry.ExpiryFolder (javadoc) class allows you to store some properties (key & value pairs) for a limited amount of time. When a property is added, it has the maximum time to live. If the property is not requested during this time then the property is removed. If the property is requested using the get() method then time to live of this property is set again to the maximum.
The ExpiryFolder is particularly interesting if you want to implement caching of the result. More for look at the online article explaining how to do result caching for a method.
BeanUtils
The org.xins.common.BeanUtils (javadoc) class allows to copy the properties of a POJO to another POJO. It can useful to fill a generated Request object on the client side or a SuccesfulResult object on the server side. Especially if you use libraries such as JPA (Java Persistence API) or the Spring Framework. It is also useful when you want to forward a request or when the result of a function call should be used as input to call another function.
If the names of the properties are different, you can also provide a mapping of the properties name as parameter, element name or attribute name. The method will also convert the types whenever possible.
FileWatcher
The org.xins.common.io.FileWatcher (javadoc) class allows you to monitor a file for changes. You just need to specify the file to monitor, the interval between two checks of the file and the listener that will be notified when the file has changed. Don't forget to invoke the start() method to start the monitoring of the file.
ElementList
The org.xins.common.xml.ElementList (javadoc) class allows you to list and get sub DOM elements of a DOM element. As described in the Javadoc, this class has several advantages over NodeList.
Optimized classes
The org.xins.common.text (javadoc) package contains classes for URL encoding, URL decoding or creation of regular expression patterns.