You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2009/09/22 12:47:08 UTC
svn commit: r817591 -
/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/
Author: werpu
Date: Tue Sep 22 10:47:07 2009
New Revision: 817591
URL: http://svn.apache.org/viewvc?rev=817591&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-18
adding implementations for validators and renderers
Added:
myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/MapEntityAnnotationScanner.java
- copied, changed from r817590, myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java
myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SingleEntityAnnotationListener.java (with props)
Modified:
myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BaseAnnotationScanListener.java
myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java
myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java
myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java
myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java
Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BaseAnnotationScanListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BaseAnnotationScanListener.java?rev=817591&r1=817590&r2=817591&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BaseAnnotationScanListener.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BaseAnnotationScanListener.java Tue Sep 22 10:47:07 2009
@@ -51,9 +51,15 @@
protected String getAnnotatedStringParam(Map<String, Object> propMap, String key) {
AnnotationConstant propVal = (AnnotationConstant) propMap.get(key);
- String name = (String) propVal.getParameterValue();
- name = name.replaceAll("\"", "");
- return name;
+ String val = (String) propVal.getParameterValue();
+ val = val.replaceAll("\"", "");
+ return val;
+ }
+
+ protected Boolean getAnnotatedBolleanParam(Map<String, Object> propMap, String key) {
+ AnnotationConstant propVal = (AnnotationConstant) propMap.get(key);
+ Boolean val = (Boolean) propVal.getParameterValue();
+ return val;
}
Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java?rev=817591&r1=817590&r2=817591&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/BehaviorImplementationListener.java Tue Sep 22 10:47:07 2009
@@ -19,29 +19,46 @@
package org.apache.myfaces.scripting.jsf2.annotation;
-
import com.thoughtworks.qdox.model.JavaClass;
import java.util.Map;
import org.apache.myfaces.scripting.api.AnnotationScanListener;
+import javax.faces.component.FacesComponent;
+import javax.faces.component.behavior.FacesBehavior;
+
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class BehaviorImplementationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
+public class BehaviorImplementationListener extends SingleEntityAnnotationListener implements AnnotationScanListener {
+ public BehaviorImplementationListener() {
+ super();
+ _entityParamValue = "value";
+ }
+
+
public boolean supportsAnnotation(String annotation) {
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ return annotation.equals(FacesBehavior.class.getName()); //To change body of implemented methods use File | Settings | File Templates.
}
- public void registerSource(Object clazz, String annotationName, Map<String, Object> params) {
- //To change body of implemented methods use File | Settings | File Templates.
+
+ protected void addEntity(Class clazz, String val) {
+ if (log.isTraceEnabled()) {
+ log.trace("addBehavior(" + val + ","
+ + clazz.getName() + ")");
+ }
+ getApplication().addBehavior(val, clazz.getName());
}
- public void register(Class clazz, String annotationName, Map<String, Object> params) {
- throw new UnsupportedOperationException("Not yet implemented");
+ protected void addEntity(JavaClass clazz, String val) {
+ if (log.isTraceEnabled()) {
+ log.trace("addBehavior (" + val + ","
+ + clazz.getFullyQualifiedName() + ")");
+ }
+ getApplication().addBehavior(val, clazz.getFullyQualifiedName());
}
}
Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java?rev=817591&r1=817590&r2=817591&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java Tue Sep 22 10:47:07 2009
@@ -22,41 +22,40 @@
import org.apache.myfaces.scripting.api.AnnotationScanListener;
import javax.faces.component.FacesComponent;
-import java.util.Map;
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ComponentImplementationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
+public class ComponentImplementationListener extends SingleEntityAnnotationListener implements AnnotationScanListener {
+
+
+ public ComponentImplementationListener() {
+ super();
+ _entityParamValue = "value";
+ }
public boolean supportsAnnotation(String annotation) {
return annotation.equals(FacesComponent.class.getName()); //To change body of implemented methods use File | Settings | File Templates.
}
- public void registerSource(Object sourceClass, String annotationName, Map<String, Object> params) {
- JavaClass clazz = (JavaClass) sourceClass;
- //To change body of implemented methods use File | Settings | File Templates.
- }
- public void register(Class clazz, String annotationName, Map<String, Object> params) {
+ protected void addEntity(Class clazz, String val) {
if (log.isTraceEnabled()) {
- log.trace("registerClass(" + clazz.getName() + ")");
+ log.trace("addComponent(" + val + ","
+ + clazz.getName() + ")");
}
+ getApplication().addComponent(val, clazz.getName());
+ }
- FacesComponent comp = (FacesComponent) clazz
- .getAnnotation(FacesComponent.class);
-
- if (comp != null) {
- if (log.isTraceEnabled()) {
- log.trace("addComponent(" + comp.value() + ","
- + clazz.getName() + ")");
- }
-
- getApplication().addComponent(comp.value(), clazz.getName());
+ protected void addEntity(JavaClass clazz, String val) {
+ if (log.isTraceEnabled()) {
+ log.trace("addComponent(" + val + ","
+ + clazz.getFullyQualifiedName() + ")");
}
+ getApplication().addComponent(val, clazz.getFullyQualifiedName());
}
}
Copied: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/MapEntityAnnotationScanner.java (from r817590, myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/MapEntityAnnotationScanner.java?p2=myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/MapEntityAnnotationScanner.java&p1=myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java&r1=817590&r2=817591&rev=817591&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ComponentImplementationListener.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/MapEntityAnnotationScanner.java Tue Sep 22 10:47:07 2009
@@ -18,45 +18,54 @@
*/
package org.apache.myfaces.scripting.jsf2.annotation;
-import com.thoughtworks.qdox.model.JavaClass;
import org.apache.myfaces.scripting.api.AnnotationScanListener;
-import javax.faces.component.FacesComponent;
import java.util.Map;
+import com.thoughtworks.qdox.model.JavaClass;
+
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ComponentImplementationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
+public abstract class MapEntityAnnotationScanner extends BaseAnnotationScanListener implements AnnotationScanListener {
- public boolean supportsAnnotation(String annotation) {
- return annotation.equals(FacesComponent.class.getName()); //To change body of implemented methods use File | Settings | File Templates.
- }
-
public void registerSource(Object sourceClass, String annotationName, Map<String, Object> params) {
JavaClass clazz = (JavaClass) sourceClass;
- //To change body of implemented methods use File | Settings | File Templates.
+ if (hasToReregister(params, clazz)) {
+ addEntity(clazz, params);
+ }
}
public void register(Class clazz, String annotationName, Map<String, Object> params) {
- if (log.isTraceEnabled()) {
- log.trace("registerClass(" + clazz.getName() + ")");
+ if (hasToReregister(params, clazz)) {
+ addEntity(clazz, params);
}
+ }
- FacesComponent comp = (FacesComponent) clazz
- .getAnnotation(FacesComponent.class);
- if (comp != null) {
- if (log.isTraceEnabled()) {
- log.trace("addComponent(" + comp.value() + ","
- + clazz.getName() + ")");
- }
+ protected abstract void addEntity(Class clazz, Map<String, Object> params);
- getApplication().addComponent(comp.value(), clazz.getName());
- }
- }
+ protected abstract void addEntity(JavaClass clazz, Map<String, Object> params);
+
+
+ protected abstract boolean hasToReregister(Map params, Class clazz);
+
+ /**
+ * simple check we do not check for the contents of the managed property here
+ * This is somewhat a simplification does not drag down the managed property handling
+ * speed too much
+ * <p/>
+ * TODO we have to find a way to enable the checking on managed property level
+ * so that we can replace the meta data on the fly (probably by extending the interface)
+ * for first registration this is enough
+ *
+ * @param params
+ * @param clazz
+ * @return
+ */
+ protected abstract boolean hasToReregister(Map params, JavaClass clazz);
}
Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java?rev=817591&r1=817590&r2=817591&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/RendererImplementationListener.java Tue Sep 22 10:47:07 2009
@@ -24,22 +24,128 @@
import org.apache.myfaces.scripting.api.AnnotationScanListener;
+import javax.faces.render.FacesRenderer;
+
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class RendererImplementationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
+public class RendererImplementationListener extends MapEntityAnnotationScanner implements AnnotationScanListener {
+ private static final String PAR_FAMILY = "componentFamily";
+ private static final String PAR_RENDERERTYPE = "rendererType";
+ private static final String PAR_RENDERKITID = "renderKitId";
+
+ class AnnotationEntry {
+ String componentFamily;
+ String rendererType;
+ String renderKitId;
+
+ AnnotationEntry(String componentFamily, String rendererType, String renderKitId) {
+ this.componentFamily = componentFamily;
+ this.rendererType = rendererType;
+ this.renderKitId = renderKitId;
+ }
+
+ public boolean equals(Object incoming) {
+ if (!(incoming instanceof AnnotationEntry)) {
+ return false;
+ }
+ AnnotationEntry toCompare = (AnnotationEntry) incoming;
+ //handle null cases
+ if ((componentFamily == null && toCompare.getComponentFamily() != null) ||
+ (componentFamily != null && toCompare.getComponentFamily() == null) ||
+ (rendererType == null && toCompare.getRendererType() != null) ||
+ (rendererType != null && toCompare.getRendererType() == null) ||
+ (renderKitId == null && toCompare.getRenderKitId() != null) ||
+ (renderKitId != null && toCompare.getRenderKitId() == null)) {
+
+ return false;
+ } else if (componentFamily == null && toCompare.getComponentFamily() == null &&
+ rendererType == null && toCompare.getRendererType() == null &&
+ renderKitId == null && toCompare.getRenderKitId() == null) {
+ return true;
+ }
+
+ return componentFamily.equals(toCompare.getComponentFamily()) &&
+ rendererType.equals(toCompare.getComponentFamily()) &&
+ renderKitId.equals(toCompare.getRenderKitId());
+ }
+
+ public String getComponentFamily() {
+ return componentFamily;
+ }
+
+ public String getRendererType() {
+ return rendererType;
+ }
+
+ public String getRenderKitId() {
+ return rendererType;
+ }
+ }
+
+
public boolean supportsAnnotation(String annotation) {
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ return annotation.equals(FacesRenderer.class.getName());
+ }
+
+
+ @Override
+ protected void addEntity(Class clazz, Map<String, Object> params) {
+ String value = (String) params.get(PAR_FAMILY);
+ String theDefault = (String) params.get(PAR_RENDERERTYPE);
+ String renderKitId = (String) params.get(PAR_RENDERKITID);
+
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault, renderKitId);
+ _alreadyRegistered.put(clazz.getName(), entry);
+
+ //getApplication().getResourceBundle(entry.getComponentFamily(), clazz.getName()) ;
}
- public void registerSource(Object sourceClass, String annotationName, Map<String, Object> params) {
- JavaClass clazz = (JavaClass) sourceClass;
+ @Override
+ protected void addEntity(JavaClass clazz, Map<String, Object> params) {
+ String value = getAnnotatedStringParam(params, PAR_FAMILY);
+ String theDefault = getAnnotatedStringParam(params, PAR_RENDERERTYPE);
+ String renderKitId = (String) getAnnotatedStringParam(params, PAR_RENDERKITID);
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault, renderKitId);
+ _alreadyRegistered.put(clazz.getFullyQualifiedName(), entry);
+
+ //getApplication().addConverter(entry.getComponentFamily(), clazz.getFullyQualifiedName());
}
- public void register(Class clazz, String annotationName, Map<String, Object> params) {
- throw new UnsupportedOperationException("Not yet implemented");
+ @Override
+ protected boolean hasToReregister(Map params, Class clazz) {
+ String value = (String) params.get(PAR_FAMILY);
+ String theDefault = (String) params.get(PAR_RENDERERTYPE);
+ String renderKitId = (String) params.get(PAR_RENDERKITID);
+
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault, renderKitId);
+
+ AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getName());
+ if (alreadyRegistered == null) {
+ return true;
+ }
+
+ return alreadyRegistered.equals(entry);
}
+ @Override
+ protected boolean hasToReregister(Map params, JavaClass clazz) {
+ String value = getAnnotatedStringParam(params, PAR_FAMILY);
+ String theDefault = (String) getAnnotatedStringParam(params, PAR_RENDERERTYPE);
+ String renderKitId = (String) getAnnotatedStringParam(params, PAR_RENDERKITID);
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault, renderKitId);
+
+ AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getFullyQualifiedName());
+ if (alreadyRegistered == null) {
+ return true;
+ }
+
+ return alreadyRegistered.equals(entry);
+ }
}
Added: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SingleEntityAnnotationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SingleEntityAnnotationListener.java?rev=817591&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SingleEntityAnnotationListener.java (added)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SingleEntityAnnotationListener.java Tue Sep 22 10:47:07 2009
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.scripting.jsf2.annotation;
+
+import org.apache.myfaces.scripting.api.AnnotationScanListener;
+
+import java.util.Map;
+
+import com.thoughtworks.qdox.model.JavaClass;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public abstract class SingleEntityAnnotationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
+ String _entityParamValue = null;
+
+ public void registerSource(Object sourceClass, String annotationName, Map<String, Object> params) {
+ JavaClass clazz = (JavaClass) sourceClass;
+ String val = getAnnotatedStringParam(params, _entityParamValue);
+ if (hasToReregister(val, clazz)) {
+ addEntity(clazz, val);
+ }
+ }
+
+ public void register(Class clazz, String annotationName, Map<String, Object> params) {
+ String val = (String) params.get(_entityParamValue);
+ if (hasToReregister(val, clazz)) {
+ addEntity(clazz, val);
+ }
+ }
+
+
+ protected abstract void addEntity(Class clazz, String val);
+
+ protected abstract void addEntity(JavaClass clazz, String val);
+
+
+ protected boolean hasToReregister(String name, Class clazz) {
+ String componentClass = (String) _alreadyRegistered.get(name);
+ return componentClass == null || !componentClass.equals(clazz.getName());
+ }
+
+ /**
+ * simple check we do not check for the contents of the managed property here
+ * This is somewhat a simplification does not drag down the managed property handling
+ * speed too much
+ * <p/>
+ * TODO we have to find a way to enable the checking on managed property level
+ * so that we can replace the meta data on the fly (probably by extending the interface)
+ * for first registration this is enough
+ *
+ * @param name
+ * @param clazz
+ * @return
+ */
+ protected boolean hasToReregister(String name, JavaClass clazz) {
+ String componentClass = (String) _alreadyRegistered.get(name);
+ return componentClass == null || !componentClass.equals(clazz.getFullyQualifiedName());
+ }
+
+}
Propchange: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SingleEntityAnnotationListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/SingleEntityAnnotationListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java?rev=817591&r1=817590&r2=817591&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java (original)
+++ myfaces/extensions/scripting/trunk/core/myfaces2-extensions/src/main/java/org/apache/myfaces/scripting/jsf2/annotation/ValidatorImplementationListener.java Tue Sep 22 10:47:07 2009
@@ -24,23 +24,108 @@
import org.apache.myfaces.scripting.api.AnnotationScanListener;
+import javax.faces.validator.FacesValidator;
+
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ValidatorImplementationListener extends BaseAnnotationScanListener implements AnnotationScanListener {
+public class ValidatorImplementationListener extends MapEntityAnnotationScanner implements AnnotationScanListener {
+ private static final String PAR_VALUE = "value";
+ private static final String PAR_DEFAULT = "default";
+
+ class AnnotationEntry {
+ String value;
+ Boolean theDefault;
+
+ AnnotationEntry(String value, Boolean theDefault) {
+ this.value = value;
+ this.theDefault = theDefault;
+ }
+
+ public boolean equals(Object incoming) {
+ if (!(incoming instanceof AnnotationEntry)) {
+ return false;
+ }
+ AnnotationEntry toCompare = (AnnotationEntry) incoming;
+ //handle null cases
+ if ((value == null && toCompare.getValue() != null) ||
+ (value != null && toCompare.getValue() == null) ||
+ (theDefault == null && toCompare.getTheDefault() != null) ||
+ (theDefault != null && toCompare.getTheDefault() == null)) {
+ return false;
+ } else if (value == null && toCompare.getValue() == null && theDefault == null && toCompare.getTheDefault() == null) {
+ return true;
+ }
+
+ return value.equals(toCompare.getValue()) && theDefault.equals(toCompare.getValue());
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public Boolean getTheDefault() {
+ return theDefault;
+ }
+ }
+
+
public boolean supportsAnnotation(String annotation) {
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ return annotation.equals(FacesValidator.class.getName());
+ }
+
+
+ @Override
+ protected void addEntity(Class clazz, Map<String, Object> params) {
+ String value = (String) params.get(PAR_VALUE);
+ Boolean theDefault = (Boolean) params.get(PAR_DEFAULT);
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault);
+ _alreadyRegistered.put(clazz.getName(), entry);
+
+ getApplication().addConverter(entry.getValue(), clazz.getName());
}
- public void registerSource(Object sourceClass, String annotationName, Map<String, Object> params) {
- JavaClass clazz = (JavaClass) sourceClass;
- //To change body of implemented methods use File | Settings | File Templates.
+ @Override
+ protected void addEntity(JavaClass clazz, Map<String, Object> params) {
+ String value = getAnnotatedStringParam(params, PAR_VALUE);
+ Boolean theDefault = getAnnotatedBolleanParam(params, PAR_DEFAULT);
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault);
+ _alreadyRegistered.put(clazz.getFullyQualifiedName(), entry);
+
+ getApplication().addConverter(entry.getValue(), clazz.getFullyQualifiedName());
}
- public void register(Class clazz, String annotationName, Map<String, Object> params) {
- throw new UnsupportedOperationException("Not yet implemented");
+ @Override
+ protected boolean hasToReregister(Map params, Class clazz) {
+ String value = (String) params.get(PAR_VALUE);
+ Boolean theDefault = (Boolean) params.get(PAR_DEFAULT);
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault);
+
+ AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getName());
+ if (alreadyRegistered == null) {
+ return true;
+ }
+
+ return alreadyRegistered.equals(entry);
}
+ @Override
+ protected boolean hasToReregister(Map params, JavaClass clazz) {
+ String value = getAnnotatedStringParam(params, PAR_VALUE);
+ Boolean theDefault = getAnnotatedBolleanParam(params, PAR_DEFAULT);
+
+ AnnotationEntry entry = new AnnotationEntry(value, theDefault);
+
+ AnnotationEntry alreadyRegistered = (AnnotationEntry) _alreadyRegistered.get(clazz.getFullyQualifiedName());
+ if (alreadyRegistered == null) {
+ return true;
+ }
+
+ return alreadyRegistered.equals(entry);
+ }
}