jPOS-EE Things

Inspired by this talk, I got reminded to play with EAVs in jPOS-EE.

I’ve created a jPOS-EE modules called “things” that I believe it’s a good thing to have in most applications.

I don’t think this is a one-size-fits-all solution, you probably don’t want to store your core tables (such as the transaction log, miniGL stuff, whatever) using this open schema approach, but for everything else, having this open schema can save your day (in the same way a ‘flags’ field in most tables can help at some point).

Using it is very simple, you create a “thing” using the ThingsManager:

   DB db = new DB();   
   ThingsManager mgr = new ThingsManager(db);
   Thing t = mgr.create("MyThing");

Then you can put Strings, Longs, Dates, Timestamps, long Strings and BigDecimals to your thing, i.e:

   t.put ("AString",  "This is a string");
   t.put ("ALong", Long.MAX_VALUE);
   t.put ("MyInteger", i);
   t.put ("Date", d);
   t.put ("Timestamp", new Timestamp(now));
   t.put ("BigDecimal", ONE_THOUSAND);
   t.putText("Text", "The quick brown fox is brown and the dog is lazy, and jumps.");

The ThingsManager has some handy methods already, and we’ll add more as the need arise.

public List getAll (String type) ;
public Thing getLast (String type);
public List listByStringName (String type, String name);
public List listByStringValue (String type, String value);
public List listByStringNameValue (String type, String name,String value);
public List listByTextName (String type, String name);
public List listByTextValue (String type, String value);
...
...

Some immediate use comes to mind, we could use this to provide a more type-safe, versionable version of our existing SysConfig table (i.e. we could have a thing called ‘SysConfig’ and keep previous versions as ‘SysConfig;1′, ‘SysConfig;2′, etc. (or another numbering scheme if you find this one too VMS-eske). It’s also good to handle extremely proprietary stuff such as fee configuration, currency exchange, etc. found in many jPOS applications.

The things module is available in jPOS-EE as of r307

Q2 transient services

In jCard and jPTS we use the concept of Stations, we have Source Stations (SS), Destination Stations (DS), Monitoring Stations (MS), Control Stations (CS) and Cryptographic Stations (HSMS), etc.

Every station usually requires a handful Q2 services (QBeans), such as a MUX or MUXPool, one or more ChannelAdaptors with their filters, LogonManager, KeyExchangeManagers, eventually an independent logger, etc.

You can configure those manually for a small set of stations, you can also use some scripts, but in order to support a large number of stations, and to easily manage them from the UI, we use a database to keep their basic configuration (station type, host, port, timeouts, etc.) and then use these new transient services provided by Q2.

When Q2 starts, it’s create an unique transient UUID, that FYI is displayed by the SystemMonitor task:

<log realm="org.jpos.q2.qbean.SystemMonitor" at="Sat Jul 24 20:14:14 UYT 2010.495">
  <info>
    <release>jPOS 1.6.9 r2950</release>
    <instance>e424833b-c2c1-4f8b-b743-8a69271912a2</instance>
    <uptime>00:00:00.170</uptime>
  </info>
   ...
   ...
</log>

When you deploy a QBean using Q2′s deployElement method (which is now public), you can flag that qbean as ‘transient’ (there’s a boolean parameter). In that case, Q2 will remove the file on exit, but just in case the system crashes, it also adds a ‘transient’ attribute to the QBean, i.e:

<server class="org.jpos.q2.iso.QServer" logger="Q2"  instance="e424833b-c2c1-4f8b-b743-8a69271912a2">
  ...
  ...
</server>

The next time it runs, Q2 will generate a new instance ID, so in the rare situation where an old deployment descriptor is present in the deploy directory, it will be ignored and deleted (as it should have been removed at the previous exit).

Q2.deployElement is a handy method that requires a JDom Element. If you are not a member of the JDom church, you can always create your QBean manually, you can get to know Q2′s instance ID by calling its getInstanceId() method that gives you an UUID,.

Note: when you deploy a bundle using Q2 –config=/path/to/your/bundle, Q2 now flags the exploded descriptors as transient.

This is available as of jPOS 1.6.9 r2950

jPOS 1.6.8 has been released

Just a quick note to let you know that jPOS 1.6.8 has been released (ChangeLog).

This is a maintenance release that fixes several bugs and adds some reasonable defaults that can avoid some problems (i.e.TransactionManager’s paused-timeout default issue).

jPOS-EE users just ‘svn update’ and you’ll get it from modules/jpos/lib/jpos.jar (r290).