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 2010/01/09 17:18:07 UTC
svn commit: r897486 - in
/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core:
dependencyScan/ reloading/ util/
Author: werpu
Date: Sat Jan 9 16:18:06 2010
New Revision: 897486
URL: http://svn.apache.org/viewvc?rev=897486&view=rev
Log:
removed a lot of warnings typos and some unused code
Modified:
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassDependencies.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanStrategy.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanUtils.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/DefaultDependencyScanner.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ExtendedClassReader.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/MethodScanVisitor.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/NoMappingReloadingStrategy.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Array.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ClassUtils.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassDependencies.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassDependencies.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassDependencies.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassDependencies.java Sat Jan 9 16:18:06 2010
@@ -54,6 +54,7 @@
*
* @param clazz the referencing class to delete
*/
+ @SuppressWarnings("unused")
public void removeReferrer(String clazz) {
List<String> emptyReferences = new ArrayList<String>(reverseIndex.size());
for (Map.Entry<String, Set<String>> entry : reverseIndex.entrySet()) {
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanStrategy.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanStrategy.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanStrategy.java Sat Jan 9 16:18:06 2010
@@ -6,11 +6,11 @@
import java.io.File;
import java.util.Set;
-import java.util.regex.Matcher;
/**
* A scan strategy for scanning class files within our api
*/
+@SuppressWarnings("unused")
public class ClassScanStrategy implements Strategy {
Set<String> _whiteList;
DependencyScanner _scanner;
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanUtils.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanUtils.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ClassScanUtils.java Sat Jan 9 16:18:06 2010
@@ -30,7 +30,6 @@
class ClassScanUtils {
public static final String BINARY_PACKAGE = "\\/";
-
private static final String DOMAIN_JAVA = "java.";
private static final String DOMAIN_JAVAX = "javax.";
private static final String DOMAIN_COM_SUN = "com.sun";
@@ -46,7 +45,6 @@
private static final String DOMAIN_JYTHON = "jython.";
private static final String DOMAIN_JRUBY = "jruby.";
-
/**
* checks if a given package or class
* belongs to a standard namespaces which is
@@ -55,8 +53,8 @@
* @param in the page or fully qualified classname
* @return true if it belongs to one of the standard namespaces, false if not
*/
- public static final boolean isStandardNamespace(String in) {
- //We dont use a regexp here, because an test has shown that direct startsWith is 5 times as fast as applying
+ public static boolean isStandardNamespace(String in) {
+ //We don't use a regexp here, because an test has shown that direct startsWith is 5 times as fast as applying
//a precompiled regexp with match
//shortcuts for a faster killing of the add before going into the heavier
@@ -86,11 +84,12 @@
* if the class or package is in the list of allowed namespaces
* a true is returned otherwise a false
*
- * @param classOrPackage
- * @param nameSpaces
- * @return
+ * @param classOrPackage the class or package name to be checked for allowance
+ * @param nameSpaces the list of allowed namespaces
+ * @return true if the namespace is within the boundaries of the whitelist false otherwise
*/
- public static final boolean allowedNamespaces(String classOrPackage, String[] nameSpaces) {
+ @SuppressWarnings("unused")
+ public static boolean allowedNamespaces(String classOrPackage, String[] nameSpaces) {
//ok this is probably the fastest way to iterate hence we use this old construct
//a direct or would be faster but we cannot do it here since we are not dynamic here
@@ -106,35 +105,34 @@
/**
* renames the internal member class descriptors of L<qualified classnamewith />; to its source name
*
- * @param parm the internal class name
+ * @param internalClassName the internal class name
* @return the changed classname in its sourceform
*/
- public static final String internalClassDescriptorToSource(String parm) {
+ public static String internalClassDescriptorToSource(String internalClassName) {
//we strip the meta information which is not needed
- //aka start mit ( alles strippen bis )
+ //aka start with ( strip all to )
//()means usually beginning of a native type
- if (parm.startsWith("(")) {
- parm = parm.substring(parm.lastIndexOf(')') + 1);
+ if (internalClassName.startsWith("(")) {
+ internalClassName = internalClassName.substring(internalClassName.lastIndexOf(')') + 1);
}
- //()I for single datatypes
- if (parm.equals("") || parm.length() == 1) {
+ //()I for single data types
+ if (internalClassName.equals("") || internalClassName.length() == 1) {
return null;
}
//fully qualified name with meta information
- if (parm.endsWith(";")) {
+ if (internalClassName.endsWith(";")) {
//we can skip all the other meta information, a class identifier on sub class level
//has to start with L the format is <META ATTRIBUTES>L<CLASS QUALIFIED NAME>;
//The meta attributes can be for instance [ for array
- parm = parm.substring(parm.indexOf('L') + 1, parm.length() - 1);
+ internalClassName = internalClassName.substring(internalClassName.indexOf('L') + 1, internalClassName.length() - 1);
}
-
//normal fully qualified name with no meta info attached
- parm = parm.replaceAll(BINARY_PACKAGE, ".");
- return parm;
+ internalClassName = internalClassName.replaceAll(BINARY_PACKAGE, ".");
+ return internalClassName;
}
/**
@@ -144,17 +142,18 @@
* for performance reasons, before going into the heavier whitelist
* namespace check)
*
- * @param dependencies the target which has to recieve the dependency in source format
- * @param parms the list of dependencies which have to be added
+ * @param dependencies the target which has to receive the dependency in source format
+ * @param whiteList the whitelist of allowed dependencies
+ * @param parameters the list of dependencies which have to be added
*/
- public static final void logParmList(Collection<String> dependencies, final Set<String> whiteList, final String... parms) {
- for (String parm : parms) {
- if (parm == null) continue;
- if (parm.equals("")) continue;
- parm = internalClassDescriptorToSource(parm);
- if (parm == null || isStandardNamespace(parm)) continue;
+ public static void logParmList(Collection<String> dependencies, final Set<String> whiteList, final String... parameters) {
+ for (String singleParameter : parameters) {
+ if (singleParameter == null) continue;
+ if (singleParameter.equals("")) continue;
+ singleParameter = internalClassDescriptorToSource(singleParameter);
+ if (singleParameter == null || isStandardNamespace(singleParameter)) continue;
- String[] packages = parm.split("\\.");
+ String[] packages = singleParameter.split("\\.");
StringBuilder fullPackage = null;
for (String currPackage : packages) {
@@ -162,13 +161,13 @@
fullPackage.append(".");
fullPackage.append(currPackage);
} else {
- fullPackage = new StringBuilder(parm.length());
+ fullPackage = new StringBuilder(singleParameter.length());
fullPackage.append(currPackage);
}
String tempPackage = fullPackage.toString();
if (whiteList.contains(tempPackage)) {
- dependencies.add(parm);
+ dependencies.add(singleParameter);
break;
}
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/DefaultDependencyScanner.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/DefaultDependencyScanner.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/DefaultDependencyScanner.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/DefaultDependencyScanner.java Sat Jan 9 16:18:06 2010
@@ -46,8 +46,8 @@
}
/**
- * @param className
- * @return
+ * @param className the class name of the class which has to be investigated for the code dependencies
+ * @return a set of dependencies as string representation of their class names
*/
public synchronized final Set<String> fetchDependencies(ClassLoader loader, String className, final Set<String> whiteList) {
Set<String> retVal = new HashSet<String>();
@@ -55,7 +55,6 @@
return retVal;
}
-
/**
* this investigates the classes inheritance hierarchy for
* more dependencies, for now annotations and interfaces
@@ -63,9 +62,12 @@
* (maybe in the long run we will add interfaces and annotations as well
* but for now we will leave them away for speed reasons)
*
- * @param retVal
+ * @param loader the classLoader which should be used for the hierarchy scanning
+ * @param retVal the receiving set
+ * @param className the className which has to be investigated
+ * @param whiteList the package scanning whitelist
*/
- private final void investigateInheritanceHierarchy(ClassLoader loader, Set<String> retVal, String className, Set<String> whiteList) {
+ private void investigateInheritanceHierarchy(ClassLoader loader, Set<String> retVal, String className, Set<String> whiteList) {
//we now have to fetch the parent hierarchy
try {
@@ -86,13 +88,15 @@
/**
* scans one level of the inheritance hierarchy
*
- * @param retVal
- * @param currentClassName
+ * @param loader the classLoader which should be used for the hierarchy scanning
+ * @param retVal the receiving set
+ * @param currentClassName the className which has to be investigated
+ * @param whiteList the package scanning whitelist
*/
- private final void scanCurrentClass(ClassLoader loader, Set<String> retVal, String currentClassName, Set<String> whiteList) {
+ private void scanCurrentClass(ClassLoader loader, Set<String> retVal, String currentClassName, Set<String> whiteList) {
cp.setDependencyTarget(retVal);
cp.setWhiteList(whiteList);
- ClassReader cr = null;
+ ClassReader cr;
try {
cr = new ExtendedClassReader(loader, currentClassName);
@@ -102,5 +106,4 @@
}
}
-
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ExtendedClassReader.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ExtendedClassReader.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ExtendedClassReader.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/ExtendedClassReader.java Sat Jan 9 16:18:06 2010
@@ -5,19 +5,18 @@
import java.io.IOException;
/**
- * Created by IntelliJ IDEA.
- * User: werpu2
- * Date: 23.12.2009
- * Time: 09:01:10
- * To change this template use File | Settings | File Templates.
+ * Class reader for ASM which allows to plug our own loader instead
+ * of the default one
+ * <p/>
+ * (ASM makes too many assumptions regarding the loader)
*/
public class ExtendedClassReader extends ClassReader {
/**
* classloader pluggable classreader
*
- * @param loader
- * @param className
- * @throws IOException
+ * @param loader the loader which has to be plugged into the system
+ * @param className the class name for the class which has to be investigated
+ * @throws IOException in case of a loading error (class cannot be loaded for whatever reason)
*/
public ExtendedClassReader(ClassLoader loader, String className) throws IOException {
super(loader.getResourceAsStream(className.replace('.', '/')
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/MethodScanVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/MethodScanVisitor.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/MethodScanVisitor.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/MethodScanVisitor.java Sat Jan 9 16:18:06 2010
@@ -32,8 +32,6 @@
class MethodScanVisitor implements MethodVisitor {
- //static final Logger log = Logger.getLogger("MethodScanVisitor");
-
final Set<String> dependencies;
final Set<String> whiteList;
@@ -42,7 +40,6 @@
this.whiteList = whiteList;
}
-
public AnnotationVisitor visitAnnotationDefault() {
return null;
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/GlobalReloadingStrategy.java Sat Jan 9 16:18:06 2010
@@ -18,7 +18,6 @@
*/
package org.apache.myfaces.scripting.core.reloading;
-import org.apache.myfaces.scripting.api.BaseWeaver;
import org.apache.myfaces.scripting.api.ReloadingStrategy;
import org.apache.myfaces.scripting.api.ScriptingConst;
import org.apache.myfaces.scripting.api.ScriptingWeaver;
@@ -28,7 +27,7 @@
* @version $Revision$ $Date$
* <p/>
* A reloading strategy chain of responsibility which switches
- * depending on the artefact type to the correct
+ * depending on the artifact type to the correct
* strategy
*/
@@ -44,7 +43,6 @@
setWeaver(weaver);
}
-
public GlobalReloadingStrategy() {
}
@@ -53,28 +51,28 @@
* the strategy callback which switches between various strategies
* we have in our system
*
- * @param toReload
- * @param artefactType
- * @return
+ * @param toReload the object which has to be reloaded
+ * @param artifactType the artifact type for which the reloading strategy has to be applied to
+ * @return either the same or a reloading object depending on the current state of the object
*/
- public Object reload(Object toReload, int artefactType) {
+ public Object reload(Object toReload, int artifactType) {
- switch (artefactType) {
+ switch (artifactType) {
case ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN:
- return _beanStrategy.reload(toReload, artefactType);
+ return _beanStrategy.reload(toReload, artifactType);
case ScriptingConst.ARTIFACT_TYPE_RENDERER:
- return _noMappingStrategy.reload(toReload, artefactType);
+ return _noMappingStrategy.reload(toReload, artifactType);
case ScriptingConst.ARTIFACT_TYPE_BEHAVIOR:
- return _noMappingStrategy.reload(toReload, artefactType);
+ return _noMappingStrategy.reload(toReload, artifactType);
case ScriptingConst.ARTIFACT_TYPE_CLIENTBEHAVIORRENDERER:
- return _noMappingStrategy.reload(toReload, artefactType);
+ return _noMappingStrategy.reload(toReload, artifactType);
case ScriptingConst.ARTIFACT_TYPE_COMPONENT:
- return _noMappingStrategy.reload(toReload, artefactType);
+ return _noMappingStrategy.reload(toReload, artifactType);
case ScriptingConst.ARTIFACT_TYPE_VALIDATOR:
- return _noMappingStrategy.reload(toReload, artefactType);
- //TODO Add other artefact loading strategies on demand here
+ return _noMappingStrategy.reload(toReload, artifactType);
+ //TODO Add other artifact loading strategies on demand here
default:
- return _allOthers.reload(toReload, artefactType);
+ return _allOthers.reload(toReload, artifactType);
}
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/ManagedBeanReloadingStrategy.java Sat Jan 9 16:18:06 2010
@@ -18,23 +18,8 @@
*/
package org.apache.myfaces.scripting.core.reloading;
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.annotation.LifecycleProvider;
-import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
-import org.apache.myfaces.config.element.ManagedBean;
-import org.apache.myfaces.scripting.api.BaseWeaver;
import org.apache.myfaces.scripting.api.ReloadingStrategy;
import org.apache.myfaces.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.scripting.core.util.ReflectUtil;
-import org.apache.myfaces.scripting.core.util.WeavingContext;
-
-import javax.faces.context.FacesContext;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Map;
/**
* @author Werner Punz (latest modification by $Author$)
@@ -51,10 +36,6 @@
public class ManagedBeanReloadingStrategy implements ReloadingStrategy {
ScriptingWeaver _weaver;
- Map<String, List<ManagedBean>> _managedBeanIdx = null;
-
- static final String RELOAD_PERFORMED = "beanReloadPerformed";
-
public ManagedBeanReloadingStrategy(ScriptingWeaver weaver) {
_weaver = weaver;
@@ -64,14 +45,15 @@
}
/**
- * In our case the dropping already has happend at request time
+ * In our case the dropping already has happened at request time
* no need for another reloading here
*
- * @param scriptingInstance
- * @param artefactType
- * @return
+ * @param scriptingInstance the instance which has to be reloaded
+ * @param artifactType the type of artifact
+ * @return does nothing in this case and returns only the original instance, the reloading is handled
+ * for managed beans on another level
*/
- public Object reload(Object scriptingInstance, int artefactType) {
+ public Object reload(Object scriptingInstance, int artifactType) {
return scriptingInstance;
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/NoMappingReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/NoMappingReloadingStrategy.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/NoMappingReloadingStrategy.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/NoMappingReloadingStrategy.java Sat Jan 9 16:18:06 2010
@@ -18,8 +18,6 @@
*/
package org.apache.myfaces.scripting.core.reloading;
-import org.apache.myfaces.scripting.api.ReloadingStrategy;
-import org.apache.myfaces.scripting.api.BaseWeaver;
import org.apache.myfaces.scripting.api.ScriptingWeaver;
/**
@@ -49,9 +47,7 @@
super(weaver);
}
-
@Override
protected void mapProperties(Object target, Object src) {
- return;
}
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/reloading/SimpleReloadingStrategy.java Sat Jan 9 16:18:06 2010
@@ -18,13 +18,11 @@
*/
package org.apache.myfaces.scripting.core.reloading;
-import org.apache.myfaces.scripting.api.ReloadingStrategy;
-import org.apache.myfaces.scripting.api.BaseWeaver;
-import org.apache.myfaces.scripting.api.ScriptingWeaver;
-import org.apache.myfaces.scripting.refresh.ReloadingMetadata;
+import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.beanutils.BeanUtils;
+import org.apache.myfaces.scripting.api.ReloadingStrategy;
+import org.apache.myfaces.scripting.api.ScriptingWeaver;
import java.lang.reflect.InvocationTargetException;
@@ -36,7 +34,7 @@
* pattern this is the most basic implementation
* covering our reloading.
* <p/>
- * Applicable for most artefacts except for now managed beans
+ * Applicable for most artifacts except for now managed beans
* <p/>
*/
@@ -52,7 +50,6 @@
}
-
/**
* <p>
* the central callback for our strategy here
@@ -76,7 +73,7 @@
getLog().info("[EXT-SCRIPTING] possible reload for " + scriptingInstance.getClass().getName());
/*only recreation of empty constructor classes is possible*/
try {
- //reload the object by instiating a new class and
+ //reload the object by instantiating a new class and
// assigning the attributes properly
Object newObject = aclass.newInstance();
@@ -91,17 +88,16 @@
}
-
/**
* helper to map the properties wherever possible
* <p/>
* This is the simplest solution for now,
* we apply only a copy properties here, which should be enough
- * for all artefacts except the managed beans and the ones
+ * for all artifacts except the managed beans and the ones
* which have to preserve some kind of delegate before instantiation.
*
- * @param target
- * @param src
+ * @param target the target which has to receive the properties
+ * @param src the source which has the original properties
*/
protected void mapProperties(Object target, Object src) {
try {
@@ -119,7 +115,6 @@
return LogFactory.getLog(this.getClass());
}
-
public ScriptingWeaver getWeaver() {
return _weaver; //To change body of implemented methods use File | Settings | File Templates.
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Array.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Array.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Array.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/Array.java Sat Jan 9 16:18:06 2010
@@ -22,7 +22,7 @@
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-
+@SuppressWarnings("unused")
public class Array extends Cast {
public Array(Class clazz, Object... value) {
super(java.lang.reflect.Array.newInstance(clazz, 0).getClass(), value);
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ClassUtils.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ClassUtils.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ClassUtils.java Sat Jan 9 16:18:06 2010
@@ -18,16 +18,9 @@
*/
package org.apache.myfaces.scripting.core.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.shared_impl.util.ClassLoaderExtension;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
/**
* @author werpu
@@ -54,92 +47,9 @@
return true;
}
-
- /**
- * We use asm here to add the marker annotation
- * to the list of our public annotations
- *
- * @param classPath the root classPath which hosts our class
- * @param className the className from the class which has to be rewritten
- * @throws ClassNotFoundException
- */
- /* public static void markAsDynamicJava(String classPath, String className) throws ClassNotFoundException {
- FileInputStream fIstr = null;
- FileOutputStream foStream = null;
- try {
- File classFile = classNameToFile(classPath, className);
- fIstr = new FileInputStream(classFile);
-
- ClassNode node = new ClassNode();
- ClassReader clsReader = new ClassReader(fIstr);
- //ClassWriter wrt = new ClassWriter();
- clsReader.accept((ClassVisitor) node, ClassReader.SKIP_FRAMES);
- //node.accept(wrt);
- ClassWriter wrt = new ClassWriter(0);
-
- if (node.visibleAnnotations == null) {
- node.visibleAnnotations = new LinkedList<AnnotationNode>();
- }
-
- boolean hasAnnotation = false;
- String annotationMarker = Type.getDescriptor(ScriptingClass.class);
- for (Object elem : node.visibleAnnotations) {
- AnnotationNode aNode = (AnnotationNode) elem;
- if (aNode.desc.equals(annotationMarker)) {
- hasAnnotation = true;
- break;
- }
- }
- if (!hasAnnotation) {
- node.visibleAnnotations.add(new AnnotationNode(annotationMarker));
- }
- node.accept(wrt);
-
- byte[] finalClass = wrt.toByteArray();
- fIstr.close();
- fIstr = null;
-
- foStream = new FileOutputStream(classNameToFile(classPath, className));
- foStream.write(finalClass);
- foStream.flush();
-
- } catch (FileNotFoundException ex) {
- throw new ClassNotFoundException("Class " + className + " not found ");
-
- } catch (IOException e) {
- logError(e);
- } finally {
- closeStreams(fIstr, foStream);
- }
-
-} */
- private static void logError(IOException e) {
- Log log = LogFactory.getLog(ClassUtils.class);
- log.error(e);
- }
-
- private static void closeStreams(FileInputStream fIstr, FileOutputStream foStream) {
- try {
- if (fIstr != null) {
- fIstr.close();
- }
- } catch (IOException e) {
- logError(e);
- }
- try {
- if (foStream != null) {
- foStream.close();
- }
- } catch (IOException e) {
- logError(e);
- }
- }
-
-
public static File classNameToFile(String classPath, String className) {
String classFileName = classNameToRelativeFileName(className);
- File target = new File(classPath + File.separator + classFileName);
- return target;
+ return new File(classPath + File.separator + classFileName);
}
private static String classNameToRelativeFileName(String className) {
@@ -162,8 +72,4 @@
org.apache.myfaces.shared_impl.util.ClassUtils.addClassLoadingExtension(extension, top);
}
- public Class classForName(String name) throws ClassNotFoundException {
- return org.apache.myfaces.shared_impl.util.ClassUtils.classForName(name);
- }
-
}
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/FileUtils.java Sat Jan 9 16:18:06 2010
@@ -57,7 +57,7 @@
}
public static File getTempDir() {
- File tempDir = null;
+ File tempDir;
String baseTempPath = System.getProperty("java.io.tmpdir");
String tempDirName = "myfaces_compilation_" + _tempMarker;
@@ -72,21 +72,21 @@
if (tempDir.exists()) {
return tempDir;
}
- tempDir.mkdirs();
- tempDir.deleteOnExit();
+ if (tempDir.mkdirs()) {
+ tempDir.deleteOnExit();
+ }
}
return tempDir;
}
-
/**
- * we roll our own treewalker here
+ * we roll our own tree walker here
* to avoid a dependency into commons fileutils
* and to apply an easier pattern than
* commons fileutils uses
*
- * @param rootDir
- * @param strategy
+ * @param rootDir the root dir for our walking
+ * @param strategy the strategy to apply to for our walking
*/
public static void listFiles(File rootDir, Strategy strategy) {
if (!rootDir.isDirectory()) {
@@ -112,7 +112,7 @@
* target path check to check if the targetPath is valid or can be created
* </p>
*
- * @param path
+ * @param path the path to be investigated
*/
public static void assertPath(File path) {
// The destination directory must already exist as javac will not create the destination directory.
@@ -127,13 +127,12 @@
}
}
-
/**
* fetches recursively the files under the current root
*
* @param sourcePath the source path from which the walker should start from
* @param fileType the pattern upon which the file has to be matched to aka *.java etc...
- * @return
+ * @return a list of source files
*/
public static List<File> fetchSourceFiles(File sourcePath, String fileType) {
FileStrategy strategy = new FileStrategy(fileType);
@@ -142,7 +141,6 @@
return strategy.getFoundFiles();
}
-
/**
* fetches the source paths from a given root directory in the format
* <path>/<appendix>;...
@@ -151,6 +149,7 @@
* @param appendix the appendix which has to be appended to every path found
* @return a string builder of the paths found
*/
+ @SuppressWarnings("unused")
public static StringBuilder fetchSourcePaths(File sourcePath, String appendix) {
DirStrategy dirStrategy = new DirStrategy();
listFiles(sourcePath, dirStrategy);
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java?rev=897486&r1=897485&r2=897486&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/core/util/ReflectUtil.java Sat Jan 9 16:18:06 2010
@@ -44,7 +44,7 @@
/**
* A simplified instantiation over reflection
*
- * @param clazz the class to be istantiated
+ * @param clazz the class to be instantiated
* @param varargs the instantiation parameters
* @return the instantiated object
*/
@@ -74,8 +74,8 @@
throw new RuntimeException(e);
}
}/*this is mostly just a helper to bypass a groovy bug in a more
- * complex delegation environemt. Groovy throws a classcast
- * exeption wrongly, delegating the instantiation code to java
+ * complex delegation environment. Groovy throws a classcast
+ * exception wrongly, delegating the instantiation code to java
* fixes that
* */
@@ -83,7 +83,6 @@
return clazz.newInstance();
}
-
/**
* Generic execute method which simplifies the reflection api
* down to a usable system
@@ -112,7 +111,6 @@
}
-
public static Collection<Method> getAllMethods(Class clazz, String methodName, int varargLength) {
ArrayList<Method> retVal = new ArrayList<Method>(30);
while (clazz.equals(java.lang.Object.class)) {
@@ -127,7 +125,6 @@
return retVal;
}
-
public static Collection<Method> getMethods(Class clazz, String methodName, int varargLength) {
ArrayList<Method> retVal = new ArrayList<Method>(30);
for (Method m : clazz.getDeclaredMethods()) {
@@ -139,7 +136,6 @@
return retVal;
}
-
/**
* Generic execute method which simplifies the reflection api
* down to a usable system
@@ -148,10 +144,10 @@
* @param methodName the method name
* @param varargs the arguments which have to be passed to the method
* @return the return value of the method
- * @throws a generic runtime exception in case of a failure
- * we use unmanaged exceptions here to get a behavior similar to scripting
- * language execution where failures can happen but method executions
- * should not enforce exception handling
+ * @throws RuntimeException a generic runtime exception in case of a failure
+ * we use unmanaged exceptions here to get a behavior similar to scripting
+ * language execution where failures can happen but method executions
+ * should not enforce exception handling
*/
public static Object executeMethod(Object obj, String methodName, Object... varargs) {
@@ -210,7 +206,6 @@
static class _MethodNotFound {
}
-
/**
* check if the return vaue is a method not found return val which
* indicates we have to follow the next workflow step
@@ -222,7 +217,6 @@
return retVal instanceof _MethodNotFound;
}
-
/**
* executes a method in an invocation handler
*
@@ -269,7 +263,6 @@
return new _MethodNotFound();
}
-
/**
* executes a static method on a class
*
@@ -293,7 +286,6 @@
return new _MethodNotFound();
}
-
private static void handleException(Throwable e) {
if (e instanceof IllegalAccessException) {
//do nothing
@@ -304,7 +296,6 @@
}
}
-
/**
* executes a function method on a target object
*
@@ -341,7 +332,6 @@
}
-
/**
* faster reflection call
* if we know the data types excactly we can