Flex Addon Tutorial

Link 

The tutorial is good, but there are a couple of problems for pom.xml

1. change SNAPSHOT to M1. That's because SNAPSHOT repository is not available now.

     spring-flex-core
     1.5.0.BUILD-SNAPSHOT
need to be changed to 1.5.0.M1

           org.springframework.flex.roo.annotations
           1.0.0.BUILD-SNAPSHOT
need to be changed to 1.0.0.M1     

2. add plugin-repository

<pluginRepository>
   <id>flex-mojos-repository2</id>
   <url>http://repository.sonatype.org/content/groups/flexgroup</url>
</pluginRepository>

The url is
http://localhost:8080/flex2spring/flex2spring_scaffold.html

<project name>_scaffold.html

Spring Roo and Spring Flex Addon

According to link, there are 2 combinations that are working so far.

a. Spring-flex-1.5.0.M1 release (org.springframework.flex.roo.addon-1.0.0.M1.jar) is only compatible with spring-roo-1.1.0.M1 and STS 2.3.3.M1.
b. There is a patch (org.springframework.flex.roo.addon-1.0.0.BUILD-20110219.075648-225.jar), which will work with Spring-roo-1.1.1.Release.

Spring-flex-1.5.0.M1 release is the only release so far which contains Spring Flex Addon.
The good thing is the latest STS (Version: 2.6.0.RELEASE) is compatible with Spring-roo-1.1.1.Release, this will give us all the three featrues:
a. the most updated STS
b. Spring Roo
c. Flex Addon for Spring Roo

Be noted, if you want to option b, which probably most of us will do, you need manually add the following lines to pom.xml
Introducint Flex Addon for Spring Roo
Flex Spring Forum
STS with Flash Builder Plugin
Getting Started With Spring Roo

Mecurial

1. install TortoiseHg
2. If you type hg in cmd, it's not working, make sure C:\Program Files\TortoiseHg in path.
2. use command
In C:\Users\hliu\mercurial.ini,
add something like

[ui]
username = hliu <haiboliu@dovetailsystems.com>

Otherwise, when you type hg commit, it will have an error

"abort: no username supplied (see "hg help config")"

3. create a repository at your local for your own use
go to top level of your coeds
hg init
hg add
hg commit

http://hginit.com/

EJB Transaction


Bean Type
Container-Managed
Bean-Managed
JTA
JDBC
EntityYNN
SessionYYY
Message-drivenYYY

Callback

In computer programming, a callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code. 

JMS in Spring

If you used JMS before, you knew the drill. Before we could send/receive a message, we need create get a connection factory, then create a connection, start a connection, create a session, create a queue or topic, create a producer/consumer....and after that, we need clean up the connection and session.

Now enter Spring

All we need is inject a JmsTemplate and Destination to producer/consumer bean.

Here is how to send a message in producer bean.
jmsTemplate.send(destination,
    new MessageCreator()
    {
     public Message createMessage(Session session) throws JMSException
     {
      TextMessage message = session.createTextMessage("Hello, World!");
      return message;
     }
    });

Here is how to receive a message in consumer bean.
Message message = (Message) jmsTemplate.receive(destination);
Here is the configuration for JmsTemplate and Destination
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
     <property name="brokerURL" value="tcp://localhost:61616"/>
</bean>

<bean id="queue_destination" class="org.apache.activemq.command.ActiveMQQueue">
     <constructor-arg index="0" value="BolunQueue"/>
</bean>
You are welcome!

Regular Expression Example

^[0-9]+:

This will look for at the start of each line something like 1:

It's very useful to reformat some java codes which were posted with line number.

What's wrong with ActiveMQ version apache-activemq-5.5.0-bin.zip

I am trying to play with the most updated ActiveMQ: apache-activemq-5.5.0-bin.zip.

I thought it should be fairly easy. Download the zip file, unzip it, put lib\ and activemq-all-5.5.0.jar in classpath, and make sure java in PATH, I got everything covered.

But when I try to start activemq, I got an error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

Dear God, this drives me crazy, I could not figure it out anything that I did wrong to cause this, tried all the options that I could think of, finally I gave up, I told myself, what about try some other version, let's say, apache-activemq-5.4.2-bin.zip. 

Guess what, it is working!

Find + Grep

find . -name "*Extent.java" -exec echo "{}," \; -exec grep " CLASSNAME" '{}' > output.xml \;

This is search all the files ends with "Extent.java", print the name, then grep the line which contains "ClASSNAME", then put everything into output.xml

snippet of output.xml

/advising/src/com/dovetailsys/advising/Q5CNPBankRestrictionExtent.java,
    public static final String CLASSNAME = "CNPBankRestriction";

JEE Transaction

2 types of transactions:
a. Container-managed transactions
b. Bean-managed transactions

Table 14-1 Transaction Attributes and Scope 
Transaction Attribute Client's Transaction Business Method's Transaction
Required None T2
T1 T1
RequiresNew None T2
T1 T2
Mandatory None error
T1 T1
NotSupported None None
T1 None
Supports None None
T1 T1
Never None None
T1 Error

Mandatory vs Never
NotSupported vs Supports
@TransactionAttribute(NOT_SUPPORTED)
@Stateful
public class TransactionBean implements Transaction {
...
    @TransactionAttribute(REQUIRES_NEW)
    public void firstMethod() {...}
 
    @TransactionAttribute(REQUIRED)
    public void secondMethod() {...}
 
    public void thirdMethod() {...}
 
    public void fourthMethod() {...}
}