4/29/2012

How to use Spring Java Config

Filed under: — Aviran Mordo

With Spring framework you can configure your beans with Java code instead of xml files, however mixing the two might cause unexpected results, if you don’t use Java config correctly.

One example we were facing when we used mixed configuration methods (xml and java) is that beans you reference in your Java config are not yet initialized thus you might get nulls in places you don’t expect to get them.

Here is an example how you should NOT use Java config:

Never user members annotated as resource and use them in your Bean definition. Spring will not guarantee that the bean will be injected on that time.


BAD example

class MyConfig {
@Resource
private MyResource myResource

@Bean
MyClientBridge myClientBridge(){
return new MyClientBridge(myResource);
}
}

In above code, myResource may be null.

So how can we use it properly?
You can still define beans similar in both xml files and Java Config however when you use them in Java Config you need to pass them as arguments to the bean definition. If the arguments are Spring beans then Spring will inject them with the relevant dependencies.

Here is the CORRECT usage:


Good Example

class MyConfig {

@Bean
MyClientBridge myClientBridge(MyResource myResource){
return new MyClientBridge(myResource);
}
}

Spring will now inject the myResource to the method and make sure it is initialized before it does that.

4/19/2012

Dad sues Apple for pushing cash-draining ‘free’ games at kids

Filed under: — Aviran Mordo

An iPhone-owner whose daughter downloaded $200 worth of “Zombie Toxin” and “Gems” through in-app purchases on his iPhone has been allowed to pursue a class action suit against Apple for compensation of up to $5m.

Garen Meguerian of Pennsylvania launched the class-action case against Apple in October 2011 after he discovered that his nine-year-old daughter had been draining his credit card account through in-app purchases on “free” games incluing Zombie Cafe and Treasure Story. This month, Judge Edward J Davila in San Jose District Federal Court has allowed the case to go to trial, rejecting Apple’s claim that the case should be dismissed.

Meguerian claimed that Apple was unfairly targeting children by allowing games geared at kids to push them to make purchases. He describes games that are free to play but require purchases of virtual goods to progress as “bait apps” and says they should not be aimed at children:

Numerous gaming apps are offered for free, although many such games are designed to induce purchases of what Apple refers to as “In-App Purchases” or “In-App Content” i.e. virtual supplies, ammunition, fruits and vegetables, cash and other fake “currency”, etc within the game in order to play the game with any success.

These games are highly addictive, designed deliberately so, and tend to compel children playing them to purchase large quantities of Game Currency, amounting to as much as $100 per purchase or more.

4/10/2012

Android grabs more than half of US smartphone market

Filed under: — Aviran Mordo

Android increased its US smartphone market share to more than 50 percent for the first time during the three months to February 2012.

Digital measurement firm ComScore found that Android’s market share hit 50.1 percent, up from 46.9 percent in November 2011 and up 17 percentage points compared to February 2011. Google announced this week that nearly 3 percent of all Android devices have now been upgraded to the latest Ice Cream Sandwich version of the OS.

Apple’s iOS had the second largest share with 30.2 percent of the market, up five percentage points compared to a year ago. RIM’s BlackBerry OS came in third with 13.4 percent, followed by Microsoft’s Windows Phone 3.9 percent and Symbian 1.5 percent.

Powered by WordPress