[webbeans-commits] Webbeans SVN: r724 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: ejb and 3 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Dec 24 18:55:15 EST 2008


Author: pete.muir at jboss.org
Date: 2008-12-24 18:55:15 -0500 (Wed, 24 Dec 2008)
New Revision: 724

Added:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java
Removed:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSF.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/Servlet.java
Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
Log:
WBRI-70

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2008-12-24 23:37:34 UTC (rev 723)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -24,13 +24,6 @@
 import static org.jboss.webbeans.bean.BeanFactory.createProducerFieldBean;
 import static org.jboss.webbeans.bean.BeanFactory.createProducerMethodBean;
 import static org.jboss.webbeans.bean.BeanFactory.createSimpleBean;
-import static org.jboss.webbeans.ejb.EJB.ENTERPRISE_BEAN_CLASS;
-import static org.jboss.webbeans.jsf.JSF.UICOMPONENT_CLASS;
-import static org.jboss.webbeans.servlet.Servlet.FILTER_CLASS;
-import static org.jboss.webbeans.servlet.Servlet.HTTP_SESSION_LISTENER_CLASS;
-import static org.jboss.webbeans.servlet.Servlet.SERVLET_CLASS;
-import static org.jboss.webbeans.servlet.Servlet.SERVLET_CONTEXT_LISTENER_CLASS;
-import static org.jboss.webbeans.servlet.Servlet.SERVLET_REQUEST_LISTENER_CLASS;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
@@ -59,14 +52,17 @@
 import org.jboss.webbeans.bean.SimpleBean;
 import org.jboss.webbeans.bindings.InitializedBinding;
 import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.ejb.EJBApiAbstraction;
 import org.jboss.webbeans.event.ObserverImpl;
 import org.jboss.webbeans.introspector.AnnotatedField;
 import org.jboss.webbeans.introspector.AnnotatedItem;
 import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.AnnotatedParameter;
+import org.jboss.webbeans.jsf.JSFApiAbstraction;
 import org.jboss.webbeans.log.LogProvider;
 import org.jboss.webbeans.log.Logging;
 import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.servlet.ServletApiAbstraction;
 import org.jboss.webbeans.transaction.Transaction;
 import org.jboss.webbeans.util.Reflections;
 
@@ -327,18 +323,21 @@
     * @param type The type to inspect
     * @return True if simple Web Bean, false otherwise
     */
