Archive for the ‘IT’ Category

Introduction to JPA

Well its that time of my career where you need to sharpen yourself again to find stumble on the right career path for you and for me it means finding the right project. Originally being a Linux, C/C++ guy, I couldn’t simply ignore the Java buzz and the importance different pieces of Java plays in the architecture world.

Talking about architecture, database enabled Java enterprise applications are of prime importance as they form the basic of any application deployed in the enterprise world.Taking it a bit further,knowledge of persistence APIs are a must have skills in your resume if you want to survive the competition. So this multi-part blog is an effort to help programmers like me to deep dive into the basics of persistence with Java.

2006 saw the final release of EJB 3.0 which was based on JSR-220 (Java Specification Request). This release gave the programmers the ability to store and retrieve application data to and from the database respectively.  This set of APIs is known as the Java Persistence API  or JPA. JPA incorporates many of the concepts and standards from leading persistence frameworks like Toplink (from Oracle) and Hibernate (from JBoss). One of the great benefits of JPA is that it is an independent API and can nicely integrate with J2EE as well as J2SE applications.

By plain definition in Java terms, Java Persistence API (JPA) provides POJO (Plain Old Java Object) standard and object relational mapping (OR mapping) for data persistence among applications.

So what is POJO?

Plain Old Java Object is a term used to refer Java objects that do not extend or implement some specialized classes. The following classes are not POJO classes because the first one extends a specialized class and the second one implements a specialized class.

    class MyServlet extends HttpServlet {}
    class MyRemote implements SessionBean {}

What is Object-Relation Mapping?

OR Mapping – Object-Relation mapping is the process of the transformation of the data between the class objects and databases. Applications can depend on an OR-M like tool that greatly simplifies this work instead of manually coding the transformation process.

Entities

Persistent Data normally refers to permanent data in an application. The state of these data is made permanent by storing them in a persistent medium like database, files or a disk tape. In JPA terms, these persistent data are referred as entities. An entity refers to a logical collection of data that can be stored or retrieved as a whole. For example, in a banking application, Customer and BankAccount can be treated as entities. Customer name, customer address etc can be logically grouped together for representing a Customer entity. Similarly account number, total balance etc may be logically grouped under BankAccount entity.

Since entities form the heart of the JPA, they have some unique properties like

  1. Persistability:- deals with the storing and retrieving of entity from and to a persistent medium like database.
  2.  Identity:- is usually used to identity one unique entity among multiple entities (or multiple entity instances) in a database.
  3. Transactionability:- CRUD operations (Create, Update and Delete) for entity objects will occur within a transactional context and it is one of the major characteristic for an entity object as the real state of an entity depends whether a transaction completes (commits/fails) or not.

Next article in series:- Creating entity classes.

The US government may have legalized Jail breaking the iPhone, but think twice before you jump on the bandwagon to jailbreak your iDevices powered by iOS 4 and above.  The new web-based jail breaking technique JailBreakMe 2.0  has some substantial security risks. The JailbreakMe 2.0 “Star” exploit tool for iOS 4 and iOS 4.01 devices – iPad, iPhone and iPod Touch, allows malicious access to your phone, via websites.

Well before you really think that this jail break technique actually leaves a backdoor on your device, let me tell that’s not the case. What a jail break, really does is prevents you from getting the fixes and patches from Apple for security issues and loopholes already present in the device. To add to this, jail breaking allows scripts from websites to bypass the restrictions of the device and load malicious code to your iOS device allowing them access to your contacts in the address book, text messages, stored files, memos and what not!

wwwery.com reports of a malicious exploit that has surfaced so far is a “PDF JailbreakMe Exploit,” that allows loading PDFs with malicious code without user prompt. However “PDF Loading Warner” has also been released, which attempts to plug this security hole.

The real issue with jail breaking the iOS 4 is that you will have to keep a track of these individual issues/exploits as they surface and might not even realize when your personal data on the device has been compromised. Also from my personal experience of jail breaking a 3.x device, I experienced a degrade in the performance of the device as well as in its reception capability.

