good explanations on inner classes, especially anonymous class

We’ve already seen examples of the syntax for defining and instantiating an anonymous class. We can express that syntax more formally as:

new class-name ( [ argument-list ] ) { class-body }

new interface-name () { class-body }


and Syntax for anonymous classes
Before getting into actual code in the sample program, I want to explain the syntax used to define and instantiate an anonymous class.
The definition and instantiation of an anonymous class uses one or the other of the two expressions shown in Figure 1.
new className(optional argument list){classBody}

new interfaceName(){classBody}
Figure 1

Usually, this expression is included inside a larger overall expression, such as an argument to a method call.

What does the first expression mean?

Here is how I usually explain this syntax to my students. The first expression in Figure 1 starts out fairly normal, but becomes cryptic very quickly. This expression instantiates a new object from an unnamed and previously undefined class, which automatically extends the class named className, and which cannot explicitly implement any interfaces. The body of the new class is given by classBody.

The result of executing this expression is that a new class that extends className is defined, a new object of the new class is instantiated, and the expression is replaced by a reference to the new object.


Spring AOP

the project I am currently working on, has used Spring AOPs, for service auditing purposes.

here is the very detailed explanation on this topic, however, it’s too much detailed, just quickly go through and pick up the important points.

some points to note are,
1. Spring AOP support both schema-based, and aspectJ-based AOP
2. the former is by configurations purely in schema, as defining the aspect, join-point and advice, using XML.
3. the latter, AspectJ-based, is using AspectJ annotations., plus just enable aspectj-autoproxing in schema
4. to Note, choose either or, not both. which is the current situation my project having now, redundant

AOP + OOP, quite good pattern

very good explanation on java imports

import FAQ

1. Q: Does importing all classes in a package make my object file (.class or .jar) larger?

A: No, import only tells the compiler where to look for symbols.
2. Q: Is it less efficient to import all classes than only the classes I need?

A: No. The search for names is very efficient so there is no effective difference.
3. Q: Doesn’t it provide better documentation to import each class explicitly?

A: This shows good intentions, but …
* It’s hard to remember to remove classes when they are no longer used, so the import list is surprisingly often wrong. It can seriously slow down reading because unusual or unexpected class imports make me look for that class, only to discover that it must have been used in an earlier version.
* Explicit class imports permit accidentally defining classes with names that conflict with the standard library names. This is very bad. Using “*” to import all classes prevents this dangerous naming accident.
* It’s annoying to always update this list, altho if you use NetBeans, fixing the list is only a click away (see below).
4. Q: I’ve imported java.awt.*, why do I also need java.awt.event.*?

A: The wildcard “*” only makes the classes in this package visible, not any of the subpackages.
5. Q: Why don’t I need an import to use String, System, etc?

A: All classes in the java.lang package are visible without an import.
6. Q: Is the order of the imports important?

A: No. Group them for readability.


struts 2 action flows

and “All objects in this architecture (Actions, Results, Interceptors, and so forth) are created by an ObjectFactory. This ObjectFactory is pluggable. We can provide our own ObjectFactory for any reason that requires knowing when objects in the framework are created. A popular ObjectFactory implementation uses Spring as provided by the Spring Plugin.”

Besides, for dependency injection, it’s generally referred as, “instead of creating its own required objects, object creation would be done by an object factory.”

For struts, spring integration, using struts-spring plugin, the struts.objectFactory is configured to use the spring object factory as in the struts-plugin.xml. nothing needs to be configured( unless special requirements), other than simply put the struts-spring plugin jar in class path.

for this integration, or DI, or IoC, whatever called, possible usage examples are,


<action name=”check” class=”checkActionClass” ….>


Spring applicationContext.xml

<bean id=”checkActionClass”…..>


which would wire the object, initialized using spring object factory, or framework(till now, i m still not that clear about those concepts, many more books to read).


<action name=”check” class=”whatever(either wired through struts internal auto-wiring, or spring framework, depends on whether its been defined in spring bean definitions, since that’s the priotiry)”/>

while inside this “whateve” action class, its constructors would be initialized first, then followingly, all setter methods conducted!! again, priority goes to spring first.

for example, if there is one property inside the action class, like

class WhateverActionClass{


InterfaceServiceA serviceA;

//methods, using the serviceA method update DB

//setters, set the sevriceA


spring, application-context.xml

<bean id=”serviceA” …./>

after initilization of the whateverActionClass, all its properties setters methods would be called, and set using the bean definitions which has bean id same as its property name; due to the default auto-wiring is byName.


add on, to this DI, or IoC,

java class file version

yesterday trying to build the current project, in the course, having encountered the class file version problem, like saying “class file version 50 required, yet it’s currently version 49” something like this.

This problem is due to the jdk version difference. The currently compiling class is using a jdk version different from its dependency class, which has been already compiled by a different version jdk.

basically, class version 50, is compiled using jdk 6. version 49 using jdk 5. version 48 using jdk 4

Google Adwords

Just created an google anlytics account for my google site,

there is a promotion for google adwords these days, with free $100 promotion. So I just created an account, and use it to promote

It’s quite powerful, 18 more views today, that’s same amount as past several days. But just there is only one CPC, but it’s priced at $1.6.

Go to google adwords account, change CPC auto to manual mode, then set CPC limit at $0.10.

The CPC limit is for the ranking. But for me, currently I just wanna save money.

set up filezilla ftp sever from home sever

FTP protocol is first draft in 1971, and current specs are from 1985. It’s an ancient technology where NAT, firewalls not there.

As for now, to set up a FTP server from home LAN, some configurations need to be catered as a result.

There are actually two connections for FTP, control connections and data connections. Two modes for data connections, passive mode (for server), and active mode (for server).

Passive mode is recommended,  which is the case, client come to pull data. While port or active mode is server to push data to client.

Settings are actually not complex, but deserve attention and carefulness. To add on the frustration for this is the lack of proper explanation from the internet.

Too much messed info is worse than no info.

For the server set up,

  1. general settings, to specify the listen port, which is default 21. But some ISPs might block this port, including mine. So specify a different port, and NAT it from your external IP to your filezilla server internal ip. lets say port 29000. eg.
  2. (Somewhere most problems seen from internet are due to this) under passive mode settings, specify the external ip address, which is, for my case.
  3. The tricky part, specify the port range, let’s say 30000-40000, and NAT it also. The configuration of this is the data connections of the two FTP connections, other than the control connections, which lying on port 29000.

    A lot of problems seen from internet are due to this, cause other than the listening port, FTP uses another range of ports, for data connections.

refer, Network Configuration
Done this, it works fine.