You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2011/03/03 14:14:37 UTC
svn commit: r1076613 -
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
Author: struberg
Date: Thu Mar 3 13:14:37 2011
New Revision: 1076613
URL: http://svn.apache.org/viewvc?rev=1076613&view=rev
Log:
OWB-539 also treat typeClosures lazily
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java?rev=1076613&r1=1076612&r2=1076613&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java Thu Mar 3 13:14:37 2011
@@ -38,7 +38,7 @@ abstract class AbstractAnnotated impleme
private final Type baseType;
/**Type closures*/
- private Set<Type> typeClosures = new HashSet<Type>();
+ private Set<Type> typeClosures = null;
/**Set of annotations*/
private Set<Annotation> annotations = new HashSet<Annotation>();
@@ -51,8 +51,6 @@ abstract class AbstractAnnotated impleme
protected AbstractAnnotated(Type baseType)
{
this.baseType = baseType;
- this.typeClosures.add(Object.class);
- ClassUtil.setTypeHierarchy(this.typeClosures, this.baseType);
}
/**
@@ -69,7 +67,7 @@ abstract class AbstractAnnotated impleme
/**
* Adds new annotation to set.
*
- * @param annotation new annotation
+ * @param annotations new annotations
*/
protected void setAnnotations(Annotation[] annotations)
{
@@ -123,7 +121,21 @@ abstract class AbstractAnnotated impleme
@Override
public Set<Type> getTypeClosure()
{
- return this.typeClosures;
+ if (typeClosures == null)
+ {
+ initTypeClosures();
+ }
+ return typeClosures;
+ }
+
+ private synchronized void initTypeClosures()
+ {
+ if (typeClosures == null)
+ {
+ typeClosures = new HashSet<Type>();
+ this.typeClosures.add(Object.class);
+ ClassUtil.setTypeHierarchy(this.typeClosures, this.baseType);
+ }
}
/**
@@ -148,7 +160,7 @@ abstract class AbstractAnnotated impleme
StringBuilder builder = new StringBuilder();
builder.append("Base Type : " + baseType.toString() + ",");
- builder.append("Type Closures : " + typeClosures.toString() + ",");
+ builder.append("Type Closures : " + typeClosures + ",");
builder.append("Annotations : " + annotations.toString());
return builder.toString();