So my advice, stay away from jail breaking as long as you can!

When Apple announces launch of any iPhone related stuff be it the OS or device itself, the entire web goes crazy. Perhaps nothing else on the Internet other than those trojans, can generate such a traffic on the Internet. So like others I also joined the craziness bandwagon and tried to find out what Apple has packed for us in the new iPhone 4.0

A new name
Since iPhone OS is being used in iPhone, iTouch and iPad it will no longer be known as iPhone OS, from now it on it would be rather iOS 4. Fair enough!

Multitasking
After a long time iPhone will finally have the multi-tasking capabilities, might sound lame to a few people from the multi-tasking world, but Apple had it’s own reason to avoid multi-tasking till now. As always they managed me amuse me. If you are an entrepreneur  it’s always a good idea to challenge your people when it comes to creativity. That’s what apple does the best. Challenged it’s developers to add multi-tasking and still maintain battery life, viola we have selective multi-tasking. What Apple really did is went over all the applications it has in the app store and determined the kind of applications and the kind of multi-tasking they would need and from this pool selected the services and exposed them as kernel APIs. Neat way huh.

Unified E-mail
iOS 4 gets a unified in-box for multiple e-mail accounts. It includes threaded e-mail conversations and the ability to delete all conversations at once. As of in the older generations of iPhone, if you have setup multiple mail boxes you have to switch between mailboxes to read mails. The new OS now allows you to read them in a single view. It would be interesting tough to see how they are going to manage multiple folders in the mailboxes. I’ll wait to see that.

Folders
If you always thought that your applications are kind of unorganized on your iDevice (that’s a generic term I like to use for either iTouch, iPhone or iPad) and that dragging applications between pages can be boring, well now Apple has folders just for you. You can now create folders by dragging one app on top of another, a good way to create a sort-of application launcher. You can rename folders and drag on more apps at any time.

Camera software
The new iPhone camera has a lot of wow factor for me, the camera hardware is bumped up from 3 megapixels to 5, the onboard software gets 5x digital zoom and tap to focus. I wish I had that feature on my iPhone.

Video conferencing
Taking advantage of the front-facing camera is support for video conferencing. FaceTime, as it’s called, works over Wi-Fi in landscape or portrait mode for any iOS 4 device with a front-facing camera. Wi-Fi only for now, but 3G support may be soon on it’s way.

HD video recording
Ok movie makers this is potentially for you, one of the new features that iOS 4 adds  is a high-def recording rate of 720p at 30 frames per second and allows you to share the video in a single click. Mind the battery as the LED flash is always on during the recording. I won’t be surprised if Apple launches its own Mobile Movie Competition after this to beat Nokia Mobile Movie Competition.

iMovie for iPhone
Apple did provide you with a HD camera and it also provided you with the iMovies app using which you can edit HD videos from the phone. From there, you’ll be able to MMS, share videos via MobileMe, YouTube, and e-mail–but notably not through Facebook. iMovie will be able to pan and zoom and add effects, transitions, and themes. It will also tack geolocation into the movie titles. You can record videos directly into a video timeline and pinch to change the scale or drag to trim or edit the video. You’ll also be able to choose your export size. iMovie will cost $4.99 in the App Store. Looks like you can setup your own movie studio on your iPhone.

iBooks
The e-book reader war is heating and that is what Apple has brought to your cellphone if you don’t want to put your money behind Kindle, Nook or even iPad, Apple does make sure that they have the share of your money they are eyeing on. Later this month, you’ll be able to annotate, tap to bookmark a page, view and read PDFs, and select between books or PDFs within your iBooks shelves. The table of contents will display all your bookmarks and notes.

There are still other many features like iAd and others which i took the liberty to skip out in my post as I also wanted to talk a little bit about what iOS 4 missed.

