Archive | Team RSS feed for this section

Create a Virtual Company

Nowadays there are many tools available on the Net ranging from IM to cloud computing that certainly lowers the barrier for entrepreneurs like us. Today, I am going to list out the tools that helps me to run my company:

Set up virtual office

  1. Skype – Save you from long distance bill
    • FREE. If you pay a rate, it will let you connect to phone line.
    • When I am tired of typing, it will switch to this.
    • If you like face to face conversion, I would use iChat on Mac. All you need is an AOL account.
  2. Yugma – Web conferencing
    • FREE up to 20 attendees.
    • It has Skype integration.
  3. Free conferencing
    • FREE
    • In case you don’t have internet access or your laptop is not next to you. This is a good tool because it gives you a dedicated line to dail in. However, the number is not TOLL-FREE.
    • Why 712 area code? Check this out
  4. Google tools – all FREE
    • Google doc (shareable)
    • Google calendar (it can sync with my iCal on Mac now. If you use Outlook, you need to install a plugin to do the calendar sync). Follow this guide to set it up.
    • Google email (have gmail to host your mail server – yourname@yourcompany.com)
  5. MediaWiki – good wiki tool for information sharing
  6. Posterous – create your company blog via email :)
  7. iPhone
    • Not FREE
    • I use it for sync email, calendar and access Web.
  8. VNC – Remote desktop tool
    • FREE
    • For Mac, download OSXVine Server from here.
    • If you are using DSL that assigns you IP address dynamically, it is quite a headache to keep track of it. You can obtain a domain name from DynDNS to abstract you from the IP address.
    • By default, VNC server will be listened on port 5900. If you want to do remote desktop outside your subnet, make sure your DSL router open a port for that and forward the request to your machine.
    • Here is a web-based VNC viewer. With that, you can do remote desktop anywhere. Just key in your dynDNS domain and you are done.
    • If you want to make this access security, you can password protected your box via configure the VNS Server.
    • Here is a great article for that.
    • There are people who uses LogMeIn service that provides more remote secure featuers. However, it is NOT FREE. To me, VNC Server is good enough solution.

Build your virtual dev team

  1. Tracs – combine wiki, ticket system, project planning in one
    • FREE
    • A bit complicated to set it up in web hosting company
    • It integrates with Subversion as well
    • Bugzilla is pretty good for issue tracking as well
  2. Dreamhost for web hosting
    • Below $10 per month
    • I currently use it for hosting my own blog and subversion repository.
    • No java support yet.
    • For VPS solution, this one is cheap and my buddy said it is great.
  3. VirtualBox – have several operating system runs on your laptop. Very appealing!
    • FREE
    • I set up Ubundu on my Mac. Full screen, share folders, share mouse. I love it.
    • With this, I can ensure all developers are working on the same environment. Furthermore, I can have dev, qa and production using the same environment.
  4. Omnigraffle – design graphical tool on Mac
    • NOT FREE but cheap
    • Free stencils available on here.
  5.  Amazon AWS
    • Way low cost comparing to hire your own team to make sure your system 24×7
    • Cloud computing allows you scale on demand.
    • Processing power via EC2
    • Storage via S3
    • CDN via CloudFront
    • Messaging via Amazon SQS

 

Leave a comment Continue Reading →

Wiring up Flex, Mate, BlazeDS, Spring, Hibernate and MySQL with Maven 2 – Part 1

Introduction

This article is written on top of the great work that Sébastien Arbogast has done. He has written 3 articles that showed you how to wire up Flex, BlazeDS, Spring, Hibernate and MySQL with Maven as build process. I have included his articles below as your reference.

  1. The Flex, Spring, and BlazeDS full stack – Part 1: Creating a Flex module
  2. The Flex, Spring and BlazeDS full stack – Part 2: Writing the to-do list server
  3. The Flex, Spring and BlazeDS full stack – Part 3: Putting the application together

I have found Sebastien’s work as a good foundation for my own project. To contribute back to the community, I will write a series of articles to show you how can customize and extend the todolist sample.

