[jboss-cvs] JBossAS SVN: r99432 - in projects/snowdrop/examples/trunk/sportsclub: sportsclub-invoicing-webmvc and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 14 19:44:53 EST 2010
Author: marius.bogoevici
Date: 2010-01-14 19:44:53 -0500 (Thu, 14 Jan 2010)
New Revision: 99432
Added:
projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/audit/
projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/audit/PaymentAuditor.java
Modified:
projects/snowdrop/examples/trunk/sportsclub/sportsclub-ear/pom.xml
projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/pom.xml
projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/spring-business-context.xml
Log:
basic auditing + exposing audit bean w/JMX
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-ear/pom.xml
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-ear/pom.xml 2010-01-14 22:33:04 UTC (rev 99431)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-ear/pom.xml 2010-01-15 00:44:53 UTC (rev 99432)
@@ -66,6 +66,16 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ <version>1.6.3</version>
+ </dependency>
</dependencies>
<build>
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/pom.xml
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/pom.xml 2010-01-14 22:33:04 UTC (rev 99431)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/pom.xml 2010-01-15 00:44:53 UTC (rev 99432)
@@ -77,6 +77,18 @@
<version>1.1</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.6.3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ <version>1.6.3</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<finalName>sportsclub-invoicing-webmvc</finalName>
Added: projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/audit/PaymentAuditor.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/audit/PaymentAuditor.java (rev 0)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/java/org/jboss/snowdrop/samples/sportsclub/audit/PaymentAuditor.java 2010-01-15 00:44:53 UTC (rev 99432)
@@ -0,0 +1,37 @@
+package org.jboss.snowdrop.samples.sportsclub.audit;
+
+import java.math.BigDecimal;
+
+import org.springframework.jmx.export.annotation.ManagedAttribute;
+import org.springframework.jmx.export.annotation.ManagedResource;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Marius Bogoevici
+ */
+ at ManagedResource(objectName = "sportsclub:name=paymentAuditor", description = "Payment Auditor", logFile = "log-sportsclub-auditor-jmx.log")
+ at Component
+public class PaymentAuditor
+{
+ private boolean enabled = true;
+
+ @ManagedAttribute
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ @ManagedAttribute
+ public boolean getEnabled()
+ {
+ return this.enabled;
+ }
+
+ public void auditPayment(Long accountId, BigDecimal amount)
+ {
+ if (this.enabled)
+ {
+ System.out.println("A payment has been made to account " + accountId + " in total of " + amount);
+ }
+ }
+}
Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/spring-business-context.xml
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/spring-business-context.xml 2010-01-14 22:33:04 UTC (rev 99431)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-invoicing-webmvc/src/main/webapp/WEB-INF/spring-business-context.xml 2010-01-15 00:44:53 UTC (rev 99432)
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--suppress DuplicatedBeanNamesInspection -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<import resource="classpath*:dao-context.xml"/>
@@ -62,4 +65,31 @@
</bean>
<tx:annotation-driven/>
+
+ <aop:config>
+ <aop:aspect ref="paymentAuditor">
+ <aop:pointcut id="processingPayment" expression="execution(* *..PaymentProcessor+.*(..)) && args(accountId, amount)"/>
+ <aop:before arg-names="accountId, amount" pointcut-ref="processingPayment" method="auditPayment"/>
+ </aop:aspect>
+ </aop:config>
+
+ <bean id="paymentAuditor" class="org.jboss.snowdrop.samples.sportsclub.audit.PaymentAuditor"/>
+
+ <bean id="attributeSource" class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/>
+
+ <bean class="org.springframework.jmx.export.MBeanExporter">
+ <property name="autodetectModeName" value="AUTODETECT_ASSEMBLER"/>
+ <property name="ensureUniqueRuntimeObjectNames" value="true"/>
+ <property name="namingStrategy">
+ <bean class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
+ <property name="attributeSource" ref="attributeSource"/>
+ </bean>
+ </property>
+ <property name="assembler">
+ <bean class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
+ <property name="attributeSource" ref="attributeSource"/>
+ </bean>
+ </property>
+ </bean>
+
</beans>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list