Pointcut for classes inside different package or sub-packages marked Deprecated and at the time whenever they...
up vote
0
down vote
favorite
I want to write a point cut for class instantiation in various packages,like classes inside the subpackages inside com.kepler.xenon (eg.com.kepler.xenon.modules.ticklers.pojo.Tickler,
com.kepler.xenon.modules.product.pojo.Product etc).
//This is my advice
@Aspect
@Component
public class OxAspect {
@After("execution(* com.oxane.xenon..*new(..)) && @within(java.lang.Deprecated)")
public void myAdvice(final JoinPoint jp){
System.out.println(jp.getSignature().getName()+""+jp.getTarget().getClass());
}
}
//This is my class
package com.kepler.xenon.modules.ticklers.pojo;
@Deprecated
public Class Ticklers{
@Id
@TableGenerator(name = "TICKLERS_ID", table = "ID_GENERATOR", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "TICKLERS_ID", allocationSize = 1, initialValue = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TICKLERS_ID")
@Column(name = "TICKLERS_ID", unique = true, nullable = false)
private int ticklersId;
@Column(name = "TASK", nullable = false, length = 256)
private String taskName;
public int getTicklersId() {
return ticklersId;
}
public void setTicklersId(int ticklersId) {
this.ticklersId = ticklersId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
}
What i want is that if anyone tries to access the class which is deprecated,then pointcut filters that call and triggers advice.
I have done it for methods but i am failing to do it for classes.
I am adding aspect which works for methods,controller and Dao
@Aspect
@Component
public class OxAspect {
private final OxAspectService oxAspectService;
public OxAspect(OxAspectService oxAspectService) {
this.oxAspectService=oxAspectService;
}
@Pointcut("execution(@java.lang.Deprecated * com.oxane.xenon..*(..))"
+ " || execution(* com.oxane.xenon..*.*(..)) && @within(java.lang.Deprecated)")
public void deprecated() {
}
@Before("deprecated()")
public void log(final JoinPoint jp) {
oxAspectService.logDeprecatedMethod(jp);
}
}
Edit:
I have done some research on spring io and found that it can't be done using spring aop. I have to use load time weaving or compile time weaving to achieve what i want. For that i have to use pure aspect j implementation. Correct me if i am wrong.
aop aspect pointcut
|
show 1 more comment
up vote
0
down vote
favorite
I want to write a point cut for class instantiation in various packages,like classes inside the subpackages inside com.kepler.xenon (eg.com.kepler.xenon.modules.ticklers.pojo.Tickler,
com.kepler.xenon.modules.product.pojo.Product etc).
//This is my advice
@Aspect
@Component
public class OxAspect {
@After("execution(* com.oxane.xenon..*new(..)) && @within(java.lang.Deprecated)")
public void myAdvice(final JoinPoint jp){
System.out.println(jp.getSignature().getName()+""+jp.getTarget().getClass());
}
}
//This is my class
package com.kepler.xenon.modules.ticklers.pojo;
@Deprecated
public Class Ticklers{
@Id
@TableGenerator(name = "TICKLERS_ID", table = "ID_GENERATOR", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "TICKLERS_ID", allocationSize = 1, initialValue = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TICKLERS_ID")
@Column(name = "TICKLERS_ID", unique = true, nullable = false)
private int ticklersId;
@Column(name = "TASK", nullable = false, length = 256)
private String taskName;
public int getTicklersId() {
return ticklersId;
}
public void setTicklersId(int ticklersId) {
this.ticklersId = ticklersId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
}
What i want is that if anyone tries to access the class which is deprecated,then pointcut filters that call and triggers advice.
I have done it for methods but i am failing to do it for classes.
I am adding aspect which works for methods,controller and Dao
@Aspect
@Component
public class OxAspect {
private final OxAspectService oxAspectService;
public OxAspect(OxAspectService oxAspectService) {
this.oxAspectService=oxAspectService;
}
@Pointcut("execution(@java.lang.Deprecated * com.oxane.xenon..*(..))"
+ " || execution(* com.oxane.xenon..*.*(..)) && @within(java.lang.Deprecated)")
public void deprecated() {
}
@Before("deprecated()")
public void log(final JoinPoint jp) {
oxAspectService.logDeprecatedMethod(jp);
}
}
Edit:
I have done some research on spring io and found that it can't be done using spring aop. I have to use load time weaving or compile time weaving to achieve what i want. For that i have to use pure aspect j implementation. Correct me if i am wrong.
aop aspect pointcut
1
What is "it" you have done for methods and are failing to do for classes. Be more specific, please, and ideally extend your snippets into an MCVE demonstrating what works and what does not. I would like to see something I can actually run.
– kriegaex
Nov 25 at 8:22
I wanted to paste my whole pojo, but it didn't seem right to me. So i left my Ticklers class empty. Even then it should not be difficult to reproduce, i will add a field, and constructor above from my original code if that helps.
– aakash singh
Nov 26 at 7:06
Thanks for extending the source code. It does not answer my previous question, though. I repeat: What is "it" you have done for methods and are failing to do for classes? I do not understand from your explanation what it is exactly that you got working with methods but not with classes. Are you referring to where you put the annotation, e.g. on methods or classes? You can intercept annotated methods but not methods within annotated classes?
– kriegaex
Nov 29 at 5:35
Like i said, if i mark method,controller and service @Deprecated(with different pointcut), Pointcut catches it with no problem. But as soon as i try to write pointcut for Pojo, nothing happens. For clarity i will put pointcut for method,services and dao(spring beans).
– aakash singh
Nov 29 at 6:20
Maybe it is my mistake that I do not understand your English, I am sorry for that. But why would it not work with Spring AOP? Are you trying to intercept non-Spring classes, i.e. classes which are not@Component
s or otherwise wired as Spring beans? In that case your assumption would be correct, for non-Spring classes you have to use an AOP framework which is not dependent on Spring mechanisms, i.e. AspectJ.
– kriegaex
Dec 11 at 3:39
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to write a point cut for class instantiation in various packages,like classes inside the subpackages inside com.kepler.xenon (eg.com.kepler.xenon.modules.ticklers.pojo.Tickler,
com.kepler.xenon.modules.product.pojo.Product etc).
//This is my advice
@Aspect
@Component
public class OxAspect {
@After("execution(* com.oxane.xenon..*new(..)) && @within(java.lang.Deprecated)")
public void myAdvice(final JoinPoint jp){
System.out.println(jp.getSignature().getName()+""+jp.getTarget().getClass());
}
}
//This is my class
package com.kepler.xenon.modules.ticklers.pojo;
@Deprecated
public Class Ticklers{
@Id
@TableGenerator(name = "TICKLERS_ID", table = "ID_GENERATOR", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "TICKLERS_ID", allocationSize = 1, initialValue = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TICKLERS_ID")
@Column(name = "TICKLERS_ID", unique = true, nullable = false)
private int ticklersId;
@Column(name = "TASK", nullable = false, length = 256)
private String taskName;
public int getTicklersId() {
return ticklersId;
}
public void setTicklersId(int ticklersId) {
this.ticklersId = ticklersId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
}
What i want is that if anyone tries to access the class which is deprecated,then pointcut filters that call and triggers advice.
I have done it for methods but i am failing to do it for classes.
I am adding aspect which works for methods,controller and Dao
@Aspect
@Component
public class OxAspect {
private final OxAspectService oxAspectService;
public OxAspect(OxAspectService oxAspectService) {
this.oxAspectService=oxAspectService;
}
@Pointcut("execution(@java.lang.Deprecated * com.oxane.xenon..*(..))"
+ " || execution(* com.oxane.xenon..*.*(..)) && @within(java.lang.Deprecated)")
public void deprecated() {
}
@Before("deprecated()")
public void log(final JoinPoint jp) {
oxAspectService.logDeprecatedMethod(jp);
}
}
Edit:
I have done some research on spring io and found that it can't be done using spring aop. I have to use load time weaving or compile time weaving to achieve what i want. For that i have to use pure aspect j implementation. Correct me if i am wrong.
aop aspect pointcut
I want to write a point cut for class instantiation in various packages,like classes inside the subpackages inside com.kepler.xenon (eg.com.kepler.xenon.modules.ticklers.pojo.Tickler,
com.kepler.xenon.modules.product.pojo.Product etc).
//This is my advice
@Aspect
@Component
public class OxAspect {
@After("execution(* com.oxane.xenon..*new(..)) && @within(java.lang.Deprecated)")
public void myAdvice(final JoinPoint jp){
System.out.println(jp.getSignature().getName()+""+jp.getTarget().getClass());
}
}
//This is my class
package com.kepler.xenon.modules.ticklers.pojo;
@Deprecated
public Class Ticklers{
@Id
@TableGenerator(name = "TICKLERS_ID", table = "ID_GENERATOR", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "TICKLERS_ID", allocationSize = 1, initialValue = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TICKLERS_ID")
@Column(name = "TICKLERS_ID", unique = true, nullable = false)
private int ticklersId;
@Column(name = "TASK", nullable = false, length = 256)
private String taskName;
public int getTicklersId() {
return ticklersId;
}
public void setTicklersId(int ticklersId) {
this.ticklersId = ticklersId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
}
What i want is that if anyone tries to access the class which is deprecated,then pointcut filters that call and triggers advice.
I have done it for methods but i am failing to do it for classes.
I am adding aspect which works for methods,controller and Dao
@Aspect
@Component
public class OxAspect {
private final OxAspectService oxAspectService;
public OxAspect(OxAspectService oxAspectService) {
this.oxAspectService=oxAspectService;
}
@Pointcut("execution(@java.lang.Deprecated * com.oxane.xenon..*(..))"
+ " || execution(* com.oxane.xenon..*.*(..)) && @within(java.lang.Deprecated)")
public void deprecated() {
}
@Before("deprecated()")
public void log(final JoinPoint jp) {
oxAspectService.logDeprecatedMethod(jp);
}
}
Edit:
I have done some research on spring io and found that it can't be done using spring aop. I have to use load time weaving or compile time weaving to achieve what i want. For that i have to use pure aspect j implementation. Correct me if i am wrong.
aop aspect pointcut
aop aspect pointcut
edited Nov 29 at 6:23
asked Nov 20 at 14:53
aakash singh
13
13
1
What is "it" you have done for methods and are failing to do for classes. Be more specific, please, and ideally extend your snippets into an MCVE demonstrating what works and what does not. I would like to see something I can actually run.
– kriegaex
Nov 25 at 8:22
I wanted to paste my whole pojo, but it didn't seem right to me. So i left my Ticklers class empty. Even then it should not be difficult to reproduce, i will add a field, and constructor above from my original code if that helps.
– aakash singh
Nov 26 at 7:06
Thanks for extending the source code. It does not answer my previous question, though. I repeat: What is "it" you have done for methods and are failing to do for classes? I do not understand from your explanation what it is exactly that you got working with methods but not with classes. Are you referring to where you put the annotation, e.g. on methods or classes? You can intercept annotated methods but not methods within annotated classes?
– kriegaex
Nov 29 at 5:35
Like i said, if i mark method,controller and service @Deprecated(with different pointcut), Pointcut catches it with no problem. But as soon as i try to write pointcut for Pojo, nothing happens. For clarity i will put pointcut for method,services and dao(spring beans).
– aakash singh
Nov 29 at 6:20
Maybe it is my mistake that I do not understand your English, I am sorry for that. But why would it not work with Spring AOP? Are you trying to intercept non-Spring classes, i.e. classes which are not@Component
s or otherwise wired as Spring beans? In that case your assumption would be correct, for non-Spring classes you have to use an AOP framework which is not dependent on Spring mechanisms, i.e. AspectJ.
– kriegaex
Dec 11 at 3:39
|
show 1 more comment
1
What is "it" you have done for methods and are failing to do for classes. Be more specific, please, and ideally extend your snippets into an MCVE demonstrating what works and what does not. I would like to see something I can actually run.
– kriegaex
Nov 25 at 8:22
I wanted to paste my whole pojo, but it didn't seem right to me. So i left my Ticklers class empty. Even then it should not be difficult to reproduce, i will add a field, and constructor above from my original code if that helps.
– aakash singh
Nov 26 at 7:06
Thanks for extending the source code. It does not answer my previous question, though. I repeat: What is "it" you have done for methods and are failing to do for classes? I do not understand from your explanation what it is exactly that you got working with methods but not with classes. Are you referring to where you put the annotation, e.g. on methods or classes? You can intercept annotated methods but not methods within annotated classes?
– kriegaex
Nov 29 at 5:35
Like i said, if i mark method,controller and service @Deprecated(with different pointcut), Pointcut catches it with no problem. But as soon as i try to write pointcut for Pojo, nothing happens. For clarity i will put pointcut for method,services and dao(spring beans).
– aakash singh
Nov 29 at 6:20
Maybe it is my mistake that I do not understand your English, I am sorry for that. But why would it not work with Spring AOP? Are you trying to intercept non-Spring classes, i.e. classes which are not@Component
s or otherwise wired as Spring beans? In that case your assumption would be correct, for non-Spring classes you have to use an AOP framework which is not dependent on Spring mechanisms, i.e. AspectJ.
– kriegaex
Dec 11 at 3:39
1
1
What is "it" you have done for methods and are failing to do for classes. Be more specific, please, and ideally extend your snippets into an MCVE demonstrating what works and what does not. I would like to see something I can actually run.
– kriegaex
Nov 25 at 8:22
What is "it" you have done for methods and are failing to do for classes. Be more specific, please, and ideally extend your snippets into an MCVE demonstrating what works and what does not. I would like to see something I can actually run.
– kriegaex
Nov 25 at 8:22
I wanted to paste my whole pojo, but it didn't seem right to me. So i left my Ticklers class empty. Even then it should not be difficult to reproduce, i will add a field, and constructor above from my original code if that helps.
– aakash singh
Nov 26 at 7:06
I wanted to paste my whole pojo, but it didn't seem right to me. So i left my Ticklers class empty. Even then it should not be difficult to reproduce, i will add a field, and constructor above from my original code if that helps.
– aakash singh
Nov 26 at 7:06
Thanks for extending the source code. It does not answer my previous question, though. I repeat: What is "it" you have done for methods and are failing to do for classes? I do not understand from your explanation what it is exactly that you got working with methods but not with classes. Are you referring to where you put the annotation, e.g. on methods or classes? You can intercept annotated methods but not methods within annotated classes?
– kriegaex
Nov 29 at 5:35
Thanks for extending the source code. It does not answer my previous question, though. I repeat: What is "it" you have done for methods and are failing to do for classes? I do not understand from your explanation what it is exactly that you got working with methods but not with classes. Are you referring to where you put the annotation, e.g. on methods or classes? You can intercept annotated methods but not methods within annotated classes?
– kriegaex
Nov 29 at 5:35
Like i said, if i mark method,controller and service @Deprecated(with different pointcut), Pointcut catches it with no problem. But as soon as i try to write pointcut for Pojo, nothing happens. For clarity i will put pointcut for method,services and dao(spring beans).
– aakash singh
Nov 29 at 6:20
Like i said, if i mark method,controller and service @Deprecated(with different pointcut), Pointcut catches it with no problem. But as soon as i try to write pointcut for Pojo, nothing happens. For clarity i will put pointcut for method,services and dao(spring beans).
– aakash singh
Nov 29 at 6:20
Maybe it is my mistake that I do not understand your English, I am sorry for that. But why would it not work with Spring AOP? Are you trying to intercept non-Spring classes, i.e. classes which are not
@Component
s or otherwise wired as Spring beans? In that case your assumption would be correct, for non-Spring classes you have to use an AOP framework which is not dependent on Spring mechanisms, i.e. AspectJ.– kriegaex
Dec 11 at 3:39
Maybe it is my mistake that I do not understand your English, I am sorry for that. But why would it not work with Spring AOP? Are you trying to intercept non-Spring classes, i.e. classes which are not
@Component
s or otherwise wired as Spring beans? In that case your assumption would be correct, for non-Spring classes you have to use an AOP framework which is not dependent on Spring mechanisms, i.e. AspectJ.– kriegaex
Dec 11 at 3:39
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
If I were you I will devide @Pointcut
to signle condition like below:
@Pointcut("execution(* com.oxane.xenon..*(..))")
public void anyClassInSubpackage() {
}
@Pointcut("@annotation(java.lang.Deprecated)")
public void deprecatedClass() {
}
@Pointcut("execution(* com.oxane.xenon..*new(..))")
public void anyMethodInSubpackege() {
}
@Pointcut("@within(java.lang.Deprecated)")
public void deprecatedMethod() {
}
@Before("(anyClassInSubpackage() && deprecatedClass()) || (anyMethodInSubpackege() && deprecatedMethod())")
public void myAdvice(final JoinPoint jp){
//TODO
}
I have combined that in my final code initially for test purpose i was using@Pointcut("execution(* com.oxane.xenon..*new(..))") public void anyMethodInSubpackege() { }
but it didn't worked for me.
– aakash singh
Nov 29 at 7:31
try with@Pointcut("execution(* com.oxane.xenon..*.new(..))")
– Victor1125
Nov 29 at 7:57
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395666%2fpointcut-for-classes-inside-different-package-or-sub-packages-marked-deprecated%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If I were you I will devide @Pointcut
to signle condition like below:
@Pointcut("execution(* com.oxane.xenon..*(..))")
public void anyClassInSubpackage() {
}
@Pointcut("@annotation(java.lang.Deprecated)")
public void deprecatedClass() {
}
@Pointcut("execution(* com.oxane.xenon..*new(..))")
public void anyMethodInSubpackege() {
}
@Pointcut("@within(java.lang.Deprecated)")
public void deprecatedMethod() {
}
@Before("(anyClassInSubpackage() && deprecatedClass()) || (anyMethodInSubpackege() && deprecatedMethod())")
public void myAdvice(final JoinPoint jp){
//TODO
}
I have combined that in my final code initially for test purpose i was using@Pointcut("execution(* com.oxane.xenon..*new(..))") public void anyMethodInSubpackege() { }
but it didn't worked for me.
– aakash singh
Nov 29 at 7:31
try with@Pointcut("execution(* com.oxane.xenon..*.new(..))")
– Victor1125
Nov 29 at 7:57
add a comment |
up vote
0
down vote
If I were you I will devide @Pointcut
to signle condition like below:
@Pointcut("execution(* com.oxane.xenon..*(..))")
public void anyClassInSubpackage() {
}
@Pointcut("@annotation(java.lang.Deprecated)")
public void deprecatedClass() {
}
@Pointcut("execution(* com.oxane.xenon..*new(..))")
public void anyMethodInSubpackege() {
}
@Pointcut("@within(java.lang.Deprecated)")
public void deprecatedMethod() {
}
@Before("(anyClassInSubpackage() && deprecatedClass()) || (anyMethodInSubpackege() && deprecatedMethod())")
public void myAdvice(final JoinPoint jp){
//TODO
}
I have combined that in my final code initially for test purpose i was using@Pointcut("execution(* com.oxane.xenon..*new(..))") public void anyMethodInSubpackege() { }
but it didn't worked for me.
– aakash singh
Nov 29 at 7:31
try with@Pointcut("execution(* com.oxane.xenon..*.new(..))")
– Victor1125
Nov 29 at 7:57
add a comment |
up vote
0
down vote
up vote
0
down vote
If I were you I will devide @Pointcut
to signle condition like below:
@Pointcut("execution(* com.oxane.xenon..*(..))")
public void anyClassInSubpackage() {
}
@Pointcut("@annotation(java.lang.Deprecated)")
public void deprecatedClass() {
}
@Pointcut("execution(* com.oxane.xenon..*new(..))")
public void anyMethodInSubpackege() {
}
@Pointcut("@within(java.lang.Deprecated)")
public void deprecatedMethod() {
}
@Before("(anyClassInSubpackage() && deprecatedClass()) || (anyMethodInSubpackege() && deprecatedMethod())")
public void myAdvice(final JoinPoint jp){
//TODO
}
If I were you I will devide @Pointcut
to signle condition like below:
@Pointcut("execution(* com.oxane.xenon..*(..))")
public void anyClassInSubpackage() {
}
@Pointcut("@annotation(java.lang.Deprecated)")
public void deprecatedClass() {
}
@Pointcut("execution(* com.oxane.xenon..*new(..))")
public void anyMethodInSubpackege() {
}
@Pointcut("@within(java.lang.Deprecated)")
public void deprecatedMethod() {
}
@Before("(anyClassInSubpackage() && deprecatedClass()) || (anyMethodInSubpackege() && deprecatedMethod())")
public void myAdvice(final JoinPoint jp){
//TODO
}
answered Nov 29 at 7:00
Victor1125
1859
1859
I have combined that in my final code initially for test purpose i was using@Pointcut("execution(* com.oxane.xenon..*new(..))") public void anyMethodInSubpackege() { }
but it didn't worked for me.
– aakash singh
Nov 29 at 7:31
try with@Pointcut("execution(* com.oxane.xenon..*.new(..))")
– Victor1125
Nov 29 at 7:57
add a comment |
I have combined that in my final code initially for test purpose i was using@Pointcut("execution(* com.oxane.xenon..*new(..))") public void anyMethodInSubpackege() { }
but it didn't worked for me.
– aakash singh
Nov 29 at 7:31
try with@Pointcut("execution(* com.oxane.xenon..*.new(..))")
– Victor1125
Nov 29 at 7:57
I have combined that in my final code initially for test purpose i was using
@Pointcut("execution(* com.oxane.xenon..*new(..))") public void anyMethodInSubpackege() { }
but it didn't worked for me.– aakash singh
Nov 29 at 7:31
I have combined that in my final code initially for test purpose i was using
@Pointcut("execution(* com.oxane.xenon..*new(..))") public void anyMethodInSubpackege() { }
but it didn't worked for me.– aakash singh
Nov 29 at 7:31
try with
@Pointcut("execution(* com.oxane.xenon..*.new(..))")
– Victor1125
Nov 29 at 7:57
try with
@Pointcut("execution(* com.oxane.xenon..*.new(..))")
– Victor1125
Nov 29 at 7:57
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395666%2fpointcut-for-classes-inside-different-package-or-sub-packages-marked-deprecated%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What is "it" you have done for methods and are failing to do for classes. Be more specific, please, and ideally extend your snippets into an MCVE demonstrating what works and what does not. I would like to see something I can actually run.
– kriegaex
Nov 25 at 8:22
I wanted to paste my whole pojo, but it didn't seem right to me. So i left my Ticklers class empty. Even then it should not be difficult to reproduce, i will add a field, and constructor above from my original code if that helps.
– aakash singh
Nov 26 at 7:06
Thanks for extending the source code. It does not answer my previous question, though. I repeat: What is "it" you have done for methods and are failing to do for classes? I do not understand from your explanation what it is exactly that you got working with methods but not with classes. Are you referring to where you put the annotation, e.g. on methods or classes? You can intercept annotated methods but not methods within annotated classes?
– kriegaex
Nov 29 at 5:35
Like i said, if i mark method,controller and service @Deprecated(with different pointcut), Pointcut catches it with no problem. But as soon as i try to write pointcut for Pojo, nothing happens. For clarity i will put pointcut for method,services and dao(spring beans).
– aakash singh
Nov 29 at 6:20
Maybe it is my mistake that I do not understand your English, I am sorry for that. But why would it not work with Spring AOP? Are you trying to intercept non-Spring classes, i.e. classes which are not
@Component
s or otherwise wired as Spring beans? In that case your assumption would be correct, for non-Spring classes you have to use an AOP framework which is not dependent on Spring mechanisms, i.e. AspectJ.– kriegaex
Dec 11 at 3:39