Wednesday, February 27, 2013

Java / Struts2 I18N and DB backed ResourceBundle

I am a strong believer in deployment processes which don't involve making a patchwork of changes to a previously deployed WAR file in a production environment.  The downside to that is things like minor changes to properties files require a full deployment (and across a number of servers in this case).  The time consumed by this combined with the fact that the normal maintenance window is at a time I would rather spend with the family drove me to look for other solution.  After some searching, it seemed that the most reasonable solution fitting our needs involved moving the data to the database and writing some code to leverage the ResourceBundle framework.  It was hoped that struts would seamlessly work with this.  That didn't turn out quite true.

For the moment, I ended up having to force the pre-load of the Resource bundles (English and Spanish) before they seemed to be found fairly reliably. There is some odd behavior when working with our custom ResourceBundle.Control which could be a root cause.  There are still some problems where some application areas seem to not pickup the Spanish data and this may be an issue with struts.  Further debugging is required - hopefully this can be resolved fully even if no optimal solution is found.

I truly wish that DB backed ResourceBundles were supported directly by struts 2.  I believe some other newer frameworks support this - maybe it is time to revisit framework decisions.

[2015/11/8] Notes added below..

My current use of this works by pre-loading the bundle from the DB before the first real need. After that point, the cached bundle is returned during request from struts, etc.  I am using the Spring framework to initialize/load the ResourceBundles early in the web application startup - thereby getting the bundles cached.

Link(s) I think I found/used regarding DB backed resource bundles originally.
DB backed resource bundle reference 1

Potential Issues:
For ResourceBundle.Control the Java doc for the "needsReload" method says
"The calling ResourceBundle.getBundle factory method calls this method on the ResourceBundle.Control instance used for its current invocation, not on the instance used in the invocation that originally loaded the resource bundle. "  
and the "getTimeToLive" method Java doc says
"All cached resource bundles are subject to removal from the cache due to memory constraints of the runtime environment. "
This seems to leave the possibility that a bundle could be dropped from the cache and would not reload properly since it wouldn't access the correct ResourceBundle.Control instance which is only used during the application initialization.  I ran into something that acted like this (but without memory pressure that I am aware of) with the result of getting resource not found exceptions. I'll be looking into this at some point.

I would really like to propose some Java change that would prevent the above potential issue but some aspects of the JCP membership agreement and my employer make that difficult.  I had also considered that maybe a change at the JSF2 (my current focus) layer could work but have not looked into it any further.

[2016/05/19] New info.
I ran across something useful and likely better than my original design.  It is facilitated by the new as of JDK 8 ResourceBundleControlProvider interface.  See the Oracle docs here. When time permits or the need arises (which might be soon) I will give this method a shot.

As an alternative, I have considered creating a ListResourceBundle that still uses a database for the data.  The downside of this is still the need of a class per bundle because resolving a bundle is done by looking for a class name reflecting the bundle name and locale. A superclass could probably be created which does all/most of the heavy lifting and sub-classes would exist mainly for Java logic performing the bundle to class resolution..

The more I think about it, the more I think the ResourceBundleControlProvider is probably the better way.  It will be more complex - without further research I am concerned about getting the database connectivity into provider early enough to be useful and without having class loader issues.  Much of my DB connectivity uses Spring based configuration and involves a number of dependencies.  I'd hate to create a new configuration method to get connections into the provider but it could be needed.  I'll have to prototype it to verify.

Friday, December 28, 2012

Medical records data - HL7

I keep thinking about a career adjustment - basically converting from more general applications development to more specialized applications.  I had considered going back to college for a masters degree in bioinformatics and trying to start over from there.  I decided that was too much disruption to my family mainly for just my benefit - at least while my kids are young.  I have considered trying to learn HL7 (mainly v3) and look for an appropriate job opportunity.  That is by the fact that my current employment takes more time than I care to admit and to the detriment of my family as well some days. 

[Update] I decided that it is more practical to look into career paths more inline with my existing eduction and some other interests.  I still find it useful to understand the technology as you never know when it will come in handy in some way.

I have looking into HL7 for a year or 2.  This was challenging since there was little freely available information/tools.  In the meantime, some of basic information is now more freely available along with a few tools.  The only other major hurdle is that I would likely learn using freely available Java resources whereas it seems, based on job postings, that most jobs are doing .NET solutions (or mainframe).  Learning .NET (versus just C/C++ on Windows from years ago) is on my list to do but time consuming as well.  My current job will likely require an increasing amount of .NET work so given time.. but this is off topic a bit.

I'm trying to keep a list of potentially useful resources (with a majority of focus on freely available resources) to learn/utilize.  I have not reviewed any of these in more than passing at this time.
  • http://en.wikipedia.org/wiki/Health_Level_7
  • http://www.hl7.org/participate/toolsandresources.cfm
  • http://sourceforge.net/projects/hl7inspector/
  • http://www.openehealth.org/display/ipf2/Home
