You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/03/12 22:58:51 UTC
svn commit: r517418 - in /myfaces/core/branches/jsf12/impl: ./
src/main/java/org/apache/ src/main/java/org/apache/myfaces/
src/main/java/org/apache/myfaces/config/
src/main/java/org/apache/myfaces/config/annotation/
src/main/java/org/apache/myfaces/web...
Author: bommel
Date: Mon Mar 12 14:58:50 2007
New Revision: 517418
URL: http://svn.apache.org/viewvc?view=rev&rev=517418
Log:
(MYFACES-1246)
Move AnnotationProcessor to myfaces package
AnnotationProcessorFactory now discovered by common discovery
Added:
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/AnnotationProcessor.java
- copied, changed from r515266, myfaces/core/branches/jsf12/impl/src/main/java/org/apache/AnnotationProcessor.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProcessorFactory.java
Removed:
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/AnnotationProcessor.java
Modified:
myfaces/core/branches/jsf12/impl/pom.xml
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/DiscoverableAnnotationProcessor.java
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/AllAnnotationProcessor.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationProcessorFactory.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationProcessor.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NopAnnotationProcessor.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/ResourceAnnotationProcessor.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/OwnAnnotationProcessorTestCase.java
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestAnnotationProcessor.java
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestDiscoverableAnnotationProcessor.java
Modified: myfaces/core/branches/jsf12/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/pom.xml?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/pom.xml (original)
+++ myfaces/core/branches/jsf12/impl/pom.xml Mon Mar 12 14:58:50 2007
@@ -314,7 +314,12 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>6.0.10</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
@@ -391,4 +396,10 @@
<url>http://people.apache.org/~baranda/repo</url>
</pluginRepository>
</pluginRepositories>
+ <repositories>
+ <repository>
+ <id>tomcat</id>
+ <url>http://tomcat.apache.org/dev/dist/m2-repository</url>
+ </repository>
+ </repositories>
</project>
Copied: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/AnnotationProcessor.java (from r515266, myfaces/core/branches/jsf12/impl/src/main/java/org/apache/AnnotationProcessor.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/AnnotationProcessor.java?view=diff&rev=517418&p1=myfaces/core/branches/jsf12/impl/src/main/java/org/apache/AnnotationProcessor.java&r1=515266&p2=myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/AnnotationProcessor.java&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/AnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/AnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -1,4 +1,4 @@
-package org.apache;
+package org.apache.myfaces;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +25,8 @@
*/
public interface AnnotationProcessor {
+ public Object newInstance(String className)
+ throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException;
public void postConstruct(Object instance)
throws IllegalAccessException, InvocationTargetException;
public void preDestroy(Object instance)
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/DiscoverableAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/DiscoverableAnnotationProcessor.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/DiscoverableAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/DiscoverableAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -18,7 +18,7 @@
*/
-import org.apache.AnnotationProcessor;
+import org.apache.myfaces.AnnotationProcessor;
public interface DiscoverableAnnotationProcessor extends AnnotationProcessor
{
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=517418&r1=517417&r2=517418
==============================================================================
--- 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 Mon Mar 12 14:58:50 2007
@@ -46,6 +46,7 @@
import org.apache.myfaces.config.element.MapEntries;
import org.apache.myfaces.config.element.MapEntry;
import org.apache.myfaces.shared_impl.util.ClassUtils;
+import org.apache.myfaces.AnnotationProcessor;
/**
@@ -65,22 +66,77 @@
public Object buildManagedBean(FacesContext facesContext, ManagedBean beanConfiguration) throws FacesException
{
- final Object bean = ClassUtils.newInstance(beanConfiguration.getManagedBeanClassName());
/*final AnnotatedManagedBeanHandler handler = new AnnotatedManagedBeanHandler(bean,
- beanConfiguration.getManagedBeanScope(), beanConfiguration.getManagedBeanName());
-
- final boolean threwUnchecked = handler.invokePostConstruct();
+ beanConfiguration.getManagedBeanScope(), beanConfiguration.getManagedBeanName());
- if(threwUnchecked)
- return null;*/
+ final boolean threwUnchecked = handler.invokePostConstruct();
+
+ if(threwUnchecked)
+ return null;*/
try
{
- AnnotationProcessorFactory.getAnnotatonProcessor(facesContext.getExternalContext()).processAnnotations(bean);
+ AnnotationProcessor annotationProcessor =
+ AnnotationProcessorFactory.getAnnotatonProcessorFactory().getAnnotatonProcessor(facesContext.getExternalContext());
+ final Object bean = annotationProcessor.newInstance(beanConfiguration.getManagedBeanClassName());
+
+ annotationProcessor.processAnnotations(bean);
+
if (!beanConfiguration.getManagedBeanScope().equals(ManagedBeanBuilder.NONE))
{
- AnnotationProcessorFactory.getAnnotatonProcessor(facesContext.getExternalContext()).postConstruct(bean);
+ annotationProcessor.postConstruct(bean);
}
+
+ switch (beanConfiguration.getInitMode())
+ {
+ case ManagedBean.INIT_MODE_PROPERTIES:
+ try
+ {
+ initializeProperties(facesContext, beanConfiguration.getManagedProperties(),
+ beanConfiguration.getManagedBeanScope(), bean);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new IllegalArgumentException(
+ e.getMessage()
+ + " for bean '"
+ + beanConfiguration.getManagedBeanName()
+ + "' check the configuration to make sure all properties correspond with get/set methods", e);
+ }
+ break;
+
+ case ManagedBean.INIT_MODE_MAP:
+ if (!(bean instanceof Map))
+ {
+ throw new IllegalArgumentException("Class " + bean.getClass().getName()
+ + " of managed bean "
+ + beanConfiguration.getManagedBeanName()
+ + " is not a Map.");
+ }
+ initializeMap(facesContext, beanConfiguration.getMapEntries(), (Map) bean);
+ break;
+
+ case ManagedBean.INIT_MODE_LIST:
+ if (!(bean instanceof List))
+ {
+ throw new IllegalArgumentException("Class " + bean.getClass().getName()
+ + " of managed bean "
+ + beanConfiguration.getManagedBeanName()
+ + " is not a List.");
+ }
+ initializeList(facesContext, beanConfiguration.getListEntries(), (List) bean);
+ break;
+
+ case ManagedBean.INIT_MODE_NO_INIT:
+ // no init values
+ break;
+
+ default:
+ throw new IllegalStateException("Unknown managed bean type "
+ + bean.getClass().getName() + " for managed bean "
+ + beanConfiguration.getManagedBeanName() + '.');
+ }
+ return bean;
}
catch (IllegalAccessException e)
{
@@ -93,55 +149,16 @@
catch (NamingException e)
{
throw new FacesException(e);
- }
-
- switch (beanConfiguration.getInitMode())
+ }
+ catch (ClassNotFoundException e)
{
- case ManagedBean.INIT_MODE_PROPERTIES:
- try {
- initializeProperties(facesContext, beanConfiguration.getManagedProperties(),
- beanConfiguration.getManagedBeanScope(), bean);
- } catch (IllegalArgumentException e) {
- throw new IllegalArgumentException(
- e.getMessage()
- + " for bean '"
- + beanConfiguration.getManagedBeanName()
- + "' check the configuration to make sure all properties correspond with get/set methods", e);
- }
- break;
-
- case ManagedBean.INIT_MODE_MAP:
- if (!(bean instanceof Map))
- {
- throw new IllegalArgumentException("Class " + bean.getClass().getName()
- + " of managed bean "
- + beanConfiguration.getManagedBeanName()
- + " is not a Map.");
- }
- initializeMap(facesContext, beanConfiguration.getMapEntries(), (Map) bean);
- break;
-
- case ManagedBean.INIT_MODE_LIST:
- if (!(bean instanceof List))
- {
- throw new IllegalArgumentException("Class " + bean.getClass().getName()
- + " of managed bean "
- + beanConfiguration.getManagedBeanName()
- + " is not a List.");
- }
- initializeList(facesContext, beanConfiguration.getListEntries(), (List) bean);
- break;
-
- case ManagedBean.INIT_MODE_NO_INIT:
- // no init values
- break;
-
- default:
- throw new IllegalStateException("Unknown managed bean type "
- + bean.getClass().getName() + " for managed bean "
- + beanConfiguration.getManagedBeanName() + '.');
+ throw new FacesException(e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new FacesException(e);
}
- return bean;
+
}
@@ -149,7 +166,7 @@
{
ELResolver elResolver = facesContext.getApplication().getELResolver();
ELContext elContext = facesContext.getELContext();
-
+
while (managedProperties.hasNext())
{
ManagedProperty property = (ManagedProperty) managedProperties.next();
@@ -158,48 +175,56 @@
switch (property.getType())
{
case ManagedProperty.TYPE_LIST:
-
- // JSF 1.1, 5.3.1.3
- // Call the property getter, if it exists.
- // If the getter returns null or doesn't exist, create a java.util.ArrayList,
- // otherwise use the returned Object ...
- if(PropertyUtils.isReadable(bean, property.getPropertyName()))
- value = elResolver.getValue(elContext, bean, property.getPropertyName());
- value = value == null ? new ArrayList() : value;
-
- if (value instanceof List) {
+
+ // JSF 1.1, 5.3.1.3
+ // Call the property getter, if it exists.
+ // If the getter returns null or doesn't exist, create a java.util.ArrayList,
+ // otherwise use the returned Object ...
+ if (PropertyUtils.isReadable(bean, property.getPropertyName()))
+ value = elResolver.getValue(elContext, bean, property.getPropertyName());
+ value = value == null ? new ArrayList() : value;
+
+ if (value instanceof List)
+ {
initializeList(facesContext, property.getListEntries(), (List) value);
- } else if (value != null && value.getClass().isArray()) {
+ }
+ else if (value != null && value.getClass().isArray())
+ {
int length = Array.getLength(value);
ArrayList temp = new ArrayList(length);
- for (int i = 0; i < length; i++) {
+ for (int i = 0; i < length; i++)
+ {
temp.add(Array.get(value, i));
}
initializeList(facesContext, property.getListEntries(), temp);
value = Array.newInstance(value.getClass().getComponentType(), temp.size());
length = temp.size();
- for (int i = 0; i < length; i++) {
+ for (int i = 0; i < length; i++)
+ {
Array.set(value, i, temp.get(i));
}
- } else {
- value = new ArrayList();
+ }
+ else
+ {
+ value = new ArrayList();
initializeList(facesContext, property.getListEntries(), (List) value);
}
break;
case ManagedProperty.TYPE_MAP:
- // JSF 1.1, 5.3.1.3
- // Call the property getter, if it exists.
- // If the getter returns null or doesn't exist, create a java.util.HashMap,
- // otherwise use the returned java.util.Map .
- if(PropertyUtils.isReadable(bean, property.getPropertyName()))
- value = elResolver.getValue(elContext, bean, property.getPropertyName());
- value = value == null ? new HashMap() : value;
-
- if (! (value instanceof Map)) {
+ // JSF 1.1, 5.3.1.3
+ // Call the property getter, if it exists.
+ // If the getter returns null or doesn't exist, create a java.util.HashMap,
+ // otherwise use the returned java.util.Map .
+ if (PropertyUtils.isReadable(bean, property.getPropertyName()))
+ value = elResolver.getValue(elContext, bean, property.getPropertyName());
+ value = value == null ? new HashMap() : value;
+
+ if (!(value instanceof Map))
+ {
value = new HashMap();
}
@@ -210,9 +235,10 @@
break;
case ManagedProperty.TYPE_VALUE:
// check for correct scope of a referenced bean
- if (! isInValidScope(facesContext, property, targetScope)) {
+ if (!isInValidScope(facesContext, property, targetScope))
+ {
throw new FacesException("Property " + property.getPropertyName() +
- " references object in a scope with shorter lifetime than the target scope " + targetScope);
+ " references object in a scope with shorter lifetime than the target scope " + targetScope);
}
value = property.getRuntimeValue(facesContext);
break;
@@ -222,22 +248,23 @@
if (property.getPropertyClass() == null)
{
propertyClass = elResolver
- .getType(elContext, bean, property.getPropertyName());
+ .getType(elContext, bean, property.getPropertyName());
}
else
{
propertyClass = ClassUtils
- .simpleJavaTypeToClass(property.getPropertyClass());
+ .simpleJavaTypeToClass(property.getPropertyClass());
}
- if(null == propertyClass) {
- throw new IllegalArgumentException("unable to find the type of property " + property.getPropertyName());
+ if (null == propertyClass)
+ {
+ throw new IllegalArgumentException("unable to find the type of property " + property.getPropertyName());
}
Object coercedValue = coerceToType(facesContext, value, propertyClass);
elResolver.setValue(
- elContext, bean, property.getPropertyName(), coercedValue);
+ elContext, bean, property.getPropertyName(), coercedValue);
}
}
-
+
// We no longer use the convertToType from shared impl because we switched
// to unified EL in JSF 1.2
public static Object coerceToType(FacesContext facesContext, Object value, Class desiredClass)
@@ -254,7 +281,7 @@
catch (ELException e)
{
String message = "Cannot coerce " + value.getClass().getName()
- + " to " + desiredClass.getName();
+ + " to " + desiredClass.getName();
log.error(message, e);
throw new FacesException(message, e);
}
@@ -263,39 +290,48 @@
/**
* Check if the scope of the property value is valid for a bean to be stored in targetScope.
+ *
* @param facesContext
- * @param property the property to be checked
- * @param targetScope name of the target scope of the bean under construction
+ * @param property the property to be checked
+ * @param targetScope name of the target scope of the bean under construction
*/
private boolean isInValidScope(FacesContext facesContext, ManagedProperty property, String targetScope)
{
- if (! property.isValueReference()) {
+ if (!property.isValueReference())
+ {
// no value reference but a literal value -> nothing to check
return true;
}
String[] expressions = extractExpressions(property.getValueBinding(facesContext).getExpressionString());
- for (int i = 0; i < expressions.length; i++) {
+ for (int i = 0; i < expressions.length; i++)
+ {
String expression = expressions[i];
- if (expression == null) {
+ if (expression == null)
+ {
continue;
}
String valueScope = getScope(facesContext, expression);
// if the target scope is 'none' value scope has to be 'none', too
- if (targetScope == null || targetScope.equalsIgnoreCase(NONE)) {
- if (valueScope != null && !(valueScope.equalsIgnoreCase(NONE))) {
+ if (targetScope == null || targetScope.equalsIgnoreCase(NONE))
+ {
+ if (valueScope != null && !(valueScope.equalsIgnoreCase(NONE)))
+ {
return false;
}
return true;
}
// 'application' scope can reference 'application' and 'none'
- if (targetScope.equalsIgnoreCase(APPLICATION)) {
- if (valueScope != null) {
+ if (targetScope.equalsIgnoreCase(APPLICATION))
+ {
+ if (valueScope != null)
+ {
if (valueScope.equalsIgnoreCase(REQUEST) ||
- valueScope.equalsIgnoreCase(SESSION)) {
+ valueScope.equalsIgnoreCase(SESSION))
+ {
return false;
}
}
@@ -303,9 +339,12 @@
}
// 'session' scope can reference 'session', 'application', and 'none' but not 'request'
- if (targetScope.equalsIgnoreCase(SESSION)) {
- if (valueScope != null) {
- if (valueScope.equalsIgnoreCase(REQUEST)) {
+ if (targetScope.equalsIgnoreCase(SESSION))
+ {
+ if (valueScope != null)
+ {
+ if (valueScope.equalsIgnoreCase(REQUEST))
+ {
return false;
}
}
@@ -313,7 +352,8 @@
}
// 'request' scope can reference any value scope
- if (targetScope.equalsIgnoreCase(REQUEST)) {
+ if (targetScope.equalsIgnoreCase(REQUEST))
+ {
return true;
}
}
@@ -325,54 +365,68 @@
{
String beanName = getFirstSegment(expression);
ExternalContext externalContext = facesContext.getExternalContext();
-
- // check scope objects
- if (beanName.equalsIgnoreCase("requestScope")) {
+
+ // check scope objects
+ if (beanName.equalsIgnoreCase("requestScope"))
+ {
return REQUEST;
}
- if (beanName.equalsIgnoreCase("sessionScope")) {
+ if (beanName.equalsIgnoreCase("sessionScope"))
+ {
return SESSION;
}
- if (beanName.equalsIgnoreCase("applicationScope")) {
+ if (beanName.equalsIgnoreCase("applicationScope"))
+ {
return APPLICATION;
}
- // check implicit objects
- if (beanName.equalsIgnoreCase("cookie")) {
- return REQUEST;
+ // check implicit objects
+ if (beanName.equalsIgnoreCase("cookie"))
+ {
+ return REQUEST;
}
- if (beanName.equalsIgnoreCase("facesContext")) {
+ if (beanName.equalsIgnoreCase("facesContext"))
+ {
return REQUEST;
}
- if (beanName.equalsIgnoreCase("header")) {
+ if (beanName.equalsIgnoreCase("header"))
+ {
return REQUEST;
}
- if (beanName.equalsIgnoreCase("headerValues")) {
+ if (beanName.equalsIgnoreCase("headerValues"))
+ {
return REQUEST;
}
- if (beanName.equalsIgnoreCase("initParam")) {
- return APPLICATION;
+ if (beanName.equalsIgnoreCase("initParam"))
+ {
+ return APPLICATION;
}
- if (beanName.equalsIgnoreCase("param")) {
+ if (beanName.equalsIgnoreCase("param"))
+ {
return REQUEST;
}
- if (beanName.equalsIgnoreCase("paramValues")) {
+ if (beanName.equalsIgnoreCase("paramValues"))
+ {
return REQUEST;
}
- if (beanName.equalsIgnoreCase("view")) {
+ if (beanName.equalsIgnoreCase("view"))
+ {
return REQUEST;
}
// not found so far - check all scopes
- if (externalContext.getRequestMap().get(beanName) != null) {
+ if (externalContext.getRequestMap().get(beanName) != null)
+ {
return REQUEST;
}
- if (externalContext.getSessionMap().get(beanName) != null) {
+ if (externalContext.getSessionMap().get(beanName) != null)
+ {
return SESSION;
}
- if (externalContext.getApplicationMap().get(beanName) != null) {
+ if (externalContext.getApplicationMap().get(beanName) != null)
+ {
return APPLICATION;
}
@@ -380,7 +434,8 @@
ManagedBean mbc = getRuntimeConfig(facesContext).getManagedBean(beanName);
- if (mbc != null) {
+ if (mbc != null)
+ {
return mbc.getManagedBeanScope();
}
@@ -389,6 +444,7 @@
/**
* Extract the first expression segment, that is the substring up to the first '.' or '['
+ *
* @param expression
* @return first segment of the expression
*/
@@ -397,28 +453,34 @@
int indexDot = expression.indexOf('.');
int indexBracket = expression.indexOf('[');
- if (indexBracket < 0) {
-
- return indexDot < 0 ? expression : expression.substring(0, indexDot);
-
- }
-
- if (indexDot < 0) {
+ if (indexBracket < 0)
+ {
+
+ return indexDot < 0 ? expression : expression.substring(0, indexDot);
+
+ }
+
+ if (indexDot < 0)
+ {
return expression.substring(0, indexBracket);
}
-
+
return expression.substring(0, Math.min(indexDot, indexBracket));
-
+
}
private String[] extractExpressions(String expressionString)
{
String[] expressions = expressionString.split("\\#\\{");
- for (int i = 0; i < expressions.length; i++) {
+ for (int i = 0; i < expressions.length; i++)
+ {
String expression = expressions[i];
- if (expression.trim().length() == 0) {
+ if (expression.trim().length() == 0)
+ {
expressions[i] = null;
- } else {
+ }
+ else
+ {
int index = expression.indexOf('}');
expressions[i] = expression.substring(0, index);
}
@@ -431,13 +493,13 @@
{
Application application = facesContext.getApplication();
Class keyClass = (mapEntries.getKeyClass() == null)
- ? String.class : ClassUtils.simpleJavaTypeToClass(mapEntries.getKeyClass());
+ ? String.class : ClassUtils.simpleJavaTypeToClass(mapEntries.getKeyClass());
Class valueClass = (mapEntries.getValueClass() == null)
- ? String.class : ClassUtils.simpleJavaTypeToClass(mapEntries.getValueClass());
+ ? String.class : ClassUtils.simpleJavaTypeToClass(mapEntries.getValueClass());
ValueExpression valueExpression;
ExpressionFactory expFactory = application.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
-
+
for (Iterator iterator = mapEntries.getMapEntries(); iterator.hasNext();)
{
MapEntry entry = (MapEntry) iterator.next();
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AllAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AllAnnotationProcessor.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AllAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/AllAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -29,6 +29,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Field;
+// TODO @EJBs
public class AllAnnotationProcessor extends ResourceAnnotationProcessor
{
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=517418&r1=517417&r2=517418
==============================================================================
--- 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 Mon Mar 12 14:58:50 2007
@@ -17,192 +17,29 @@
* limitations under the License.
*/
-import org.apache.AnnotationProcessor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.discovery.resource.names.DiscoverServiceNames;
-import org.apache.commons.discovery.resource.ClassLoaders;
-import org.apache.commons.discovery.ResourceNameIterator;
-
-import org.apache.myfaces.shared_impl.util.ClassUtils;
-import org.apache.myfaces.DiscoverableAnnotationProcessor;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.faces.context.ExternalContext;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-
-public class AnnotationProcessorFactory
-{
- private static Log log = LogFactory.getLog(AnnotationProcessorFactory.class);
- private static AnnotationProcessor ANNOTATION_PROCESSOR_INSTANCE;
- public static final String ANNOTATION_PROCESSOR_PROVIDER = "org.apache.myfaces.AnnotationProcessor";
+import org.apache.commons.discovery.tools.DiscoverSingleton;
+import org.apache.myfaces.AnnotationProcessor;
- public static AnnotationProcessor getAnnotatonProcessor(ExternalContext externalContext)
- {
- if (ANNOTATION_PROCESSOR_INSTANCE == null)
- {
- if (externalContext == null)
- {
- log.info("No ExternalContext using fallback annotation processor.");
- resolveFallbackAnnotationProcessor();
- }
- else
- {
- if (!resolveAnnotationProcessorFromExternalContext(externalContext))
- {
- if (!resolveAnnotationProcessorFromService(externalContext))
- {
- resolveFallbackAnnotationProcessor();
- }
- }
- }
- log.info("Using AnnotationProcessor "+ ANNOTATION_PROCESSOR_INSTANCE.getClass().getName());
- }
- return ANNOTATION_PROCESSOR_INSTANCE;
- }
-
- public static void release() {
- ANNOTATION_PROCESSOR_INSTANCE = null;
- }
+import javax.faces.context.ExternalContext;
+public abstract class AnnotationProcessorFactory
+{
+ protected static final String FACTORY_DEFAULT = DefaultAnnotationProcessorFactory.class.getName();
- private static boolean resolveAnnotationProcessorFromExternalContext(ExternalContext externalContext)
+ protected AnnotationProcessorFactory()
{
- try
- {
- String annotationProcessorClassName = externalContext.getInitParameter(ANNOTATION_PROCESSOR_PROVIDER);
- if (annotationProcessorClassName != null)
- {
-
- Object obj = createClass(annotationProcessorClassName, externalContext);
-
- if (obj instanceof AnnotationProcessor) {
- ANNOTATION_PROCESSOR_INSTANCE = (AnnotationProcessor) obj;
- return true;
- }
- }
- }
- catch (ClassNotFoundException e)
- {
- log.error("", e);
- }
- catch (InstantiationException e)
- {
- log.error("", e);
- }
- catch (IllegalAccessException e)
- {
- log.error("", e);
- }
- catch (InvocationTargetException e)
- {
- log.error("", e);
- }
- return false;
}
- private static boolean resolveAnnotationProcessorFromService(ExternalContext externalContext) {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- ClassLoaders loaders = new ClassLoaders();
- loaders.put(classLoader);
- DiscoverServiceNames dsn = new DiscoverServiceNames(loaders);
- ResourceNameIterator iter = dsn.findResourceNames(ANNOTATION_PROCESSOR_PROVIDER);
- while (iter.hasNext()) {
- String className = iter.nextResourceName();
- try
- {
- Object obj = createClass(className, externalContext);
- if (DiscoverableAnnotationProcessor.class.isAssignableFrom(obj.getClass())) {
- DiscoverableAnnotationProcessor discoverableAnnotationProcessor =
- (DiscoverableAnnotationProcessor) obj;
- if (discoverableAnnotationProcessor.isAvailable()) {
- ANNOTATION_PROCESSOR_INSTANCE = discoverableAnnotationProcessor;
- return true;
- }
- }
- }
- catch (ClassNotFoundException e)
- {
- log.error("", e);
- }
- catch (NoClassDefFoundError e)
- {
- log.error("", e);
- }
- catch (InstantiationException e)
- {
- log.error("", e);
- }
- catch (IllegalAccessException e)
- {
- log.error("", e);
- }
- catch (InvocationTargetException e)
- {
- log.error("", e);
- }
- }
- return false;
- }
-
- private static Object createClass(String className, ExternalContext externalContext)
- throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException
+ public static AnnotationProcessorFactory getAnnotatonProcessorFactory()
{
- Class clazz = ClassUtils.classForName(className);
-
- Object obj;
- try
- {
- Constructor constructor = clazz.getConstructor(ExternalContext.class);
- obj = constructor.newInstance(externalContext);
- } catch (NoSuchMethodException e) {
- obj = clazz.newInstance();
- }
- return obj;
+ return (AnnotationProcessorFactory) DiscoverSingleton.find(AnnotationProcessorFactory.class, FACTORY_DEFAULT);
}
+ public abstract AnnotationProcessor getAnnotatonProcessor(ExternalContext externalContext);
- private static void resolveFallbackAnnotationProcessor()
- {
- try
- {
- ClassUtils.classForName("javax.annotation.PreDestroy");
- }
- catch (ClassNotFoundException e)
- {
- // no annotation available don't process annotations
- ANNOTATION_PROCESSOR_INSTANCE = new NopAnnotationProcessor();
- return;
- }
- Context context;
- try
- {
- context = new InitialContext();
- try
- {
- ClassUtils.classForName("javax.ejb.EJB");
- // Asume full JEE 5 container
- ANNOTATION_PROCESSOR_INSTANCE = new AllAnnotationProcessor(context);
- }
- catch (ClassNotFoundException e)
- {
- // something else
- ANNOTATION_PROCESSOR_INSTANCE = new ResourceAnnotationProcessor(context);
- }
- }
- catch (NamingException e)
- {
- // no initial context available no injection
- ANNOTATION_PROCESSOR_INSTANCE = new NoInjectionAnnotationProcessor();
- log.error("No InitialContext found. Using NoInjectionAnnotationProcessor.", e);
+ public abstract void release();
- }
- }
}
Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProcessorFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProcessorFactory.java?view=auto&rev=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProcessorFactory.java (added)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProcessorFactory.java Mon Mar 12 14:58:50 2007
@@ -0,0 +1,217 @@
+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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.discovery.resource.ClassLoaders;
+import org.apache.commons.discovery.resource.names.DiscoverServiceNames;
+import org.apache.commons.discovery.ResourceNameIterator;
+import org.apache.myfaces.AnnotationProcessor;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
+import org.apache.myfaces.DiscoverableAnnotationProcessor;
+
+import javax.faces.context.ExternalContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Constructor;
+
+/*
+ * Date: Mar 12, 2007
+ * Time: 9:53:40 PM
+ */
+public class DefaultAnnotationProcessorFactory extends AnnotationProcessorFactory
+{
+ private static Log log = LogFactory.getLog(AnnotationProcessorFactory.class);
+ private static AnnotationProcessor ANNOTATION_PROCESSOR_INSTANCE;
+ public static final String ANNOTATION_PROCESSOR_PROVIDER = "org.apache.myfaces.AnnotationProcessor";
+
+
+ public DefaultAnnotationProcessorFactory()
+ {
+ }
+
+ public AnnotationProcessor getAnnotatonProcessor(ExternalContext externalContext)
+ {
+ if (ANNOTATION_PROCESSOR_INSTANCE == null)
+ {
+ if (externalContext == null)
+ {
+ log.info("No ExternalContext using fallback annotation processor.");
+ resolveFallbackAnnotationProcessor();
+ }
+ else
+ {
+ if (!resolveAnnotationProcessorFromExternalContext(externalContext))
+ {
+ if (!resolveAnnotationProcessorFromService(externalContext))
+ {
+ resolveFallbackAnnotationProcessor();
+ }
+ }
+ }
+ log.info("Using AnnotationProcessor "+ ANNOTATION_PROCESSOR_INSTANCE.getClass().getName());
+ }
+ return ANNOTATION_PROCESSOR_INSTANCE;
+ }
+
+ public void release() {
+ ANNOTATION_PROCESSOR_INSTANCE = null;
+ }
+
+
+
+ private boolean resolveAnnotationProcessorFromExternalContext(ExternalContext externalContext)
+ {
+ try
+ {
+ String annotationProcessorClassName = externalContext.getInitParameter(ANNOTATION_PROCESSOR_PROVIDER);
+ if (annotationProcessorClassName != null)
+ {
+
+ Object obj = createClass(annotationProcessorClassName, externalContext);
+
+ if (obj instanceof AnnotationProcessor) {
+ ANNOTATION_PROCESSOR_INSTANCE = (AnnotationProcessor) obj;
+ return true;
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("", e);
+ }
+ catch (InstantiationException e)
+ {
+ log.error("", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("", e);
+ }
+ catch (InvocationTargetException e)
+ {
+ log.error("", e);
+ }
+ return false;
+ }
+
+
+ private boolean resolveAnnotationProcessorFromService(ExternalContext externalContext) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoaders loaders = new ClassLoaders();
+ loaders.put(classLoader);
+ DiscoverServiceNames dsn = new DiscoverServiceNames(loaders);
+ ResourceNameIterator iter = dsn.findResourceNames(ANNOTATION_PROCESSOR_PROVIDER);
+ while (iter.hasNext()) {
+ String className = iter.nextResourceName();
+ try
+ {
+ Object obj = createClass(className, externalContext);
+ if (DiscoverableAnnotationProcessor.class.isAssignableFrom(obj.getClass())) {
+ DiscoverableAnnotationProcessor discoverableAnnotationProcessor =
+ (DiscoverableAnnotationProcessor) obj;
+ if (discoverableAnnotationProcessor.isAvailable()) {
+ ANNOTATION_PROCESSOR_INSTANCE = discoverableAnnotationProcessor;
+ return true;
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("", e);
+ }
+ catch (NoClassDefFoundError e)
+ {
+ log.error("", e);
+ }
+ catch (InstantiationException e)
+ {
+ log.error("", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("", e);
+ }
+ catch (InvocationTargetException e)
+ {
+ log.error("", e);
+ }
+ }
+ return false;
+ }
+
+ private Object createClass(String className, ExternalContext externalContext)
+ throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException
+ {
+ Class clazz = ClassUtils.classForName(className);
+
+ Object obj;
+ try
+ {
+ Constructor constructor = clazz.getConstructor(ExternalContext.class);
+ obj = constructor.newInstance(externalContext);
+ }
+ catch (NoSuchMethodException e)
+ {
+ obj = clazz.newInstance();
+ }
+ return obj;
+ }
+
+
+ private void resolveFallbackAnnotationProcessor()
+ {
+ try
+ {
+ ClassUtils.classForName("javax.annotation.PreDestroy");
+ }
+ catch (ClassNotFoundException e)
+ {
+ // no annotation available don't process annotations
+ ANNOTATION_PROCESSOR_INSTANCE = new NopAnnotationProcessor();
+ return;
+ }
+ Context context;
+ try
+ {
+ context = new InitialContext();
+ try
+ {
+ ClassUtils.classForName("javax.ejb.EJB");
+ // Asume full JEE 5 container
+ ANNOTATION_PROCESSOR_INSTANCE = new AllAnnotationProcessor(context);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // something else
+ ANNOTATION_PROCESSOR_INSTANCE = new ResourceAnnotationProcessor(context);
+ }
+ }
+ catch (NamingException e)
+ {
+ // no initial context available no injection
+ ANNOTATION_PROCESSOR_INSTANCE = new NoInjectionAnnotationProcessor();
+ log.error("No InitialContext found. Using NoInjectionAnnotationProcessor.", e);
+
+ }
+ }
+}
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationProcessor.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -17,7 +17,8 @@
* limitations under the License.
*/
-import org.apache.AnnotationProcessor;
+import org.apache.myfaces.AnnotationProcessor;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@@ -32,8 +33,15 @@
*/
-public class NoInjectionAnnotationProcessor implements AnnotationProcessor
-{
+public class NoInjectionAnnotationProcessor implements AnnotationProcessor {
+
+
+ public Object newInstance(String className)
+ throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException
+ {
+ Class clazz = ClassUtils.classForName(className);
+ return clazz.newInstance();
+ }
/**
* Call postConstruct method on the specified instance.
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NopAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NopAnnotationProcessor.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NopAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/NopAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -17,7 +17,8 @@
* limitations under the License.
*/
-import org.apache.AnnotationProcessor;
+import org.apache.myfaces.AnnotationProcessor;
+import org.apache.myfaces.shared_impl.util.ClassUtils;
import javax.naming.NamingException;
import java.lang.reflect.InvocationTargetException;
@@ -25,6 +26,12 @@
public class NopAnnotationProcessor implements AnnotationProcessor
{
+
+ public Object newInstance(String className) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException
+ {
+ Class clazz = ClassUtils.classForName(className);
+ return clazz.newInstance();
+ }
public void postConstruct(Object instance)
throws IllegalAccessException, InvocationTargetException
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/ResourceAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/ResourceAnnotationProcessor.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/ResourceAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/ResourceAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -24,6 +24,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Field;
+// TODO @Resources
public class ResourceAnnotationProcessor extends NoInjectionAnnotationProcessor
{
@@ -53,6 +54,9 @@
/* TODO the servlet spec is not clear about searching in superclass??
* May be only check non private fields and methods
+ * for @Resource (JSR 250), if used all superclasses MUST be examined
+ * to discover all uses of this annotation.
+
Class superclass = instance.getClass().getSuperclass();
while (superclass != null && (!superclass.equals(Object.class)))
{
Modified: 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=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -19,7 +19,6 @@
import org.apache.myfaces.DiscoverableAnnotationProcessor;
-import org.apache.AnnotationProcessor;
import org.apache.myfaces.shared_impl.util.ClassUtils;
import javax.naming.NamingException;
@@ -36,6 +35,13 @@
this.externalContext = externalContext;
}
+
+ public Object newInstance(String className)
+ throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
+ Class clazz = ClassUtils.classForName(className);
+ return clazz.newInstance();
+ }
+
public boolean isAvailable()
{
try
@@ -62,9 +68,10 @@
getAnnotationPrcessor().processAnnotations(instance);
}
- private AnnotationProcessor getAnnotationPrcessor()
+ private org.apache.AnnotationProcessor getAnnotationPrcessor()
{
- return (AnnotationProcessor) ((ServletContext) externalContext.getContext()).getAttribute(AnnotationProcessor.class.getName());
+ return (org.apache.AnnotationProcessor)
+ ((ServletContext) externalContext.getContext()).getAttribute(org.apache.AnnotationProcessor.class.getName());
}
}
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/webapp/AbstractMyFacesListener.java Mon Mar 12 14:58:50 2007
@@ -57,7 +57,7 @@
try
{
- AnnotationProcessorFactory.getAnnotatonProcessor(null).preDestroy(value);
+ AnnotationProcessorFactory.getAnnotatonProcessorFactory().getAnnotatonProcessor(null).preDestroy(value);
} catch (IllegalAccessException e)
{
log.error("", e);
Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java (original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/AnnotationProcessorTestCase.java Mon Mar 12 14:58:50 2007
@@ -18,7 +18,7 @@
*/
import org.apache.shale.test.base.AbstractJsfTestCase;
-import org.apache.AnnotationProcessor;
+import org.apache.myfaces.AnnotationProcessor;
import java.lang.reflect.InvocationTargetException;
@@ -36,7 +36,7 @@
public void setUp() throws Exception {
super.setUp();
- processor = AnnotationProcessorFactory.getAnnotatonProcessor(externalContext);
+ processor = AnnotationProcessorFactory.getAnnotatonProcessorFactory().getAnnotatonProcessor(externalContext);
managedBean = new AnnotatedManagedBean();
}
Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/OwnAnnotationProcessorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/OwnAnnotationProcessorTestCase.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/OwnAnnotationProcessorTestCase.java (original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/OwnAnnotationProcessorTestCase.java Mon Mar 12 14:58:50 2007
@@ -18,7 +18,7 @@
*/
import org.apache.shale.test.base.AbstractJsfTestCase;
-import org.apache.AnnotationProcessor;
+import org.apache.myfaces.AnnotationProcessor;
public class OwnAnnotationProcessorTestCase extends AbstractJsfTestCase
@@ -35,9 +35,9 @@
public void setUp() throws Exception {
super.setUp();
- AnnotationProcessorFactory.release();
- servletContext.addInitParameter(AnnotationProcessorFactory.ANNOTATION_PROCESSOR_PROVIDER, TEST_ANNOTATION_PROCESSOR);
- processor = AnnotationProcessorFactory.getAnnotatonProcessor(externalContext);
+ AnnotationProcessorFactory.getAnnotatonProcessorFactory().release();
+ servletContext.addInitParameter(DefaultAnnotationProcessorFactory.ANNOTATION_PROCESSOR_PROVIDER, TEST_ANNOTATION_PROCESSOR);
+ processor = AnnotationProcessorFactory.getAnnotatonProcessorFactory().getAnnotatonProcessor(externalContext);
managedBean = new AnnotatedManagedBean();
}
Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestAnnotationProcessor.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -17,7 +17,7 @@
* limitations under the License.
*/
-import org.apache.AnnotationProcessor;
+import org.apache.myfaces.AnnotationProcessor;
import javax.naming.NamingException;
import java.lang.reflect.InvocationTargetException;
@@ -26,6 +26,12 @@
public class TestAnnotationProcessor implements AnnotationProcessor
{
private AnnotationProcessor processor = new NoInjectionAnnotationProcessor();
+
+
+ public Object newInstance(String className) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException
+ {
+ return processor.newInstance(className);
+ }
public void postConstruct(Object instance) throws IllegalAccessException, InvocationTargetException
{
Modified: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestDiscoverableAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestDiscoverableAnnotationProcessor.java?view=diff&rev=517418&r1=517417&r2=517418
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestDiscoverableAnnotationProcessor.java (original)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/config/annotation/TestDiscoverableAnnotationProcessor.java Mon Mar 12 14:58:50 2007
@@ -18,7 +18,7 @@
*/
import org.apache.myfaces.DiscoverableAnnotationProcessor;
-import org.apache.AnnotationProcessor;
+import org.apache.myfaces.AnnotationProcessor;
import javax.naming.NamingException;
import java.lang.reflect.InvocationTargetException;
@@ -32,6 +32,11 @@
public boolean isAvailable()
{
return true;
+ }
+
+ public Object newInstance(String className) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException
+ {
+ return processor.newInstance(className);
}
public void postConstruct(Object instance) throws IllegalAccessException, InvocationTargetException