annotations,aop,aspectj , AspectJ annotations: Pointcut params

AspectJ annotations: Pointcut params


Tag: annotations,aop,aspectj

I'm trying to log a login action with AspectJ. I need to obtain the logged user. I tried this but it doesn't work. The joinpoint is never executed.

public class LoginActivityAspect {

    @Pointcut(value = "call(void && this(username)", argNames = "username")
    public void loginSuccess(String username) {}

    @Before(value = "loginSuccess(username)")
    public void logLoginSuccess(username) {
        logger.debug("loginSuccess", "Login success: " + username);

In LoginActivity I have this method:

public void loginSuccess(String username){
    //DO STUFF

What am I doing wrong? Thanks.


Solved! Sorry I'm newbie in AOP.

I have modified the pointcut into this:

 @Pointcut(value = "call(void && args(username)")
    public void loginSuccess(String username) {}


Adding a pin annotation to a map view on a long press in swift

I'm trying to make an iPhone app which requires users to be able to long press on a place on a map view to drop a pin there. Does anybody know how this is done? The behaviour is observable in apple maps when you long press on the screen. It...

Groovy multiple Delegate annotation/Wrapper for list

I'm struggling how to use the @Delegate annotation in Groovy. What I'm trying to achieve is the following. I have two types of items (itemA & itemB). ItemB basically consists of a list of itemA's, so I used the @Delegate annotation. Furthermore, multiple itemA's are stored in a collection (collectionA),...

Get id column name from POJO, using reflection

@Entity @Table(name="MY_TABLE") public class MyTable{ @Id @Column(name="MY_TABLE_ID") @GeneratedValue(strategy = GenerationType.AUTO ,generator="SQ_MY_TABLE") @SequenceGenerator(name="SQ_MY_TABLE", sequenceName="SQ_MY_TABLE") private Long myTableId; How can I, using reflection, get the primary key column name from my POJO, defined with the javax.persistence.Id annotation? I'd have to find the @Id and then get the name property of the @Column...

Technical debt on custom web rule in sonarqube 5.1

I am facing issue in technical debt with custom web rules. I have web plugin but no technical debt is assigned to rules. I want code or annotation through which i can assign some constat/issue value to each rule and can calculate debt from that. I used following anotations while...

What should I annotate when I unit test the GPS function with Robolectric?

I am referring the following site . There it was mentioned that we should annotate @LargeTest if our test method is accessing the network feature. I am using Roboloectric for unit testing. And my method uses the shadowLocationManager to simulate the GPS location. I am not sure what should...

Dynamic annotation/attribute values

I run into a problem using data annotations in c#. I am using custom required and range attributes and I want to set an object as the error message. [MyOwnRequired(ErrorCode=GlobalMessages.Message01] public string Description { get; set; } The problem is that I do have a class holding several objects (GlobalMessages.Message01,...

How to map multiple One-to-Many association in Hibernate


How can I configure AOP in Liferay Service Builder?

I want to to intercept a method in Service Builder, for example: XXXLocalService.update(). But I don't know the correct way to do this. I have done some research but I haven't found a clear way to do this. Any help will be greatly appreciated....

Read annotation of generic class Java

I had an idea to use a Dao class ( class Dao <Model extends AbstractModel> { public String getUrl() { return Model.class.getAnnotation(MyPath.class).url(); } } and a model like this ( @MyPath(url = "blabla") class Account extends AbstractModel { ... } but the problem is that in that case if i...

Is there a way to enclose multiple event declarations on a single [] block?

It is a little tedious to write: let e1 = Event<_>() let e... = Event<_>() let en = Event<_>() [<CLIEvent>] member this.E1 = e1.Publish [<CLIEvent>] member this.E... = e....Publish [<CLIEvent>] member this.En = en.Publish In the code, I show how I need to write n [<CLIEvent>], 1 for each event....

spring data mongodb find by collection

I am using spring-data-mongodb. Here is my controller method: Controller: @RequestMapping(value = "/getByCategory",method = RequestMethod.GET, consumes=MediaType.APPLICATION_JSON, produces=MediaType.APPLICATION_JSON) public Iterable<Node> getByCategory(@RequestParam(value="categories") List<String> categories) throws EntityNotFoundException { Iterable<Node> nodes = nodeService.getByCategory(categories); return nodes; } Here I am passing list of string as a request parameter. My service method is: public Iterable<Node>...

pointcut execution for specific class constructor

I'm trying to create specific class constructor pointcut execution but I get the following marker: Aspect code: public aspect CarLogger { private Logger logger; pointcut instantiate() : execution (; after() : instantiate(){ logger.log(Level.INFO, "In Car::Car()", thisJoinPoint.getThis()); } this code returns no match for this type name Car. But if I...

AOP pointcut expression for specific annotated variable

I have a scenario like this.. A custom annotation definition... @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheMe{ String node(); } User details class... class User { String name; String ssn; } And a class with "User" object as variable and uses @CacheMe annotation Class Test{ @CacheMe(node="user") User user; public User getUser(Long id){...

Why must a setter be empty, if the property uses annotation attributes?

i want to use the setter to auto-correct the value and want to use the RequiredAttribute too. But in this case the RequiredAttribute do not work, because the setter is not empty. So, why have the setter to be empty? [Required(AllowEmptyStrings = false, ErrorMessage = "The Name cannot be empty....

How can I specify the type of the field that an Annotation should be applied to in Java?

I'm creating a simple annotation, to help me inflating settings inside my Android application. The annotation is this: @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface CoreSettings { String name() default ""; } I want to ensure it will only be used in fields which type extends a custom class named BaseSettings. In the...

Python anotation arrow direction

I am trying to annotate a scatter plot in Python 2.7, with Matplotlib. Here is the plot code: import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.DataFrame(np.random.rand(5,3), columns=list('ABC')) df.insert(0,'Annotation_Text',['ABC','DEF','GHI','JKL','mnop']) q = 2 pqr = 1 # Scatter Plot: x = df['A'] y = df.iloc[:,q]...

Symfony2 AnnotationException You have to enable OPCache or ZendOptimizer

I have application based on the Symfony2 framework. I have moved to the production environment, website was running fine (I was trying to adjust caching - on my hosting is xcache). But suddenly I has this error: Fatal error: Uncaught exception 'Doctrine\Common\Annotations\AnnotationException' with message 'You have to enable opcache.save_comments=1 or...

why spring 4 recommend annotation rather than configuration file? [closed]

Recently I'm learning the spring framework of java. I am curious that why spring 4 recommend annotation to set up spring rather using configuration file? Some people said that the spring configuration file is too complicated. But I think using annotation is going to the opposite direction of purpose of...

Read controllers custom annotations from a custom Command in Symfony 2

I have created custom annotations to generate JSON files (for NodeRed if you ask...) and i'm testing them successfully from a dummy method in a dummy controller. I would like to port all that to a custom Sf command whose job would be to read all Controllers annotations in my...

How do I access parameters specified in a Java Aspect?

I have an annotation called "@ProgressCheck" that we can put on a controller to check the progress of an application. If the application is already submitted or late, then it throws the user to a page appropriate for that situation. The annotation interface is: @Retention(RetentionPolicy.RUNTIME) public @interface ProgressCheck { }...

AOP (without Spring) not working on Tomcat but Eclipse

Implemented AOP using AspectJ without Spring. It works perfectly fine when running in Eclipse (Tomcat server) but not when run directly in Tomcat. Have added required dependencies in the pom but of no use. Not able to figure out the issue. Aspect class: @Aspect public class FeatureAOP { private static...

Pros and cons of using type annotations in Swift

I was wondering the difference of using and not using type annotations(var a: Int = 1 vs var a = 1) in Swift, so I read Apple's The Swift Programming Language. However, it only says: You can provide a type annotation when you declare a constant or variable, to be...

spring-cassandra UDT data insert

Can someone help me to find out how to insert Cassandra UDT data using Spring POJO class? I created one POJO class to map Cassandra's Table and Created one another class for Cassandra UDT, but when i inserted main POJO class that map Cassandra's table than it's not recognized another...

@PathVariable and @RequestParam not working together

I have below code in my controller: @RequestMapping(value = "/child/{nodeId}/{relType}",method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON) public Iterable<Node> getConnectedNodes(@RequestParam("page")int page, @RequestParam("size")int size, @PathVariable("nodeId") String nodeId, @PathVariable("relType") String relType) { return nodeService.getConnectedNodes(nodeId, relType,page,size); } And this is the API url i am hitting...

How to automatically format PHP annotations in PHPStorm

I'm working with a large number of files that have PHP block docs with Swagger PHP annotations on them, however they are not indented. Is there anyway to automatically format them with spaces? Turning /** * @SWG\Api( * path="/building/{buildingId}", * @SWG\Operation( * method="GET", * type="Building", * summary="Returns a Building object...

Symfony2 Annotation Inheritance

In my project, I have a BaseController class which implements several methods used by all of my controllers. Now I wanted to add @QueryParam for that base class. My class looks like this: class DoctrineRESTQueryController extends FOSRestController { /** * @QueryParam(name="start",default=0) * @QueryParam(name="limit",default=null) */ public function getQueryResponseAction (ParamFetcher $paramFetcher) {...

What is the correct CascadeType in @ManyToMany Hibernate annotation?

I am trying to model a transient operations solution schema in Hibernate and I am unsure how to get the object graph and behavior I want from the model. The table structure uses a correlation table (many-to-many) to create lists of users for the operation: Operation OperationUsers Users op_id op_id...

Filter array based on coordinate from mapview frame in objective C

I have hundred's of map annotation. Annotation are from array of dictionary with lat and long val same data shown in table view. Table view and map view are same view based on screenheight/2. What I need for example in my array have 100 lat and long value table view...

Ambiguous mapping found when I use extends clause

I have a CustomerController and CustomerCardController classes that extend CrudMethods class. I choose so, because these two controller use the same methods (getFileCustomer() is one of these). And I thought that it had been better use the inheritance to save code's rows. CustomerController @Controller public class CustomerController extends CrudMethods {...

android json data to spring mvc4

I am new to using Spring mvc4 annotation . In all i want to do is using spring mvc as a web service . so i would be thankful if anyone could provide me a solution for it. My android code is as: HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 5000);...

How to get @interface parameter in jersey WriterInterceptor Implementation

I have an interface, for example @NameBinding @Retention(RetentionPolicy.RUNTIME) public @interface AutoLogged { boolean query() default false; } How can I get query parameter in interceptor implementation? @Provider @AutoLogged public class AutoLoggedInterceptor implements WriterInterceptor { @Context private ResourceInfo resourceInfo; @Override public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException { try {...

How to inject a Map using the @Value Spring Annotation?

How can i inject values into a Map from the properties file using the @Value annotation in Spring ? My Spring Java class is and i tried using the $ but, got the following error message Could not autowire field: private java.util.Map Test.standard; nested exception is java.lang.IllegalArgumentException: Could not resolve...

PHP-DI annotation not working

I have installed php-di 4.4 in a new custom project using composer.Im runing a xampp localhost with php 5.6.3 but I set netbeans for php 5.4 on this project. Im new to php-di, I did use annotations in my android projects but cant seem to make it work here. The...

Java custom annotation to find methods

I want to create annotation (for which I can set some kind of id), which I can put on variable, and write method which return getter or setter method of this variable by annotations setted id; As example I made something like that but only for method, so I need...

Specify user handlers for JAX-RS when using annotation scanning

How to specify user handlers for JAX-RS when using annotation scanning? I am following this link and have created my custom handlers. I have annotated my Application subclass as: @ApplicationPath("rest") public class RestfulResourceLoader extends Application { } so that I don't have to entry in web.xml file. What I am...

How to add Coordinates to CLLocationCoordinate2D from Dynamic NSMutableArray?

I have a MapView in which I would like to add annotations and a route from defined coordinates that I add from a Textfield and store in an NSMutableArray. Now I'm able to show the route from multiple coordinates but only when I insert them in my code as follow...

How to implement a parameter decorator in TypeScript?

I've been trying to use a parameter decorator @logParameter: class Person { public name: string; public surname: string; constructor(name : string, surname : string) { = name; this.surname = surname; } public saySomethingAsync(something: string, @logParameter cb: (said : string) => void) { cb( + " " + this.surname +...

Python - Add annotation in subplot imshow

I would like to add some annotations on a figure with multiple subplots...On the figure below i would like to write something below the 2 right figures and at the left top. How can i do that? I try with : ax3.text(0.1, 0.5, '$\sigma =$' resV.mean(), size=12, ha='center', va='center') But...

Animated annotation on WKInterfaceMap Watchkit

Is there anyway to have an animated annotation for WKInterfaceMap of Watchkit? I have 35 images to form the animation. Currently I am using a NSTimer which calls -(void)addAnnotation:(CLLocationCoordinate2D)location withImageNamed:(NSString *)name centerOffset:(CGPoint)offset method with a different image names but the result is not efficient and the animation is not smooth...

Load different Entities from a single table with a column as discriminator

I have the following table with 3 types of people, boy, man and woman: CREATE TABLE IF NOT EXISTS person( id int unsigned NOT NULL AUTO_INCREMENT, type VARCHAR(100), name VARCHAR(100), description VARCHAR(2000), PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO person (id, type, name, description) VALUES(1, 'child', 'Omar', '');...

Representation of inner source-retained annotation

We have this class: public class MyClass { @Retention(RetentionPolicy.SOURCE) private @interface MyInterface { } @MyInterface public void hello() { } } As you can see, it has an inner, source-only annotation. My question is: should the exported binary (jar) contain the MyClass$MyInterface.class file or not? If we look at the...

Annotator dependencies: UIMA Type Capabilities?

In my UIMA application, I have some annotators that must run after a certain annotator has run. At first, I thought about aggregating these annotators together, but I have other annotators that are also dependent on this (and other) annotator, which makes aggregating hard and/or unpractical. I read about Type...

Spring AOP use AspectJ to works or what?

I am studying Spring AOP and I have the following doubt. From what I know there are 2 ways to implement AOP behavior into a Java application that are: AspectJ: that is the first original AOP technology that uses byte code modification for aspect weaving. Spring AOP: Java-based AOP framework...

Annotations to detect method calls with wrong order of String parameters

We have a big application which uses a lot of Strings: for serial numbers for product names for order number for customer references ... and many more ... Unfortunately our developers are only human. Sometimes the String values get mixed up when calling methods. For example: // this method public...

How to get full return type forwarding in Xtend's Active Annotations?

I'm trying out Xtend's Active Annotations by writing a simple "Logged" annotation for tracing when methods have been called. Basically I want to write this in Xtend: @Logged override onCreate() { sampleFuncCall() } and get something like this in Java: @Override void onCreate() { Log.d("TAG", "onCreate started"); sampleFuncCall(); Log.d("TAG", "onCreate...

Symfony2 / Doctrine2 : how to access an entity annotation mapping?

In my Symfony2/doctrine2 application, I have two entities, Media and Recipe. They can be linked by a oneToMany or a ManyToMany association. In the case of a oneToMany relationship, I am using the following code to retrieve the Recipe linked to an instance of Media : $accessor = PropertyAccess::createPropertyAccessor(); $reflect...

How to define an annotation for more than one target in Groovy?

In Java, to define an annotation for more than one target, the curly braces can be used: @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.FIELD}) public @interface AnnotExample { String name(); } However, this doesn't work in Groovy: $ groovyc AnnotExample.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: AnnotExample.groovy: 8: expecting '}', found ',' @ line 8, column 26....

In a JUnit test is there a rule to set the subject of the test

I've been writing a lot of JUnit tests lately and see this same boilerplate pattern. public class MathOpTest { private MathOp a; @Before public void setUp(){ a = new MathOp(); } ... } Is there an annotation to set this up for me as I always need to write a...

Update custom annotation pin image to standard annotation pin in swift

I want to update map view every 60 seconds & make an annotation with custom pin/image but want to show standard pin [red color - See Figure 6-1] icon to the previously drawn annotation. I tried like below code but that does not working properly. With another custom image it...