Friday, November 28, 2014

Interceptors dependency code path and inherited interceptors

They are 
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
and inside
jboss-interceptors-api_1.1_spec-1.0.0.Final.jar .

For wildfly, the remoting has changed again, port 4447 obsoleted, 8080 now, so the precidio-jndi-calc.tar.gz package is this,
, and I have 2 classes, one extends another. My experiment shows that the base object's interceptor is invoked first the the more specific object's interceptor is invoked, like this,
20:58:39,027 INFO  [stdout] (EJB default - 7) *** Intercepting call to baseInterceptor()
20:58:39,029 INFO  [stdout] (EJB default - 7) *** Intercepting call to siliconInterceptor()

Calling Stateless Application EJB JARs From Plain Java Code

The stateless application jar is compiled with ejb api. But the invoker should not need the ejb api jars if it can avoid triggering ejb related code, or can it? We have a application for intensive computing farm for intra-red-EM-wave photoresonator calculation of quartz business Precidio Inc. ,

The precidio-jndi-calc.jar has this,
import javax.ejb.Remote;
import javax.ejb.Stateless;

public class ResonatorCalculatorBean implements RemoteResonatorCalculator {

    public int add(int a, int b) {
        return a + b + 111;

    public int subtract(int a, int b) {
        return Math.abs(a - b) - 11;
, and we should be able to -cp precidio-calc.jar , instantiate ResonatorCalculatorBean, and run the add command. This is the essence of EJB.

What is the problem, then, when -cp precidio-calc.jar ? 

[root@android01 ~]# cat 

import CalculatorBean;

public class UseEjb {

public static void main (String [] args) {


CalculatorBean cb = new CalculatorBean();

System.out.println(cb.add ( 1, 2));


[root@android01 ~]# javac -cp precidio-jndi-calc/build/precidio-calc.jar error: '.' expected
import CalculatorBean;
                     ^ error: ';' expected
import CalculatorBean;
2 errors
[root@android01 ~]#
Why? Non-packaged classes can not be imported. Instead, use it without importing it,
[root@android01 ~]# cat 
public class UseEjb {
public static void main (String [] args) {
CalculatorBean cb = new CalculatorBean();
System.out.println(cb.add ( 1, 2));
[root@android01 ~]# javac -cp precidio-jndi-calc/build/precidio-calc.jar warning: Cannot find annotation method 'value()' in type 'Remote': class file for javax.ejb.Remote not found
1 warning
[root@android01 ~]# java -cp precidio-jndi-calc/build/precidio-calc.jar:. UseEjb
[root@android01 ~]#java -cp precidio-jndi-calc/build/precidio-calc.jar UseEjb
Error: Could not find or load main class UseEjb
[root@android01 ~]# 

As predicted, as long as the invoker don't touch EJB specific workings, the regular java interpreter can invoke ejb jar without incident. It has a warning at compile time.

This exercise actually exposes the defect of java cp. The cp actually disturbs the java interpreter's original work path. Original java interpreter looks at current working directory in search for a class file, UseEjb in this case. So, simple java UseEjb does not have error of "Cloud not find" UseEjb. When -cp argument is in, it erases the default looking at current working directory.

Monday, November 10, 2014

The internals of running Fedora22 in a large screen phone.

All the internals are included in my Fedora...21-6.tar.gz and no need to do it if you just extract my Fedora...22-6.tar.gz .

Stop process killer

If you replace the adjusting of process killing priorities in with below one line,
echo '0,0,0,0,0,0' > /sys/module/lowmemorykiller/parameters/minfree
, your desktop mate will not be killed when you switch to android. But with my 2g memory with android 5.1 , I often run out of memory with just 3 apps, like a browser and a map and a music player and the system freezes requiring reset.

Run X with mate session

Put a am start -n
in /data/local/fedora/ .  ActivityName is often “MainActivity”. This is needed because the Startup app often can’t time the startup sequence and the XSDL X app needs time before accepting mate session. can also periodically set XSDL priority to -17 to prevent app closing by android system. This is already included in my Fedora22...5.tar.gz,
# cat /mnt/tmp/bin/
am start -n
# the 3 minute sleep allows the android's process killer to kill off
# unused apps before we enter the Desktop mode when 000000 cancels
# all killings.
sleep 180
echo '0,0,0,0,0,0' > /sys/module/lowmemorykiller/parameters/minfree

Chroot enter the PC operating system

# cat /mnt/tmp/bin/
export fedora="/data/local/chroots/fedora"
/system/xbin/busybox mount -t proc proc $fedora/proc
/system/xbin/busybox mount --bind /sys $fedora/sys
/system/xbin/busybox mount --bind /dev $fedora/dev
/system/xbin/busybox mount -t devpts devpts $fedora/dev/pts
#/system/xbin/busybox mount --bind /storage/sdcard1 $fedora/root/SDCard
export TERM=vt100
export HOME=/root
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:.
export SHELL=/usr/bin/bash
export EDITOR=vi
if [ ! -d /dev/shm ] ; then /system/xbin/busybox mkdir /dev/shm ; fi
/system/xbin/busybox chroot $fedora $SHELL -l

Run Mate' desktop

At chroot entering the PC operating system, which includes login, the root account's bash init script is responsible to invoke mate-session .
[root@android01 ~]# tail .bash_profile
if ! test -d /dev/shm ; then mkdir /dev/shm ; fi
export HOSTNAME=android01
hostname android01
export DISPLAY=:0
if test -z "`pidof sshd`" ; then /usr/sbin/sshd; fi
if test -z "`pidof mate-session`" ; then mate-session & fi 2>/dev/null
if test -z "`pidof Xvnc`" ; then vncserver -geometry 1920x1080 -localhost ; fi
[root@android01 ~]#

Development work 

For smooth terminal without "Queue background data", disable Xperia's Settings->Power Management->Queue background data, disable the Settings->WiFi->Settings-> Advanced->WiFi optimization to save power.
You can't edit source code through WIFI to the phone when vim's key strokes are delayed and come in bursts. Disable the queuing option is a must.

Flash player and chromium browser

Archlinux generously gives out builds at . And I donated to it multiple times. I have also subscribed to RedHat enterprise for 1 year, which the payout should reach Fedora developers.

 More internal works 

The source image we receive from redhat is often a dd image dump of a working fedora arm installation, and we are expected to be able to mount the filesystem inside the dd raw image when the raw image is burned to a USB flash. In an android phone, the mouting utility may or may not be able to mount ext4 or other file systems due to pared down phone kernel. So, we need to mount it with a desktop pc linux. With a desktop pc, we don't need to burn USB, and we can just mount with offset to the root partition of the raw image. To figure out the offset, use fdisk to look at the raw image. The starting block number of the root partition times the number of bytes per block is the offset.  For example,
mount -o offset=4096 Fedora-sda.raw /tmp/chroots/fedora 
, assuming root partition starts at block 8, and block size is 512.