Archive | January, 2008

Integrate Jasper into Spring Framework

http://www.somaco.co.uk/index.php?Itemid=26&id=49&option=com_content&task=view

http://dynamicjasperplayground.fdvs.com.ar/ar.com.fdvs.dj.example.djApp/djApp.html

http://assets.devx.com/download/16974.pdf

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 →

Do I need JBoss?

Recently I have been asked, "Why you need JBoss if Tomcat and Spring already give you the stuff for Web application development?".Hmm… Good question. I have kept using JBoss as I used to do EJB development and I found JBoss is a great open source application server. Later, I adopted Spring POJO container and dropped EJB. However, I still continue to use JBoss because Spring will happily live within a JBoss-deployed WAR. So, I never ask myself this question. OK, let me step back and think over what else JBoss provides me apart from EJB support.

Here is the list I come out that I may use JBoss for:

  1. JMX Container
  2. Deployment Lifecycle and Deployment
  3. Transaction Manager
  4. EAR deployment/ Classloading Architecture
  5. MDB
  6. Distributed architecture and clustering capabilities

Here is what I use Spring for:

  1. IoC (Service Configuration, including Hibernate)
  2. AOP
  3. Integration Testing Framework
  4. Transaction Demarcation
  5. JDBC Template
  6. Spring Acegi Security Framework
  7. Spring Remoting – Hessian, Web Service…

How I move away from JBoss

Now, let me see whether I can live without JBoss. Here is what I can do if I move away from JBoss.

  1. JMX Container -> I will expose it via Spring and have JConsole from JDK to monitor it.
  2. Deployment Lifecycle and Deployment -> This one I am not sure
  3. Transaction Manager -> I will use the one provided by Spring. I am not sure which one is better.
  4. EAR deployment/ Classloading Architecture -> I will do WAR deployment only.
  5. Message-driven bean -> I will use Message-Driven POJO on top of ActiveMQ
  6. Clustering -> Tomcat v5 now has clustering and session replication support

How do I feel after that

In conclusion, for simplicity, I believe I am good to move away from JBoss for my web application development. There are other benefits that drive me to move away from JBoss. Here are the list:

  1. Shorter load and start up time for Tomcat. JBoss takes 2 minutes to start up whereas Tomcat will load in a matter of seconds.
  2. Less memory consumption for Tomcat.
  3. Classloading in Tomcat is standard.

However, there are some areas I want to point out after I dropped EJB and go purely on POJO. Using Spring remoting is lightweighted. However EJB remoting has its own strength in terms of distributed transaction management. Without EJB, there is no distributed rollback. Follow up: I have found an article showing me how to do distribute transaction with Spring alone. I put the article reference below.

Reference

XA transaction using Spring http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html?page=1

Leave a comment Continue Reading →

Planning a Behavioral Marketing Campaign

To have an effective marketing strategy, you should follow the steps below:

  1. Audience segmentation
  2. Targeting
  3. Positioning

Audience Segmentation

We normally segment our audience based on the following characteristics:

  1. Geographical - location like country, dma, city, zip
  2. Demograhical - gender, age, income, education, culture and job.
  3. Behavioral - online/offline shopping behavior, web usage, website loyalty, prior purchases.
  4. Psychographical - social class, lifestyle, personality, type

For a market segment to be useful to marketers, it should meet some certain criteria:

  1. Measurable and obtainable
  2. Accessible with minimum of cost and effort
  3. Large enough to be profitable

Targeting

How to target the segment you chose? There are many ways that you can do it: email, banner advertising or viral marketing. Here I will not go through each of them. I will focus on banner ad with behavioral targeting. The idea of advertisement is to drive more sell and profit to the company. To do that, you need to be targeted in order to make the advertiseing dollars you spent more effective. Segmentation is a good start. After that, you need to understand that the buying cycle of your product. It normally drives from customers’ needs. If there is a need, users normally start to do the information gathering and the buying window is open at that time. If you successfully push your relevant ads with the right message to them at that time, there is good chance they will react on your ad. The idea is simple but in practice it involves a lots of work. First, we need to gather enough information to segment our users. Normally, online traffic stream doesn’t contain demographic and psychographic info. That is why big giants like Google pay top dollars to buy the social networking site. They are not buying their tech but the huge user-based and site-stickiness.

Leave a comment Continue Reading →

How cookie deletion impacts ad network?

More and more people are concerned with privacy and start deleting cookie to prevent being tracked. How will this impact on the ad network?

  1. Undercount the conversion (both click and view-based). However, vast majority of conversions (70-90%) occur within 24-hour window of the corresponding click or impression and there are not too many people delete cookie daily. So, the impact is not that much.
  2. Underestimate the frequency and overestimate the reach
  3. Users may continually fall off the profiled segment and behaviorial targeting. If the trend continues, that may translate to less available profile inventory, which could result in higher prices or under-delivery. Nonetheless, cookie deletion should not diminish the value of the targeted impressions that publishers are currently able to deliver. There are even an argument that cookie deleting may actually increase the value of targeted inventory since recency is a dominant driver of effectiveness in behavioral targeting.
Leave a comment Continue Reading →