[jboss-cvs] JBossAS SVN: r80109 - in projects/demos/microcontainer/trunk: ioc/src/main/resources/META-INF and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 27 10:52:05 EDT 2008
Author: alesj
Date: 2008-10-27 10:52:05 -0400 (Mon, 27 Oct 2008)
New Revision: 80109
Added:
projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/Executor.java
projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/ExecutorInvoker.java
Modified:
projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/AnnotatedExecutor.java
projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/SimpleExecutor.java
projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/StopWatchInterceptor.java
projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/annotations-beans.xml
projects/demos/microcontainer/trunk/jmx/src/main/resources/META-INF/aop-beans.xml
Log:
Add Exceutor and its invoker.
Add aop interceptor - TODO on CL.
Simplify AspectManager name usage.
Modified: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/AnnotatedExecutor.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/AnnotatedExecutor.java 2008-10-27 14:24:49 UTC (rev 80108)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/AnnotatedExecutor.java 2008-10-27 14:52:05 UTC (rev 80109)
@@ -24,7 +24,7 @@
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class AnnotatedExecutor
+public class AnnotatedExecutor implements Executor
{
private SimpleExecutor delegate;
Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/Executor.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/Executor.java (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/Executor.java 2008-10-27 14:52:05 UTC (rev 80109)
@@ -0,0 +1,30 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.demos.ioc.annotations;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface Executor
+{
+ void execute() throws Exception;
+}
Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/ExecutorInvoker.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/ExecutorInvoker.java (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/ExecutorInvoker.java 2008-10-27 14:52:05 UTC (rev 80109)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.demos.ioc.annotations;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ExecutorInvoker
+{
+ public void addExecutor(Executor executor) throws Exception
+ {
+ executor.execute();
+ }
+}
Modified: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/SimpleExecutor.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/SimpleExecutor.java 2008-10-27 14:24:49 UTC (rev 80108)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/SimpleExecutor.java 2008-10-27 14:52:05 UTC (rev 80109)
@@ -26,11 +26,11 @@
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class SimpleExecutor
+public class SimpleExecutor implements Executor
{
public void execute() throws Exception
{
Random random = new Random();
- Thread.sleep(Math.abs(random.nextLong() % 1000l));
+ Thread.sleep(Math.abs(random.nextLong() % 101));
}
}
\ No newline at end of file
Modified: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/StopWatchInterceptor.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/StopWatchInterceptor.java 2008-10-27 14:24:49 UTC (rev 80108)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/annotations/StopWatchInterceptor.java 2008-10-27 14:52:05 UTC (rev 80109)
@@ -21,9 +21,33 @@
*/
package org.jboss.demos.ioc.annotations;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class StopWatchInterceptor // todo interceptor
+public class StopWatchInterceptor implements Interceptor
{
+ private Logger log = Logger.getLogger("StopWatch");
+
+ public String getName()
+ {
+ return "StopWatchInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ long time = System.currentTimeMillis();
+ log.info("Invocation start: " + time);
+ try
+ {
+ return invocation.invokeNext();
+ }
+ finally
+ {
+ log.info("Invocation time: " + (System.currentTimeMillis() - time));
+ }
+ }
}
Modified: projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/annotations-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/annotations-beans.xml 2008-10-27 14:24:49 UTC (rev 80108)
+++ projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/annotations-beans.xml 2008-10-27 14:52:05 UTC (rev 80109)
@@ -1,6 +1,12 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!--<aop/> TODO add interceptor -->
+<!--
+ <interceptor xmlns="urn:jboss:aop-beans:1.0" name="StopWatchInterceptor" class="org.jboss.demos.ioc.annotations.StopWatchInterceptor"/>
+
+ <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* @org.jboss.demos.ioc.annotations.StopWatchLog->*(..)) OR execution(* *->@org.jboss.demos.ioc.annotations.StopWatchLog(..))">
+ <interceptor-ref name="StopWatchInterceptor"/>
+ </bind>
+-->
<bean name="AnnotatedExecutor" class="org.jboss.demos.ioc.annotations.AnnotatedExecutor">
<constructor>
@@ -18,4 +24,8 @@
</install>
</bean>
+ <bean name="ExecutorInvoker" class="org.jboss.demos.ioc.annotations.ExecutorInvoker">
+ <incallback method="addExecutor"/>
+ </bean>
+
</deployment>
Modified: projects/demos/microcontainer/trunk/jmx/src/main/resources/META-INF/aop-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/jmx/src/main/resources/META-INF/aop-beans.xml 2008-10-27 14:24:49 UTC (rev 80108)
+++ projects/demos/microcontainer/trunk/jmx/src/main/resources/META-INF/aop-beans.xml 2008-10-27 14:52:05 UTC (rev 80109)
@@ -18,13 +18,12 @@
</bean>
-->
-
<!--
Valid values for the AspectManager bean for use with enableTransformer=true are:
* org.jboss.aop.deployers.AspectManagerJDK5 - works with the -javaagent:pluggable-instrumentor.jar switch
* org.jboss.aop.deployers.AspectManagerJRockit - works with JRockit and the -Xmanagement:class=org.jboss.aop.hook.JRockitPluggableClassPreProcessor switch
-->
- <bean name="AspectManager" class="org.jboss.aop.deployers.AspectManagerJDK5">
+ <bean name="AspectManagerJDK5" class="org.jboss.aop.deployers.AspectManagerJDK5">
<constructor>
<parameter><![CDATA[
<aop>
@@ -65,36 +64,35 @@
-->
</bean>
+ <!-- Simplify name usage -->
+ <bean name="AspectManager">
+ <constructor factoryMethod="getAspectManager"><factory bean="AspectManagerJDK5"/></constructor>
+ </bean>
+
<!-- Support for @JMX -->
<lifecycle-configure xmlns="urn:jboss:aop-beans:1.0"
name="JMXRegistrationAdvice"
class="org.jboss.system.microcontainer.jmx.ServiceControllerRegistrationLifecycleCallback"
- classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
- manager-bean="AspectManager"
- manager-property="aspectManager">
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
<property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
</lifecycle-configure>
<lifecycle-create xmlns="urn:jboss:aop-beans:1.0"
name="JMXCreateDestroyAdvice"
class="org.jboss.system.microcontainer.jmx.ServiceControllerCreateDestroyLifecycleCallback"
- classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
- manager-bean="AspectManager"
- manager-property="aspectManager">
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
<property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
</lifecycle-create>
<lifecycle-install xmlns="urn:jboss:aop-beans:1.0"
name="JMXStartStopAdvice"
class="org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback"
- classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
- manager-bean="AspectManager"
- manager-property="aspectManager">
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
<property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
</lifecycle-install>
<!-- MBean for making sure that the underlying AspectManagerService gets registered in JMX -->
<bean name="AspectManagerJMXRegistrar" class="org.jboss.aop.deployers.AspectManagerJMXRegistrar">
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
- <property name="aspectManager"><inject bean="AspectManager"/></property>
+ <property name="aspectManager"><inject bean="AspectManagerJDK5"/></property>
</bean>
</deployment>
More information about the jboss-cvs-commits
mailing list