-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
309d216
commit bbc3d87
Showing
7 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/resources/java/com/wwq/calculator/CalculatorIntroduction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.wwq.calculator; | ||
|
||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.DeclareParents; | ||
|
||
@Aspect | ||
public class CalculatorIntroduction { | ||
@DeclareParents( | ||
value = "com.wwq.calculator.ArithmeticCalculatorImpl", | ||
defaultImpl = MaxCalculatorImpl.class) | ||
public MaxCalculator maxCalculator; | ||
|
||
@DeclareParents( | ||
value = "com.wwq.calculator.ArithmeticCalculatorImpl", | ||
defaultImpl = MinCalculatorImpl.class) | ||
public MinCalculator minCalculator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/resources/java/com/wwq/calculator/MaxCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wwq.calculator; | ||
|
||
public interface MaxCalculator { | ||
public double max(double a, double b); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/resources/java/com/wwq/calculator/MaxCalculatorImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.wwq.calculator; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
public class MaxCalculatorImpl implements MaxCalculator { | ||
/** | ||
* Logger for this class | ||
*/ | ||
private static final Logger logger = Logger | ||
.getLogger(MaxCalculatorImpl.class); | ||
|
||
@Override | ||
public double max(double a, double b) { | ||
// TODO Auto-generated method stub | ||
double result = (a >= b) ? a : b; | ||
logger.info("max(" + a + ", " + b + ") = " + result); | ||
return result; | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/resources/java/com/wwq/calculator/MinCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wwq.calculator; | ||
|
||
public interface MinCalculator { | ||
public double min(double a, double b); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/resources/java/com/wwq/calculator/MinCalculatorImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.wwq.calculator; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
public class MinCalculatorImpl implements MinCalculator { | ||
/** | ||
* Logger for this class | ||
*/ | ||
private static final Logger logger = Logger | ||
.getLogger(MinCalculatorImpl.class); | ||
|
||
@Override | ||
public double min(double a, double b) { | ||
// TODO Auto-generated method stub | ||
double result = (a <= b) ? a : b; | ||
logger.info("min(" + a + ", " + b + ") = " + result); | ||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters