[jgentle] r74 commited - optimize code

0 views
Skip to first unread message

codesite...@google.com

unread,
Jul 26, 2009, 2:59:16 PM7/26/09
to jgentl...@googlegroups.com
Revision: 74
Author: Skydunkpro
Date: Sun Jul 26 11:58:11 2009
Log: optimize code
http://code.google.com/p/jgentle/source/detail?r=74

Modified:

/trunk/JGentleProject/src/org/jgentleframework/configure/SystemConfigImpl.java

/trunk/JGentleProject/src/org/jgentleframework/configure/annotation/Block.java

/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/IPresentLoadingClass.java

/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectAttachImpl.java

/trunk/JGentleProject/src/org/jgentleframework/context/ProviderCoreCreator.java

/trunk/JGentleProject/src/org/jgentleframework/context/injecting/AbstractBeanFactory.java

/trunk/JGentleProject/src/org/jgentleframework/context/injecting/SingletonInstanceScopeName.java

/trunk/JGentleProject/src/org/jgentleframework/core/factory/support/CommonFactory.java

/trunk/JGentleProject/src/org/jgentleframework/core/reflection/metadata/AnnoMeta.java

/trunk/JGentleProject/src/org/jgentleframework/core/reflection/metadata/AnnoMetaImpl.java
/trunk/JGentleProject/src/org/jgentleframework/utils/ReflectUtils.java

=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/SystemConfigImpl.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/SystemConfigImpl.java
Sun Jul 26 11:58:11 2009
@@ -22,7 +22,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
@@ -81,9 +80,8 @@

/*
* (non-Javadoc)
- * @see
- *
org.jgentleframework.configure.jgentle.SystemConfig#addAnnotationPostProcessor
- * (java.lang.Class,
+ * @seeorg.jgentleframework.configure.jgentle.SystemConfig#
+ * addAnnotationPostProcessor (java.lang.Class,
*
org.jgentleframework.core.reflection.annohandler.AnnotationPostProcessor)
*/
@Override
@@ -99,9 +97,8 @@

/*
* (non-Javadoc)
- * @see
- *
org.jgentleframework.configure.jgentle.SystemConfig#addAnnotationPostProcessor
- * (java.lang.Class, java.lang.Class)
+ * @seeorg.jgentleframework.configure.jgentle.SystemConfig#
+ * addAnnotationPostProcessor (java.lang.Class, java.lang.Class)
*/
@Override
@SuppressWarnings("unchecked")
@@ -117,9 +114,8 @@

/*
* (non-Javadoc)
- * @see
- *
org.jgentleframework.configure.jgentle.SystemConfig#addDefinitionPostProcessor
- * (java.lang.Class<? extends
+ * @seeorg.jgentleframework.configure.jgentle.SystemConfig#
+ * addDefinitionPostProcessor (java.lang.Class<? extends
* org.jgentleframework.core.reflection.aohreflect.
* DefinitionPostProcessor>[])
*/
@@ -138,10 +134,10 @@

