Maven Setting Up

1. download the zip, unzip it into some folder, let's say C:\Applications\apache-maven-3.0.3
2. setting up variables
M2_HOME=C:\Applications\apache-maven-3.0.3
put %M2_HOME% into PATH
M2_REPO=C:\Users\Paul\.m2\repository
3. mvn -v   should work now.
4. to make sure a project maven compatible, use mvn eclipse:eclipse
5. in Eclipse, you need setup M2_REPO variable
select Window > Preferences. Select the Java > Build Path > Classpath Variables page.

Inject Non-Spring Bean

Additional Jar files:

org.springframework.aspects-3.1.0.M1.jar
c:\aspectj-1.6.11\lib\aspectjweaver.jar

Also need make sure JVM AspectJ-enabled.

put -javaagent:C:/aspectj-1.6.11/lib/aspectjweaver.jar
into VM Argument section

The above are just setting environments.

Why/when we want to inject stuff into a non-spring bean?
There are many scenarios that a bean is not instantiated by Spring, but we still want to inject value/references into this bean.

In config:

xmlns:aop="http://www.springframework.org/schema/aop"
...
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
...

<aop:spring-configured/>

<bean id='noSpringBean' class="packageA.NoSpringBean" abstract="true">
<property name="beanName" value="Bolun"/>
<property name="height" value="187"/>
</bean>

NoSpringBean.java

@Configurable("noSpringBean")
public class NoSpringBean
{
...
}

When you test it, you will see a lot of Waving stuff before our codes are really executed, performance wise, this could be really bad.

Adding org.springframework.transaction-3.1.0.M1.jar into path, removed a lot of complains.

Spring Example: Wired Together


package packageA;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloApp2 
{
   public static void main(String[] args) 
   {
     ApplicationContext ctx = new ClassPathXmlApplicationContext("config.xml");
     GreetingService greetingService = (GreetingService) ctx.getBean("greetingService");
     greetingService.sayALotOfGreeting();
     greetingService.theWinnderOfOscar();
     greetingService.sayGreeting();

     Lime iLime = (Lime) ctx.getBean("lime");
     iLime.drink();
   }
}

Spring Example: Groovy File


class Lime implements packageA.Lime 
{
    void drink() 
    {
      print "Groovy not in line!"
    }
}

Spring Example: Injected Method Implementation


package packageA;

import java.lang.reflect.Method;
import org.springframework.beans.factory.support.MethodReplacer;

public class WinnerInEnvelop implements MethodReplacer
{
   public Object reimplement(Object arg0, Method arg1, Object[] arg2) throws Throwable 
   {
      System.out.println("Samuel Bolun Liu");
      return null;
   }
}

Spring Example: Config file

Groovy in Spring

Now I could inject Groovy class into Spring, but the problem is Groovy class has to implement a Java interface, in this way, I could get the bean from application context.

I am wondering is it possible that I could get Groovy class without using interface?

Groovy in Spring

--------------------for DI---------------------
org.springframework.asm-3.1.0.M1.jar
org.springframework.beans-3.1.0.M1.jar
org.springframework.context-3.1.0.M1.jar
org.springframework.core-3.1.0.M1.jar
org.springframework.expression-3.1.0.M1
c:\springsource\spring-framework-3.1.0.M1\dist\dependencies\commons-logging-1.1.1.jar
--------------------for method injection---------------------
c:\springsource\spring-framework-3.1.0.M1\dist\dependencies\cglib-nodep-2.2.jar
--------------------for Groovy integration------------------
c:\springsource\spring-framework-3.1.0.M1\dist\dependencies\aopalliance.jar
org.springframework.aop-3.1.0.M1.jar
c:\groovy-1.7.2\lib\antlr-2.7.7.jar
c:\groovy-1.7.2\lib\asm-3.2.jar
c:\groovy-1.7.2\lib\groovy-1.7.2.jar

Groovy, Grails, Ruby, Rails

The combination of Groovy and Grails offers productivity benefits rivaling Ruby on Rails, but on the proven, scalable, and seamlessly integrated Java platform.

Ruby and Groovy are languages.

Rails and Grails are frameworks.

Python is a language.

Django is a framework.

tulpe vs list

A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The only difference is that tuples can't be changed ie. tuples are immutable and tuples use parentheses and lists use square brackets.

JMS

JNDI Context (jndi.properties)
QueueConnectionFactory
QueueConnection
QueueSession
QueueSender
QueueSender could send message

Don't you hate this? To send a message, we have go through all these....

Spring continue (2)

I tried to implement some method injection. Easy, right?

But I keep getting some weird errors, it turns out that I missed a jar called cglib, I just don't understand why Spring doesn't include this jar? or did I miss the boat?

I also found I actually need cglib-nodep-2.2.jar (see "nodep" part? means no dependency), if you just use cglib-2.2.jar, you'll get other compilation error, because this jar need other jars as dependencies.

Aghh....

check this out

ls -1

ls -1: Print one entry per line of output.

Spring continue

You can configure both simple property values (using the value attribute) and properties with references to other beans (using the ref attribute). But value and ref are only useful when your bean’s properties are singular.

What if a property is a collection of values?

list
set
map
props

Spring 3.1.0.M1

Here are the contents of \spring-framework-3.1.0.M1\dist\