-   protected static boolean isTypeSimpleWebBean(Class<?> type)
+   protected boolean isTypeSimpleWebBean(Class<?> type)
    {
+      EJBApiAbstraction ejbApiAbstraction = new EJBApiAbstraction(getResourceLoader());
+      JSFApiAbstraction jsfApiAbstraction = new JSFApiAbstraction(getResourceLoader());
+      ServletApiAbstraction servletApiAbstraction = new ServletApiAbstraction(getResourceLoader());
       //TODO: check 3.2.1 for more rules!!!!!!
       return !type.isAnnotation() && 
       	    !Reflections.isAbstract(type) && 
-      	    !SERVLET_CLASS.isAssignableFrom(type) && 
-      	    !FILTER_CLASS.isAssignableFrom(type) && 
-      	    !SERVLET_CONTEXT_LISTENER_CLASS.isAssignableFrom(type) && 
-      	    !HTTP_SESSION_LISTENER_CLASS.isAssignableFrom(type) && 
-      	    !SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(type) && 
-      	    !ENTERPRISE_BEAN_CLASS.isAssignableFrom(type) && 
-      	    !UICOMPONENT_CLASS.isAssignableFrom(type) &&
+      	    !servletApiAbstraction.SERVLET_CLASS.isAssignableFrom(type) && 
+      	    !servletApiAbstraction.FILTER_CLASS.isAssignableFrom(type) && 
+      	    !servletApiAbstraction.SERVLET_CONTEXT_LISTENER_CLASS.isAssignableFrom(type) && 
+      	    !servletApiAbstraction.HTTP_SESSION_LISTENER_CLASS.isAssignableFrom(type) && 
+      	    !servletApiAbstraction.SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(type) && 
+      	    !ejbApiAbstraction.ENTERPRISE_BEAN_CLASS.isAssignableFrom(type) && 
+      	    !jsfApiAbstraction.UICOMPONENT_CLASS.isAssignableFrom(type) &&
       	    hasSimpleWebBeanConstructor(type);
    }
 

Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java	2008-12-24 23:37:34 UTC (rev 723)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.ejb;
-
-import org.jboss.webbeans.util.ApiAbstraction;
-
-/**
- * Utility class for EJB classes etc. EJB metadata should NOT be inspected here
- * 
- * @author Pete Muir
- */
-public class EJB extends ApiAbstraction
-{
-   
-   public static final Class<?> ENTERPRISE_BEAN_CLASS;
-
-   /**
-    * Static initialization block
-    */
-   static
-   {
-      ENTERPRISE_BEAN_CLASS = classForName("javax.ejb.EnterpriseBean");
-   }
-
-}

Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java (from rev 723, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.ejb;
+
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.util.ApiAbstraction;
+
+/**
+ * Utility class for EJB classes etc. EJB metadata should NOT be inspected here
+ * 
+ * @author Pete Muir
+ */
+public class EJBApiAbstraction extends ApiAbstraction
+{
+   
+   public EJBApiAbstraction(ResourceLoader resourceLoader)
+   {
+      super(resourceLoader);
+      ENTERPRISE_BEAN_CLASS = classForName("javax.ejb.EnterpriseBean");
+   }
+
+   public final Class<?> ENTERPRISE_BEAN_CLASS;
+
+}


Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSF.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSF.java	2008-12-24 23:37:34 UTC (rev 723)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSF.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.jsf;
-
-import org.jboss.webbeans.util.ApiAbstraction;
-
-/**
- * Utility class for JSF related components, concepts etc.
- * 
- * @author Pete Muir
- * 
- */
-public class JSF extends ApiAbstraction
-{
-   // An UI component
-   public static final Class<?> UICOMPONENT_CLASS = classForName("javax.faces.component.UIComponent");
-
-}

Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java (from rev 723, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSF.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.jsf;
+
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.util.ApiAbstraction;
+
+/**
+ * Utility class for JSF related components, concepts etc.
+ * 
+ * @author Pete Muir
+ * 
+ */
+public class JSFApiAbstraction extends ApiAbstraction
+{
+
+
+   // An UI component
+   public final Class<?> UICOMPONENT_CLASS;
+   
+   public JSFApiAbstraction(ResourceLoader resourceLoader)
+   {
+      super(resourceLoader);
+      this.UICOMPONENT_CLASS = classForName("javax.faces.component.UIComponent");
+   }
+
+}


Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/Servlet.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/Servlet.java	2008-12-24 23:37:34 UTC (rev 723)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/Servlet.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -1,14 +0,0 @@
-package org.jboss.webbeans.servlet;
-
-import org.jboss.webbeans.util.ApiAbstraction;
-
-public class Servlet extends ApiAbstraction
-{
-   
-   public static final Class<?> SERVLET_CLASS = classForName("javax.servlet.Servlet");
-   public static final Class<?> FILTER_CLASS = classForName("javax.servlet.Filter");
-   public static final Class<?> SERVLET_CONTEXT_LISTENER_CLASS = classForName("javax.servlet.ServletContextListener");
-   public static final Class<?> HTTP_SESSION_LISTENER_CLASS = classForName("javax.servlet.http.HttpSessionListener");
-   public static final Class<?> SERVLET_REQUEST_LISTENER_CLASS = classForName("javax.servlet.ServletRequestListener");
-   
-}

Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java (from rev 723, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/Servlet.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -0,0 +1,26 @@
+package org.jboss.webbeans.servlet;
+
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.util.ApiAbstraction;
+
+public class ServletApiAbstraction extends ApiAbstraction
+{
+   
+   public final Class<?> SERVLET_CLASS;
+   public final Class<?> FILTER_CLASS;
+   public final Class<?> SERVLET_CONTEXT_LISTENER_CLASS;
+   public final Class<?> HTTP_SESSION_LISTENER_CLASS;
+   public final Class<?> SERVLET_REQUEST_LISTENER_CLASS;
+   
+   public ServletApiAbstraction(ResourceLoader resourceLoader)
+   {
+      super(resourceLoader);
+      SERVLET_CLASS = classForName("javax.servlet.Servlet");
+      FILTER_CLASS = classForName("javax.servlet.Filter");
+      SERVLET_CONTEXT_LISTENER_CLASS = classForName("javax.servlet.ServletContextListener");
+      HTTP_SESSION_LISTENER_CLASS = classForName("javax.servlet.http.HttpSessionListener");
+      SERVLET_REQUEST_LISTENER_CLASS = classForName("javax.servlet.ServletRequestListener");
+   }
+   
+   
+}


Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java	2008-12-24 23:37:34 UTC (rev 723)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -19,6 +19,9 @@
 
 import java.lang.annotation.Annotation;
 
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.resources.spi.ResourceLoadingException;
+
 /**
  * A base class for utility classes that represent annotations, classes etc
  * 
@@ -26,6 +29,8 @@
  */
 public class ApiAbstraction
 {
+   
+   private ResourceLoader resourceLoader;
 
    /**
     * "Not found" annotation
@@ -40,7 +45,14 @@
    public interface Dummy
    {
    }
+   
+   
 
+   public ApiAbstraction(ResourceLoader resourceLoader)
+   {
+      this.resourceLoader = resourceLoader;
+   }
+
    /**
     * Initializes an annotation class
     * 
@@ -49,13 +61,13 @@
     *         not found
     */
    @SuppressWarnings("unchecked")
-   protected static Class<? extends Annotation> annotationTypeForName(String name)
+   protected Class<? extends Annotation> annotationTypeForName(String name)
    {
       try
       {
-         return (Class<? extends Annotation>) Reflections.classForName(name);
+         return (Class<? extends Annotation>) resourceLoader.classForName(name);
       }
-      catch (ClassNotFoundException cnfe)
+      catch (ResourceLoadingException cnfe)
       {
          return DummyAnnotation.class;
       }
@@ -69,13 +81,13 @@
     *         found.
     */
    @SuppressWarnings("unchecked")
-   protected static Class<?> classForName(String name)
+   protected Class<?> classForName(String name)
    {
       try
       {
-         return (Class<? extends Annotation>) Reflections.classForName(name);
+         return (Class<? extends Annotation>) resourceLoader.classForName(name);
       }
-      catch (ClassNotFoundException cnfe)
+      catch (ResourceLoadingException cnfe)
       {
          return Dummy.class;
       }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java	2008-12-24 23:37:34 UTC (rev 723)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java	2008-12-24 23:55:15 UTC (rev 724)
@@ -46,39 +46,6 @@
 {
 
    /**
-    * Creates an instance from a class name
-    * 
-    * @param name The class name
-    * @return The instance
-    * @throws ClassNotFoundException If the class if not found
-    */
-   public static Class<?> classForName(String name) throws ClassNotFoundException
-   {
-      return classForName(name, Thread.currentThread().getContextClassLoader());
-   }
-   
-   /**
-    * Creates an instance from a class name
-    * 
-    * @param name The class name
-    * @return The instance
-    * @throws ClassNotFoundException If the class if not found
-    */
-   private static Class<?> classForName(String name, ClassLoader classLoader) throws ClassNotFoundException
-   {
-      try
-      {
-         return classLoader.loadClass(name);
-      }
-      catch (Exception e)
-      {
-         return Class.forName(name);
-      }
-   }
-   
-   
-
-   /**
     * Gets the property name from a getter method
     * 
     * @param method The getter method




More information about the weld-commits mailing list