What is in the Part 1 of the series…

  1. Enhancements on the Maven build process
    • Leverage RSL to factor our the framework swc, so the size of the application swf will be reduced. Apart from that, I also take advantage of Flash Player Cache that is available after version 9 update 3 to cache the framework libraries.
    • Clean up the Flex and BlazeDS dependencies in POM as the latest version of the sdk is available and the BlazeDS dependencies are officially available.
    • Include some common reports for maven site generation
    • Embed Jetty web server in the build process for quick deployment and testing
  2. Document how to get the sample up on Eclipse for development
  3. Use Mate as Flex framework
    • Restructure ToDoList sample to leverage Mate framework
    • Factor out Mate as RSL and integrate it with Maven build process via Flex-mojo plugin.

What are in the coming articles…

  1. In part 2 of this series, I will show you how to use flex-mojo to build a modular Flex application.
  2. In part 3 of this series, I will show you how to test your flex app via FlexUnit (Unit test) and FlexMonkey (Functional test)
  3. In part 4 or this series, I will work on server side. I am planning to add monitoring, caching and security to the server side.

Review “ToDoList” sample

Before I start my journey, let me highlight what Sebastien has done first:

  1. Sebastien’s sample demonstrates how to use Maven as a build process. There are 3 parts or subprojects in his sample. They are:
    • todolist-config (configuration files shared by other subprojects)
    • todolist-ria (Flex frontend)
    • todolist-web (Server side that supports the Frontend)
  2. All these subprojects are considered as modules of the main project (root POM). Finally, they are combined together into war artifact and ready to deploy to Tomcat or other J2EE webapp server.
  3. Flex frontend and backend communicate through a binary RPC protocol – AMF. AMF is considered to be the simplest and fastest remoting approach available in Flex. Recently, Adobe has released BlazeDS as an open source implementation of AMF spec. In this sample, BlazeDS is used. To use BlazeDS, there are few things you need to do:
    • Externalize your POJO service via BlazeDS. This sample shows you how to integrate BlazeDS with Spring
    • Make BlazeDS endpoints availabe to the Net via Servlet.
    • Have frontend and backend shared the same BlazeDS configuration files.
  4. In this sample, you can also find out how to use flex-mojo maven plugin to compile the Flex frontend code into swf. Apart from flex-mojo plugin, there are other two good plugins worth to mention:
    • maven-assembly-plugin - can be used to bundle all the files under a directory into a zip file. It is used by todolist-config to bundle all the configuration files (service-config.xml and remoting-config.xml) into a zip during the package phase.
    • maven-dependency-plugincan be used to unpack the zip file and move to the place you want. It is used by todolist-web to unpack the config zip during the generate-resources phase.

Enhancements on maven POM

I have modified the sample’s maven pom as follows:

  • Link to new repository “Sonatype Forge” in the root POM. So, I can use the new version of flex-mojo and simplify the todolist-ria adobe framework dependencies. Apart from that, I also take away the private repository from Sebastein because BlazeDS libraries are available in official maven repository (Note: The BlazeDS libraries available in official maven repo are in version 3.0 instead of 3.0.0.544. So, you need to modify the webapp pom correspondingly).

    <repositories>
        <repository>
            <id>flex-mojos-repository</id>
            <url>http://svn.sonatype.org/flexmojos/repository/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>flex-mojos-repository</id>
            <url>http://svn.sonatype.org/flexmojos/repository/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

  • Because I link to Sonatype repository, I can have my todolist-ria depends on one flex-framework pom dependency instead of all the swc dependencies. Note that the pom dependency is a way to factor out all the adobe swc dependencies that makes your pom easier to maintain.

        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>flex-framework</artifactId>
            <version>3.1.0.2710</version>
            <type>pom</type>
        </dependency>

  • I include mysql driver as dependency in my webapp pom. I think it is cleaner to bundle it in war. I have also added jetty plugin in the POM so you have a web server embedded in the build process. With this, you can run this sample application right after you check it out from svn (assume you have maven 2 installed). To start jetty, you can issue the following maven command under your webapp project.

project_root> mvn clean install
project_root/jp-web> mvn jetty:run-war

  • I have included some reports that will be shown after site generation. You may not be able to do mvn site-deploy because it is linked to my web hosting site. However, you can modify it for your own sake.

Get the sample up on Eclipse

To develop on Eclipse, you can follow the steps below:

  1. Create Eclipse project file via running the command below at the project root. This will create 2 eclipse projects. One for todolist-ria and one for the webapp. You noticed that I use the -Declipse.downloadSource=true to include the source files of my dependencies in my eclipse project. Therefore, I can get to the source code if needed.

