• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between Joint Point and Point Cut  RSS feed

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1) Difference between Joint Point and Point Cut?Please explain with example or real life terminology?
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When you go out to a restaurant, you look at a menu and see several options to choose from. You can order one or more of any of the items on the menu. But until you actually order them, they are just "opportunities to dine". Once you place the order and the waiter brings it to your table, it's a meal.

Join points are the options on the menu and pointcuts are the items you select. A joinpoint is an opportunity within code for you to apply an aspect...just an opportunity. Once you take that opportunity and select one or more joinpoints and apply an aspect to them, you've got a pointcut.

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Craig.
 
Muneeswaran Balasubramanian
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
great and crystal clear explanation.Thanks.
 
Khuma Chhakchhuak
Ranch Hand
Posts: 37
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A very good explaination indeed.
 
Tanzeem Akhtar
Greenhorn
Posts: 9
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I perceive joint points and point cut as follows--

Assume during the program execution, control meets a condition--

if (condition) {
//Conditional tasks to execute
}

Here condition can be observed as Join Points, and the attribute "if" as point cut.
The "Conditional tasks to execute" as advice.
As we can use multiple condition, so join points can have more than one condition.

Hope this will help to memorize the diffidence between joint points and point cut.

Thanks,
Tanzy.
 
raja singh kumar
Ranch Hand
Posts: 189
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Join points are the options on the menu and pointcuts are the items you select

But isn't pointcut an expression or predicate which is a more generalized expression and join points the ones which are more specific and satisfy the pointcut expression?

Let's take an example. Suppose I have a Triangle class with two variables namely name and type. We have two getters in this class namely getName() and getType()

In my aspect class I write a pointcut as @Pointcut("execution(* get*())") then in this case what exactly is joinpoint and what is pointcut?
 
raja singh kumar
Ranch Hand
Posts: 189
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone please help me
 
Anton Golovin
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satyajeet Kadam wrote:Q1) Difference between Joint Point and Point Cut?Please explain with example or real life terminology?


Hi, Satyajeet,

A join point is where you can make a point cut.

It's where you have the possibility to insert your AOP functionality while a point cut is the actual inserting of your AOP functionality.

That's what i think... maybe i am wrong, but it sounds right.

With best regards,

Anton.
 
raja singh kumar
Ranch Hand
Posts: 189
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, when I say @Pointcut("execution(* get*())") does "* get*()" represent the pointcut?
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Anton said is right. Pointcut is used to define join points where you want to add your logic. You generally don't need to worry about Join Points as you only need to define Pointcuts. So all method calls in your program are join points. Using a Pointcut expression, you can apply your logic (called advice) to any number of join points.

You can read this article which explains the difference in a paragraph...
 
raja singh kumar
Ranch Hand
Posts: 189
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting. The article says:"Join points are the options on the menu and pointcuts are the items you select. "

So if I have a class which has 10 methods and two are satisfying the pointcut expression, then those 10 methods are the join points and the expression represents the pointcut?
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Raja, whenever those 10 methods are called, the method calls are join points (as the method call is sort of an event, just like throwing of exception). You can apply advice on them by using pointcut expression which can apply the advice on few or all of those join points...
 
raja singh kumar
Ranch Hand
Posts: 189
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I am getting confused. Say there are 10 methods in a class. Out of this 8 DONT have any cross cutting concern associated with it.Only 2 methods have cross cutting concern associated with it and those 2 methods satisy the pointcut expression.

1. Now the expression represents the pointcut right?
2. Do those 2 methods which satisfy the pointcut expression represent the join point or all the 10 methods represent the join points?
 
raja singh kumar
Ranch Hand
Posts: 189
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a minute. Are you saying all methods which have a cross cutting concern and are called at different times represent the join points while the pointcut expression is a way of filtering them?
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Join point is anything on which you can apply your advice. So as Anton also said, it is an opportunity to apply your advice. In Spring join points can be method calls. So any method call is a join point. When you write a pointcut expression, Spring will see what all join points match that expression. Advice will be applied to only those join points. So in your example, all 10 methods are join points and your pointcut matches 2 of them...
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!