The Misses

  1. The Apple vs Adobe war is no secret and so as expected, Flash support is still not it. Apple thinks of Flash as a battery hogging proprietary platform. But well in my opinion, look at any iDevice you won’t even miss Flash. Why the fuss, I don’t need Flash on my iPhone.
  2. FM Radio is a basic feature for most of the phone makers like Nokia, Sony Ericsson etc but Apple decided to give it a miss this time too. I would say why I would need FM radio when I have my own iPod packed in my phone. I would any time prefer to listen my own collection of songs rather than some DJ’s collection.
  3. The File Manager, a central app to manage all your documents, songs and photos on the device, is still not in. I wish this was included in iOS 4.

Availability
Developers get iOS 4 on Monday (i.e. today), which means that the general public won’t. iPhone 3GS, iPhone 3G, and iPod Touch (except the first generation) will get a free upgrade on their existing iPhones on June 21, though not all features will be supported off the bat–for example, FaceCall, which requires a front-facing camera that those devices don’t have.

E-mail: iOS 4 gets a unified in-box for multiple e-mail accounts. It includes threaded e-mail conversations and the ability to delete all conversations at once.

Folders: Create folders by dragging one app on top of another, a good way to create a sort-of application launcher. You can rename folders and drag on more apps at any time.

Camera software: As camera hardware jumps from 3 megapixels to 5, the onboard software gets 5x digital zoom and tap to focus.

HD video recording: New to iOS 4 is a high-def recording rate of 720p at 30 frames per second (and keeps the LED flash on for HD recordings). One-click sharing from the phone.

iMovie for iPhone: The iMovies app can edit HD videos from the phone. From there, you’ll be able to MMS, share videos via MobileMe, YouTube, and e-mail–but notably not through Facebook. iMovie will be able to pan and zoom and add effects, transitions, and themes. It will also tack geolocation into the movie titles. You can record videos directly into a video timeline and pinch to change the scale or drag to trim or edit the video. You’ll also be able to choose your export size. iMovie will cost $4.99 in the App Store.

Video conferencing: Taking advantage of the front-facing camera is support for video conferencing. FaceTime, as it’s called, works over Wi-Fi in landscape or portrait mode for any iOS 4 device with a front-facing camera. Wi-Fi only for now, but Jobs hinted that 3G is coming.

iBooks: Later this month, you’ll be able to annotate, tap to bookmark a page, view and read PDFs, and select between books or PDFs within your iBooks shelves. The table of contents will display all your bookmarks and notes.

Bing: Apple is adding Bing to iPhone’s search. You’ll be able to choose Google, Yahoo, or Bing for your search engine.

Enterprise integration: Data protection, device management, wireless app distribution, deeper VPN support, and support for multiple Exchange accounts (and Exchange Server 2010) are coming to iOS 4.

iAds: A new ad platform builds ads into apps, and keeps the app experience bound within the app. Translation: You won’t get kicked out of the app if you click an ad.

Miscellaneous additions: Half curl page transitions and draggable map annotations all for app developers.

Availability: Developers get iOS 4 on Monday, which means that the general public won’t. iPhone 3GS, iPhone 3G, and iPod Touch (except the first generation) will get a free upgrade on their existing iPhones on June 21, though not all features will be supported off the bat–for example, FaceCall, which requires a front-facing camera that those devices don’t have.

Ever since the “push” became the buzz word for iPhone 3.0 OS, I was curious to find out how the push notifications worked with iPhone. My initial thought was that, iPhone needed a dedicated push server visible within the operator network, just like Blackberry, but then how did iTouch used the same apps and still used the push notifications for the Wi-Fi. I began investigating and found a cool technique that Apple implemented for it’s push notifications, but I also found out a few things that I really didn’t like.

Why Push?

There is an inherent problem with the iPhone OS and the problem is that there is no “backgrounding” on iPhone, which means unlike other smart phones, the apps don’t run in background on iPhone when you exit them. This effected applications for iPhone which needed constant polling with a publication server. E.g. a RSS reader application won’t be able to poll the feeds for the new updates from the phone. To read the feeds, the user will have to open the application and manually fetch the feeds. To address the issue Apple came up with a smarter approach. They implemented push mechanism for iPhone.

Poll vs Push

An application constantly running in the background of your phone and polling for feeds or updates causes battery consumption. So if you have multiple applications doing the polling from your mobile device, your battery might get drained pretty quickly than you expect. Push however doesn’t implement the poll mechanism and you get updates as it happens.

