[jgentle] r73 commited - optimize code, fix some bugs and increase performance

0 views
Skip to first unread message

codesite...@google.com

unread,
Jul 23, 2009, 9:04:09 PM7/23/09
to jgentl...@googlegroups.com
Revision: 73
Author: Skydunkpro
Date: Thu Jul 23 18:03:29 2009
Log: optimize code, fix some bugs and increase performance
http://code.google.com/p/jgentle/source/detail?r=73

Modified:

/trunk/JGentleProject/src/org/jgentleframework/configure/AbstractBindingConfig.java
/trunk/JGentleProject/src/org/jgentleframework/configure/BindingConfig.java

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

/trunk/JGentleProject/src/org/jgentleframework/configure/ConfigurationProxy.java
/trunk/JGentleProject/src/org/jgentleframework/configure/enums/Scope.java

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

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

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

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

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

/trunk/JGentleProject/src/org/jgentleframework/context/AbstractServiceManagement.java
/trunk/JGentleProject/src/org/jgentleframework/context/JGentle.java

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

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

/trunk/JGentleProject/src/org/jgentleframework/context/injecting/autodetect/ExtensionPointsDetector.java

/trunk/JGentleProject/src/org/jgentleframework/core/factory/InOutExecutor.java

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

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

/trunk/JGentleProject/src/org/jgentleframework/core/provider/DomainManagerImpl.java
/trunk/JGentleProject/src/org/jgentleframework/utils/Utils.java

