20 December 2012

Model in Spring MVC

you can use the model items like ${modelitem} but you had to put the modelitm in the model prior to that, something like model.put(modelitem, "this is modelitem")

Rule of thumb when you need to manipulate data in your MVC application:
Try looking into the referenceData method in your controller, this is the main method grabbing data from resources and adding them into the model object. Look for something like:

protected Map referenceData(HttpServletRequest request, Object command,Errors errors) throws Exception

13 December 2012

Tree command in Mac

The one thing that I was really missing in Mac was the tree command line. If you are a terminal addict and a developer, you are among those with high probability of using this in linux. However, in Mac you don't have the option (it is not built-in). But there is always hope, you can follow the instructions on this post and have your tree command working.

Update: Kevin mentioned in google+ that it is pheasible (and might be even easier) to use Macports (or homebrew) to install the tree command. 

12 December 2012

JndiLoginInitialContextFactory & JBoss

JndiLoginInitialContextFactory is not working with JBoss >5. It worked with earlier version though. JBoss ignores the credentials for that.

7 December 2012

Google is closing down its free Apps. Wait, not for its (loyal) old customers!

One of the hot topics of Technology world today was about Google Apps. Google is shutting down its free Apps offering for small businesses. I am using Google Apps but I didn't know if it was small business account or something else that I was using. Looking into the Google Apps website, you won't no longer see any free option from today either. So I was looking on any piece of page I can find on internet to find out what will happen to my Google Apps service. I finally found this post on google enterprise blog saying the Free Apps won't be affected. However, the link was not working at the time of posting. Later that day I got an email from Google saying:
Starting today, we're no longer accepting new sign-ups for the free version of Google Apps (the version you're currently using). Because you're already a customer, this change has no impact on your service, and you can continue to use Google Apps for free.
Reading this comforted me. I never expected Google to make a free service to become fee based and force its users to pay. It is really nice of them to let those free Apps users keep their account. Otherwise I was looking for at least 50$ a year, or most probably getting my own hosting (for double that price of course) but with many additional options.

This reminds me of the time Google bought Feedburner and somehow messed up some feedburner feeds' names. Apologizing its customers, it sent them a nice package of mouse and pen. The package was not that important but the move; showing how much they appreciate their customers.

3 December 2012

Constraint vs. Trigger

Have you ever wondered which one to choose if you want constraint(s) to be forced on data? You can achieve your goal by using Triggers or Constraints (or even both). But the questions is which one to choose, and which one is better to use? Shall one go with Constraint all the time or pick Triggers every now and then? The relief is that there is a simple answer to that. Try to use constraints if you can. Constraints are "closer" to databases. Constraint are relational restriction you are setting for your data, and if you are using a relational database it is always best to use them. As all we know databases nowadays do more than just storing data and retrieving them, they perform optimization on queries as well. Defining constraint in your database, which is a relational principle, will give another chance for your database to deal with performance issues.

For more discussion head to this page: Performance consideratinos for Triggers vs Constraints

30 November 2012

JBoss and security

JBoss implementaiton of security is JBossSX. It both supports declarative J2EE (JEE) and role-based security model.
  • Default implementation for declarative security model is JAAS.
Declarative: you declare the security roles and permissions using a standard XML message, rather than embedding in your code.
Secure access to EJBs and web components using ejb-jar.xml and web.xml deployment descriptors.
  • isCallerInRole
  • security-role-ref/role-name
New from EJB 2.0, specify what identity an EJC should use when it invokes methods on other components.

26 November 2012

First impression of AppStore for Mac

I do like having all the applications that can be installed in one place. It is a really nice feature to have. Whenever you want, you can go there, find your app, have your apps backed up, read others reviews and so on.
These are all good only and only if the application you are installing won't be different from what you can get out of the AppStore. Interesting right? Apple has put some guideline in place for those applications in App Store of its Mac. For example, if you install TextWrangler from AppStore you won't get the ability to use its command line tools, such as edit .bash_profile. However, if you download from their website, you will get the full application with all the perks. See what they are saying themselves.

In order to comply with Apple’s submission guidelines, the Mac App Store version of BBEdit does not support automatic installation and updating of the bbedit, bbfind, and bbdiff command-line tools (and their associated man pages). However, it is possible to install the tools without using BBEdit’s built-in installation, and once installed, they will work correctly.

