aspectj

How can I exclude getters and setters in aspectJ?

情到浓时终转凉″ 提交于 2019-12-08 07:29:13
问题 I have a class aspectJ in my maven project whitch hepls me to show the Begin and the End of any called method in my project. I try now to exclude all getters and setters. I try modify this annotation: @Around("execution(public * *(..)) by @Around("execution(public * *(..) && !within(* set*(..))") But it doesn't whork and it gives me that in the consol: [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project spb-lceb: AJC compiler errors: [ERROR]

AspectJ Load Time Weaving with Spring Transaction Manager and Maven

こ雲淡風輕ζ 提交于 2019-12-08 07:24:51
问题 I'm attempting to enable load time weaving with Spring's transaction manager but without too much luck. Currently I'm just trying to run a simple em.persist() in a @Transactional method but it does not appear to running a transaction as seen through: TransactionSynchronizationManager.isActualTransactionActive() My application context file contains : <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value=

AspectJ load time weaving not working for Spring beans

て烟熏妆下的殇ゞ 提交于 2019-12-08 06:09:17
问题 I am facing the same issue as: AspectJ load time weaving not working on Spring beans The solution of returning 'Object' is working, but I don't know the reason. I have gone through: http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch08s08.html#aop-aj-ltw but still no clue. 回答1: As I commented on that other thread. The load-time weaver, as the name suggest, will only operate on the loading of classes. Now when a class is already loaded it cannot be processed anymore. When the return

Spring-AOP load-time weaving on 3rd-party classes

落花浮王杯 提交于 2019-12-08 06:03:46
问题 I wrote an aspect that I'm trying to test with junit. The aspect has an @Around advice on a 3rd party method called setQuery . At compile time it complains: Can't find referenced pointcut setQuery Here's my aspect: @Component @Aspect public class ElasticsearchQuerySecurityAspect { @Around("org.elasticsearch.action.search.SearchRequestBuilder.setQuery() && args(queryBuilder)") public void addFilter(final ProceedingJoinPoint pjp, QueryBuilder queryBuilder) throws Throwable { Object[] args = pjp

Struts 2 ModelDriven Action how to exclude some properties from beaing updated

瘦欲@ 提交于 2019-12-08 05:47:35
问题 We are using an action with ModelDriven interface. The action has the scopedModelDriven interceptor and we save the model in session. The model is as below: public class Fundtransfer{ private String amount; private String sourceAccount; private String destinationAccount; private String sign //setter's and getter's ommited } The Fundtransfer bean is used as a model. The JSP form has amount, sourceAcount and destinationAcount fields which maps to Fundtransfer bean automatically via modelDriven

Get method parameters with specific annotation in aspect in scala using java reflection

蹲街弑〆低调 提交于 2019-12-08 04:15:55
问题 I am using aop in scala using aspectj . I have a method def delete(@Id id:Long, name:String) How can I get the value of id in my aspect file. @Around("execution (* com.myapp.Employee.delete(..))") def message(joinPoint: ProceedingJoinPoint): Object = { val methodSignature =joinPoint.getSignature.asInstanceOf[MethodSignature] //get the value of the field id joinPoint.proceed } I am not able to get the values. If I try val res = methodSignature.getMethod.getParameterAnnotations res.map

Compiling errors occur while convert a project to AspectJ project with AspectJ eclipse 3.4 plugin, ajdt2.0.1

五迷三道 提交于 2019-12-08 04:13:06
问题 Hey, I wanna to add AOP to my web project. I download ajdt2.0.1 for eclipse 3.4.1. But when I convert this project to AspectJ projects, I got so many compile errors which shouldn't occur. Such as "XXXDAO cannot be resolved", etc. When I remove AspectJ Capability, everything goes well. Does anyone meet this problems? Thanks in advance. 回答1: I have solved it by set ajc option with "-encoding UTF-8". That's mysterious, cause the encoding of eclipse is exactly utf-8. Does that mean ajc use my OS

Tomcat 7 - Get the application name during runtime without login via java-agent/aspectj

末鹿安然 提交于 2019-12-08 02:37:59
问题 I'm trying to get a list of all deployed applications, and specifically the name of the application mapped to tomcat root . I want to be able to do it during runtime, using a java agent that collects information on the tomcat server. I tried using this code sample: private Iterable<String> collectAllDeployedApps() { try { final Set<String> result = new HashSet<>(); final Set<ObjectName> instances = findServer() .queryNames(new ObjectName("Tomcat:j2eeType=WebModule,*"), null); for (ObjectName

Load-time weaving and java -jar

不问归期 提交于 2019-12-07 21:01:56
问题 Is it possible to add the aspectj load-time agent when start a program with -jar ? With Jetty, if I start java -javaagent:aspectjweaver-1.8.0.jar -classpath toto.jar -jar start.jar The aspectj is not apply. But I if call java -javaagent:aspectjweaver-1.8.0.jar -classpath toto.jar;start.jar org.eclipse.jetty.start.Main all was fine. 回答1: The problem with -jar and LTW seems to be that there is something different with the classloading order compared to the -cp (...) my.MainClass approach.

How to disable Spring's JpaExceptionTranslatorAspect

僤鯓⒐⒋嵵緔 提交于 2019-12-07 18:48:09
问题 I'm migrating from Spring 2.5.6 to 3.2.5. The jar spring-aspects-3.2.5 contains the new aspect JpaExceptionTranslatorAspect which translates standard JPA exceptions into Spring exceptions. It seems to be a Roo-specific aspect. This aspect gets automatically weaved into repositories (annotated with @Repository). Consequently, standard JPA exceptions are not caught anymore and the application is broken. How can I exclude JpaExceptionTranslatorAspect from being weaved? If it can't be done, is