vmassol 2004/02/15 03:18:58
Modified: scratchpad/cactus2/framework/conf aspectwerkz.xml
scratchpad/cactus2/samples/servlet/conf aspectwerkz.xml
Added: scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/aspect
ListenerAspect.java
scratchpad/cactus2/framework/src/main/org/apache/cactus/framework
Listener.java
scratchpad/cactus2/framework/src/test/org/apache/cactus/framework
ListenerTest.java
Removed: scratchpad/cactus2/framework/src/main/org/apache/cactus/framework
TestListenerAspect.java
Log:
- Move aspects in a an aspect package
- Separate aspects from pure java code which makes it easier to swap a different AOP
implementation should we need it and it also makes it easier for unit testing
Revision Changes Path
1.1
jakarta-cactus/scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/aspect/ListenerAspect.java
Index: ListenerAspect.java
===================================================================
/*
* ========================================================================
*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================================================================
*/
package org.apache.cactus.framework.aspect;
import org.apache.cactus.framework.Listener;
import org.codehaus.aspectwerkz.attribdef.Pointcut;
import org.codehaus.aspectwerkz.attribdef.aspect.Aspect;
import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
/**
* Intercepts client side JUnit tests and sets up the test listener socket
* if not set.
*/
public class ListenerAspect extends Aspect
{
/**
* @Execution * *..TestCase+.test*()
*/
private Pointcut interceptClientTest;
private Listener listener = new Listener();
/**
* @Around interceptClientTest
*/
public Object setupListener(JoinPoint joinPoint) throws Throwable
{
this.listener.setupListener();
return joinPoint.proceed();
}
}
1.1
jakarta-cactus/scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/Listener.java
Index: Listener.java
===================================================================
/*
* ========================================================================
*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================================================================
*/
package org.apache.cactus.framework;
public class Listener
{
/**
* Has the test listener socket been set up?
*/
private boolean isSetup = false;
public synchronized void setupListener() throws Throwable
{
if (!this.isSetup)
{
System.out.println("Setting up test listener socket");
this.isSetup = true;
}
}
}
1.1
jakarta-cactus/scratchpad/cactus2/framework/src/test/org/apache/cactus/framework/ListenerTest.java
Index: ListenerTest.java
===================================================================
/*
* ========================================================================
*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================================================================
*/
package org.apache.cactus.framework;
import junit.framework.TestCase;
/**
* Unit test for [EMAIL PROTECTED] Listener}.
*/
public class ListenerTest extends TestCase
{
public void testSetupListenerWhenNotAlreadySetup() throws Throwable
{
// Note: This test is invalid for the time being...
Listener listener = new Listener();
listener.setupListener();
}
}
1.2 +1 -1 jakarta-cactus/scratchpad/cactus2/framework/conf/aspectwerkz.xml
Index: aspectwerkz.xml
===================================================================
RCS file:
/home/cvs/jakarta-cactus/scratchpad/cactus2/framework/conf/aspectwerkz.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- aspectwerkz.xml 13 Feb 2004 14:12:49 -0000 1.1
+++ aspectwerkz.xml 15 Feb 2004 11:18:58 -0000 1.2
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectwerkz PUBLIC "-//AspectWerkz//DTD//EN"
"http://aspectwerkz.codehaus.org/dtd/aspectwerkz.dtd">
-<aspectwerkz>
<system>
<package name="org.apache.cactus.framework">
<use-aspect class="TestListenerAspect"/>
</package>
</system>
</aspectwerkz>
+<aspectwerkz>
<system id="cactus">
<package name="org.apache.cactus.framework.aspect">
<use-aspect class="ListenerAspect"/>
</package>
</system>
</aspectwerkz>
1.2 +1 -1
jakarta-cactus/scratchpad/cactus2/samples/servlet/conf/aspectwerkz.xml
Index: aspectwerkz.xml
===================================================================
RCS file:
/home/cvs/jakarta-cactus/scratchpad/cactus2/samples/servlet/conf/aspectwerkz.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- aspectwerkz.xml 13 Feb 2004 14:12:49 -0000 1.1
+++ aspectwerkz.xml 15 Feb 2004 11:18:58 -0000 1.2
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectwerkz PUBLIC "-//AspectWerkz//DTD//EN"
"http://aspectwerkz.codehaus.org/dtd/aspectwerkz.dtd">
-<aspectwerkz>
<system>
<package name="org.apache.cactus.sample.servlet">
<use-aspect class="TestSampleServletAspectWerkz$GetRequestParametersTestAdvice"/>
</package>
<package name="org.apache.cactus.framework">
<use-aspect class="TestListenerAspect"/>
</package>
</system>
</aspectwerkz>
+<aspectwerkz>
<system id="cactus">
<package name="org.apache.cactus.sample.servlet">
<use-aspect class="TestSampleServletAspectWerkz$GetRequestParametersTestAdvice"/>
</package>
<package name="org.apache.cactus.framework.aspect">
<use-aspect class="ListenerAspect"/>
</package>
</system>
</aspectwerkz>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]