org.springframework.aop-3.1.0.M1.jar
org.springframework.asm-3.1.0.M1.jar
org.springframework.aspects-3.1.0.M1.jar
org.springframework.beans-3.1.0.M1.jar
org.springframework.context.support-3.1.0.M1.jar
org.springframework.context-3.1.0.M1.jar
org.springframework.core-3.1.0.M1.jar
org.springframework.expression-3.1.0.M1.jar
org.springframework.instrument.tomcat-3.1.0.M1.jar
org.springframework.instrument-3.1.0.M1.jar
org.springframework.jdbc-3.1.0.M1.jar
org.springframework.jms-3.1.0.M1.jar
org.springframework.orm-3.1.0.M1.jar
org.springframework.oxm-3.1.0.M1.jar
org.springframework.test-3.1.0.M1.jar
org.springframework.transaction-3.1.0.M1.jar
org.springframework.web.portlet-3.1.0.M1.jar
org.springframework.web.servlet-3.1.0.M1.jar
org.springframework.web.struts-3.1.0.M1.jar
org.springframework.web-3.1.0.M1.jar

I tried an really easy example, try to use ApplicationContext and ClassPathXmlApplicationContext, guess what, it's not that easy to make a simple program to work!

First, you have to add commons-logging-1.1.1.jar into classpath, I guess Spring is using this jar, but they don't put it into one of their package???
Second, I have to import all the following jars:

org.springframework.asm-3.1.0.M1.jar
org.springframework.beans-3.1.0.M1.jar
org.springframework.context-3.1.0.M1.jar
org.springframework.core-3.1.0.M1.jar
org.springframework.expression-3.1.0.M1.jar

although in the code, I don't see anywhere I am explicitly using asm.jar and expression.jar, just weird. 

One usage of Python

Image you have something like
data1=value1,data2=value2,....

And you want to format them into 'data1':value1, 'data2':value2,...

You could do this quickly using python

def foramtConversion(**items):
     print items

then put your values into this foramtConversion() function as parameters, boom, you get what you want, simple like that.

Notebook

I am trying to look for a notebook that could expand and collapse inside the notebook...too much to ask?

AM-notebook is not bad.

Copy and Paste in Outlook Without Messing Up Your Formatting

This trick works at Other office products too.

Tools->Options->Mail Format->Editor Options->Advanced->Cut, copy, and paste

Pasting from other programs: you could set Keep Text Only.

There are other options, you get what I mean.

Other tricks, if you do have formatted text in office product, select them, then process CTRL + space, it will remove the formatter.

Google Search

If you search "-D32" without quotes, you will get nothing, you need put "" around -D32.

That's because in Google search, when you attach - before a word, it means you do not want pages that contain this word to appear in your results.

For info, see the link

Cannot load 64-bit SWT libraries on 32-bit JVM

Link

Be noted: Switching modes is only possible on Solaris. A JVM is either 64bit or 32bit, except on Solaris where both run modes are available in a single JVM.

(In windows, this will not work.)

Eclipse -> Preferences -> Java -> Installed JRE
select the JRE that you want to change, click Edit
add -d32

Python Scribbles

Installation:
1. download, select the right version, seem there are some for AMD.
2. there are 2 major versions here. 2X and 3X, 3X is for the future, but you might have some compatible issue, after all, not everyone is up to the speed yet.
3. set C:\python at PATH, be notes, it's just C:\python, not C:\python\bin. After that you are in business.
4. type python, you are in.
5. run a python script, say, named as "test.py"
print "help world!"
file = open("data.txt", "w")
file.write("this is a test for python script, just showing that we could write python script\n")
file.close()
you could run it using: python test.py  

Be noted, you don't need import any lib for this scripts. (that's because print, open are build-in functions)

Other things:
1. there is ActivePython: saying python for windows.
2. WLST (weblogic scripting tool): Jython
3. there are some version of python which are database modules (must be easy to work with database).
4. google command line (python)
5. Jython: Jython programs can seamlessly import and use any Java class. Except for some standard modules, Jython programs use Java classes instead of Python modules.
6. .pyw: the .pyw extension simply means: run this Python script without creating a console window. This is
generally what you want if you have a program which is GUI-based. You can run *exactly* the same program with a console window simply by renaming it to .py.
7. PyDev is a Python IDE for Eclipse, which may be used in Python, Jython and IronPython development.
7.1. Aptana Studio 3 (has PyDev pre-installed.)
8. Python module is a file containing Python definitions and statements.

Weblogic Domain

domain is the basic administration unit for WebLogic Server instances. A domain consists of one or more WebLogic Server instances (and their associated resources) that you manage with a single Administration Server. You can define multiple domains based on different system administrators' responsibilities, application boundaries, or geographical locations of servers. Conversely, you can use a single domain to centralize all WebLogic Server administration activities.
Each domain's configuration is stored in a separate configuration file called config.xml, which is stored on the Administration Server along with other files such as logs and security files. When you use the Administration Server to perform a configuration task, the changes you make apply only to the domain managed by that Administration Server. To manage another domain, use the Administration Server for that domain. For this reason, the servers instances, applications, and resources in one domain should be treated as being independent of servers, applications, and resources in a different domain.You cannot perform configuration or deployment tasks in multiple domains at the same time.

Deploying BlazeDS to Weblogic 10.0

Link