=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/AbstractBindingConfig.java
Fri Jun 19 09:56:17 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/AbstractBindingConfig.java
Thu Jul 23 18:03:29 2009
@@ -19,7 +19,7 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.util.ArrayList;
+import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
@@ -60,24 +60,24 @@
public abstract class AbstractBindingConfig extends AbstractConfigModule
implements CoreBinding {
/** The bean class list. */
- protected ArrayList<Class<?>> beanClassList = null;
+ protected List<Class<?>> beanClassList = null;

/** The object binding constant list. */
- protected ArrayList<ObjectBindingConstant> objBindingConstantList =
null;
+ protected List<ObjectBindingConstant> objBindingConstantList = null;

/** The object binding interceptor list. */
- protected ArrayList<ObjectBindingInterceptor> objBindingInterceptorList =
null;
+ protected List<ObjectBindingInterceptor> objBindingInterceptorList = null;

/** The object attach list. */
- protected ArrayList<ObjectAttach<?>> objectAttachList = null;
+ protected List<ObjectAttach<?>> objectAttachList = null;

/** The object constant list. */
- protected ArrayList<ObjectConstant> objectConstantList = null;
+ protected List<ObjectConstant> objectConstantList = null;

/** The log. */
- protected final Log log = LogFactory
- .getLog(this
- .getClass());
+ protected final Log log = LogFactory
+ .getLog(this
+ .getClass());

/*
* (non-Javadoc)
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/BindingConfig.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/BindingConfig.java
Thu Jul 23 18:03:29 2009
@@ -18,6 +18,7 @@
package org.jgentleframework.configure;

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

import org.jgentleframework.configure.objectmeta.ObjectAttach;
@@ -40,25 +41,25 @@
* Returns an {@link ArrayList} containing all object classes of mapping
* bean.
*/
- public ArrayList<Class<?>> getBeanClassList();
+ public List<Class<?>> getBeanClassList();

/**
* Returns an {@link ArrayList} containing all current binding of beans (
* {@link ObjectBindingConstant}).
*/
- public ArrayList<ObjectBindingConstant> getObjBindingConstantList();
+ public List<ObjectBindingConstant> getObjBindingConstantList();

/**
* Returns an {@link ArrayList} containing all current attach mappings (
* {@link ObjectAttach})
*/
- public ArrayList<ObjectAttach<?>> getObjectAttachList();
+ public List<ObjectAttach<?>> getObjectAttachList();

/**
* Returns an {@link ArrayList} containing all current attach constant
* mappings ({@link ObjectConstant})
*/
- public ArrayList<ObjectConstant> getObjectConstantList();
+ public List<ObjectConstant> getObjectConstantList();

/**
* Returns option list
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/BindingConfigImpl.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/BindingConfigImpl.java
Thu Jul 23 18:03:29 2009
@@ -18,7 +18,8 @@
package org.jgentleframework.configure;

import java.lang.reflect.Method;
-import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;

import org.jgentleframework.configure.objectmeta.ObjectAttach;
@@ -43,7 +44,7 @@
* org.jgentleframework.configure.jgentle.BindingConfig#getBeanClassList()
*/
@Override
- public ArrayList<Class<?>> getBeanClassList() {
+ public List<Class<?>> getBeanClassList() {

return beanClassList;
}
@@ -54,7 +55,7 @@
* getObjBindingConstantList ()
*/
@Override
- public ArrayList<ObjectBindingConstant> getObjBindingConstantList() {
+ public List<ObjectBindingConstant> getObjBindingConstantList() {

return objBindingConstantList;
}
@@ -66,7 +67,7 @@
* ()
*/
@Override
- public ArrayList<ObjectAttach<?>> getObjectAttachList() {
+ public List<ObjectAttach<?>> getObjectAttachList() {

return objectAttachList;
}
@@ -78,7 +79,7 @@
* ()
*/
@Override
- public ArrayList<ObjectConstant> getObjectConstantList() {
+ public List<ObjectConstant> getObjectConstantList() {

return objectConstantList;
}
@@ -164,19 +165,19 @@
/*
* add các danh sách thông tin cấu hình
*/
- this.beanClassList = new ArrayList<Class<?>>();
+ this.beanClassList = new LinkedList<Class<?>>();
this.optionsList
.put(AbstractConfig.BEAN_CLASS_LIST, this.beanClassList);
- this.objectAttachList = new ArrayList<ObjectAttach<?>>();
+ this.objectAttachList = new LinkedList<ObjectAttach<?>>();
this.optionsList.put(AbstractConfig.OBJECT_ATTACH_LIST,
this.objectAttachList);
- this.objectConstantList = new ArrayList<ObjectConstant>();
+ this.objectConstantList = new LinkedList<ObjectConstant>();
this.optionsList.put(AbstractConfig.OBJECT_CONSTANT_LIST,
this.objectConstantList);
- this.objBindingConstantList = new ArrayList<ObjectBindingConstant>();
+ this.objBindingConstantList = new LinkedList<ObjectBindingConstant>();
this.optionsList.put(AbstractConfig.OBJECT_BINDING_CONSTANT_LIST,
this.objBindingConstantList);
- this.objBindingInterceptorList = new
ArrayList<ObjectBindingInterceptor>();
+ this.objBindingInterceptorList = new
LinkedList<ObjectBindingInterceptor>();
this.optionsList.put(AbstractConfig.OBJECT_BINDING_INTERCEPTOR_LIST,
this.objBindingInterceptorList);
}
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/ConfigurationProxy.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/ConfigurationProxy.java
Thu Jul 23 18:03:29 2009
@@ -19,11 +19,11 @@

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;
import java.util.List;
+import java.util.Map;
import java.util.Set;

import net.sf.cglib.proxy.Enhancer;
@@ -51,10 +51,10 @@
Class<? extends Configurable> targetClass = null;

/** The options list. */
- HashMap<String, Object> optionsList = null;
+ Map<String, Object> optionsList = null;

/** The config obj list. */
- HashMap<Class<?>, Object> configObjList = null;
+ Map<Class<?>, Object> configObjList = null;

/** The obj block list. */
List<ObjectBlock> objBlockList = new LinkedList<ObjectBlock>();
@@ -73,8 +73,7 @@
* the config obj list
*/
public ConfigurationProxy(Class<? extends Configurable> targetClass,
- HashMap<String, Object> optionsList,
- HashMap<Class<?>, Object> configObjList) {
+ Map<String, Object> optionsList, Map<Class<?>, Object> configObjList) {

this.targetClass = targetClass;
this.optionsList = optionsList;
@@ -195,7 +194,7 @@
if (!this.objBlockList.isEmpty()) {
ObjectBlock objb = this.objBlockList.get(this.configObjList
.size() - 1);
- ArrayList<Class<?>> clazzList = null;
+ List<Class<?>> clazzList = null;
clazzList = objb.getBlockList();
for (Class<?> clazz : clazzList) {
Object objConfig = this.configObjList.get(clazz);
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/enums/Scope.java
Tue Jul 21 22:10:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/enums/Scope.java
Thu Jul 23 18:03:29 2009
@@ -238,28 +238,26 @@
Provider provider = objFactory.getProvider();
Map<String, ScopeInstance> scopeList = objFactory.getScopeList();
Map<String, Object> mapDirectList = objFactory.getMapDirectList();
- Scope scope = null;
synchronized (scopeList) {
if (scopeList.containsKey(scopeName)) {
- scope = (Scope) scopeList.get(scopeName);
scopeList.remove(scopeName);
}
}
// If is Prototype scope
- if (scope != null) {
- if (scope.equals(Scope.PROTOTYPE)) {
+ if (this != null) {
+ if (this.equals(Scope.PROTOTYPE)) {
throw new InvalidRemovingOperationException(
"Removing Operation does not support prototype-scoped bean !");
}
// If is Singleton scope
- else if (scope.equals(Scope.SINGLETON)) {
+ else if (this.equals(Scope.SINGLETON)) {
synchronized (mapDirectList) {
result = mapDirectList.remove(scopeName);
}
return result;
}
- else if (scope.equals(Scope.REQUEST) || scope.equals(Scope.SESSION)
- || scope.equals(Scope.APPLICATION)) {
+ else if (this.equals(Scope.REQUEST) || this.equals(Scope.SESSION)
+ || this.equals(Scope.APPLICATION)) {
if (!ReflectUtils.isCast(WebProvider.class, provider)) {
throw new InvalidRemovingOperationException(
"This container does not support REQUEST, SESSION or APPLICATION
scope.");
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectAttach.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectAttach.java
Thu Jul 23 18:03:29 2009
@@ -17,7 +17,7 @@
*/
package org.jgentleframework.configure.objectmeta;

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

@@ -181,7 +181,7 @@
*
* @return the scopeList
*/
- public HashMap<Entry<Class<?>, Class<?>>, ScopeInstance> getScopeList();
+ public Map<Entry<Class<?>, Class<?>>, ScopeInstance> getScopeList();

/**
* Returns an array containing all existent class type of current
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectAttachImpl.java
Fri Jul 17 08:54:34 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectAttachImpl.java
Thu Jul 23 18:03:29 2009
@@ -19,6 +19,9 @@

import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Map.Entry;
@@ -39,22 +42,22 @@
*/
public class ObjectAttachImpl<T> implements ObjectAttach<T> {
/** The hash list. */
- private HashMap<Class<?>, Class<?>> hashList = new
HashMap<Class<?>, Class<?>>();
+ private Map<Class<?>, Class<?>> hashList = new HashMap<Class<?>,
Class<?>>();

/** The name. */
- private String name = "";
+ private String name = "";

/** The name bool. */
- private boolean nameBool = true;
+ private boolean nameBool = true;

/** The scope list. */
- private HashMap<Entry<Class<?>, Class<?>>, ScopeInstance> scopeList = new
HashMap<Entry<Class<?>, Class<?>>, ScopeInstance>();
+ private Map<Entry<Class<?>, Class<?>>, ScopeInstance> scopeList = new
HashMap<Entry<Class<?>, Class<?>>, ScopeInstance>();

/** The type list. */
- private ArrayList<Class<?>> typeList = new ArrayList<Class<?>>();
+ private List<Class<?>> typeList = new LinkedList<Class<?>>();

/** lazy_init property, default setting is <b>false</b>. */
- private boolean lazyInit = false;
+ private boolean lazyInit = false;

/**
* The Constructor.
@@ -170,7 +173,7 @@
* ()
*/
@Override
- public HashMap<Entry<Class<?>, Class<?>>, ScopeInstance> getScopeList() {
+ public Map<Entry<Class<?>, Class<?>>, ScopeInstance> getScopeList() {

return scopeList;
}
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectBlock.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectBlock.java
Thu Jul 23 18:03:29 2009
@@ -18,7 +18,8 @@
package org.jgentleframework.configure.objectmeta;

import java.lang.reflect.Method;
-import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;

import org.jgentleframework.utils.Assertor;

@@ -31,9 +32,10 @@
*/
public class ObjectBlock {
/** The block list. */
- ArrayList<Class<?>> blockList = null;
+ List<Class<?>> blockList = null;
+
/** The method. */
- Method method = null;
+ Method method = null;

/**
* Instantiates a new object block.
@@ -48,7 +50,7 @@
Assertor.notNull(interfazes);
Assertor.notNull(method);
this.method = method;
- this.blockList = new ArrayList<Class<?>>();
+ this.blockList = new LinkedList<Class<?>>();
for (Class<?> interfaze : interfazes) {
if (!this.blockList.contains(interfaze)) {
this.blockList.add(interfaze);
@@ -61,7 +63,7 @@
*
* @return the blockList
*/
- public ArrayList<Class<?>> getBlockList() {
+ public List<Class<?>> getBlockList() {

return blockList;
}
@@ -82,7 +84,7 @@
* @param blockList
* the blockList to set
*/
- public void setBlockList(ArrayList<Class<?>> blockList) {
+ public void setBlockList(List<Class<?>> blockList) {

this.blockList = blockList;
}
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectConstantImpl.java
Tue Jul 21 19:08:49 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/configure/objectmeta/ObjectConstantImpl.java
Thu Jul 23 18:03:29 2009
@@ -19,6 +19,9 @@

import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

@@ -41,13 +44,13 @@
*/
public class ObjectConstantImpl implements ObjectConstant {
/** The hash direct list. */
- private HashMap<String, Object> hashDirectList = new HashMap<String,
Object>();
+ private Map<String, Object> hashDirectList = new HashMap<String,
Object>();

/** The str name list. */
- private ArrayList<String> strNameList = new ArrayList<String>();
+ private List<String> strNameList = new LinkedList<String>();

/** The scope instance. */
- private ScopeInstance scope = Scope.SINGLETON;
+ private ScopeInstance scope = Scope.SINGLETON;

/**
* Constructor.
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/AbstractInitLoading.java
Thu Jul 23 05:38:37 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/AbstractInitLoading.java
Thu Jul 23 18:03:29 2009
@@ -72,12 +72,12 @@
List<ObjectConstant> ocList = new LinkedList<ObjectConstant>();
for (Map<String, Object> optionsList : OLArray) {
/***************/
- List<DefinitionPostProcessor> dpp =
(ArrayList<DefinitionPostProcessor>) optionsList
+ List<DefinitionPostProcessor> dpp = (List<DefinitionPostProcessor>)
optionsList
.get(AbstractConfig.DEFINITION_POST_PROCESSOR);
if (dpp != null)
dppList.addAll(dpp);
/***************/
- Map<Class, AnnotationBeanProcessor> abp = (HashMap<Class,
AnnotationBeanProcessor>) optionsList
+ Map<Class, AnnotationBeanProcessor> abp = (Map<Class,
AnnotationBeanProcessor>) optionsList
.get(AbstractConfig.ANNOTATION_BEAN_PROCESSOR_LIST);
if (abp != null)
abpHash.putAll(abp);
@@ -97,7 +97,7 @@
if (obc != null)
obcList.addAll(obc);
/***************/
- List<ObjectConstant> oc = (ArrayList<ObjectConstant>) optionsList
+ List<ObjectConstant> oc = (List<ObjectConstant>) optionsList
.get(AbstractConfig.OBJECT_CONSTANT_LIST);
if (oc != null)
ocList.addAll(oc);
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/AbstractServiceManagement.java
Thu Jul 23 05:38:37 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/AbstractServiceManagement.java
Thu Jul 23 18:03:29 2009
@@ -18,6 +18,7 @@
package org.jgentleframework.context;

import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -192,10 +193,11 @@
@Override
protected void init(List<Map<String, Object>> OLArray) {

- ArrayList<ObjectBindingInterceptor> obiList = new
ArrayList<ObjectBindingInterceptor>();
+ List<ObjectBindingInterceptor> obiList = new
LinkedList<ObjectBindingInterceptor>();
for (Map<String, Object> optionsList : OLArray) {
- obiList.addAll((ArrayList<ObjectBindingInterceptor>) optionsList
- .get(AbstractConfig.OBJECT_BINDING_INTERCEPTOR_LIST));
+ obiList
+ .addAll((Collection<? extends ObjectBindingInterceptor>) optionsList
+ .get(AbstractConfig.OBJECT_BINDING_INTERCEPTOR_LIST));
}
for (int i = 0; i < obiList.size(); i++) {
ObjectBindingInterceptor obi = obiList.get(i);
=======================================
--- /trunk/JGentleProject/src/org/jgentleframework/context/JGentle.java Fri
Jul 17 08:54:34 2009
+++ /trunk/JGentleProject/src/org/jgentleframework/context/JGentle.java Thu
Jul 23 18:03:29 2009
@@ -377,17 +377,10 @@
* @return the provider
*/
@SuppressWarnings("unchecked")
- public static Provider buildProvider(Class... configClasses) {
-
- try {
- return (Provider) buildContext(false, null, null,
- (Class<? extends Configurable>[]) configClasses);
- }
- catch (ClassCastException e) {
- throw new IllegalArgumentException(
- "The configurable class is not an implementation of '"
- + Configurable.class.toString() + "'");
- }
+ public static Provider buildProvider(Class<?>... configClasses) {
+
+ return (Provider) buildContext(false, null, null,
+ (Class<? extends Configurable>[]) configClasses);
}

/**
@@ -429,15 +422,7 @@
@SuppressWarnings("unchecked")
public static ServiceProvider buildServiceProvider(Class...
configClasses) {

- try {
- return JGentle.buildServiceProvider(null, null,
- (Class<? extends Configurable>[]) configClasses);
- }
- catch (ClassCastException e) {
- throw new IllegalArgumentException(
- "The configurable class is not an implementation of '"
- + Configurable.class.toString() + "'");
- }
+ return JGentle.buildServiceProvider(null, null, configClasses);
}

/**
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/AbstractBeanCacher.java
Thu Jul 23 05:38:37 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/AbstractBeanCacher.java
Thu Jul 23 18:03:29 2009
@@ -65,7 +65,7 @@
protected Map<Class<?>, Class<?>> mappingList = null;

/** The NULL sharedobject. */
- protected final Object NULL_SHAREDOBJECT = new Object();
+ public static final Object NULL_SHAREDOBJECT = new Object();

/** The root scope name. */
protected Map<Object, SingletonInstanceScopeName> rootScopeName = new
HashMap<Object, SingletonInstanceScopeName>();
@@ -137,7 +137,7 @@
root = str;
scopeName = Utils.createScopeName(instanceName);
this.rootScopeName.put(root, new SingletonInstanceScopeName(
- scopeName, NULL_SHAREDOBJECT));
+ scopeName, AbstractBeanCacher.NULL_SHAREDOBJECT));
}
}
ScopeInstance scope = null;
@@ -147,7 +147,7 @@
// If is Singleton scope
if ((scope != null && scope.equals(Scope.SINGLETON))) {
this.rootScopeName.put(root, new SingletonInstanceScopeName(
- scopeName, NULL_SHAREDOBJECT));
+ scopeName, AbstractBeanCacher.NULL_SHAREDOBJECT));
}
return new AppropriateScopeNameClass(clazz, targetClass, definition,
ref, scopeName, mappingName);
@@ -178,7 +178,7 @@
SecurityException, InstantiationException, IllegalAccessException,
NoSuchMethodException {

- Object result = NULL_SHAREDOBJECT;
+ Object result = AbstractBeanCacher.NULL_SHAREDOBJECT;
Definition definition = targetSelector.getDefinition();
// find in cache
CachedConstructor cons = cachingList.get(definition);
@@ -186,12 +186,6 @@
int hashcodeID = cons.hashcodeID();
if (hashcodeID == (definition.hashCode() ^ cons.hashCode())) {
result = cons.newInstance(targetSelector.getArgs());
- // executes process after bean is created
- // MetaDefObject metaObj = new MetaDefObject();
- // AbstractProcesserChecker.findInOutNonRuntime(metaObj,
- // definition);
- // AbstractProcesserChecker.prepareSingletonBean(targetSelector,
- // this, result);
CommonFactory.singleton().executeProcessAfterBeanCreated(
targetSelector.getTargetClass(),
cons.getMetaDefObject(), this, result, definition);
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/AbstractBeanFactory.java
Thu Jul 23 05:38:37 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/AbstractBeanFactory.java
Thu Jul 23 18:03:29 2009
@@ -362,8 +362,11 @@
try {
if (scope != null && !scope.equals(Scope.SINGLETON)) {
result = returnsCachingResult(coreSelector);
- if (result == NULL_SHAREDOBJECT) {
- return getBeanInstance(coreSelector);
+ if (result != AbstractBeanCacher.NULL_SHAREDOBJECT) {
+ return result;
+ }
+ else {
+ result = getBeanInstance(coreSelector);
}
}
else
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/autodetect/ExtensionPointsDetector.java
Thu Jul 23 05:38:37 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/context/injecting/autodetect/ExtensionPointsDetector.java
Thu Jul 23 18:03:29 2009
@@ -17,7 +17,6 @@
*/
package org.jgentleframework.context.injecting.autodetect;

-import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -320,9 +319,10 @@
obcList
.addAll((Collection<? extends ObjectBindingConstant>) optionsList
.get(AbstractConfig.OBJECT_BINDING_CONSTANT_LIST));
- objectAttachList.addAll((ArrayList<ObjectAttach<?>>) optionsList
- .get(AbstractConfig.OBJECT_ATTACH_LIST));
- beanClassList.addAll((ArrayList<Class<?>>) optionsList
+ objectAttachList
+ .addAll((Collection<? extends ObjectAttach<?>>) optionsList
+ .get(AbstractConfig.OBJECT_ATTACH_LIST));
+ beanClassList.addAll((Collection<? extends Class<?>>) optionsList
.get(AbstractConfig.BEAN_CLASS_LIST));
}
/*
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/core/factory/InOutExecutor.java
Thu Jul 23 05:38:37 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/core/factory/InOutExecutor.java
Thu Jul 23 18:03:29 2009
@@ -20,9 +20,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

@@ -35,6 +33,7 @@
import org.jgentleframework.configure.enums.WrapperPrimitiveTypeList;
import org.jgentleframework.context.beans.Builder;
import org.jgentleframework.context.beans.Filter;
+import org.jgentleframework.context.injecting.AbstractBeanCacher;
import org.jgentleframework.context.injecting.Provider;
import
org.jgentleframework.context.injecting.scope.InvalidAddingOperationException;
import org.jgentleframework.context.injecting.scope.ScopeImplementation;
@@ -80,23 +79,20 @@

Map<Field, Object> result = new HashMap<Field, Object>();
if (fields != null) {
- List<Field> fieldList = new ArrayList<Field>();
- for (Field field : fields) {
- Definition defField = definition.getMemberDefinition(field);
+ for (int i = 0; i < fields.length; i++) {
+ Definition defField = definition.getMemberDefinition(fields[i]);
if (defField != null
&& defField.isAnnotationPresent(Inject.class)) {
Inject inject = defField.getAnnotation(Inject.class);
Object injected = InOutExecutor.getInjectedDependency(
- inject, field.getType(), provider);
- field.setAccessible(true);
- Object current = field.get(target);
+ inject, fields[i].getType(), provider);
+ fields[i].setAccessible(true);
+ Object current = fields[i].get(target);
if (inject.alwaysInject() == false && current != null) {
continue;
}
- result.put(field, current);
- field.set(target, injected);
- if (!fieldList.contains(field))
- fieldList.add(field);
+ result.put(fields[i], current);
+ fields[i].set(target, injected);
}
else
continue;
@@ -126,24 +122,24 @@
throws IllegalArgumentException, IllegalAccessException {

if (fields != null) {
- for (Field field : fields) {
+ for (int i = 0; i < fields.length; i++) {
Object outjectObj = null;
- Definition defField = definition.getMemberDefinition(field);
+ Definition defField = definition.getMemberDefinition(fields[i]);
if (defField != null
&& defField.isAnnotationPresent(Outject.class)) {
Outject outject = defField.getAnnotation(Outject.class);
- field.setAccessible(true);
- outjectObj = field.get(target);
+ fields[i].setAccessible(true);
+ outjectObj = fields[i].get(target);
/*
* Executes builder
*/
if (ReflectUtils.isCast(Builder.class, target)) {
Builder builder = (Builder) target;
- if (builder.getOutjectValue(field) != null)
- outjectObj = builder.getOutjectValue(field);
+ if (builder.getOutjectValue(fields[i]) != null)
+ outjectObj = builder.getOutjectValue(fields[i]);
}
InOutExecutor.setOutjectedDependency(outject, outjectObj,
- provider, field.getClass());
+ provider, fields[i].getClass());
}
else
continue;
@@ -178,18 +174,19 @@

Map<Field, Object> result = new HashMap<Field, Object>();
if (setters != null) {
- for (Method method : setters) {
- Definition defMethod = definition.getMemberDefinition(method);
+ for (int i = 0; i < setters.length; i++) {
+ Definition defMethod = definition
+ .getMemberDefinition(setters[i]);
if (defMethod == null)
continue;
else {
- Object[] args = Utils.getInjectedParametersOf(method,
+ Object[] args = Utils.getInjectedParametersOf(setters[i],
defMethod, provider);
- method.setAccessible(true);
+ setters[i].setAccessible(true);
// Find field corresponding to setter method.
Field field = null;
try {
- field = Utils.getFieldOfDefaultSetGetter(method,
+ field = Utils.getFieldOfDefaultSetGetter(setters[i],
(Class<?>) definition.getKey());
field.setAccessible(true);
result.put(field, field.get(target));
@@ -199,7 +196,7 @@
}
catch (NoSuchFieldException e) {
}
- method.invoke(target, args);
+ setters[i].invoke(target, args);
}
}
}
@@ -270,7 +267,6 @@
Field field = entry.getKey();
field.setAccessible(true);
field.set(target, entry.getValue());
- field.setAccessible(false);
}
}
}
@@ -299,22 +295,23 @@
InvocationTargetException {

if (getters != null) {
- for (Method method : getters) {
- Definition defMethod = definition.getMemberDefinition(method);
+ for (int i = 0; i < getters.length; i++) {
+ Definition defMethod = definition
+ .getMemberDefinition(getters[i]);
if (defMethod == null)
continue;
else {
- Class<?> returnType = method.getReturnType();
- Object[] args = Utils.getInjectedParametersOf(method,
+ Class<?> returnType = getters[i].getReturnType();
+ Object[] args = Utils.getInjectedParametersOf(getters[i],
defMethod, provider);
Object outjectObj = null;
- method.setAccessible(true);
- outjectObj = args.length == 0 ? method.invoke(target)
- : method.invoke(target, args);
+ getters[i].setAccessible(true);
+ outjectObj = args.length == 0 ? getters[i].invoke(target)
+ : getters[i].invoke(target, args);
Outject outject = defMethod.getAnnotation(Outject.class);
Field field = null;
try {
- field = Utils.getFieldOfDefaultSetGetter(method,
+ field = Utils.getFieldOfDefaultSetGetter(getters[i],
(Class<?>) definition.getKey());
}
catch (InvalidOperationException e) {
@@ -360,12 +357,12 @@
if (provider != null) {
if (value != null && !value.isEmpty()) {
result = provider.getBean(value);
- result = result == null || result == NullClass.class ? provider
- .getBean(type) : result;
+ if (result == null || result == NullClass.class
+ || result == AbstractBeanCacher.NULL_SHAREDOBJECT)
+ result = provider.getBean(type);
}
else {
- if (result == null)
- result = provider.getBean(type);
+ result = provider.getBean(type);
}
}
else {
@@ -376,12 +373,13 @@
}
}
// checking constrant
- if ((result == null || result == NullClass.class)
+ if ((result == null || result == NullClass.class || result ==
AbstractBeanCacher.NULL_SHAREDOBJECT)
&& inject.required() == true) {
throw new RequiredException(
"Injected dependency object must not be null.");
}
- if (result != null && result != NullClass.class && type.isPrimitive()) {
+ if (result != null && result != NullClass.class && type.isPrimitive()
+ && result != AbstractBeanCacher.NULL_SHAREDOBJECT) {
int i = 0;
for (WrapperPrimitiveTypeList wt : WrapperPrimitiveTypeList
.values()) {
@@ -400,9 +398,9 @@
"Can not identify the primitive type '" + type + "'");
}
}
- else if (result != null && result != NullClass.class) {
+ else if (result != null && result != NullClass.class
+ && result != AbstractBeanCacher.NULL_SHAREDOBJECT) {
if (!ReflectUtils.isCast(type, result)) {
- System.out.println(result);
throw new InOutDependencyException(
"The injected dependency instance can not be cast to '"
+ type + "'");
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/core/factory/support/CachedConstructor.java
Tue Jul 21 21:08:46 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/core/factory/support/CachedConstructor.java
Thu Jul 23 18:03:29 2009
@@ -17,6 +17,7 @@
*/
package org.jgentleframework.core.factory.support;

+import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
@@ -48,6 +49,13 @@
* @param mdo
*/
void setMetaDefObject(MetaDefObject mdo);
+
+ /**
+ * Gets the java constructor.
+ *
+ * @return the java constructor
+ */
+ Constructor<?> getJavaConstructor();

/**
* Returns the hashcodeID of this {@link CachedConstructor}
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/core/factory/support/CommonFactory.java
Tue Jul 21 22:10:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/core/factory/support/CommonFactory.java
Thu Jul 23 18:03:29 2009
@@ -53,7 +53,7 @@
/**
* Returns a unique instance of {@link CommonFactory}.
*
- * @return {@link CommonFactory}
+ * @return {@link CommonFactory} instance
*/
public static CommonFactory singleton() {

@@ -70,7 +70,7 @@
/**
* Do init.
*
- * @param def
+ * @param definition
* the definition
* @param obj
* object bean
@@ -87,7 +87,7 @@
* @throws SecurityException
* the security exception
*/
- public void doInit(Definition def, Object obj, Class<?> clazz)
+ public void doInit(Definition definition, Object obj, Class<?> clazz)
throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException, SecurityException, NoSuchMethodException {

@@ -95,7 +95,7 @@
((Initializing) obj).activate();
}
else {
- List<Method> methods = def
+ List<Method> methods = definition
.getMethodsAnnotatedWith(InitializingMethod.class);
if (methods != null && methods.size() != 0) {
for (Method method : methods) {
=======================================
---
/trunk/JGentleProject/src/org/jgentleframework/core/provider/DomainManagerImpl.java
Fri May 15 05:16:41 2009
+++
/trunk/JGentleProject/src/org/jgentleframework/core/provider/DomainManagerImpl.java
Thu Jul 23 18:03:29 2009
@@ -20,6 +20,7 @@
import java.beans.beancontext.BeanContextSupport;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Map;

import org.jgentleframework.core.JGentleException;
import org.jgentleframework.core.handling.DefinitionManager;
@@ -34,10 +35,10 @@
*/
public class DomainManagerImpl implements DomainManager {
/** The domain list. */
- HashMap<String, Domain> domainList = new HashMap<String, Domain>();
+ Map<String, Domain> domainList = new HashMap<String, Domain>();

/** The def manager. */
- DefinitionManager definitionManager;
+ DefinitionManager definitionManager;

/**
* Instantiates a new domain manager impl.
=======================================
--- /trunk/JGentleProject/src/org/jgentleframework/utils/Utils.java Tue Jul
21 21:08:46 2009
+++ /trunk/JGentleProject/src/org/jgentleframework/utils/Utils.java Thu Jul
23 18:03:29 2009
@@ -22,6 +22,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -138,6 +139,12 @@

this.mdoInner = mdo;
}
+
+ @Override
+ public Constructor<?> getJavaConstructor() {
+
+ return fastConstructor.getJavaConstructor();
+ }
};
}

@@ -379,6 +386,17 @@
return null;
}
}
+ if (getter != null && !Modifier.isPublic(getter.getModifiers()))
+ try {
+ throw new IllegalAccessException();
+ }
+ catch (IllegalAccessException e) {
+ if (log.isErrorEnabled()) {
+ log.error("The getter method [" + getter.getName()
+ + "] declared in [" + declaringClass
+ + "] must be public", e);
+ }
+ }
return getter;
}

@@ -396,15 +414,31 @@
String fieldName) {

Method setter = null;
+ Field field = null;
String methodName = "set" + fieldName.substring(0, 1).toUpperCase()
+ fieldName.substring(1);
try {
+ field = ReflectUtils.getSupportedField(declaringClass, fieldName);
setter = ReflectUtils.getSupportedMethod(declaringClass,
- methodName, null);
+ methodName, new Class<?>[] { field.getType() });
+ }
+ catch (NoSuchFieldException e1) {
+ return null;
}
catch (NoSuchMethodException e) {
return null;
}
+ try {
+ if (setter != null && !Modifier.isPublic(setter.getModifiers()))
+ throw new IllegalAccessException();
+ }
+ catch (IllegalAccessException e) {
+ if (log.isErrorEnabled()) {
+ log.error("The setter method [" + methodName
+ + "] declared in [" + declaringClass
+ + "] must be public", e);
+ }
+ }
return setter;
}

Reply all
Reply to author
Forward
0 new messages