I would have liked to join in some free webinars related to HL7 but so far they have always occurred at times when I was not able to take off from work (nor could I really justify it during my normal work day since it is not really related to my current employment).

Finding realistic sample data to learn from may be challenging.  Anyways, even if this doesn't lead to a job change, I think it is still a worthwhile to stretch my knowledge into other areas.  I find it quite amazing when some seemingly unrelated information helps me with a current difficult task.

 I'll hopefully add more interesting and useful content related to this over time.


Friday, December 21, 2012

IT and requests for Cloud Technology solutions

[2016/05/19] Update
 Ok, I'm actually finding some reasonable use cases for 3rd party cloud solutions. I still don't think it makes sense in instances where multiple large applications and lots of integration's are involved but for "point" solutions with few integration needs it may make good sense.  The cases I am thinking about (outside of family :) ) are development tools/process related.  With staffing so slim, it is pretty risky having only one person that knows how all the development and operations infrastructure is built, installed, setup and maintained. Having someone else deal with most of that means that staff have more time to focus on actual development. As is, maintenance of development tools/processes is falling to the wayside more and more for lack of time - that increases risk that something could go very wrong resulting in loss of assets or substantial disruption to systems/processes.  I will say that a cloud solution isn't a silver bullet though - it has its own risks like provider outages, network disruptions etc which can have a large negative impact on development processes too.  Which risks are more likely and have the higher negative impact?  Hard to tell right now but worth thinking about.

Anyways, use the appropriate tool for the job..
-------------------------------------------------------

This post is a bit of a general complaint against some people in IT and management.  It seems that there is an increasing tendency for people to request "cloud" applications or make requests to convert existing applications to "cloud" applications.  Why should this concern anyone?  I find it concerning because these requests are made for a specific solution instead of having a specific need or requirement where "the cloud" is the best solution.  The decisions behind any IT solutions should be made to solve specific problems or meet specific requirements.  Technology decisions based mainly on some research companies "quadrant" leads me to
  • wonder whether the solution is really a good fit for the organization
  • concern regarding the longer term viability of a solution
  • concern whether a project is setup for failure from the start
  • concern that the total/on-going cost will be wasteful of money and/or other resources
I am not saying that there is anything wrong with "cloud" technology but I am saying that many people don't understand more than the executive briefing level of information that the media pushes.  Although, if management makes a final decision that they want "cloud solutions" then I (and anyone else) should abide an employers decisions and do their best to make it work as well as possible.  If a person cannot get themselves  to do that then they should consider a different employer - but let me leave that for a different post.

The type of situation that leads me to finding a lack of in-depth understanding includes someone trying to justify a cloud solution by saying it will save money but can't back that with any further details.  If the only further justification is "we don't need to by hardware" then you are likely in the same situation.  If the application/service is a mission critical application then you may end up with a really big problem. 

If someone wants to talk about cloud solutions with me then I expect them to be willing to start the discussion with the following items at a minimum:
  1. Security requirements
    1. application access
    2. data sensitivity
  2. User base
    1. size
    2. locations
    3. types of users
      1. public
      2. internal only
      3. etc
  3. Data sources, locations and integration types
  4. Performance/capacity requirements
  5. Availability requirements
  6. Disaster recovery requirements
  7. Compliance/auditing requirements
 If the answers don't exclude cloud solutions then some cloud questions/discussion items should include:
  1. Potential internal staffing needs
    1. training
      1. developers
      2. operations/support personnel
  2. Potential network requirements
  3. cloud types
    1. 3rd party -  external cloud / hosted solution
    2. internal cloud
    3. hybrid
This last question (especially if potentially working with 3rd party/external cloud) should lead into
  1. Potential maintenance logistics/coordination
    1. If you require specific availability windows unsupported by the 3rd party then what?
    2. If you have maintenance windows for integrations/data sources then how is that handled/coordinated?
  2. Help desk / communications logistics
    1. If there is a problem, how is it reported?
    2. How are users notified?
  3. Monitoring
    1. how is it performed?  Can you leverage existing infrastructure? 
    2. Who performs it?
    3. what are the boundries?  If there is a performance issue, how do you identify whether it is a cloud issue or a data source integration issue?
  4. Contracts
    1. Do you have adequate legal counsel to help in evaluating contracts so you are not left high and dry if a problem of any sort comes up?
      1. hosting company goes out of business
      2. hosting company raises rates beyond what is affordable
      3. hosting company can no longer meet your needs
      4. hosting company not adaptable to changing technology needs
    2. Cost model
      1. Are you able to account for all changes required by your organization and still determine that there is a real cost savings?
This last item should cause you to ask - if you are forced to leave a hosting company:
  • Can you get all your data out?
  • What format is your data available in?
  • How transportable is your application/service to some other cloud vendor?    Do you have to rewrite your application from scratch? 
 This is certainly not a comprehensive list of things to consider but is meant to cause people to pause and consider more than just the short briefs on cloud computing (and technology in general for that matter).  Every organization is different so decision makers must use knowledge, experience and common sense of  their own and from people with a proven track record that work for them.