BBEdit is another product of Bare Bones Software, similar to TextWrangler. To me, it is not a really nice direction Apple is heading. Asking developers to reduce their software capabilities to be accepted in AppStore is not something I am looking for. After learning that, I didn't even once clicked on the AppStore icon in the Mac, old school searching, finding the application website, and downloading directly from there was and will be what I am going to do.

16 November 2012

Eclipse Project Red Exclamation Mark

This is something bothering me for a long time. I was working in a project dealing with several dependencies. After some reboots I got an exclamation mark next to the java project, like this one. There are no notes or suggestions on what is going wrong. Cleaning the projects won't work either. After some research, I have figured out that this kind of problem is related to the working code, which means it is something going wrong on the build directory. Whenever you got exclamation mark error, you first better try to clean your project, if no success, try deleting the build directory and any other build related material in your project code.

Here it says

The red exclamation mark means Eclipse is having trouble finding a required library or source.

15 November 2012

Bashrc, Bash_profile & how to change shell color in linux

There is a difference between bashrc and bash_profile in different distributions of Linux. You might need to specifically find out about the distribution you are working with. Generally difference between them are as follow:

According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells. (more)

There are several things you can do with your bash_profile and bashrc. Let us examine some of them. Let's say you want to change how the command prompt looks, you can each time set it to what you want, or better you can set it in your bash_profile and let it be. You can set something like this:

export PS1="\e[0;31m[\u@\h \W]\$ \e[m"

for a full range of what you can do with your PS1 (prompt in Linux/Unix) you can search online or look at BASH Shell change the color of my shell prompt under Linux or UNIX or How to: Change / Setup bash custom prompt (PS1)

8 November 2012

How to reload bash_profile in Linux / Unix ?

Have you ever wanted to reload your bash_profile in your Linux / Unix system? You obviously don't want to restart your whole system or re-login to your system to enable your new settings like newbies. What you can do is to reload your bash_profile file using a simple syntax. You just need to use source to do that as so:

source .bash_profile

and it will do the trick.

6 November 2012

JAAS Notes

Java Authentication and Authorization Service, or JAAS, pronounced "Jazz"

Configuration files for JAAS
  • *.login.conf (e.g. form login)
  • *.policy (which identity grant which permission)
LoginModule (interface)
LoginContext (Class)
  • Kick off authentication process by creating a subject (if no subject passed to it will create a new one)
  • e.g. user, resource, system, ...
  • Face of subject
  • subject 1..* principal

  1. Create instance of LoginContext e.g. LoginContext(string, callBackHandler) [string the name, callBackHandler used for passing information back to LoginModule]
  2. CallBackHandler (->Handle Method ->Transfers required information to LoginModule)
    empty subject created before authentication begin
    passed to all LoginModuels
    if authentication successful, populated with principals and credentials
    then subject can be get from getSubject in LoginContext

Login Process (Two Passes)

  • Phase 1
LoginMethod each loginModule login
  • Phase 2
commit method of all login modules invokes
login if successful -> commit methods of all login modules invoked -> then attaching principals and credentials

5 November 2012

Extending task-bar using dual monitor in Windows 7

Have you noticed whenever you are connecting your Microsoft Windows PC or laptop to a second monitor, there is only one task-bar and it will stay with the main display? Is it a good option or not, you can have your say. However, I believe for most developers like me, it is not a great advantage. You do not know which windows are open in which monitor. So, if you are eager to have extended task-bar for your extra monitor, I would recommend using Actual Multiple Monitors. This is not an open source program nor it is a free one, but is has many free features that you can utilize. If you find yourself so in love with the application to use all its features you can try buying it. I have tried several applications and this is one of the best I came across. My criteria was simplicity and the ability to show the window position related to the monitor its being used. 

25 September 2012

Control your windows 7 sound with win key + mouse scroll

One great feature in Linux is its unified place for all of your keyboard shortcuts. You can use it to set them they way you wish. I have used ctrl + down key for lowering the volume and the up key for raising it in my Linux box. However, after switching to windows, you can easily miss that option since there isn't any option like that in windows. If you want to achieve something like that, you need to install an application called 3RVX (http://matthew.malensek.net/software/). This simple (& smart) software will overtake volume control and provide you with an on-screen display as well. After that, you are able to use win-key + mouse scroll to lower and raise the volume, you can even change those key combinations.

