[webbeans-commits] Webbeans SVN: r2067 - ri/trunk/impl.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-17 08:55:57 -0400 (Tue, 17 Mar 2009)
New Revision: 2067
Modified:
ri/trunk/impl/pom.xml
Log:
mark log4j optional
Modified: ri/trunk/impl/pom.xml
===================================================================
--- ri/trunk/impl/pom.xml 2009-03-17 11:54:05 UTC (rev 2066)
+++ ri/trunk/impl/pom.xml 2009-03-17 12:55:57 UTC (rev 2067)
@@ -83,6 +83,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2066 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: helpers and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-03-17 07:54:05 -0400 (Tue, 17 Mar 2009)
New Revision: 2066
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
Log:
minor
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java 2009-03-17 11:37:31 UTC (rev 2065)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java 2009-03-17 11:54:05 UTC (rev 2066)
@@ -35,7 +35,6 @@
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.Elements;
import org.jboss.webbeans.xsd.helpers.DataSetter;
import org.jboss.webbeans.xsd.helpers.XSDHelper;
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 11:37:31 UTC (rev 2065)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 11:54:05 UTC (rev 2066)
@@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;
-import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.PackageElement;
import javax.tools.StandardLocation;
@@ -32,7 +31,6 @@
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
-import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
@@ -47,7 +45,6 @@
*/
public class XSDHelper
{
-
// The annotation processing environment
private ProcessingEnvironment processingEnvironment;
// The cache of already processed classes
@@ -90,7 +87,7 @@
private Document createSchema(String packageName)
{
Document packageXSD = DocumentHelper.createDocument();
- packageXSD.addElement("Package");
+ packageXSD.addElement("schema");
return packageXSD;
}
@@ -123,39 +120,15 @@
}
}
- /**
- * Writes package info to the disk
- *
- * @param schema The package info to store
- */
- private void writePackageInfo(Schema schema)
+ private void writeSchema(Schema schema) throws IOException
{
- try
- {
- writeSchema(schema.getPackageName(), schema.getDocument());
- }
- catch (IOException e)
- {
- throw new RuntimeException("Could not write schema for " + schema.getPackageName());
- }
- }
-
- /**
- * Writes a schema to disk
- *
- * @param packageName The package name
- * @param schema The schema
- * @throws IOException If the file could not be written
- */
- private void writeSchema(String packageName, Document schema) throws IOException
- {
OutputStream out = null;
try
{
OutputFormat format = OutputFormat.createPrettyPrint();
- out = processingEnvironment.getFiler().createResource(StandardLocation.CLASS_OUTPUT, packageName, "schema.xsd").openOutputStream();
+ out = processingEnvironment.getFiler().createResource(StandardLocation.CLASS_OUTPUT, schema.getPackageName(), "schema.xsd").openOutputStream();
XMLWriter writer = new XMLWriter(out, format);
- writer.write(schema);
+ writer.write(schema.getDocument());
writer.flush();
writer.close();
}
@@ -209,7 +182,14 @@
{
schema.rebuild(packageModels.get(schema.getPackageName()));
System.out.println(schema.getPackageName() + " (" + schema.getNamespaces() + ")");
- writePackageInfo(schema);
+ try
+ {
+ writeSchema(schema);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Could not write schema for " + schema.getPackageName());
+ }
}
}
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2065 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-17 07:37:31 -0400 (Tue, 17 Mar 2009)
New Revision: 2065
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
Log:
minor
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java 2009-03-17 11:33:34 UTC (rev 2064)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java 2009-03-17 11:37:31 UTC (rev 2065)
@@ -33,5 +33,6 @@
public void testQualifiedNameLookup()
{
assert getCurrentConfiguration().getEl().evaluateValueExpression("#{javax.context.conversation}", Conversation.class) != null;
+ assert getCurrentConfiguration().getEl().evaluateValueExpression("#{javax.context.conversation}", Conversation.class) instanceof Conversation;
}
}
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2064 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: helpers and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-03-17 07:33:34 -0400 (Tue, 17 Mar 2009)
New Revision: 2064
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
Log:
some more xsd stuff
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java 2009-03-17 09:24:27 UTC (rev 2063)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageSchemaGenerator.java 2009-03-17 11:33:34 UTC (rev 2064)
@@ -18,7 +18,9 @@
package org.jboss.webbeans.xsd;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
@@ -28,10 +30,12 @@
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.Elements;
import org.jboss.webbeans.xsd.helpers.DataSetter;
import org.jboss.webbeans.xsd.helpers.XSDHelper;
@@ -52,29 +56,32 @@
XSDHelper helper;
@Override
- public synchronized void init(ProcessingEnvironment processingEnv)
+ public synchronized void init(ProcessingEnvironment processingEnvironment)
{
- super.init(processingEnv);
- helper = new XSDHelper(processingEnv.getFiler());
+ super.init(processingEnvironment);
+ helper = new XSDHelper(processingEnvironment);
}
@Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment)
{
+ Map<String, PackageElement> packageModels = new HashMap<String, PackageElement>();
List<ClassModel> workingSet = new ArrayList<ClassModel>();
+
// Iterates over the classes compiled, creates a model of the classes and
// add them to a working set
-
- for (Element element : roundEnv.getRootElements())
+ for (Element element : roundEnvironment.getRootElements())
{
- workingSet.add(inspectClass(element));
+ ClassModel classModel = inspectClass(element);
+ workingSet.add(classModel);
+ packageModels.put(classModel.getPackage(), processingEnv.getElementUtils().getPackageOf(element));
}
- if (!roundEnv.processingOver())
+ if (!roundEnvironment.processingOver())
{
// Update the package XSDs for the files changed
helper.updateSchemas(workingSet);
// And flush the changes to disk
- helper.writeSchemas();
+ helper.writeSchemas(packageModels);
}
return false;
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java 2009-03-17 09:24:27 UTC (rev 2063)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java 2009-03-17 11:33:34 UTC (rev 2064)
@@ -17,9 +17,14 @@
package org.jboss.webbeans.xsd;
+import java.util.HashSet;
import java.util.Set;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
+
import org.dom4j.Document;
+import org.jboss.webbeans.xsd.model.ClassModel;
import org.jboss.webbeans.xsd.model.TypedModel;
/**
@@ -33,21 +38,21 @@
private String packageName;
private Document document;
private NamespaceHandler namespaceHandler;
+ private Set<ClassModel> classModels;
public Schema(String packageName)
{
this.packageName = packageName;
namespaceHandler = new NamespaceHandler(packageName);
+ classModels = new HashSet<ClassModel>();
}
- public void addTypeReferences(Set<TypedModel> references)
+ public void addClass(ClassModel classModel)
{
- for (TypedModel reference : references)
+ classModels.add(classModel);
+ for (TypedModel reference : classModel.getTypeReferences())
{
- if (!reference.isPrimitive())
- {
- namespaceHandler.addPackage(reference.getTypePackage());
- }
+ namespaceHandler.addPackage(reference.getTypePackage());
}
}
@@ -76,4 +81,13 @@
return namespaceHandler.getUsedNamespaces();
}
+ public void rebuild(PackageElement packageElement)
+ {
+ System.out.println("Stuff in " + packageName);
+ for (Element e : packageElement.getEnclosedElements())
+ {
+ System.out.println(e.asType().toString());
+ }
+ }
+
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 09:24:27 UTC (rev 2063)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 11:33:34 UTC (rev 2064)
@@ -25,6 +25,8 @@
import java.util.Map;
import javax.annotation.processing.Filer;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.PackageElement;
import javax.tools.StandardLocation;
import org.dom4j.Document;
@@ -46,8 +48,8 @@
public class XSDHelper
{
- // The filed of the annotation processing environment
- private Filer filer;
+ // The annotation processing environment
+ private ProcessingEnvironment processingEnvironment;
// The cache of already processed classes
private Map<String, ClassModel> classModelCache = new HashMap<String, ClassModel>();
// The XSD documents of the affected packages
@@ -58,9 +60,9 @@
*
* @param filer The filer of the processing environment
*/
- public XSDHelper(Filer filer)
+ public XSDHelper(ProcessingEnvironment processingEnvironment)
{
- this.filer = filer;
+ this.processingEnvironment = processingEnvironment;
}
/**
@@ -105,7 +107,7 @@
InputStream in = null;
try
{
- in = filer.getResource(StandardLocation.CLASS_OUTPUT, packageName, "schema.xsd").openInputStream();
+ in = processingEnvironment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, packageName, "schema.xsd").openInputStream();
return new SAXReader().read(in);
}
catch (IOException e)
@@ -151,7 +153,7 @@
try
{
OutputFormat format = OutputFormat.createPrettyPrint();
- out = filer.createResource(StandardLocation.CLASS_OUTPUT, packageName, "schema.xsd").openOutputStream();
+ out = processingEnvironment.getFiler().createResource(StandardLocation.CLASS_OUTPUT, packageName, "schema.xsd").openOutputStream();
XMLWriter writer = new XMLWriter(out, format);
writer.write(schema);
writer.flush();
@@ -193,43 +195,25 @@
}
schemaMap.put(packageName, schema);
}
- updateClassInSchema(classModel, schema);
+ schema.addClass(classModel);
}
}
/**
* Writes the schemas back to disk
+ * @param packageModels
*/
- public void writeSchemas()
+ public void writeSchemas(Map<String, PackageElement> packageModels)
{
for (Schema schema : schemaMap.values())
{
+ schema.rebuild(packageModels.get(schema.getPackageName()));
System.out.println(schema.getPackageName() + " (" + schema.getNamespaces() + ")");
writePackageInfo(schema);
}
}
/**
- * Updates a schema with XSD from a file model
- *
- * @param schema The schema
- * @param classModel The class model
- */
- private void updateClassInSchema(ClassModel classModel, Schema schema)
- {
- Document document = schema.getDocument();
- Node oldClassModel = document.selectSingleNode("//" + classModel.getSimpleName());
- if (oldClassModel != null)
- {
- // Remove the old class definition
- document.getRootElement().remove(oldClassModel);
- }
- // Create a new one
- document.getRootElement().addElement(classModel.getSimpleName());
- schema.addTypeReferences(classModel.getTypeReferences());
- }
-
- /**
* Gets a cached class model
*
* @param FQN The FQN of the class
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java 2009-03-17 09:24:27 UTC (rev 2063)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java 2009-03-17 11:33:34 UTC (rev 2064)
@@ -165,21 +165,34 @@
Set<TypedModel> typeReferences = new HashSet<TypedModel>();
for (FieldModel field : getMergedFields())
{
- typeReferences.add(field);
+ if (!field.isPrimitive())
+ {
+ typeReferences.add(field);
+ }
}
for (MethodModel method : getMergedMethods())
{
- typeReferences.add(method.getReturnType());
+ TypedModel returnValue = method.getReturnType();
+ if (!returnValue.isPrimitive())
+ {
+ typeReferences.add(returnValue);
+ }
for (ParameterModel parameter : method.getParameters())
{
- typeReferences.add(parameter);
+ if (!parameter.isPrimitive())
+ {
+ typeReferences.add(parameter);
+ }
}
}
for (MethodModel constructor : getMergedConstructors())
{
for (ParameterModel parameter : constructor.getParameters())
{
- typeReferences.add(parameter);
+ if (!parameter.isPrimitive())
+ {
+ typeReferences.add(parameter);
+ }
}
}
return typeReferences;
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2063 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: helpers and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-03-17 05:24:27 -0400 (Tue, 17 Mar 2009)
New Revision: 2063
Added:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/test/test/
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/test/test/Tar.java
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java
Log:
xsd: minor refactorings
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java 2009-03-17 08:51:29 UTC (rev 2062)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java 2009-03-17 09:24:27 UTC (rev 2063)
@@ -50,6 +50,7 @@
public NamespaceHandler(String localPackage)
{
this.localPackage = localPackage;
+ addPackage(localPackage);
}
/**
@@ -109,6 +110,44 @@
{
return schemaNamespaces.get(packageName).shortNamespace;
}
+ else
+ {
+ throw new IllegalArgumentException("Package name " + packageName + " is not known to namespace handler of package " + localPackage);
+ }
+ }
+
+ /**
+ * Gets the short name (last part) of a package
+ *
+ * @param packageName The package name to parse
+ * @return The short name
+ */
+ private String getShortName(String packageName)
+ {
+ int lastDot = packageName.lastIndexOf(".");
+ return lastDot < 0 ? packageName : packageName.substring(lastDot + 1);
+ }
+
+ // TODO testing, remove
+ public static void main(String[] params)
+ {
+ NamespaceHandler ng = new NamespaceHandler("com.acme.foo");
+ System.out.println(ng.getShortNamespace("com.acme.foo"));
+ System.out.println(ng.getShortNamespace("com.acme.foo.foo"));
+ System.out.println(ng.getShortNamespace("com.acme.foo.foo.foo"));
+ System.out.println(ng.getShortNamespace("java.util"));
+ for (String ns : ng.getUsedNamespaces())
+ {
+ System.out.println(ns);
+ }
+ }
+
+ public void addPackage(String packageName)
+ {
+ if (schemaNamespaces.containsKey(packageName))
+ {
+ return;
+ }
String shortNamespace = "";
boolean ee = false;
if (localPackage.equals(packageName))
@@ -138,33 +177,6 @@
shortNamespace = getShortName(packageName) + countString;
}
schemaNamespaces.put(packageName, new SchemaNamespace(packageName, shortNamespace, ee));
- return shortNamespace;
}
- /**
- * Gets the short name (last part) of a package
- *
- * @param packageName The package name to parse
- * @return The short name
- */
- private String getShortName(String packageName)
- {
- int lastDot = packageName.lastIndexOf(".");
- return lastDot < 0 ? packageName : packageName.substring(lastDot + 1);
- }
-
- // TODO testing, remove
- public static void main(String[] params)
- {
- NamespaceHandler ng = new NamespaceHandler("com.acme.foo");
- System.out.println(ng.getShortNamespace("com.acme.foo"));
- System.out.println(ng.getShortNamespace("com.acme.foo.foo"));
- System.out.println(ng.getShortNamespace("com.acme.foo.foo.foo"));
- System.out.println(ng.getShortNamespace("java.util"));
- for (String ns : ng.getUsedNamespaces())
- {
- System.out.println(ns);
- }
- }
-
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java 2009-03-17 08:51:29 UTC (rev 2062)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java 2009-03-17 09:24:27 UTC (rev 2063)
@@ -17,9 +17,6 @@
package org.jboss.webbeans.xsd;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.dom4j.Document;
@@ -33,15 +30,13 @@
*/
public class Schema
{
- private Document document;
private String packageName;
- private Map<String, Set<String>> typeReferences;
+ private Document document;
private NamespaceHandler namespaceHandler;
public Schema(String packageName)
{
this.packageName = packageName;
- typeReferences = new HashMap<String, Set<String>>();
namespaceHandler = new NamespaceHandler(packageName);
}
@@ -49,13 +44,10 @@
{
for (TypedModel reference : references)
{
- Set<String> typeNames = typeReferences.get(reference.getTypePackage());
- if (typeNames == null)
+ if (!reference.isPrimitive())
{
- typeNames = new HashSet<String>();
- typeReferences.put(reference.getTypePackage(), typeNames);
+ namespaceHandler.addPackage(reference.getTypePackage());
}
- typeNames.add(reference.getType());
}
}
@@ -79,23 +71,6 @@
this.packageName = packageName;
}
- public Map<String, Set<String>> getTypeReferences()
- {
- return typeReferences;
- }
-
- // TODO: dummy, remove
- public void refreshNamespaces()
- {
- for (String p : typeReferences.keySet())
- {
- if (!"".equals(p))
- {
- String dummy = namespaceHandler.getShortNamespace(p);
- }
- }
- }
-
public Set<String> getNamespaces()
{
return namespaceHandler.getUsedNamespaces();
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 08:51:29 UTC (rev 2062)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 09:24:27 UTC (rev 2063)
@@ -204,10 +204,7 @@
{
for (Schema schema : schemaMap.values())
{
- // TODO: dummy, remove
- schema.refreshNamespaces();
System.out.println(schema.getPackageName() + " (" + schema.getNamespaces() + ")");
- System.out.println(schema.getTypeReferences());
writePackageInfo(schema);
}
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java 2009-03-17 08:51:29 UTC (rev 2062)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/Foo.java 2009-03-17 09:24:27 UTC (rev 2063)
@@ -3,6 +3,8 @@
import javax.inject.Current;
import javax.inject.Initializer;
+import org.jboss.webbeans.xsd.test.test.test.Tar;
+
@Current
public class Foo
{
@@ -10,6 +12,8 @@
public String foo;
public int poo;
public Bar bar;
+ public org.jboss.webbeans.xsd.test.test.Foo foo2;
+ public Tar tar;
@Initializer
public Foo(String foo)
Added: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/test/test/Tar.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/test/test/Tar.java (rev 0)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/test/test/test/Tar.java 2009-03-17 09:24:27 UTC (rev 2063)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.xsd.test.test.test;
+
+public class Tar
+{
+
+}
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2062 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: helpers and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-03-17 04:51:29 -0400 (Tue, 17 Mar 2009)
New Revision: 2062
Added:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
Removed:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
Log:
minor. renames/moves
Copied: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java (from rev 2061, extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java)
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java (rev 0)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java 2009-03-17 08:51:29 UTC (rev 2062)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.xsd;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Helper for generating and keeping track of namespaces in a schema
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class NamespaceHandler
+{
+ // The set of reserved EE packages
+ private static final Set<String> URN_JAVA_EE = new HashSet<String>(Arrays.asList("java.lang", "java.util", "javax.annotation", "javax.inject", "javax.context", "javax.interceptor", "javax.decorator", "javax.event", "javax.ejb", "javax.persistence", "javax.xml.ws", "javax.jms", "javax.sql"));
+
+ // The local package of the scema
+ private String localPackage;
+
+ // Duplicate shortname counters
+ private Map<String, Integer> counters = new HashMap<String, Integer>();
+ // Namespace infos
+ private Map<String, SchemaNamespace> schemaNamespaces = new HashMap<String, SchemaNamespace>();
+
+ /**
+ * Creats a new namespace generator
+ *
+ * @param localPackage The local package
+ */
+ public NamespaceHandler(String localPackage)
+ {
+ this.localPackage = localPackage;
+ }
+
+ /**
+ * Data for a package namespace
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+ private class SchemaNamespace
+ {
+ // The package name
+ String packageName;
+ // The full namespace
+ String namespace;
+ // The namespace abbreviation
+ String shortNamespace;
+ // Is this a EE reserved package?
+ boolean ee;
+
+ public SchemaNamespace(String packageName, String shortNamespace, boolean ee)
+ {
+ this.packageName = packageName;
+ this.shortNamespace = shortNamespace;
+ // Skip ":" for default namespace
+ String colon = "".equals(shortNamespace) ? "" : ":";
+ // Hardcode "ee" for EE reserved packages
+ String url = ee ? "ee" : packageName;
+ this.namespace = "xmlns" + colon + shortNamespace + "=\"urn:java:" + url + "\"";
+ this.ee = ee;
+ }
+ }
+
+ /**
+ * Gets all used namespaces for the schema
+ *
+ * @return The used namespaces
+ */
+ public Set<String> getUsedNamespaces()
+ {
+ Set<String> usedNamespaces = new HashSet<String>();
+ for (SchemaNamespace schemaNamespace : schemaNamespaces.values())
+ {
+ usedNamespaces.add(schemaNamespace.namespace);
+ }
+ return usedNamespaces;
+ }
+
+ /**
+ * Gets a namespace abbreviation for a package
+ *
+ * @param packageName The name of the package
+ * @return The namespace abbreviation
+ */
+ public String getShortNamespace(String packageName)
+ {
+ if (schemaNamespaces.containsKey(packageName))
+ {
+ return schemaNamespaces.get(packageName).shortNamespace;
+ }
+ String shortNamespace = "";
+ boolean ee = false;
+ if (localPackage.equals(packageName))
+ {
+ // Nothing to do but want to hit this case first for performance
+ }
+ else if (URN_JAVA_EE.contains(packageName))
+ {
+ shortNamespace = "ee";
+ ee = true;
+ }
+ else
+ {
+ String shortName = getShortName(packageName);
+ Integer count = counters.get(shortName);
+ String countString = "";
+ if (count == null)
+ {
+ count = new Integer(1);
+ counters.put(shortName, count);
+ }
+ else
+ {
+ count++;
+ countString = String.valueOf(count);
+ }
+ shortNamespace = getShortName(packageName) + countString;
+ }
+ schemaNamespaces.put(packageName, new SchemaNamespace(packageName, shortNamespace, ee));
+ return shortNamespace;
+ }
+
+ /**
+ * Gets the short name (last part) of a package
+ *
+ * @param packageName The package name to parse
+ * @return The short name
+ */
+ private String getShortName(String packageName)
+ {
+ int lastDot = packageName.lastIndexOf(".");
+ return lastDot < 0 ? packageName : packageName.substring(lastDot + 1);
+ }
+
+ // TODO testing, remove
+ public static void main(String[] params)
+ {
+ NamespaceHandler ng = new NamespaceHandler("com.acme.foo");
+ System.out.println(ng.getShortNamespace("com.acme.foo"));
+ System.out.println(ng.getShortNamespace("com.acme.foo.foo"));
+ System.out.println(ng.getShortNamespace("com.acme.foo.foo.foo"));
+ System.out.println(ng.getShortNamespace("java.util"));
+ for (String ns : ng.getUsedNamespaces())
+ {
+ System.out.println(ns);
+ }
+ }
+
+}
Property changes on: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/NamespaceHandler.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java 2009-03-17 07:38:35 UTC (rev 2061)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java 2009-03-17 08:51:29 UTC (rev 2062)
@@ -1,105 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.xsd;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.dom4j.Document;
-import org.jboss.webbeans.xsd.helpers.NamespaceGenerator;
-import org.jboss.webbeans.xsd.model.TypedModel;
-
-/**
- * Package information
- *
- * @author Nicklas Karlsson
- *
- */
-public class PackageInfo
-{
- private Document schema;
- private String packageName;
- private Map<String, Set<String>> typeReferences;
- private NamespaceGenerator namespaceGenerator;
-
- public PackageInfo(String packageName)
- {
- this.packageName = packageName;
- typeReferences = new HashMap<String, Set<String>>();
- namespaceGenerator = new NamespaceGenerator(packageName);
- }
-
- public void addTypeReferences(Set<TypedModel> references)
- {
- for (TypedModel reference : references)
- {
- Set<String> typeNames = typeReferences.get(reference.getTypePackage());
- if (typeNames == null)
- {
- typeNames = new HashSet<String>();
- typeReferences.put(reference.getTypePackage(), typeNames);
- }
- typeNames.add(reference.getType());
- }
- }
-
- public Document getSchema()
- {
- return schema;
- }
-
- public void setSchema(Document schema)
- {
- this.schema = schema;
- }
-
- public String getPackageName()
- {
- return packageName;
- }
-
- public void setPackageName(String packageName)
- {
- this.packageName = packageName;
- }
-
- public Map<String, Set<String>> getTypeReferences()
- {
- return typeReferences;
- }
-
- // TODO: dummy, remove
- public void refreshNamespaces()
- {
- for (String p : typeReferences.keySet())
- {
- if (!"".equals(p))
- {
- String dummy = namespaceGenerator.getShortNamespace(p);
- }
- }
- }
-
- public Set<String> getNamespaces()
- {
- return namespaceGenerator.getUsedNamespaces();
- }
-
-}
Copied: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java (from rev 2061, extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java)
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java (rev 0)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java 2009-03-17 08:51:29 UTC (rev 2062)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.xsd;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.dom4j.Document;
+import org.jboss.webbeans.xsd.model.TypedModel;
+
+/**
+ * Package information
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class Schema
+{
+ private Document document;
+ private String packageName;
+ private Map<String, Set<String>> typeReferences;
+ private NamespaceHandler namespaceHandler;
+
+ public Schema(String packageName)
+ {
+ this.packageName = packageName;
+ typeReferences = new HashMap<String, Set<String>>();
+ namespaceHandler = new NamespaceHandler(packageName);
+ }
+
+ public void addTypeReferences(Set<TypedModel> references)
+ {
+ for (TypedModel reference : references)
+ {
+ Set<String> typeNames = typeReferences.get(reference.getTypePackage());
+ if (typeNames == null)
+ {
+ typeNames = new HashSet<String>();
+ typeReferences.put(reference.getTypePackage(), typeNames);
+ }
+ typeNames.add(reference.getType());
+ }
+ }
+
+ public Document getDocument()
+ {
+ return document;
+ }
+
+ public void setDocument(Document document)
+ {
+ this.document = document;
+ }
+
+ public String getPackageName()
+ {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName)
+ {
+ this.packageName = packageName;
+ }
+
+ public Map<String, Set<String>> getTypeReferences()
+ {
+ return typeReferences;
+ }
+
+ // TODO: dummy, remove
+ public void refreshNamespaces()
+ {
+ for (String p : typeReferences.keySet())
+ {
+ if (!"".equals(p))
+ {
+ String dummy = namespaceHandler.getShortNamespace(p);
+ }
+ }
+ }
+
+ public Set<String> getNamespaces()
+ {
+ return namespaceHandler.getUsedNamespaces();
+ }
+
+}
Property changes on: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/Schema.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java 2009-03-17 07:38:35 UTC (rev 2061)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java 2009-03-17 08:51:29 UTC (rev 2062)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.xsd.helpers;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Helper for generating and keeping track of namespaces in a schema
- *
- * @author Nicklas Karlsson
- *
- */
-public class NamespaceGenerator
-{
- // The set of reserved EE packages
- private static final Set<String> URN_JAVA_EE = new HashSet<String>(Arrays.asList("java.lang", "java.util", "javax.annotation", "javax.inject", "javax.context", "javax.interceptor", "javax.decorator", "javax.event", "javax.ejb", "javax.persistence", "javax.xml.ws", "javax.jms", "javax.sql"));
-
- // The local package of the scema
- private String localPackage;
-
- // Duplicate shortname counters
- private Map<String, Integer> counters = new HashMap<String, Integer>();
- // Namespace infos
- private Map<String, NamespaceInfo> packageNamespaceInfo = new HashMap<String, NamespaceInfo>();
-
- /**
- * Creats a new namespace generator
- *
- * @param localPackage The local package
- */
- public NamespaceGenerator(String localPackage)
- {
- this.localPackage = localPackage;
- }
-
- /**
- * Data for a package namespace
- *
- * @author Nicklas Karlsson
- *
- */
- private class NamespaceInfo
- {
- // The package name
- String packageName;
- // The full namespace
- String namespace;
- // The namespace abbreviation
- String shortNamespace;
- // Is this a EE reserved package?
- boolean ee;
-
- public NamespaceInfo(String packageName, String shortNamespace, boolean ee)
- {
- this.packageName = packageName;
- this.shortNamespace = shortNamespace;
- // Skip ":" for default namespace
- String colon = "".equals(shortNamespace) ? "" : ":";
- // Hardcode "ee" for EE reserved packages
- String url = ee ? "ee" : packageName;
- this.namespace = "xmlns" + colon + shortNamespace + "=\"urn:java:" + url + "\"";
- this.ee = ee;
- }
- }
-
- /**
- * Gets all used namespaces for the schema
- *
- * @return The used namespaces
- */
- public Set<String> getUsedNamespaces()
- {
- Set<String> usedNamespaces = new HashSet<String>();
- for (NamespaceInfo namespaceInfo : packageNamespaceInfo.values())
- {
- usedNamespaces.add(namespaceInfo.namespace);
- }
- return usedNamespaces;
- }
-
- /**
- * Gets a namespace abbreviation for a package
- *
- * @param packageName The name of the package
- * @return The namespace abbreviation
- */
- public String getShortNamespace(String packageName)
- {
- if (packageNamespaceInfo.containsKey(packageName))
- {
- return packageNamespaceInfo.get(packageName).shortNamespace;
- }
- String shortNamespace = "";
- boolean ee = false;
- if (localPackage.equals(packageName))
- {
- // Nothing to do but want to hit this case first for performance
- }
- else if (URN_JAVA_EE.contains(packageName))
- {
- shortNamespace = "ee";
- ee = true;
- }
- else
- {
- String shortName = getShortName(packageName);
- Integer count = counters.get(shortName);
- String countString = "";
- if (count == null)
- {
- count = new Integer(1);
- counters.put(shortName, count);
- }
- else
- {
- count++;
- countString = String.valueOf(count);
- }
- shortNamespace = getShortName(packageName) + countString;
- }
- packageNamespaceInfo.put(packageName, new NamespaceInfo(packageName, shortNamespace, ee));
- return shortNamespace;
- }
-
- /**
- * Gets the short name (last part) of a package
- *
- * @param packageName The package name to parse
- * @return The short name
- */
- private String getShortName(String packageName)
- {
- int lastDot = packageName.lastIndexOf(".");
- return lastDot < 0 ? packageName : packageName.substring(lastDot + 1);
- }
-
- // TODO testing, remove
- public static void main(String[] params)
- {
- NamespaceGenerator ng = new NamespaceGenerator("com.acme.foo");
- System.out.println(ng.getShortNamespace("com.acme.foo"));
- System.out.println(ng.getShortNamespace("com.acme.foo.foo"));
- System.out.println(ng.getShortNamespace("com.acme.foo.foo.foo"));
- System.out.println(ng.getShortNamespace("java.util"));
- for (String ns : ng.getUsedNamespaces())
- {
- System.out.println(ns);
- }
- }
-
-}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 07:38:35 UTC (rev 2061)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 08:51:29 UTC (rev 2062)
@@ -34,7 +34,7 @@
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
-import org.jboss.webbeans.xsd.PackageInfo;
+import org.jboss.webbeans.xsd.Schema;
import org.jboss.webbeans.xsd.model.ClassModel;
/**
@@ -51,7 +51,7 @@
// The cache of already processed classes
private Map<String, ClassModel> classModelCache = new HashMap<String, ClassModel>();
// The XSD documents of the affected packages
- private Map<String, PackageInfo> packageInfoMap = new HashMap<String, PackageInfo>();
+ private Map<String, Schema> schemaMap = new HashMap<String, Schema>();
/**
* Creates a new helper
@@ -71,12 +71,12 @@
* @throws DocumentException If the schema could not be parsed
* @throws IOException If the schema could not be read
*/
- private PackageInfo readPackageInfo(String packageName) throws DocumentException, IOException
+ private Schema getSchema(String packageName) throws DocumentException, IOException
{
- PackageInfo packageInfo = new PackageInfo(packageName);
- Document schema = readSchema(packageName);
- packageInfo.setSchema(schema != null ? schema : createSchema(packageName));
- return packageInfo;
+ Schema schema = new Schema(packageName);
+ Document document = readSchema(packageName);
+ schema.setDocument(document != null ? document : createSchema(packageName));
+ return schema;
}
/**
@@ -124,17 +124,17 @@
/**
* Writes package info to the disk
*
- * @param packageInfo The package info to store
+ * @param schema The package info to store
*/
- private void writePackageInfo(PackageInfo packageInfo)
+ private void writePackageInfo(Schema schema)
{
try
{
- writeSchema(packageInfo.getPackageName(), packageInfo.getSchema());
+ writeSchema(schema.getPackageName(), schema.getDocument());
}
catch (IOException e)
{
- throw new RuntimeException("Could not write schema for " + packageInfo.getPackageName());
+ throw new RuntimeException("Could not write schema for " + schema.getPackageName());
}
}
@@ -176,12 +176,12 @@
for (ClassModel classModel : classModels)
{
String packageName = classModel.getPackage();
- PackageInfo packageInfo = packageInfoMap.get(packageName);
- if (packageInfo == null)
+ Schema schema = schemaMap.get(packageName);
+ if (schema == null)
{
try
{
- packageInfo = readPackageInfo(packageName);
+ schema = getSchema(packageName);
}
catch (DocumentException e)
{
@@ -191,9 +191,9 @@
{
throw new RuntimeException("Could not read schema for package " + packageName);
}
- packageInfoMap.put(packageName, packageInfo);
+ schemaMap.put(packageName, schema);
}
- updateClassInSchema(classModel, packageInfo);
+ updateClassInSchema(classModel, schema);
}
}
@@ -202,34 +202,34 @@
*/
public void writeSchemas()
{
- for (PackageInfo packageInfo : packageInfoMap.values())
+ for (Schema schema : schemaMap.values())
{
// TODO: dummy, remove
- packageInfo.refreshNamespaces();
- System.out.println(packageInfo.getPackageName() + " (" + packageInfo.getNamespaces() + ")");
- System.out.println(packageInfo.getTypeReferences());
- writePackageInfo(packageInfo);
+ schema.refreshNamespaces();
+ System.out.println(schema.getPackageName() + " (" + schema.getNamespaces() + ")");
+ System.out.println(schema.getTypeReferences());
+ writePackageInfo(schema);
}
}
/**
* Updates a schema with XSD from a file model
*
- * @param packageInfo The schema
+ * @param schema The schema
* @param classModel The class model
*/
- private void updateClassInSchema(ClassModel classModel, PackageInfo packageInfo)
+ private void updateClassInSchema(ClassModel classModel, Schema schema)
{
- Document schema = packageInfo.getSchema();
- Node oldClassModel = schema.selectSingleNode("//" + classModel.getSimpleName());
+ Document document = schema.getDocument();
+ Node oldClassModel = document.selectSingleNode("//" + classModel.getSimpleName());
if (oldClassModel != null)
{
// Remove the old class definition
- schema.getRootElement().remove(oldClassModel);
+ document.getRootElement().remove(oldClassModel);
}
// Create a new one
- schema.getRootElement().addElement(classModel.getSimpleName());
- packageInfo.addTypeReferences(classModel.getTypeReferences());
+ document.getRootElement().addElement(classModel.getSimpleName());
+ schema.addTypeReferences(classModel.getTypeReferences());
}
/**
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2061 - in extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd: helpers and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-03-17 03:38:35 -0400 (Tue, 17 Mar 2009)
New Revision: 2061
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java
Log:
xsd namespace stuff
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java 2009-03-17 00:07:35 UTC (rev 2060)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/PackageInfo.java 2009-03-17 07:38:35 UTC (rev 2061)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.xsd;
import java.util.HashMap;
@@ -2,16 +19,21 @@
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.dom4j.Document;
+import org.jboss.webbeans.xsd.helpers.NamespaceGenerator;
import org.jboss.webbeans.xsd.model.TypedModel;
+/**
+ * Package information
+ *
+ * @author Nicklas Karlsson
+ *
+ */
public class PackageInfo
{
- private List<String> namespaces;
private Document schema;
private String packageName;
private Map<String, Set<String>> typeReferences;
- private String namespace;
+ private NamespaceGenerator namespaceGenerator;
@@ -21,6 +43,7 @@
{
this.packageName = packageName;
typeReferences = new HashMap<String, Set<String>>();
+ namespaceGenerator = new NamespaceGenerator(packageName);
}
public void addTypeReferences(Set<TypedModel> references)
@@ -37,16 +60,6 @@
}
}
- public List<String> getNamespaces()
- {
- return namespaces;
- }
-
- public void setNamespaces(List<String> namespaces)
- {
- this.namespaces = namespaces;
- }
-
public Document getSchema()
{
return schema;
@@ -72,13 +85,21 @@
return typeReferences;
}
- public String getNamespace()
+ // TODO: dummy, remove
+ public void refreshNamespaces()
{
- return namespace;
+ for (String p : typeReferences.keySet())
+ {
+ if (!"".equals(p))
+ {
+ String dummy = namespaceGenerator.getShortNamespace(p);
+ }
+ }
}
- public void setNamespace(String namespace)
+ public Set<String> getNamespaces()
{
- this.namespace = namespace;
+ return namespaceGenerator.getUsedNamespaces();
}
+
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java 2009-03-17 00:07:35 UTC (rev 2060)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/NamespaceGenerator.java 2009-03-17 07:38:35 UTC (rev 2061)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.xsd.helpers;
import java.util.Arrays;
@@ -6,43 +23,148 @@
import java.util.Map;
import java.util.Set;
+/**
+ * Helper for generating and keeping track of namespaces in a schema
+ *
+ * @author Nicklas Karlsson
+ *
+ */
public class NamespaceGenerator
{
+ // The set of reserved EE packages
private static final Set<String> URN_JAVA_EE = new HashSet<String>(Arrays.asList("java.lang", "java.util", "javax.annotation", "javax.inject", "javax.context", "javax.interceptor", "javax.decorator", "javax.event", "javax.ejb", "javax.persistence", "javax.xml.ws", "javax.jms", "javax.sql"));
- public Map<String, Integer> counters = new HashMap<String, Integer>();
+ // The local package of the scema
+ private String localPackage;
- public String getNamespace(String packageName)
+ // Duplicate shortname counters
+ private Map<String, Integer> counters = new HashMap<String, Integer>();
+ // Namespace infos
+ private Map<String, NamespaceInfo> packageNamespaceInfo = new HashMap<String, NamespaceInfo>();
+
+ /**
+ * Creats a new namespace generator
+ *
+ * @param localPackage The local package
+ */
+ public NamespaceGenerator(String localPackage)
{
- String shortName = getShortName(packageName);
- if (URN_JAVA_EE.contains(getBasePackage(packageName)))
+ this.localPackage = localPackage;
+ }
+
+ /**
+ * Data for a package namespace
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+ private class NamespaceInfo
+ {
+ // The package name
+ String packageName;
+ // The full namespace
+ String namespace;
+ // The namespace abbreviation
+ String shortNamespace;
+ // Is this a EE reserved package?
+ boolean ee;
+
+ public NamespaceInfo(String packageName, String shortNamespace, boolean ee)
{
- return "xmlns=\"urn:java:ee\"";
+ this.packageName = packageName;
+ this.shortNamespace = shortNamespace;
+ // Skip ":" for default namespace
+ String colon = "".equals(shortNamespace) ? "" : ":";
+ // Hardcode "ee" for EE reserved packages
+ String url = ee ? "ee" : packageName;
+ this.namespace = "xmlns" + colon + shortNamespace + "=\"urn:java:" + url + "\"";
+ this.ee = ee;
}
- Integer count = counters.get(shortName);
- String countString = "";
- if (count == null)
+ }
+
+ /**
+ * Gets all used namespaces for the schema
+ *
+ * @return The used namespaces
+ */
+ public Set<String> getUsedNamespaces()
+ {
+ Set<String> usedNamespaces = new HashSet<String>();
+ for (NamespaceInfo namespaceInfo : packageNamespaceInfo.values())
{
- count = new Integer(1);
- counters.put(shortName, count);
+ usedNamespaces.add(namespaceInfo.namespace);
}
+ return usedNamespaces;
+ }
+
+ /**
+ * Gets a namespace abbreviation for a package
+ *
+ * @param packageName The name of the package
+ * @return The namespace abbreviation
+ */
+ public String getShortNamespace(String packageName)
+ {
+ if (packageNamespaceInfo.containsKey(packageName))
+ {
+ return packageNamespaceInfo.get(packageName).shortNamespace;
+ }
+ String shortNamespace = "";
+ boolean ee = false;
+ if (localPackage.equals(packageName))
+ {
+ // Nothing to do but want to hit this case first for performance
+ }
+ else if (URN_JAVA_EE.contains(packageName))
+ {
+ shortNamespace = "ee";
+ ee = true;
+ }
else
{
- count++;
- countString = String.valueOf(count);
+ String shortName = getShortName(packageName);
+ Integer count = counters.get(shortName);
+ String countString = "";
+ if (count == null)
+ {
+ count = new Integer(1);
+ counters.put(shortName, count);
+ }
+ else
+ {
+ count++;
+ countString = String.valueOf(count);
+ }
+ shortNamespace = getShortName(packageName) + countString;
}
- return "xmlns:" + shortName + countString + "=\"java:urn:" + packageName + "\"";
+ packageNamespaceInfo.put(packageName, new NamespaceInfo(packageName, shortNamespace, ee));
+ return shortNamespace;
}
- private String getBasePackage(String packageName)
- {
- return packageName.substring(0, getShortName(packageName).length());
- }
-
+ /**
+ * Gets the short name (last part) of a package
+ *
+ * @param packageName The package name to parse
+ * @return The short name
+ */
private String getShortName(String packageName)
{
int lastDot = packageName.lastIndexOf(".");
return lastDot < 0 ? packageName : packageName.substring(lastDot + 1);
}
+
+ // TODO testing, remove
+ public static void main(String[] params)
+ {
+ NamespaceGenerator ng = new NamespaceGenerator("com.acme.foo");
+ System.out.println(ng.getShortNamespace("com.acme.foo"));
+ System.out.println(ng.getShortNamespace("com.acme.foo.foo"));
+ System.out.println(ng.getShortNamespace("com.acme.foo.foo.foo"));
+ System.out.println(ng.getShortNamespace("java.util"));
+ for (String ns : ng.getUsedNamespaces())
+ {
+ System.out.println(ns);
+ }
+ }
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 00:07:35 UTC (rev 2060)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/XSDHelper.java 2009-03-17 07:38:35 UTC (rev 2061)
@@ -20,14 +20,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
import javax.annotation.processing.Filer;
import javax.tools.StandardLocation;
@@ -57,7 +52,6 @@
private Map<String, ClassModel> classModelCache = new HashMap<String, ClassModel>();
// The XSD documents of the affected packages
private Map<String, PackageInfo> packageInfoMap = new HashMap<String, PackageInfo>();
- private NamespaceGenerator namespaceGenerator = new NamespaceGenerator();
/**
* Creates a new helper
@@ -80,25 +74,12 @@
private PackageInfo readPackageInfo(String packageName) throws DocumentException, IOException
{
PackageInfo packageInfo = new PackageInfo(packageName);
- packageInfo.setNamespaces(readNamespaces(packageName));
Document schema = readSchema(packageName);
packageInfo.setSchema(schema != null ? schema : createSchema(packageName));
return packageInfo;
}
/**
- * Reads the namespaces for a package
- *
- * @param packageName The name of the package
- * @return The namespaces
- */
- private List<String> readNamespaces(String packageName)
- {
- // TODO dummy
- return new ArrayList<String>();
- }
-
- /**
* Creates a new schema document
*
* @param packageName The package name of the schema
@@ -155,21 +136,9 @@
{
throw new RuntimeException("Could not write schema for " + packageInfo.getPackageName());
}
- writeNamespaces(packageInfo.getPackageName(), packageInfo.getNamespaces());
}
/**
- * Writes the namespaces to disk
- *
- * @param packageName The package name
- * @param namespaces The namespaces
- */
- private void writeNamespaces(String packageName, List<String> namespaces)
- {
- // TODO dummy
- }
-
- /**
* Writes a schema to disk
*
* @param packageName The package name
@@ -235,8 +204,9 @@
{
for (PackageInfo packageInfo : packageInfoMap.values())
{
- packageInfo.setNamespace(namespaceGenerator.getNamespace(packageInfo.getPackageName()));
- System.out.println(packageInfo.getPackageName() + " (" + packageInfo.getNamespace() + ")");
+ // TODO: dummy, remove
+ packageInfo.refreshNamespaces();
+ System.out.println(packageInfo.getPackageName() + " (" + packageInfo.getNamespaces() + ")");
System.out.println(packageInfo.getTypeReferences());
writePackageInfo(packageInfo);
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java 2009-03-17 00:07:35 UTC (rev 2060)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java 2009-03-17 07:38:35 UTC (rev 2061)
@@ -70,18 +70,6 @@
methods.add(methodModel);
}
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
- buffer.append("----------------------------------\n" + annotationString + name + "\n");
- buffer.append("Constructors:\n " + getMergedConstructors() + "\n");
- buffer.append("Methods:\n" + getMergedMethods() + "\n");
- buffer.append("Fields:\n" + getMergedFields() + "\n");
- return buffer.toString();
- }
-
/**
* Gets the parent class model of the class
*
@@ -167,6 +155,11 @@
return mergedMethods;
}
+ /**
+ * Gets the type references used in the package and its contained members
+ *
+ * @return The set of types
+ */
public Set<TypedModel> getTypeReferences()
{
Set<TypedModel> typeReferences = new HashSet<TypedModel>();
@@ -192,16 +185,38 @@
return typeReferences;
}
+ /**
+ * Gets the package of the class
+ *
+ * @return The package (or "nopak" if root package)
+ */
public String getPackage()
{
int lastDot = name.lastIndexOf(".");
return lastDot < 0 ? "nopak" : name.substring(0, lastDot);
}
+ /**
+ * Gets the simple name of a class
+ *
+ * @return The simple name
+ */
public String getSimpleName()
{
int lastDot = name.lastIndexOf(".");
return lastDot < 0 ? name : name.substring(lastDot + 1);
}
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ String annotationString = (annotations.isEmpty()) ? "" : "@" + annotations + ": ";
+ buffer.append("----------------------------------\n" + annotationString + name + "\n");
+ buffer.append("Constructors:\n " + getMergedConstructors() + "\n");
+ buffer.append("Methods:\n" + getMergedMethods() + "\n");
+ buffer.append("Fields:\n" + getMergedFields() + "\n");
+ return buffer.toString();
+ }
+
}
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java
===================================================================
--- extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java 2009-03-17 00:07:35 UTC (rev 2060)
+++ extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java 2009-03-17 07:38:35 UTC (rev 2061)
@@ -1,5 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.xsd.model;
+/**
+ * The model of a typed member
+ *
+ * @author Nicklas Karlsson
+ *
+ */
public class TypedModel
{
protected String type;
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2060 - ri/trunk/impl/src/main/java/org/jboss/webbeans/el and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-16 20:07:35 -0400 (Mon, 16 Mar 2009)
New Revision: 2060
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
Log:
WBRI-174
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-03-16 23:01:12 UTC (rev 2059)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-03-17 00:07:35 UTC (rev 2060)
@@ -33,7 +33,7 @@
* @see javax.context.Conversation
*/
@RequestScoped
-@Named("javax.webbeans.conversation")
+@Named("javax.context.conversation")
@Standard
public class ConversationImpl implements Conversation
{
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java 2009-03-17 00:07:35 UTC (rev 2060)
@@ -0,0 +1,66 @@
+package org.jboss.webbeans.el;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A namespace for Seam component names.
+ *
+ * @author Gavin King
+ *
+ */
+public class Namespace
+{
+
+ private String name;
+ private Map<String, Namespace> children = new HashMap<String, Namespace>();
+
+ public Namespace(String name)
+ {
+ this.name = name;
+ }
+
+ public Namespace getChild(String key)
+ {
+ Namespace result = children.get(key);
+ if (result==null)
+ {
+ result = new Namespace( getQualifiedName(key) + '.' );
+ children.put(name, result);
+ }
+ return result;
+ }
+
+ public String getQualifiedName(String key)
+ {
+ return name==null ? key : name + key;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name==null ? 0 : name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if ( !(other instanceof Namespace) )
+ {
+ return false;
+ }
+ else
+ {
+ Namespace ns = (Namespace) other;
+ return this.name==ns.name ||
+ ( this.name!=null && this.name.equals(ns.name) );
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Namespace(" + ( name==null ? "Root" : name ) + ')';
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java 2009-03-17 00:07:35 UTC (rev 2060)
@@ -0,0 +1,110 @@
+package org.jboss.webbeans.el;
+
+
+import javax.el.ELContext;
+import javax.inject.ExecutionException;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.DependentInstancesStore;
+import org.jboss.webbeans.context.DependentStorageRequest;
+
+class NamespacedResolver
+{
+
+ private final ELContext context;
+ private final String property;
+ private final Namespace namespace;
+ private Object value;
+
+ public NamespacedResolver(ELContext context, Namespace namespace, String property)
+ {
+ this.context = context;
+ this.property = property;
+ this.namespace = namespace;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public NamespacedResolver run()
+ {
+
+ try
+ {
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ value = CurrentManager.rootManager().getInstanceByName(namespace.getQualifiedName(property));
+ if (value != null)
+ {
+ context.setPropertyResolved(true);
+ }
+ }
+
+ }.run();
+ }
+ catch (Exception e)
+ {
+ throw new ExecutionException("Error resolving EL " + property);
+ }
+
+ if (!context.isPropertyResolved())
+ {
+ // look for a namespace
+ value = namespace.getChild(property);
+ if (value != null)
+ {
+ context.setPropertyResolved(true);
+ }
+ }
+ return this;
+ }
+
+ static abstract class RunInDependentContext
+ {
+
+ private final DependentStorageRequest dependentStorageRequest;
+
+ public RunInDependentContext()
+ {
+ dependentStorageRequest = DependentStorageRequest.of(new DependentInstancesStore(), new Object());
+ }
+
+ private void setup()
+ {
+ DependentContext.INSTANCE.setActive(true);
+ DependentContext.INSTANCE.startCollectingDependents(dependentStorageRequest);
+ }
+
+ private void cleanup()
+ {
+ DependentContext.INSTANCE.stopCollectingDependents(dependentStorageRequest);
+ // TODO kinky
+ dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
+ DependentContext.INSTANCE.setActive(false);
+ }
+
+ protected abstract void execute() throws Exception;
+
+ public final void run() throws Exception
+ {
+ try
+ {
+ setup();
+ execute();
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-03-16 23:01:12 UTC (rev 2059)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-03-17 00:07:35 UTC (rev 2060)
@@ -23,11 +23,6 @@
import javax.el.ELContext;
import javax.el.ELResolver;
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentInstancesStore;
-import org.jboss.webbeans.context.DependentStorageRequest;
-
/**
* An EL-resolver against the named beans
*
@@ -36,6 +31,8 @@
public class WebBeansELResolver extends ELResolver
{
+ private static final Namespace ROOT = new Namespace(null);
+
/**
* @see javax.el.ELResolver#getCommonPropertyType(ELContext, Object)
*/
@@ -69,32 +66,18 @@
@Override
public Object getValue(ELContext context, Object base, Object property)
{
- if (base == null && property != null)
+ if (property != null)
{
- DependentStorageRequest dependentStorageRequest = DependentStorageRequest.of(new DependentInstancesStore(), new Object());
- try
+ if (base == null)
{
- DependentContext.INSTANCE.setActive(true);
- DependentContext.INSTANCE.startCollectingDependents(dependentStorageRequest);
- Object value = CurrentManager.rootManager().getInstanceByName(property.toString());
- if (value != null)
- {
- context.setPropertyResolved(true);
- }
- return value;
+ return new NamespacedResolver(context, ROOT, property.toString()).run().getValue();
}
- finally
+ else if (base instanceof Namespace)
{
- DependentContext.INSTANCE.stopCollectingDependents(dependentStorageRequest);
- // TODO kinky
- dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
- DependentContext.INSTANCE.setActive(false);
+ return new NamespacedResolver(context, (Namespace) base, property.toString()).run().getValue();
}
}
- else
- {
- return null;
- }
+ return null;
}
/**
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2009-03-16 23:01:12 UTC (rev 2059)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2009-03-17 00:07:35 UTC (rev 2060)
@@ -66,7 +66,7 @@
assert found;
}
- @Test(groups = { "contexts", "ri-broken" })
+ @Test(groups = { "contexts" })
@SpecAssertion(section = "8.5.4", id = "ie")
public void testBeanWithNameJavaxContextConversation()
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java 2009-03-16 23:01:12 UTC (rev 2059)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java 2009-03-17 00:07:35 UTC (rev 2060)
@@ -1,7 +1,10 @@
package org.jboss.jsr299.tck.tests.lookup.el;
+import javax.context.Conversation;
+
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
/**
@@ -9,6 +12,7 @@
* Spec version: PRD2
*
*/
+@Artifact
public class ResolutionByNameTest extends AbstractJSR299Test
{
@@ -23,4 +27,11 @@
{
assert false;
}
+
+ @Test
+ @SpecAssertion(section="unknown", id="unknown")
+ public void testQualifiedNameLookup()
+ {
+ assert getCurrentConfiguration().getEl().evaluateValueExpression("#{javax.context.conversation}", Conversation.class) != null;
+ }
}
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2059 - in ri/trunk: tests and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-16 19:01:12 -0400 (Mon, 16 Mar 2009)
New Revision: 2059
Modified:
ri/trunk/impl/pom.xml
ri/trunk/tests/pom.xml
Log:
minor
Modified: ri/trunk/impl/pom.xml
===================================================================
--- ri/trunk/impl/pom.xml 2009-03-16 22:53:19 UTC (rev 2058)
+++ ri/trunk/impl/pom.xml 2009-03-16 23:01:12 UTC (rev 2059)
@@ -30,19 +30,6 @@
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-logging</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- <classifier>jdk15</classifier>
- <exclusions>
- <exclusion>
- <artifactId>junit</artifactId>
- <groupId>junit</groupId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.jboss.ejb3</groupId>
@@ -121,174 +108,10 @@
<optional>true</optional>
</dependency>
- <dependency>
- <groupId>org.jboss.test-harness</groupId>
- <artifactId>jboss-test-harness</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.test-harness</groupId>
- <artifactId>jboss-test-harness-jboss-as-5</artifactId>
- <scope>test</scope>
- </dependency>
-
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <suiteXmlFiles>
- <suiteXmlFile>unit-tests.xml</suiteXmlFile>
- </suiteXmlFiles>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-test-report</id>
- <phase>test</phase>
- <goals>
- <goal>report-only</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
- <outputName>test-report</outputName>
- </configuration>
- </plugin>
- </plugins>
</build>
- <profiles>
- <profile>
- <id>incontainer</id>
- <activation>
- <property>
- <name>incontainer</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy</id>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <stripVersion>true</stripVersion>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.test-harness</groupId>
- <artifactId>jboss-test-harness</artifactId>
- <overWrite>true</overWrite>
- <outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
- </artifactItem>
- <artifactItem>
- <groupId>javax.el</groupId>
- <artifactId>el-ri</artifactId>
- <overWrite>true</overWrite>
- <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <suiteXmlFiles>
- <suiteXmlFile>unit-tests.xml</suiteXmlFile>
- </suiteXmlFiles>
- <systemProperties>
- <property>
- <name>org.jboss.testharness.standalone</name>
- <value>false</value>
- </property>
- <property>
- <name>jboss-as.dir</name>
- <value>../jboss-as</value>
- </property>
- <property>
- <name>jboss.force.restart</name>
- <value>true</value>
- </property>
- <property>
- <name>org.jboss.testharness.runIntegrationTests</name>
- <value>true</value>
- </property>
- <property>
- <name>org.jboss.testharness.libraryDirectory</name>
- <value>target/dependency/lib</value>
- </property>
- <property>
- <name>org.jboss.testharness.outputDirectory</name>
- <value>target</value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>write-artifacts-to-disk</id>
- <activation>
- <property>
- <name>dumpArtifacts</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-test-artifacts</id>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>java</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <mainClass>org.jboss.testharness.api.TCK</mainClass>
- <classpathScope>test</classpathScope>
- <systemProperties>
- <systemProperty>
- <key>dumpArtifacts</key>
- <value>true</value>
- </systemProperty>
- <systemProperty>
- <key>org.jboss.testharness.outputDirectory</key>
- <value>target/test-artifacts</value>
- </systemProperty>
- <systemProperty>
- <key>org.jboss.testharness.libraryDirectory</key>
- <value>target/dependency/lib</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-
</project>
Modified: ri/trunk/tests/pom.xml
===================================================================
--- ri/trunk/tests/pom.xml 2009-03-16 22:53:19 UTC (rev 2058)
+++ ri/trunk/tests/pom.xml 2009-03-16 23:01:12 UTC (rev 2059)
@@ -41,6 +41,26 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jbossws</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-transaction-api</artifactId>
+ <groupId>org.jboss.javaee</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jboss.jbossws</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
<build>
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2058 - in ri/trunk: impl/src/test and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-16 18:53:19 -0400 (Mon, 16 Mar 2009)
New Revision: 2058
Removed:
ri/trunk/impl/src/test/debug-resources/
ri/trunk/impl/src/test/java/org/
ri/trunk/impl/src/test/resources/META-INF/
ri/trunk/impl/src/test/resources/org/
Modified:
ri/trunk/core-api/
ri/trunk/tests/
Log:
cleanup
Property changes on: ri/trunk/core-api
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Property changes on: ri/trunk/tests
___________________________________________________________________
Name: svn:ignore
+ .project
.classpath
.settings
target
15 years, 8 months