[weld-commits] Weld SVN: r6158 - in extensions/trunk/src: main/java/org/jboss/weld/extensions/interceptor and 5 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sun Apr 25 18:30:02 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-04-25 18:30:01 -0400 (Sun, 25 Apr 2010)
New Revision: 6158

Added:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/
   extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/InterceptorExtension.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/Interceptors.java
   extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/
   extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/BarInterceptor.java
   extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/Foo.java
   extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/FooInterceptor.java
   extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/InterceptorsTest.java
   extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/PrimaryInterceptionBinding.java
Removed:
   extensions/trunk/src/test/resources/log4j.xml
Modified:
   extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
   extensions/trunk/src/test/resources/META-INF/beans.xml
Log:
WELDX-91

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/InterceptorExtension.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/InterceptorExtension.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/InterceptorExtension.java	2010-04-25 22:30:01 UTC (rev 6158)
@@ -0,0 +1,36 @@
+package org.jboss.weld.extensions.interceptor;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.Interceptor;
+import javax.enterprise.inject.spi.ProcessBean;
+
+public class InterceptorExtension implements Extension
+{
+   
+   private final Collection<Class<?>> enabledInterceptors;
+   
+   public InterceptorExtension()
+   {
+      this.enabledInterceptors = Collections.synchronizedSet(new HashSet<Class<?>>());
+   }
+
+   @SuppressWarnings("unused")
+   public void observeInterceptors(@Observes ProcessBean<?> pmb)
+   {
+      if (pmb.getBean() instanceof Interceptor<?>)
+      {
+         this.enabledInterceptors.add(pmb.getBean().getBeanClass());
+      }
+   }
+   
+   public Collection<Class<?>> getEnabledInterceptors()
+   {
+      return enabledInterceptors;
+   }
+   
+}


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/InterceptorExtension.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/Interceptors.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/Interceptors.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/Interceptors.java	2010-04-25 22:30:01 UTC (rev 6158)
@@ -0,0 +1,21 @@
+package org.jboss.weld.extensions.interceptor;
+
+import javax.inject.Inject;
+
+public class Interceptors
+{
+   
+   @Inject
+   private InterceptorExtension interceptorExtension;
+   
+   private Interceptors()
+   {
+      // TODO Auto-generated constructor stub
+   }
+   
+   public boolean isInterceptorEnabled(Class<?> clazz)
+   {
+      return interceptorExtension.getEnabledInterceptors().contains(clazz);
+   }
+
+}


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/interceptor/Interceptors.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension	2010-04-25 22:05:48 UTC (rev 6157)
+++ extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension	2010-04-25 22:30:01 UTC (rev 6158)
@@ -2,4 +2,5 @@
 org.jboss.weld.extensions.resources.servlet.ServletResourceExtension
 org.jboss.weld.extensions.beanlookup.IdentifiableBeanExtension
 org.jboss.weld.extensions.CoreExtension
-org.jboss.weld.extensions.managedproducer.ManagedProducerExtension
\ No newline at end of file
+org.jboss.weld.extensions.managedproducer.ManagedProducerExtension
+org.jboss.weld.extensions.interceptor.InterceptorExtension
\ No newline at end of file

Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/BarInterceptor.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/BarInterceptor.java	                        (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/BarInterceptor.java	2010-04-25 22:30:01 UTC (rev 6158)
@@ -0,0 +1,18 @@
+package org.jboss.weld.test.extensions.interceptor;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+ at Interceptor
+ at PrimaryInterceptionBinding
+public class BarInterceptor
+{
+
+   @AroundInvoke
+   public void aroundInvoke(InvocationContext ctx) throws Exception 
+   {
+      
+   }
+   
+}


Property changes on: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/BarInterceptor.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/Foo.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/Foo.java	                        (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/Foo.java	2010-04-25 22:30:01 UTC (rev 6158)
@@ -0,0 +1,6 @@
+package org.jboss.weld.test.extensions.interceptor;
+
+public class Foo
+{
+
+}


Property changes on: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/Foo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/FooInterceptor.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/FooInterceptor.java	                        (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/FooInterceptor.java	2010-04-25 22:30:01 UTC (rev 6158)
@@ -0,0 +1,18 @@
+package org.jboss.weld.test.extensions.interceptor;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+ at Interceptor
+ at PrimaryInterceptionBinding
+public class FooInterceptor
+{
+
+   @AroundInvoke
+   public void aroundInvoke(InvocationContext ctx) throws Exception 
+   {
+      
+   }
+   
+}


Property changes on: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/FooInterceptor.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/InterceptorsTest.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/InterceptorsTest.java	                        (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/InterceptorsTest.java	2010-04-25 22:30:01 UTC (rev 6158)
@@ -0,0 +1,23 @@
+package org.jboss.weld.test.extensions.interceptor;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.weld.extensions.interceptor.Interceptors;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+ at Artifact
+ at Classes(Interceptors.class)
+public class InterceptorsTest extends AbstractWeldTest
+{
+   
+   @Test
+   public void testInterceptorResolvable()
+   {
+      assert getReference(Interceptors.class).isInterceptorEnabled(FooInterceptor.class);
+      // Waiting on WELD-503
+    //  assert !getReference(Interceptors.class).isInterceptorEnabled(BarInterceptor.class);
+      
+   }
+
+}


Property changes on: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/InterceptorsTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/PrimaryInterceptionBinding.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/PrimaryInterceptionBinding.java	                        (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/PrimaryInterceptionBinding.java	2010-04-25 22:30:01 UTC (rev 6158)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.weld.test.extensions.interceptor;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at InterceptorBinding
+ at Documented
+ at Retention(RUNTIME)
+ at Target({METHOD, TYPE})
+public @interface PrimaryInterceptionBinding
+{
+}


Property changes on: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/interceptor/PrimaryInterceptionBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: extensions/trunk/src/test/resources/META-INF/beans.xml
===================================================================
--- extensions/trunk/src/test/resources/META-INF/beans.xml	2010-04-25 22:05:48 UTC (rev 6157)
+++ extensions/trunk/src/test/resources/META-INF/beans.xml	2010-04-25 22:30:01 UTC (rev 6158)
@@ -1,5 +1,8 @@
-<beans xmlns="http://java.sun.com/xml/ns/javaee"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
 
+   <interceptors>
+      <class>org.jboss.weld.test.extensions.interceptor.FooInterceptor</class>
+   </interceptors>
+
 </beans>

Deleted: extensions/trunk/src/test/resources/log4j.xml
===================================================================
--- extensions/trunk/src/test/resources/log4j.xml	2010-04-25 22:05:48 UTC (rev 6157)
+++ extensions/trunk/src/test/resources/log4j.xml	2010-04-25 22:30:01 UTC (rev 6158)
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
-
-    <appender name="CONSOLE" class="org.jboss.weld.test.log.TestAppender">
-        <layout class="org.apache.log4j.PatternLayout">
-            <!-- The default pattern: Date Priority [Category] Message\n -->
-            <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{2}] %m%n"/>
-        </layout>
-    </appender>
-
-    <category name="org.jboss.webbeans.test">
-        <priority value="INFO"/>
-    </category>
-
-    <root>
-        <priority value="INFO"/>
-        <appender-ref ref="CONSOLE"/>
-    </root>
-
-</log4j:configuration>



More information about the weld-commits mailing list