myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r515026 - in /myfaces: core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/ core/branches/jsf12/impl/src/main/resources/META-INF/services/ current12/t...
Date Tue, 06 Mar 2007 08:40:03 GMT
Author: bommel
Date: Tue Mar  6 00:40:02 2007
New Revision: 515026

URL: http://svn.apache.org/viewvc?view=rev&rev=515026
Log:
(MYFACES-1246)

Added a TomcatAnnotationProcessor

Testing postConstruct in test-webapp

Added:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java
    myfaces/core/branches/jsf12/impl/src/main/resources/META-INF/services/
    myfaces/core/branches/jsf12/impl/src/main/resources/META-INF/services/org.apache.myfaces.AnnotationProcessor
Modified:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationProcessorFactory.java
    myfaces/current12/test-webapp/pom.xml
    myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java?view=diff&rev=515026&r1=515025&r2=515026
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/ManagedBeanBuilder.java
Tue Mar  6 00:40:02 2007
@@ -39,7 +39,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.config.annotation.AnnotationProcessorFactory;
-import org.apache.myfaces.config.annotation.AnnotatedManagedBeanHandler;
 import org.apache.myfaces.config.element.ListEntries;
 import org.apache.myfaces.config.element.ListEntry;
 import org.apache.myfaces.config.element.ManagedBean;
@@ -68,14 +67,14 @@
     {
         final Object bean = ClassUtils.newInstance(beanConfiguration.getManagedBeanClassName());
 
-        final AnnotatedManagedBeanHandler handler = new AnnotatedManagedBeanHandler(bean,
+        /*final AnnotatedManagedBeanHandler handler = new AnnotatedManagedBeanHandler(bean,
         		beanConfiguration.getManagedBeanScope(), beanConfiguration.getManagedBeanName());
         
         final boolean threwUnchecked = handler.invokePostConstruct();
 
         if(threwUnchecked)
-        	return null;
-        /*try
+        	return null;*/
+        try
         {
             AnnotationProcessorFactory.getAnnotatonProcessor(facesContext.getExternalContext()).processAnnotations(bean);
             if (!beanConfiguration.getManagedBeanScope().equals(ManagedBeanBuilder.NONE))
@@ -94,7 +93,7 @@
         catch (NamingException e)
         {
             throw new FacesException(e);
-        } */
+        } 
 
         switch (beanConfiguration.getInitMode())
         {

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationProcessorFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationProcessorFactory.java?view=diff&rev=515026&r1=515025&r2=515026
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationProcessorFactory.java
(original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationProcessorFactory.java
Tue Mar  6 00:40:02 2007
@@ -61,6 +61,7 @@
                     }
                 }
             }
+            log.info("Using AnnotationProcessor "+ ANNOTATION_PROCESSOR_INSTANCE.getClass().getName());
         }
         return ANNOTATION_PROCESSOR_INSTANCE;
     }

Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java?view=auto&rev=515026
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java
Tue Mar  6 00:40:02 2007
@@ -0,0 +1,70 @@
+package org.apache.myfaces.config.annotation;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+
+import org.apache.myfaces.DiscoverableAnnotationProcessor;
+import org.apache.AnnotationProcessor;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+
+import javax.naming.NamingException;
+import javax.faces.context.ExternalContext;
+import javax.servlet.ServletContext;
+import java.lang.reflect.InvocationTargetException;
+
+public class TomcatAnnotationProcessor implements DiscoverableAnnotationProcessor
+{
+    private ExternalContext externalContext;
+
+    public TomcatAnnotationProcessor(ExternalContext externalContext)
+    {
+        this.externalContext = externalContext;
+    }
+
+    public boolean isAvailable()
+    {
+        try
+        {
+            return ClassUtils.classForName("org.apache.catalina.util.DefaultAnnotationProcessor")
!= null;
+        } catch (Exception e) {
+            // ignore
+        }
+        return false;
+    }
+
+    public void postConstruct(Object instance) throws IllegalAccessException, InvocationTargetException
+    {
+        getAnnotationPrcessor().postConstruct(instance);
+    }
+
+    public void preDestroy(Object instance) throws IllegalAccessException, InvocationTargetException
+    {
+        getAnnotationPrcessor().preDestroy(instance);
+    }
+
+    public void processAnnotations(Object instance) throws IllegalAccessException, InvocationTargetException,
NamingException
+    {
+        getAnnotationPrcessor().processAnnotations(instance);
+    }
+
+    private AnnotationProcessor getAnnotationPrcessor()
+    {
+        return (AnnotationProcessor) ((ServletContext) externalContext.getContext()).getAttribute(AnnotationProcessor.class.getName());
+    }
+
+}