mvn -Declipse.downloadSource=true eclipse:eclipse

  1. Import the projects into Eclipse
  2. Add new variable M2_REPO and set it equals to [home]/.m2/repository
  3. If you have installed Flex Builder plugin to your Eclipse, you can Add Flex Project Nature to the todolist-ria project.
    • Select Application Server Type: J2EE
    • Put check on “Use remote object access service” with LiveCycle Data Service selected.
    • Set up the path. I have my tomcat installed under C:\tools with default 8080 as port. You should make the changes if you installed it differently.
    • Remove the generated main.mxml under the src folder.
    • Set index.mxml under src folder as default Flex application file to run.
    • Use Default Flex SDK in Flex Compiler Configuration instead of Server Flex SDK
    • Right click and select Recreate HTML Template if you see error.
    • After all these, you have configured your Flex application pointing to the webapp server and sharing the BlazeDS configuration files. You can verify in Flex Compiler Configuration’s Additional Compiler Parameters. See whether you see this: -services “C:\tools\tomcat-6.0.16\webapps\jp\WEB-INF\flex\services-config.xml” -locale en_US
    • Move the war to your tomcat’s webapp folder and start it under remote debugging setting. If you are using window, set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=n under your bin/catalina.bat.
    • Start your webapp via bin/startup.bat
    • Put breakpoint under TodoServiceImpl save method and start remote debugger on localhost:8787
    • Right click the index.mxml and Run As Flex Application.
    • Add a new entry and save it on the flex app. :razz: You should see your remote debugger halt at the breakpoint for you to debug.
    • Now you can change your flex code and test it out without leaving your Eclipse. However, if you modify the service in webapp, you need to run “mvn clean install” and deploy the war to the tomcat before your flex code can call your server-side code via AMF.

Use Mate as Framework

If you are not familiar with Mate, click the image below that moves you to a nice presentation.

 

What did I do to restructure the todolist sample to make it Mate app?

  1.  

Download

I have made my work available at: www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip

Reference

Below are the references I used for the article:

  1. Flex mojo compiler user guide
  2. Flex mojo dependency scope rules
  3. Flex 3 feature introduction: Flex 3 RSL
  4. Improving Flex application performance using Flash Player Cache
  5. FNA archetype projects 

 

Leave a comment Continue Reading →

How to test my system?

Here is a good video from Google 

Testing Strategies Overview

I believe that I don’t need to stress out how important testing is. So, lets cut the crap and talk about the challenging areas related to this subject. Here are the things I want to talk about

  1. Write your unit test first then code
    • It is the core concept from Test Driven Development (TDD). Everyone tried that will tell how great it is. However, the difficult part of it is to enforce it across your team especially under the time constraint. Everyone wants to get something out right away and we are all getting so much stresses from our business side about features release to stay competitive in the market. How can we allocate time for this “luxury”? The key here is whether you believe it will save you tons of time in a long run. If not, it is hard to carry out this idea.
    • What are the areas that could save my time? Agile development may face one big challenge from the product side. The problem is mainly due to the way they break down the project into mini-specs to fit into a sprint of work. Sometimes they find it difficult to think of a project in a micro level. To deliver the mini-spec in a agile process, they may leave out the detail in the spec and try to fill them up in an iterative fashion. Write your test first forces you to think API, input, output and use cases ahead of time. This will help you to feedback the product team earlier in the loop. Otherwise, it will cause you more time to change your logic or patch your codes later.
    • If you have a suite of unit tests, you are more confidence to do refactoring because you can perform regression tests to make sure nothing is broken. Apart from that, you can add new features to someone’s code without worrying that it will break the old features as you have the unit tests from the owner to verify.
    • Things you need to pay attention are: (1) Don’t commit code to the trunk that breaks the build (compile), but it is ok that it doesn’t pass the tests temporary as you are in the middle to fill up the code and you don’t want to have your code sitting in your local box too long. (2) Do code coverage to make sure you have your unit test exercises your codes in good %.
    • Tools I used to write my unit test: TestNG/ JUnit for Java code, FlexUnit for flex code
    • How do we unit test our DAO? Test with your local database (use same vendor and version of the database as the one in production. I don’t like to use any memory databases like Hypersonic or SQLite b/c it doesn’t really test our your SQL).
  2. Functional testing – use Selenium to automate it.

Performance/load testing

