This is the best article i have seen on concurrent hashmap. Very well explained.
Concurrent hashMap
How HashSet works?
Well earlier i wasnt sure how HashSet is created internally and which data structure is used. But when I looked at the class implemenation i was surprised because of following features i noticed:
Hashset is used to store the unique elements, in which their is no gurantee of the iteration order.
Hashset internally use HashMap .
Elements passed to Hashset are stored as a key of the HashMap with null as value. Since the objects passed to set are key so no extra check is done to identify duplicates. For eg after adding integer 1 and 2 if i add 1 again, no check is performed to identify whether 1 is present or not. The hashset simply performs the put with the same value( ‘1’) in this case as key.
Similariy when an element is removed from the Set the internal HashMap remove method is called.
So HashSet data structure is nothing but a HashMap with objects as key.
HashSet Implemenation from java.util package
- public HashSet() {
map = new HashMap<E,Object>();
} - public boolean add(E o) {
return map.put(o, PRESENT)==null;
} - /**
* Removes the specified element from this set if it is present.
*
* @param o object to be removed from this set, if present.
* @return <tt>true</tt> if the set contained the specified element.
*/
public boolean remove(Object o) {
return map.remove(o)==PRESENT;
}
Spring AOP :Pointcut in details
Pointcuts determine join points of interest, and thus enable us to control when advice executes. Spring AOP only supports method execution join points for Spring beans.
A pointcut declaration has two parts: a signature comprising a name and any parameters, and a pointcut expression that determines exactly which method executions we are interested in.
• execution – for matching method execution join points, this is the primary pointcut designator you will use when working with Spring AOP
• within – limits matching to join points within certain types (simply the execution of a method declared within a matching type when using Spring AOP)
• this – limits matching to join points (the execution of methods when using Spring AOP) where the bean reference (Spring AOP proxy) is an instance of the given type
• target – limits matching to join points (the execution of methods when using Spring AOP) where the target object (application object being proxied) is an instance of the given type
• args – limits matching to join points (the execution of methods when using Spring AOP) where the arguments are instances of the given types
Pointcut expressions can also be combined using ‘&&’, ‘||’ and ‘!’. It is also possible to refer to pointcut expressions by name.
The following example shows three pointcut expressions:
anyPublicOperation (which matches if a method execution join point represents the execution of any public method); inTrading and tradingOperation :
execution(public * *(..))
private void anyPublicOperation() {}
within(com.xyz.someapp.trading..*
private void inTrading() {}
anyPublicOperation() && inTrading()
private void tradingOperation() {}
Following are the examples showing different manner in which a pointcut can be declared:
the execution of any public method:
execution(public * *(..))
the execution of any method with a name beginning with “set”:
execution(* set*(..))
the execution of any method defined by the MyService interface
execution(* com.xyz.service.MyService.*(..))
the execution of any method defined in the service package:
execution(* com.xyz.service.*.*(..))
the execution of any method defined in the service package or a sub-package:
execution(* com.xyz.service..*.*(..))
any join point (method execution only in Spring AOP) within the service package:
within(com.xyz.service.*)
any join point (method execution only in Spring AOP) within the service package or a sub-package:
within(com.xyz.service..*)
any join point (method execution only in Spring AOP) where the proxy implements the AccountService interface:
this(com.xyz.service.AccountService)
any join point (method execution only in Spring AOP) where the target object implements the AccountService interface:
target(com.xyz.service.AccountService)
any join point (method execution only in Spring AOP) which takes a single parameter, and where the argument passed at runtime is Serializable:
args(java.io.Serializable)
To know how to use pontCut in sprion AOP follow up previous post Spring AOP
The content is referred from Spring Doc
What’s In The Gmail Magic Inbox?
One almost surefire way to find if a new feature is on the verge of launching is to dig through code. That’s exactly what led to finding a reference to something called “Magic Inbox,” in Gmail. But what is it? Well, it could just be another one of those nifty, but small new features that Google loves to roll out in Gmail Labs at breakneck speed. But there’s a chance it’s something much, much bigger.
Specifically, Google Operating System, which did the digging, believes that the feature likely is a way to sort your Gmail inbox by your social graph. The two references to “friends” in the code, seems to lend some credence to this. Presumably, this would allow you to better filter your inbox based on if you have specified the emailer as a contact. As someone who gets bombarded by email everyday, most of which is not from people I actually know, I would weep with joy if such a feature were implemented. And so would my mom, as she may actually get emails back from me were that the case.
Of course, others have been working on this same idea as well. Yahoo has been saying for a while that it wants to use your inbox as a part of your social graph. Microsoft’s Hotmail has been working on things in the area as well, as has Xobni. But given all the work Google has been doing recently to tighten up its social graph across its huge network of services, a social filter in Gmail could be very, very useful.
Users are likely to have security concerns about this as well. Some people want their email client to be completely private and not a part of the social graph. Of course, Google has already been using Gmail as a key starting point for your social graph for a while now, even if you didn’t realize it. Well over a year ago, Google it rolled out its social features to Google Reader, pulling in who it thought your friends were based on who you emailed in Gmail.
This proved to be an awful idea as people you email aren’t necessarily your friends. Google eventually rolled out several updates to this feature to allow users to better tailor their relationships. And that would obviously be a key part of a Gmail social filter as well. You need to be able to separate out your actual friends from those who you simply have contacted in the past, or maybe even correspond with a lot.
While Google hasn’t exactly nailed the social features, it’s pretty clear that the company is thinking about them — a lot. And that your Google Contacts, which started as a part of Gmail, but have since been spun out, are a key part of it.
Google I/O, its large developer conference is taking place next week. Google is likely to use the event to unveil some key new things it has been working on. Could that be a “magic inbox,” which is also called “icebox inbox” in the code? We’ll be there to find out. Maybe Gmail will even leave beta — but probably not
Source : TechCrunch.com :Gmail Inbox
How to solve “error could not find java runtime 2 environment” while opening an IDE in windows
Many times it happen that the IDE which you are installing is not compatible with the old JDK version. And when you try to open the IDE this error pops up.
This is because the oldversion of JDK is set . There are many ways to get this correct of which the one i prefer most is as follows:
- Open your Registory Editor by doing ‘Windows’ button + ‘R’ key
- type regedit
- goto :HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\
- Change to current value of ‘CurrentVersion’ to the desired JDK version
And open the IDE now.