24 September 2012

Synergy and Right / Left handed issue

Have you ever tried to change your mouse orientation from right to left handed ? If you haven't done it, do it right now, it is challenging not only for your brain, but also for your hand :-).

If you are using a left-handed mouse with Synergy cross platforming your linux and windows box, and if the windows box is the server, you just need to reset the linux mouse setting to right handed and change the windows mouse setting only to left handed. if you have both them left-handed, your linux will become a right handed mouse. I am not sure, if it is windows that is not sending mouse orientation information, synergy or linux, but it seems like, making a left-handed mouse in linux, will exchange the right and left mouse buttons with each other. If it is sent to be a left-handed mouse (let's say from a windows box), then it will reverse the buttons in Linux resulting in a right handed mouse for you on your Linux box. However, if you are using Linux as your Synergy Server, it won't have any problems such. This is the solution I do suggest, to use Linux as your main box, why I am not having my own prescription? The only reason I used windows as a Synergy Server is because I have Linux installed on my laptop and don't want every time to attach and detach my mouse and keyboard to it.

23 August 2012

Comparing Strings in SQL Server

If you are trying to compare two strings in a stored procedure or trigger or ... you need to note that you have  to specify the length of the strings before comparison, if you don't do that, you won't get the expected result out of your query. Also remember, it is one equal sign not two like Java.

I am not suggesting to do that, I am looking at DBs as storage for data and to me, all manipulations on data should be exercised on the logic layer of your application.

How to Compare two strings using a if in a stored procedure in sql server 2008?

17 August 2012

Move to the next / previous tab in Eclipse

Have you ever wondered how you can move to the next / previous tab when coding in Eclipse? You might find it very helpful to know that you can do that by using Ctrl + PgUp / PgDn (in windows) for moving to the next or previous tab or by clicking Ctrl + E or Ctrl + F6 for a list of tabs to pop up, then you select which one to show using arrow keys.

More information:
Eclipse HotKey: how to switch between tabs?

3 August 2012


After a while when you do coding, you become familiar with the concept of Locale. Instinctively it means something local to the user, it's definition is as described below

"These settings usually include the following display (output) format settings:

  • Number format setting
  • Character classification, case conversion settings
  • Date/Time format setting
  • String collation setting
  • Currency format setting
  • Paper size setting
  • Etc ...

The locale settings are about formatting output given a locale. So, the timezone information and daylight saving time are not usually part of the locale settings. Less usual, but worth mentioning, is the input format setting. This is mostly defined on a per application basis."

An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user.

24 July 2012

How to convert your Blackberry notes to Android notes?

If you are trying to migrate from blackberry to the Android world, this article might help you. If you were heavily using notes in blackberry you find this article super useful.

Notes can be exported from blackberry to a computer using blackberry native program. After exporting them, you will see that they are stored as a msg format (the format outlook uses to store emails). Thus you need to convert it to a txt file, you can do that using msgText. However, if you are having lots of notes, task of converting each one to a text will be tiresome. What you can do is to copy the following text, save it as convert.bat file. Put the run.bat file where the msgText is, copy all notes in the same folder and run convert.bat.

%%f in (*.msg) do (

             call msgText "%%f"

You could expect txt files for each note and a folder containing a word format for each of your note. Then it's easy, you need a google drive account, upload all text files to your google drive and then install google drive application on your android.

6 July 2012

Local vs. Remote Interfaces in EJB (EJB3)

There are two different interfaces available when you are writing an EJB. One is remote and one is Local. Remote, as it name suggests is for remote client that want to remotely call (or fire) functions and get some results. On the other hand Local is designed to be used in a local environment, for example in a case if another EJB or even a POJO in your system is using that. The usage would be the same as when you want to use an EJB using its Remote interface. However, it has less headache for the server to handle that. That's the only reason you might want to use a Local interface instead of Remote interface. Local interface is not local to JVM but local like an other POJO class.

Local client view cannot be accessed:
  • When an EJB or web component is packaged in a different application's EAR packages. 
  • When a web component is deployed in a web container, and EJBs are deployed in an EJB container, and these containers are separated (even if they are running on the same machine)
These are main factors in considering a Local or Remote interface:
  • Client: if your client is not a web component or another bean do not use Local 
  • Beans & Beans: Are the beans loosely coupled? then it is a good idea to use Local 
  • Scalability: Remote is always better for scalability 
  • Local interfaces are recommended for entity beans, which helps with performance issue.
More to read:

28 June 2012

Google I/O 2012 - Google Maps, Places, Transit, Reviews API, Cloud Map, 3D earth and more

  • began in 2005
  • pre-render the maps
  • one search box instead of several
  • 2005 only north america
  • 2008 licensed data for the whole world
  • over 5 billion people can see their house - 2012
  • 2009 - aggregate of data from ground level maps, satellite, image analysis
  • mapmaker - contribute to google maps
  • 2012 - 187 countries with driving navigation
  • manually and computer vision - operators improve the map
  • you can report and maps will adjust
  • 800 000 google maps developers worldwide
  • reviews not available in google places API
  • google transit in Maps API
  • Symbols in Maps API - you decide what maps look like
  • google maps engine
  • upload mapping data to google maps & securely manage it
  • google earth - now 3D images of cities
  • google maps - get people find 
  • google earth - get people lost

JMX - XMBean - JBoss

JMX Mbean : A Bean following JMX Specification

  • Standard MBean *
  • Dynamic MBean
  • Open Mbean
  • Model Mbean
  • MXBean *
* Simplest Ones

Standard MBean:
  • SomethingMBean -> Interface
  • Something -> Java Class
Every method in interface defines either an attribute or an operation in MBean (no Business Process there)

management is performed by JMX agent

JMX Agent --> Mbean Server : is a managed object server in which MBeans are registered
JMX Agent --also--> set services to manage MBeans
JMX Agent [You have to write it in your project]
  1. getPlatformMbeanServer
  2. ObjectName
  3. RegisterMbean (MbeanServer, Obj)

27 June 2012

Google IO 2012

Last year, I was part of Google IO. This year however, 3 days was not feasible for me. It was a fun event, with many talented people from all over the world attending it. Last year, Google handed out Samsung Tab 10.1 and Chromebooks for free. This year I believe there is going to be a 7 inch Nexus tablet from Google and Asus for sure. Not sure, if there is going to be any more handouts or not. Although, I have attended IO last year, I have found myself watching videos of other events on my own time on YouTube. This time I have decided to do that for all sessions, starting with keynote.

Keynote Day 1:

Keynote Day 2

4 June 2012

Us, Venus & the Sun

Venus is going to pass in front of the sun tomorrow. If you are in North America, you are among the most lucky ones to observe this happening. The next happening is in the next century, so you better look out to the sun (not directly) and see a black dot passing in front of it, that's Venus. It began roughly around 5pm EST and 2pm PST. For more detail information please visit the following:

31 May 2012


This is pretty awesome. If you have not upgraded to timeline and share the fear of being upgraded without your permission, watch this video. You share the same symptoms with this people, suggestion: instead of timeline get reallife. Enjoy!

7 April 2012

Canon 60D Video Tutorial

This is one of the best videos I've ever seen presenting Canon 60D features in an interactive mode. I did learn a lot from it, you will too.

8 February 2012

Sequence generation in JPA

@Table(name = "Facility")
public class FacilityEntity implements Serializable{

private static final long serialVersionUID = -5193920209461702399L;

@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_FACILITY_ID")
@SequenceGenerator(name = "SEQ_FACILITY_ID", sequenceName="SEQ_FACILITY_ID")
private Long facilityId;


It took me some time to figure this out, you have to have sequenceName in your SequenceGenrator annotation. It might work without it, and might as well give you sequence does not exit problem. The later case in which it is hard to trace what happened.

To make sure you have enough privileges on your sequence in oracle, you can test getting next generated value by using the following command in oracle:

SQL> connect shahin/shahin
SQL> select shahin.seq_facility_id.nextval from dual;


if it doesn't show the next available value in the system, you need to login using the sysdba credentials and grant access to that sequence for that user. As follow:

SQL> connect / as sysdba
SQL> grant select any sequence to shahin;

Grant succeeded.