Wednesday, 30 September 2015

Spring Validation - collection max index.

Since Spring 3 DataBinder have aditional validation of collections which prevents out of memeory attack. This validation default limits collection size to 256 elements of collection.
If you need to increase this limit you have to use method setAutoGrowCollectionLimit before you register custom editors.

Tuesday, 29 September 2015

Angular structure and remote templates

At weekend I tried to clean my Angular project and move modules to separate files and folders. I did this but at the beginning nothing was working. I defined separate modules like:

angular.module('App', []);

In this square brackets I have to put names of other modules that are required to use in that App. That modules are injected by name.

angular.module('App', ['MyValidators','MyFilters']);


I exclude html templates to external files and use them by url.

<div .... ng-include="'templates/myTemplate.tpl.html'" />

Tuning Oracle queries with null values

Today I tested two queries in Oracle database. I noticed that when I execute query there column value is null, oracle engine directly use full access to table. I created index like:

create index MY_IDX on MY_TABLE (COLUMN_CAN_BE_NULL, -1);
and I have to use hint to use that index. Automatically oracle used full access, even when I counted statistic for this table.
However when it used index like this, it took much more then full access.

I have to dwell on a subject....

Friday, 25 September 2015

log4j and additional log param

I didn't know that so easy you can add to logs for example http session id. You need only put into MDC object value and later set log pattern as %X{sessionId}.

When I did that I had to find good place to put into MDC my sessionId parameter. I created web filter to archive that. Filter is simple and should be executed in correct order in chain.

LINK


I have to admit I had problem with logging exception stack trace. I implemented ThrowableRenderer and have set throwableRenderer tag.

SRC

AngularJS interceptor

I created AngularJS service and connection to server. On server side was Spring Security and I used CSRF. I'd like natty add this token to every request.

The best way to do that was create interceptor "csrfInterceptor"

App.config(["$httpProvider", function($httpProvider) {
    $httpProvider.interceptors.push("csrfInterceptor");
}]);

and push it into provider interceptor.

AngularJs filters

How it is easy to create in AngularJS filter I got to know when I need some special conditions.
I need to filter list of elements like this:


item in ptfs | showFilter: searchCriteria

I created filter called "showFilter" with filter criteria "searchCriteria".

Filter looks like:

App.filter('showFilter', [function($filter) {
   
    function isNotEmpty(obj){
        return obj != null && obj.trim().length > 0;
    }
   
   
    return function(inputArray, searchCriteria){      
       ....
       return data;

     };

}]);


Function returning data is a filtered copy of input data.

Thursday, 24 September 2015

ehcache and junit

Yesterday I upgraded ehcache lib to 2.8.4 in supported by me application. I have run tests and I saw in logs a few lines of notice.

Notice says, there is another CacheManager in JVM. I had to think a while. I changed configuration files and I gave them a name but it didn't fix it. I debugged this and I saw that every test is run there is loading new instance of configuration and there is created new CacheManager with known name.

I searched a little in google and I found out that I can downgrade libs to version 2.4.x or turn off cache during the test. I chose first solution.