Added: myfaces/core/branches/jsf12/impl/src/main/resources/META-INF/services/org.apache.myfaces.AnnotationProcessor
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/resources/META-INF/services/org.apache.myfaces.AnnotationProcessor?view=auto&rev=515026
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/resources/META-INF/services/org.apache.myfaces.AnnotationProcessor
(added)
+++ myfaces/core/branches/jsf12/impl/src/main/resources/META-INF/services/org.apache.myfaces.AnnotationProcessor
Tue Mar  6 00:40:02 2007
@@ -0,0 +1 @@
+org.apache.myfaces.config.annotation.TomcatAnnotationProcessor
\ No newline at end of file

Modified: myfaces/current12/test-webapp/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/pom.xml?view=diff&rev=515026&r1=515025&r2=515026
==============================================================================
--- myfaces/current12/test-webapp/pom.xml (original)
+++ myfaces/current12/test-webapp/pom.xml Tue Mar  6 00:40:02 2007
@@ -14,6 +14,16 @@
     <url>http://www.myorganization.org</url>
     <build>
         <finalName>test-webapp</finalName>
+        <plugins>
+             <plugin>
+                 <groupId>org.apache.maven.plugins</groupId>
+                 <artifactId>maven-compiler-plugin</artifactId>
+                 <configuration>
+                     <source>1.5</source>
+                     <target>1.5</target>
+                 </configuration>
+             </plugin>
+        </plugins>
     </build>
     <profiles>
         <profile>
@@ -24,9 +34,9 @@
                         <groupId>org.mortbay.jetty</groupId>
                         <artifactId>maven-jetty-plugin</artifactId>
                         <version>6.1.2rc0</version>
-                        <configuration>
+                        <!--<configuration>
                             <scanIntervalSeconds>10</scanIntervalSeconds>
-                        </configuration>
+                        </configuration>-->
                     </plugin>
                 </plugins>
             </build>
@@ -105,6 +115,12 @@
             <version>1.0</version>
             <optional>true</optional>
         </dependency>-->
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-annotation_1.0_spec</artifactId>
+             <version>1.0</version> 
+        </dependency>
 
         <dependency>
             <groupId>jstl</groupId>

Modified: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java?view=diff&rev=515026&r1=515025&r2=515026
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java
(original)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java
Tue Mar  6 00:40:02 2007
@@ -18,16 +18,20 @@
 */
 package org.apache.myfaces.blank;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import javax.faces.event.ActionEvent;
+import javax.annotation.PostConstruct;
 
 /**
  * A typical simple backing bean, that is backed to <code>helloworld.jsp</code>
  * 
- * @author <a href="mailto:matzew@apache.org">Matthias Weßendorf</a> 
+ * @author <a href="mailto:matzew@apache.org">Matthias We�endorf</a> 
  */
 public class HelloWorldBacking {
 
-    
+    private static Log log = LogFactory.getLog(HelloWorldBacking.class);
     //properties
     private String name;
     private String greeting;
@@ -38,7 +42,12 @@
     public HelloWorldBacking(){
         greeting = "Hello";
     }
-    
+
+    @PostConstruct()
+    public void postConstruct() {
+        log.error("PostConstruct");
+    }
+
     //-------------------getter & setter
     public String getName() {
         return name;



Mime
View raw message