Wednesday, November 27, 2013

WebLogic Server env conflict resolving

Durring StartWeblogic.cmd there are PATH and CLASS_PATH that will be created. You can edit the way these pathes are configured. Where to check it?

In my case this was this script:
Oracle\Middleware_dst\wlserver_10.3\bin\commonEnv.cmd

Monday, November 25, 2013

Simple explanation of what is a Java Marshalling

Marshalling is the process of converting  a POJO (Plain Old Java Object) in memory into a format that can be written to disk or send via network, usually in text formats like XML or JSON. The reverse of this technique is called unmarshalling.

Marshalling is similar to Serialization in practice but the difference is that, Marshalling also saves the code of an object in addition to its state.

Here is the link on the post:
http://tech.deepumohan.com/2011/11/marshalling-in-java.html

Sunday, November 24, 2013

Spring Android Docs Reference

http://docs.spring.io/spring-android/docs/1.0.1.RELEASE/reference/htmlsingle/#d4e34

Friday, November 22, 2013

How to wrapp GWT component into SmartGWT

Suppouse that InputListWidget is a component that extends Composite GWT class. The rest of the code snippet is a SmartGWT.

//SmartGWT
Canvas inputListWidgetWrapper = new Canvas(); 
inputListWidgetWrapper.setWidth(360);
inputListWidgetWrapper.setHeight(70);
inputListWidgetWrapper.addChild(new InputListWidget());

DynamicForm form = new DynamicForm();        
form.addChild(inputListWidgetWrapper);

GWT AutoComplete howto link

Here is the link of howto AutoComplete in GWT
http://raibledesigns.com/rd/entry/creating_a_facebook_style_autocomplete

Wednesday, November 13, 2013

Run Android project generated by Maven archetype:generate from IDE by Maven commands

When you create an Android project by Maven e.g. mvn archetype:generate your new Project will be presented in IDE as a Java project, not the Android's one. So you can't run it from IDE as an Android project "out of the box". You should use Maven commands instead:

mvm android:deploy
mvm android:run

By default Maven will deploy your apk on all available deviсes including USB's ones and emulator. So if you want to use only USB devices change related setting in pom.xml of the project.

Understanding Memory Management

The summary from this link.

HEAP is shared among all THREADS.
The heap is the RUN-TIME DATA AREA from which memory for all class instances and arrays is allocated.

OBJECTS are kept in HEAP memory.

When HEAP is full the GARBAGE is COLLECTED.

Java METHODS, THREADS, NATIVE HANLES are allocated in other memory (methods_area, stack).

TWO AREAS OR GENERATIONS OF HEAP
HEAP is divided on two areas (generations):

YOUNG_SPACE (NURSERY) for a new OBJECTS.

When NURSERY is full garbage collector runs YOUNG_COLLECTION and moves some obj. to OLD_SPACE (all threads are stopped. it is called GENERATIOANL or PARALLEL GarbCol-on where the work is done in parallel using all available CPUs.)
When OLD_SPACE is full garbage is collected by process named OLD_COLLECTION

In NURSERY is a KEEP_AREA for a newly added objects that lives there until the next YOUNG_COLLECTION. This prevents objects from being promoted (moved) just because they were allocated right before a young collection started.

JVM distinguishes SMALL and LARGE OBJECTS. (depends of JVM version,  HEAP size, GC... )
LARGE size ~ 2 - 128 kB. See the docs for -XXtlaSize and -XXlargeObjectLimit

LARGE OBJECTS allocated in TLA (thread local area) that is reserved in HEAP.



GARBAGE COLLECTION MODELS
MARK and SWEEP models.
MARK - marks up all alive objects, SWEEP writes a gaps among'em in a free list for a new objects.

Its improved versions are CONCURRENT concurrent garbage collection or PARALLEL mark and sweep.

GARBAGE COLLECTION MODES
DYNAMIC automatically selects a garbage collection strategy to use:
throughput (default mode), pausetime, deterministic.

STATIC mode uses this major strategies:
singlepar, which is a single-generational parallel garbage collector (same as parallel)
genpar, which is a two-generational parallel garbage collector
singlecon, which is a single-generational mostly concurrent garbage collector
gencon, which is a two-generational mostly concurrent garbage collector

COMPACTION
To reduce fragmentation, the JRockit JVM compacts a part of the heap at every garbage collection JVM uses COMPACTION. Compaction is performed at the beginning of or during the SWEEP phase and while all Java THREADS are PAUSED.

TWO COMPACTION METHODS
EXTERNAL
moves the objects within the compaction area to free positions outside the compaction area and as far down in the heap as possible. 

INTERNAL
moves the objects within the compaction area as far down in the compaction area as possible, thus moving them closer together.

SLIDING WINDOW SCHEMES
Each sliding window moves a notch up or down in the heap at each garbage collection, until it reaches the other end of the heap or meets a sliding window that moves in the opposite direction, and starts over again. Thus the whole heap is eventually traversed by compaction over and over again.

COMPACTION AREA SIZING
Thus the compaction area will be smaller in parts of the heap where the object density is high or where the amount of references to the objects within the area is high. Typically the object density is higher near the bottom of the heap than at the top of the heap, except at the very top where the latest allocated objects are found. Thus the compaction areas are usually smaller near the bottom of the heap than in the top half of the heap.

Thursday, November 7, 2013

Play Market Google - how to start alpha testing of an app

1. Do registration on Google Play Developer Console, you should pay once $25.
2. Do all settings for your app project e.g. add screenshots, countries etc. e.g.
3. Create in Google Group the group for all those who will be alpha testers of your app
4. Upload your apk as for Alpha testing
5. Provide Google Group email of testers
6. Give to your testers the link of apk download e.g. see the lest paragraph of this screenshot:


7. When a tester will follow the link and accept invitation to become a tester he will see this e.g.:


8. When a tester click link of Download *** from the Play Store he will see this:




Tuesday, November 5, 2013

How to covert a Boolean object array to boolean primitive array

private boolean[] toPrimitiveArray(final List<Boolean> booleanList) {
        final boolean[] primitives = new boolean[booleanList.size()];
int index = 0;

for (Boolean object : booleanList) {
            primitives[index++] = object;
}

return primitives;
}

Monday, November 4, 2013

Parsing a String representation of Double with comma decimal separator in Android cause NumberFormatException

I've used the same code parsing a String representation of Double with comma decimal separator (e.g. "0,3") on different versions of Android (2.3 and 4.*). It is strange, but in Android 2.3 the code was executed without any Exception, but in Android 4.* I've got NumberFormatException with the message: Invalid Double: 0,3

I've fixed it by replacement of comma for a dot separator in String object of my Double:

DecimalFormat newFormat = new DecimalFormat("#.#");

double result = 0;
   try {
       String doubleString = newFormat.format(constancyPercentage);
        result = Double.parseDouble(doubleString.replace(",", "."));//0,3 -> 0.3
} catch (NumberFormatException e) {
//TODO show nothing
}