AnsweredAssumed Answered

Creating Aspect proxy in plugin

Question asked by atishc on May 15, 2017

Hi

How to create Aspect which can be deployed as plugin. I have tried both Spring and AspectJ style and the proxy method never gets call.What i am trying to do is read for captcha value when service calls happens to  "com.jivesoftware.community.content.discussion.rest.impl.DiscussionServiceImpl"

 

Here is what i have

1. AspectJ class in my plugin

package com.vmware.community.antispam;


import javax.annotation.PostConstruct;


import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;


import com.jivesoftware.community.Captcha;


public aspect CaptchaValidator {
 
  private static final Logger log = LogManager.getLogger(CaptchaValidator.class);


 
Captcha captcha;
 
  @Autowired
  public void setCaptcha(Captcha captcha) {
  this.captcha = captcha;
  }
 
  @PostConstruct
  private void init() {
  log.info("CaptchaValidator aspect initiated");


  }
 
  before(): within(com.jivesoftware.community.content.discussion.rest..*) {
  Object[] args = thisJoinPoint.getArgs();
  for(int indx=0;indx<args.length;indx++){
  log.debug(indx+" -> "+args[indx]);
  }
  }
 
}

2. spring.xml entry

 <bean id="captchaValidatorAspect" class="com.vmware.community.antispam.CaptchaValidator" factory-method="aspectOf">
        <property name="captcha" ref="captcha" />
    </bean>

 

3. plugin compilation

C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building minpoint 8.0.4.0-0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.guava:guava:jar:20.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.google.guava:guava:jar:21.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.google.guava:guava:jar:22.0-SNAPSHOT is missing, no dependency information available
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ minpoint ---
[INFO] Deleting C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint\target
[INFO]
[INFO] --- jive-parent-pom-version-check-plugin:1.5:check-parent-pom-version (check-parent-pom-version) @ minpoint ---
[INFO] ************************************************************************************************************************************************
[INFO] Checking for newer versions of jive-parent-pom...
[INFO] You are currently using version 8.0.4.0-3 of jive-parent-pom.
[INFO] The latest version of jive-parent-pom is 8.0.4.0-3
[INFO] You are using the latest version.
[INFO] ************************************************************************************************************************************************
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ minpoint ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint\src\main\resources-filtered
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ minpoint ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 16 source files to C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint\target\classes
[INFO]
[INFO] --- aspectj-maven-plugin:1.7:compile (weave-aspects) @ minpoint ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] advice defined in com.vmware.community.antispam.CaptchaValidator has not been applied [Xlint:adviceDidNotMatch]
        C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint\src\main\java\com\vmware\community\antispam\CaptchaValidator.aj:29


[WARNING] advice defined in com.jivesoftware.community.audit.aop.AuditAspect has not been applied [Xlint:adviceDidNotMatch]
        C:\REPOSITORY\maven\com\jivesoftware\jive-core\8.0.4.0_559_21bdc7e\jive-core-8.0.4.0_559_21bdc7e.jar!com\jivesoftware\community\audit\aop\AuditAspect.class:26


[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
        C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint\org\springframework\mock\staticmock\AnnotationDrivenStaticEntityMockingControl.aj:115


[WARNING] advice defined in com.jivesoftware.community.license.DenyLicenseSeatStatusAspect has not been applied [Xlint:adviceDidNotMatch]
        C:\REPOSITORY\maven\com\jivesoftware\jive-core\8.0.4.0_559_21bdc7e\jive-core-8.0.4.0_559_21bdc7e.jar!com\jivesoftware\community\license\DenyLicenseSeatStatusAspect.class:33


[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (assemble-jive-artifacts) @ minpoint ---
[INFO] Skipping Antrun execution
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ minpoint ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (setup-jive-home) @ minpoint ---
[INFO] Skipping Antrun execution
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ minpoint ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ minpoint ---
[INFO] Surefire report directory: C:\WORKTEMP\Communities-Work\community-maven\communities-8040\minpoint\target\surefire-reports

Outcomes