So how does the “push” work in iPhone?

Okay, consider this, you have an application on iPhone which enables to have the push mail experience for your Gmail or AOL or any of your home grown IMAP email server. Here is a representation of how “push” mechanism would work with iPhone.

 

iPhonePush

Apple implements an intermediate server (under their own control and not under operators control or visibility) called as the Push Notification Server (PNS). The device (iPhone) maintains a constant TCP/IP connection with this server. The application developers server (or the 3rd Party Server) maintains a session with the mail server. When a new mail arrives an alert will be sent from the application developer’s server to the PNS which then pushes it to the iPhone 3.0 through the open TCP/IP socket connection. So if you had a RSS reader application, to have notifications sent to you automatically as update on a feed is available, the application developer will need to constantly monitor the feeds and notify the PNS as anything happens.

Essentially what Apple has done is moved the polling or processing need from iPhone to an intermediate level called the “App Developers Server”.

Sure this approach works for the battery benefits where background applications can claim as much as 80% of battery drain as compared to 20% on Push notifications using Apple’s technique. However the way I see it, there are some issues.

So what are the issues?

The first issue that I see from an application developer stand point is that, if I had to write a RSS reader type of application then I would have to deploy my own backend server which would monitor the feeds for the end users and notify PNS to have notifications on updates. Basically not all applications really need a backend service, but with this technique that additional layer has to be implemented. So if the number of users for my applications grow, I’ll need to setup a server farm and to recover the cost I’ll need to increase the cost of my application or charge the user a service fee which is not good either for me nor for the user.

The second and most concerning issue that bothers me is, privacy issue. Well if a third party application developer needed to constantly monitor your inbox or IM or even the RSS feeds, then it would need your credentials to establish and maintain a session with the actual mail server/chat server or should know exact feed URLs so that it can monitor them incase of RSS. How many people would really feel comfortable to know that their email usernames and passwords are being stored on a 3rd party server probably unencrypted and probably anyone managing the server would have visibility to it? To me this is the biggest issue with this approach.

A few days back, Rajesh Jain, MD, Netcore Solutions Pvt. Ltd. based in Mumbai, started a discussion on Facebook on “Mass Market Internet” talking about on the options we have for getting the millions of potential users on Internet who today either don’t have a medium to access Internet or a promising application to attract their loyalty. I wrote to him about my thoughts and below is the portion of email that I wrote to him:-

Internet Users:
Talking about Internet users, from my perspective there can be two broad category of Internet users.
 
The first ones are those people who make a consicous effort to connect themselves to the Internet and use applications delivered via the web. These are the users who are the only types of Internet users existing in India today. However the second category, which form the majority, will be those users who will be consumers of applications delivered via the web, but they may or may not realize about their connectivity to the web. From my perspective they are still Internet users as they still consume applications via the web. For them its like a service through cellphone, if you have the network you can make a call, if you have the connection you can access the application. The second category of users are the users who are illiterate or lack computer knowledge. But from this vast majority a sizeable number of them do use cellphones. For these users educating them of computers is a lengthy and expensive process, probably more expensive than setting up the Internet access infrastructure in place. For these users, a computer keyboard is more complicated to use rather than the keyboard of a cellphone or the remote control of a TV.
To get the numbers of Internet users in India to a higher point, it is important that the second category of users come online and start consuming applications regardless they know about it or not.

Medium of access:
Internet penetration not only in remote places or villages, but in small and medium towns in India is still a bottle neck. In these places, the dial-up is still the primary medium of access. Also in some of the places, the telephone exchanges have very limited capacity and the lines are prone to noise and interference. In such places, better Internet experience can be achieved through satellite Internet. At least better than dial up.

Access Device:
Television and the cellphones are the devices which have the most penetration in our country and these two are the devices, which are capable of delivering applications via Internet.
 
 
Type of Application:
From my perspective, interactive and entertainment applications will be the primary driving factor for Internet usage. Today, social networking sites are the most visited websites as they let you interact with other users in a variety of way. Even though video hosting is expensive, there are many sites which provide access to entertainment videos as there is a tremendous demand for it.
 
