Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javanica iss 907 #945

Merged
merged 16 commits into from
Oct 21, 2015
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.java.home=c:/Program Files/Java/jdk1.7.0_79
96 changes: 95 additions & 1 deletion hystrix-contrib/hystrix-javanica/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,104 @@
apply plugin: 'java'

configurations {
ajtools
ajcTestCompile.extendsFrom testCompile
ajcTestRuntime.extendsFrom testRuntime
ajc
}


sourceSets {
ajcTest {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}

ajc {
def main = sourceSets.main
java.srcDirs = main.java.srcDirs
resources.srcDirs = main.resources.srcDirs
compileClasspath = main.compileClasspath
runtimeClasspath = main.runtimeClasspath
}
}



compileAjcTestJava {

sourceCompatibility = "1.6"
targetCompatibility = "1.6"

doLast {
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajtools.asPath)
ant.iajc(source: "1.6", target: "1.6",
destDir: "${sourceSets.ajcTest.output.classesDir.absolutePath}", maxmem: "512m", fork: "true",
classpath: "${sourceSets.main.output.classesDir.absolutePath};${configurations.testCompile.asPath}")
{
sourceroots {
files("src/ajcTest/java/com/netflix/hystrix/contrib/javanica/test/aspectj", "src/test/java/com/netflix/hystrix/contrib/javanica/test/common", "src/main/java/com/netflix/hystrix/contrib/javanica/aop/aspectj").each {
File file -> pathelement(location: file.absolutePath)
}
}
}
}

}

compileAjcJava {
sourceCompatibility = "1.6"
targetCompatibility = "1.6"

doLast {
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajtools.asPath)
ant.iajc(source: "${sourceCompatibility}", target: "${targetCompatibility}",
destDir: "${sourceSets.ajc.output.classesDir.absolutePath}", maxmem: "512m", fork: "true", "showWeaveInfo": "true",
classpath: "${configurations.compile.asPath}")

{
sourceroots {
sourceSets.ajc.java.srcDirs.each {
pathelement(location: it.absolutePath)

}
}
}
}
}

task ajcTest(type: Test) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattrjacobs I added this task that creates jar with aspects compiled using ajc, so now build task results to two jars:
hystrix-javanica.jar
hystrix-javanica-ctw.jar

Should we change something else to publish both artifacts correctly ?

testClassesDir = sourceSets.ajcTest.output.classesDir
classpath = sourceSets.ajcTest.runtimeClasspath
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-Xdebug',
'-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009'
}
}

check.dependsOn test, ajcTest

repositories {
mavenCentral()
}

ext {
aspectjVersion = '1.7.4'
}


task ajcJar(type: Jar) {
archiveName = "${project.name}" + "-ctw.jar"
destinationDir = file("${buildDir}/libs")
from sourceSets.ajc.output
}

assemble.dependsOn(jar, ajcJar)

dependencies {
compile project(':hystrix-core')

ajtools "org.aspectj:aspectjtools:$aspectjVersion"
testRuntime "org.aspectj:aspectjrt:$aspectjVersion"
compile "org.aspectj:aspectjweaver:$aspectjVersion"
compile "org.aspectj:aspectjrt:$aspectjVersion"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.cache;

import com.netflix.hystrix.contrib.javanica.test.common.cache.BasicCacheTest;
import org.junit.BeforeClass;

/**
* Created by dmgcodevil
*/
public class CacheTest extends BasicCacheTest {
@BeforeClass
public static void setUpEnv() {
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
UserService userService = new UserService();
userService.init();
return userService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.collapser;

import com.netflix.hystrix.contrib.javanica.test.common.collapser.BasicCollapserTest;
import org.junit.BeforeClass;

/**
* Created by dmgcodevil
*/
public class CollapserTest extends BasicCollapserTest {
@BeforeClass
public static void setUpEnv() {
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
return new UserService();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.command;

import com.netflix.hystrix.contrib.javanica.test.common.command.BasicCommandTest;
import org.junit.BeforeClass;


public class CommandTest extends BasicCommandTest {

@BeforeClass
public static void setUpEnv(){
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
return new UserService();
}

@Override
protected AdvancedUserService createAdvancedUserServiceService() {
return new AdvancedUserService();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.configuration.collapser;

import com.netflix.hystrix.contrib.javanica.test.common.configuration.collapser.BasicCollapserPropertiesTest;
import org.junit.BeforeClass;

/**
* Created by dmgcodevil
*/
public class CollapserPropertiesTest extends BasicCollapserPropertiesTest {

@BeforeClass
public static void setUpEnv() {
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
return new UserService();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.configuration.command;

import com.netflix.hystrix.contrib.javanica.test.common.configuration.command.BasicCommandPropertiesTest;
import org.junit.BeforeClass;

/**
* Created by dmgcodevil
*/
public class CommandPropertiesTest extends BasicCommandPropertiesTest {

@BeforeClass
public static void setUpEnv() {
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
return new UserService();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.error;

import com.netflix.hystrix.contrib.javanica.test.common.error.BasicErrorPropagationTest;
import org.junit.BeforeClass;

/**
* Created by dmgcodevil
*/
public class ErrorPropagationTest extends BasicErrorPropagationTest {

@BeforeClass
public static void setUpEnv() {
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
return new UserService();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.fallback;

import com.netflix.hystrix.contrib.javanica.test.common.fallback.BasicCommandFallbackTest;
import org.junit.BeforeClass;

/**
* Created by dmgcodevil
*/
public class CommandFallbackTest extends BasicCommandFallbackTest {

@BeforeClass
public static void setUpEnv() {
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
return new UserService();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.netflix.hystrix.contrib.javanica.test.aspectj.observable;

import com.netflix.hystrix.contrib.javanica.test.common.observable.BasicObservableTest;
import org.junit.BeforeClass;

/**
* Created by dmgcodevil
*/
public class ObservableTest extends BasicObservableTest {

@BeforeClass
public static void setUpEnv() {
System.setProperty("weavingMode", "compile");
}

@Override
protected UserService createUserService() {
return new UserService();
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Define the root logger with appender console
log4j.rootLogger = ERROR, CONSOLE

# Define the console appender
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.File=${log}/log.out

# Define the layout for console appender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.conversionPattern=%m%n
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.lang.reflect.Method;

import static com.netflix.hystrix.contrib.javanica.utils.AopUtils.getMethodFromTarget;
import static com.netflix.hystrix.contrib.javanica.utils.EnvUtils.isCompileWeaving;
import static com.netflix.hystrix.contrib.javanica.utils.ajc.AjcUtils.getAjcMethodAroundAdvice;

/**
* AspectJ aspect to process methods which annotated with annotations from
Expand All @@ -54,10 +56,13 @@ public Object methodsAnnotatedWithCacheRemove(final ProceedingJoinPoint joinPoin
MetaHolder metaHolder = MetaHolder.builder()
.args(args).method(method).obj(obj)
.executionType(ExecutionType.SYNCHRONOUS)
.ajcMethod(isCompileWeaving() ? getAjcMethodAroundAdvice(obj.getClass(), method) : null)
.build();
CacheInvocationContext<CacheRemove> context = CacheInvocationContextFactory
.createCacheRemoveInvocationContext(metaHolder);
HystrixRequestCacheManager.getInstance().clearCache(context);
return joinPoint.proceed();
}


}
Loading