/*
* (non-Javadoc)
- * @see
- *
org.jgentleframework.configure.jgentle.SystemConfig#addDefinitionPostProcessor
- * (
- *
org.jgentleframework.core.reflection.aohreflect.DefinitionPostProcessor[])
+ * @seeorg.jgentleframework.configure.jgentle.SystemConfig#
+ * addDefinitionPostProcessor (
+ * org.jgentleframework.core.reflection.aohreflect
+ * .DefinitionPostProcessor[])
*/
@Override
public void addDefinitionPostProcessor(DefinitionPostProcessor... dpps) {
@@ -334,7 +330,8 @@
/*
* (non-Javadoc)
* @see
- *
org.jgentleframework.configure.jgentle.SystemConfig#initAnnotationConfig()
+ *
org.jgentleframework.configure.jgentle.SystemConfig#initAnnotationConfig
+ * ()
*/
public void initAnnotationConfig() throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException,
@@ -391,7 +388,7 @@
}
List<Field> fieldList = Arrays.asList(ReflectUtils
.getAllDeclaredFields(clazz));
- HashMap<String, Field> fieldResult = new HashMap<String, Field>();
+ Map<String, Field> fieldResult = new HashMap<String, Field>();
for (String name : properties) {
for (Field field : fieldList) {
if (RegularToolkit.matches(name, field
@@ -471,7 +468,7 @@
List<Method> methodRawList = Arrays
.asList(ReflectUtils
.getAllDeclaredMethods(clazz));
- HashMap<String, Method> methodResult = new HashMap<String,
Method>();
+ Map<String, Method> methodResult = new HashMap<String, Method>();
for (String name : methodList) {
for (Method met : methodRawList) {
if (RegularToolkit.matches(name, met
@@ -582,11 +579,11 @@
public void setOptionsList(Map<String, Object> optionsList, Method
configure) {

this.optionsList = optionsList;
- this.DPPList = new ArrayList<DefinitionPostProcessor>();
+ this.DPPList = new LinkedList<DefinitionPostProcessor>();
this.optionsList.put(AbstractConfig.DEFINITION_POST_PROCESSOR, DPPList);
- this.cscClassList = new ArrayList<Class<? extends
ComponentServiceContextType<?>>>();
+ this.cscClassList = new LinkedList<Class<? extends
ComponentServiceContextType<?>>>();
this.optionsList.put(AbstractConfig.CSC_CLASS_LIST, this.cscClassList);
- this.annotationConfigList = new ArrayList<Annotation>();
+ this.annotationConfigList = new LinkedList<Annotation>();
this.optionsList.put(AbstractConfig.ANNOTATION_CONFIG_LIST,
this.annotationConfigList);
this.annoBeanProcessorList = new HashMap<Class,
AnnotationBeanProcessor>();
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/annotation/Block.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/annotation/Block.java
Sun Jul 26 11:58:11 2009
@@ -37,9 +37,7 @@
@Target(ElementType.METHOD)
public @interface Block {
/**
- * Danh sách các config instance bị ràng buộc trong block.
- *
- * @return <code>{@code Class<?>[]}</code>
+ * A array containing all configurable instances bound to current block
*/
Class<?>[] value() default {};
}
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/IPresentLoadingClass.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/IPresentLoadingClass.java
Sun Jul 26 11:58:11 2009
@@ -18,6 +18,7 @@
package org.jgentleframework.configure.objectmeta;

import java.util.ArrayList;
+import java.util.List;

/**
* Lưu ý <code>interface</code> không được cung cấp để sử dụng như là một
@@ -40,5 +41,5 @@
* @return trả về một danh sách chứa đựng các <code>object class</code>
* nếu có, nếu không, trả về một danh sách {@link ArrayList} rỗng.
*/
- ArrayList<Class<?>> getPresentLoadingClasses();
-}
+ List<Class<?>> getPresentLoadingClasses();
+}
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectAttachImpl.java
Thu Jul 23 18:03:29 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectAttachImpl.java
Sun Jul 26 11:58:11 2009
@@ -392,9 +392,9 @@
* #getPresentLoadingClasses()
*/
@Override
- public ArrayList<Class<?>> getPresentLoadingClasses() {
-
- ArrayList<Class<?>> result = new ArrayList<Class<?>>();
+ public List<Class<?>> getPresentLoadingClasses() {
+
+ List<Class<?>> result = new ArrayList<Class<?>>();
for (Entry<Class<?>, Class<?>> entry : this.hashList.entrySet()) {
if (entry.getKey() != null && !result.contains(entry.getKey())) {
result.add(entry.getKey());
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/ProviderCoreCreator.java
Thu Jul 23 01:43:47 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/ProviderCoreCreator.java
Sun Jul 26 11:58:11 2009
@@ -302,14 +302,15 @@
return detectorController;
}

- /**
- * Gets the object bean factory.
- *
- * @return the objectBeanFactory
+ /*
+ * (non-Javadoc)
+ * @seeorg.jgentleframework.context.injecting.IAbstractBeanFactory#
+ * getObjectBeanFactory()
*/
+ @Override
public ObjectBeanFactory getObjectBeanFactory() {

- return objectBeanFactory;
+ return this.objectBeanFactory;
}

/*
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/AbstractBeanFactory.java
Thu Jul 23 18:03:29 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/AbstractBeanFactory.java
Sun Jul 26 11:58:11 2009
@@ -51,9 +51,9 @@

/**
* This abstract class is implementation of {@link IAbstractBeanFactory}
- * interface. This class is responsible for configured data management of
- * JGentle container. It provides some methods in order to check, manage
and
- * access to configured data.
+ * interface. This class is responsible for configure data management of
JGentle
+ * container. It provides some methods in order to check, manage and
access to
+ * configured data.
*
* @author LE QUOC CHUNG - mailto: <a
* href="mailto:skydu...@yahoo.com">skydu...@yahoo.com</a>
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/SingletonInstanceScopeName.java
Thu Jul 23 05:38:37 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/SingletonInstanceScopeName.java
Sun Jul 26 11:58:11 2009
@@ -26,10 +26,10 @@
*/
public final class SingletonInstanceScopeName {
/** The scope name. */
- public String scopeName;
+ public String scopeName = null;

/** The shared singleton. */
- public Object sharedSingleton;
+ public Object sharedSingleton = null;

/**
* Instantiates a new singleton instance scope name.
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/core/factory/support/CommonFactory.java
Thu Jul 23 18:03:29 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/core/factory/support/CommonFactory.java
Sun Jul 26 11:58:11 2009
@@ -52,8 +52,6 @@

/**
* Returns a unique instance of {@link CommonFactory}.
- *
- * @return {@link CommonFactory} instance
*/
public static CommonFactory singleton() {

=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/core/reflection/metadata/AnnoMeta.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/core/reflection/metadata/AnnoMeta.java
Sun Jul 26 11:58:11 2009
@@ -18,7 +18,7 @@
package org.jgentleframework.core.reflection.metadata;

import java.util.Collection;
-import java.util.HashMap;
+import java.util.Map;
import java.util.Set;

import org.aopalliance.reflect.Metadata;
@@ -85,7 +85,7 @@
/**
* Returns the list of {@link Metadata}s in this {@link AnnoMeta}
*/
- public HashMap<Object, Metadata> getMetaList();
+ public Map<Object, Metadata> getMetaList();

/**
* Returns the name of this {@link AnnoMeta}, if it is not specified, an
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/core/reflection/metadata/AnnoMetaImpl.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/core/reflection/metadata/AnnoMetaImpl.java
Sun Jul 26 11:58:11 2009
@@ -21,6 +21,7 @@
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Map;
import java.util.Set;

import org.aopalliance.reflect.Metadata;
@@ -273,7 +274,8 @@

/*
* (non-Javadoc)
- * @see
org.jgentleframework.core.reflection.metadata.MetadataImpl#getValue()
+ * @see
+ * org.jgentleframework.core.reflection.metadata.MetadataImpl#getValue()
*/
@Override
public Object getValue() {
@@ -286,7 +288,7 @@
* @see
org.jgentleframework.core.reflection.metadata.AnnoMeta#getMetaList()
*/
@Override
- public HashMap<Object, Metadata> getMetaList() {
+ public Map<Object, Metadata> getMetaList() {

return metaList;
}
=======================================
--- /trunk/JGentleProject/src/org/jgentleframework/utils/ReflectUtils.java
Tue Jul 21 19:08:49 2009
+++ /trunk/JGentleProject/src/org/jgentleframework/utils/ReflectUtils.java
Sun Jul 26 11:58:11 2009
@@ -922,6 +922,30 @@
}
return true;
}
+
+ /**
+ * Returns <b>true</b> if given list of objects are annotation
+ * implementations. If has just any object class can not be casted,
returns
+ * <b>false</b>.
+ *
+ * @param objs
+ * the list of objects need to be test.
+ */
+ public static boolean isAnnotation(Object... objs) {
+
+ Assertor.notNull((Object[]) objs);
+ if (objs.length == 0) {
+ Assertor
+ .throwRunTimeException("The list of annotation instances need to be
casted must not be empty!");
+ }
+ boolean result = true;
+ for (Object o : objs) {
+ result = isAnnotation(o);
+ if (result == false)
+ break;
+ }
+ return result;
+ }

/**
* Returns <b>true</b> if given object can be casted to the class or
@@ -937,13 +961,6 @@
public static boolean isCast(Class<?> clazz, Object obj) {

return clazz.isInstance(obj);
- // try {
- // clazz.cast(obj);
- // }
- // catch (ClassCastException e) {
- // return false;
- // }
- // return true;
}

/**
@@ -995,7 +1012,7 @@
* @return true, if checks if is constructor
*/
public static boolean isConstructor(Object obj) {
-
+
return isCast(Constructor.class, obj);
}

@@ -1036,6 +1053,7 @@
* @return true, if checks if is field
*/
public static boolean isField(Object obj) {
+
Assertor.notNull(obj);
if (obj.getClass().equals(Field.class)) {
return true;
@@ -1066,6 +1084,7 @@
* @return true, if checks if is method
*/
public static boolean isMethod(Object obj) {
+
Assertor.notNull(obj);
if (obj.getClass().equals(Method.class)) {
return true;
Reply all
Reply to author
Forward
0 new messages