Basic workflow

  1. Create use case scripts for your application via recording. For Flex, we want a tool that can convert the binary AMF message to readable text as part of our script.
  2. Introduce natural variability - varying the login credentials, records opened, records saved, and other user actions including thinking time. This step is important because it provides the real-world variability that keeps your application working hard and prevents you from missing performance problems because of caching at various layers on your server.
  3. Define test data sets to be used by your scripts as you ramp up hundreds or thousands of simulated users executing your tests.
  4. Define profiles of load on your application. You might decide to have 20% of your users entering information slowly, 20% entering information very quickly, 40% looking up information, 10% producing reports, and 10% making account changes. The breakdowns and level of detail are entirely up to you.
  5. Specify how to run the test. You control such things as the speed of ramping up user load, how fast each user executes the test, and whether there should be natural variability between users and sessions. Each tool provides different fine-grained control over this step.

Tips

  • Don’t carry performance test without passing all the functional tests.
  • Test against single box first and you should not run JMeter on the same machine running the application to be tested.
  • Make sure that the testing is affected as little as possible by network traffic (do it in the subnet to take out network IO factor).
  • Create a test plan that contains thread group(s) that controls the threads that will be created by JMeter to simulate simultaneous users. Determine # of threads and the ramp-up period. Add HttpRequest then listener to view result in table and/or graph format. Each thread will issue an HttpRequest and response time will be recorded. Then avg response time and standard deviation will be calculated. Another way people uses JMeter is to use its HTTP session recording to produce load tests.
  • On the other hand, you need to monitor your target in terms of CPU, memory and IO consumption (use OpenNMS) during the perfomance testing.
  • Create a scheduled integration build that runs JMeter tests (use CruiseControl). Read this article for integration detail.
  • How to achieve the load via distribution?
  • How to obtain meaningful information from the raw data?
  • Look at throughput (QPS), resources consumption (CPU, Memory, IO) over time and over users/ load.
  • Need to set up the database with good amount of data for testing.
  • Performance profiling
    • Obtain the rough data from performance test first
    • Identify the bottleneck and fix the problem.
    • Don’t waste too much time to over-tune your system. Just fix the bottlenecks that impact the SLA.
  • Stress testing
  • Scalability testing – testing on scaling out or up your system.
  • Availability testing

Reference

Below are the references I read to write this article

  1. http://www.opensourcetesting.org
  2. JMeter User Manual

 

Leave a comment Continue Reading →

Configuration Management and Monitoring via Spring

Externalize your configuration from war

For settings that are going to change across different environments like database connection, you should externalize them from your war file. So, you can have your war be environment agnositic. Then, you can promote via simply copying your war across different environments. In Spring, there are several ways to achieve this.

What does Spring provide?

  1. PropertyPlaceHolderConfigurer
  2. PropertyOverrideConfigurer
  3. Write your own ApplicationContext

The first solutions you can get the detailed from here. For the 3rd solution, you can subclass XmlWebApplicationContext and override the loadBeanDefinitions method.

public class XmlWebApplicationContext extends
  org.springframework.web.context.support.XmlWebApplicationContext {

  private static ApplicationContextOverride eaco = new ApplicationContextOverride();
  protected final void loadBeanDefinitions(final XmlBeanDefinitionReader reader)
     throws IOException {

     ArrayList allLocations = new ArrayList(); // get standard locations
     String[] configLocations = getConfigLocations();
     allLocations.addAll(Arrays.asList(configLocations));
     allLocations.addAll(eaco.findFiles(configLocations));
     for (String apc : allLocations) {
       log.info("loading file: " + apc);
       reader.loadBeanDefinitions(apc);
     }
  }
}

What is JMX?

JMX is a technology that enables you to instrument applications for management, monitoring and configuration. Spring JMX module enables you to export Spring beans as Model MBean (ie dynamic) so that you can see inside your application and tweak the configuration even while the application is running.

How to expose your service as MBean in Spring?

To make your service configurable via JMX, you can follow the steps below:

  1. Optional: Create a MBean Server if there is no MBean Server instance in your environment. MBean Server is a container where MBeans live and through which the MBeans are accessed.
  2. Use MBeanExporter to expose/register your Spring beans as Model MBeans in an MBean Server. MBean in MBean Server will be identified by ObjectName. You can use jConsole or MC4J to visualize it.
  3. Optional: By default, all the public members of your Spring bean are exported as MBean operations and attributes. This is probably not what you want. Don’t worry, you are given the power to select which attributes and operations to expose via MBeanInfoAssembler.

 

Leave a comment Continue Reading →