So what would be the type of applications.

Example 1. Consider a house or community which has a satellite television and Internet delivered via satellite (the connection can be a DTH connection). Apart from the standard channels, the user can tune into Netflix Internet TV by just click of a remote.
 
Example 2. Emails has been used via Internet since a long time now, consider a service which lets users send small emails as text messages to cellphone. So I can send an email to <mydadnumber>@provider.com which actually goes to an application on the email server which in turn splits the email (if needed) and sends it as an SMS to the end user, when the end user replies (keeping the subject intact) his reply is converted back in to an email and delivered in to the inbox of the original sender.

At the Apple WWDC 2009, today Apple unveiled a new iPhone with features everyone has been waiting for. Some of the notable features are:-

  • Built-in camera. 3 megapixel, not 3.2 as expected. Autofocus, whitebalance, exposure, tap to focus (big applause). Low light sensitivity better. Automacro as well, as close as 10 cm away.
  • Also captures video. New switch that says still or video. 30 frames per second. autofocus etc.
  • Edit from the iPhone.
  • Can share Internet (if the operator allows).
  • Voice control.
  • Built-in digital compass.
  • Accessibility features.
  • Support for Nike +
  • Hardware encryption (for the IT guys). Makes for instantaneous remote wipe.
  • Improved battery life. Up to 9 hours surfing with wifi, 30 hours of audio, 12 hours of 2G talk time, 5 hours of 3G talk.
  • Fastest, most powerful iPhone yet.
  • The prices are

    • 16 GB $199
    • 32 GB $299
    • 8 GB $99

    The new iPhone is expected to be available from June 19.

    Stay tuned for more updates!

    Microsoft’s new decision engine is now out in the wild and like many others I took the opportunity to try out the most talked about search engine (oh rather decision engine) these days.

    I started off with trying my search in the shopping category as it was the one most talked about. I searched for “iphone”. The first two page results that I got was all about “iphone accessories” rather the “iphone” itself. Well usually I don’t I go looking for something beyond first two pages of a search result if the first two pages doesn’t satisfy what I am looking for and I think that’s usually the case with most of us. But then I thought what if Microsoft somehow already knew that I already have an iphone, after it is their “knows it all” engine. Freaky!!!. So I changed my search, instead of “iphone”, I tried, “itouch”, got just the accessories. How about “ipod touch” or “ipod touch 16 GB”. Alas never got the results I was looking for!

    After 15 mins of trying to find “iphone” or “ipod touch” I gave up and started looking at the cash back offers on the iphone accessories and guess what they weren’t cheap. I had bought a iphone screen guard and body cover with arm band from a local store for 7$, but Bing cash back results just for the arm band was 18$. Obviously you had a 2-3% cash back as promised by Bing. You see they don’t lie to you. They just charge you more and then just give you back a tiny portion of the extra amount they snatched from you.

    Alright, I decided that from now on I would still prefer going to the individual websites or stick with Google for my online shopping needs and gave up on the much hyped shopping category. I moved on to the regular techie search, that I always do on Google. The results from Bing as compared to Google was not that great. The results were just from some well known API documentation web pages, but that is something a developer never searches for. Those API links are usually in his bookmarks. What he/she searches for is answers to the problems they face.

    However, apart from dislikes, there were actually a few things that I liked about Bing. The first one is the flashy and cool user interface and the second one was their result presentation for images and videos. The news segment was pretty much updated. A search on the Air France disaster showed me the latest news article was posted 53 mins ago while on Google news the latest news article was posted 9 hours ago.

    The left hand dynamic categorization is pretty cool and classifies the search result. Say for a keyword on “Air France”, the generated categories were, News, Reservations, Flights, Jobs, Schedule etc.

    Well from what I have seen so far, I won’t completely rule out Bing as my search option at the moment and would prefer to give it some more time analyze the user’s search behavioral patterns and improve its results. However one thing is for sure, Google is definitely here to stay for long.