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, http://static.springsource.org/spring/docs/2.5.x/reference/aop.html. 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.

site: http://leepoint.net/notes-java/language/10basics/import.html

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, http://www.martinfowler.com/articles/injection.html

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, http://www.best2jj.com.

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

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 http://www.yourWebServer.com, http://www.best2jj.com 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.

Apache plus https, set up a secure web site

Another limitation on home ISPs, besides the dynamic IP address, the http default port 80 is blocked.

Using some open port test tools check against my home external IP address, and found out 443, the default https port is still open. So I decide to use the https protocol instead.

This web site is built on top of apache web server, in windows environment. To have apache provide https connections, the apache with ssl support version should be downloaded, and installed first.

  • create the site SSL certificate

After installation, at /bin  directory of apache, there should be a openssl.exe module.  Besides, there is a openssl.conf under /conf folders.

There are three steps to create the certificate.

  1. create the new key
    openssl req –config openssl.conf –new –out ./ssl/best2jj.csr –keyout ./ssl/best2jj.pem
  2. remove the passphrase from the key(for safety)
    openssl rsa -in ./ssl/best2jj.pem -out ./ssl/best2jj.key
  3. Convert request into signed certificate
    openssl x509 -in ./ssl/best2jj.csr -out ./ssl/best2jj.cert -req -signkey ./ssl/best2jj.key -days 365
  • install or configure the certificate

modify the http.conf files, change the setting as below,

  1. enable ssl modules
    as uncomment this line, LoadModule ssl_module modules/mod_ssl.so
  2. enable ssl configurations
    as uncomment this line, Include conf/extra/httpd-ssl.conf
  3. add these lines at the end of the http.conf
    SSLMutex default
    SSLRandomSeed startup builtin
    SSLSessionCache none
  4. at httpd-ssl.conf, point to the correct certificate and certificatekey files
    SSLCertificateFile “the directory to your cert file just now created/best2jj.cert”
    SSLCertificateKeyFile “the directory to your key file just now created/best2jj.key”

Restart the server, and test using https://yourServerAddress.