[webbeans-commits] Webbeans SVN: r1411 - in tck/trunk/impl/src: main/java/org/jboss/webbeans/tck/impl/packaging and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-02-04 13:28:42 -0500 (Wed, 04 Feb 2009)
New Revision: 1411
Removed:
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/beans.xml
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java
Log:
Produce a JAR
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java 2009-02-04 17:19:36 UTC (rev 1410)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java 2009-02-04 18:28:42 UTC (rev 1411)
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.List;
+import java.util.jar.JarInputStream;
import javax.inject.manager.Manager;
@@ -39,7 +40,7 @@
{
try
{
- return deploy(new TCKArtifactDescriptor(null).asJar());
+ return deploy(new JarInputStream(new TCKArtifactDescriptor(null).asJar()));
}
catch (IOException e)
{
@@ -51,7 +52,7 @@
{
try
{
- return deploy(enabledDeploymentTypes, new TCKArtifactDescriptor(null).asJar());
+ return deploy(enabledDeploymentTypes, new JarInputStream(new TCKArtifactDescriptor(null).asJar()));
}
catch (IOException e)
{
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java 2009-02-04 17:19:36 UTC (rev 1410)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java 2009-02-04 18:28:42 UTC (rev 1411)
@@ -3,7 +3,10 @@
import static org.jboss.webbeans.tck.impl.util.Reflections.loadResourceAsStream;
import static org.jboss.webbeans.tck.impl.util.Reflections.loadResources;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -15,6 +18,8 @@
import java.util.Random;
import java.util.Set;
import java.util.jar.JarInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
import org.apache.log4j.Logger;
@@ -97,6 +102,53 @@
}
}
+
+ private static class Zipper
+ {
+
+ private final File root;
+
+ public Zipper(File root)
+ {
+ this.root = root;
+ }
+
+ public InputStream zip() throws IOException
+ {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream);
+ zip(root, zipOutputStream);
+ zipOutputStream.close();
+ return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+ }
+
+ private void zip(File directory, ZipOutputStream zipOutputStream) throws IOException
+ {
+ File[] children = directory.listFiles();
+ byte[] readBuffer = new byte[2156];
+ int bytesIn = 0;
+ //loop through dirList, and zip the files
+ for (File child : children)
+ {
+ if (child.isDirectory())
+ {
+ zip(child, zipOutputStream);
+ }
+ else
+ {
+ FileInputStream fis = new FileInputStream(child);
+ ZipEntry zipEntry = new ZipEntry(child.getPath().substring(root.getPath().length() + 1));
+ zipOutputStream.putNextEntry(zipEntry);
+ while((bytesIn = fis.read(readBuffer)) != -1)
+ {
+ zipOutputStream.write(readBuffer, 0, bytesIn);
+ }
+ fis.close();
+ }
+ }
+ }
+
+ }
public static final Random random = new Random(System.currentTimeMillis());
@@ -113,8 +165,8 @@
}
public JarInputStream asJar() throws IOException
- {
- return new JarInputStream(create().toURL().openStream());
+ {
+ return new JarInputStream(new Zipper(create()).zip());
}
public File create() throws IOException
Deleted: tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/beans.xml
===================================================================
Modified: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java 2009-02-04 17:19:36 UTC (rev 1410)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java 2009-02-04 18:28:42 UTC (rev 1411)
@@ -2,6 +2,10 @@
import java.io.File;
import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
import org.jboss.webbeans.tck.AbstractTest;
import org.jboss.webbeans.tck.impl.packaging.ArtifactDescriptor;
@@ -66,4 +70,23 @@
assert getPackageAsFile(AbstractTest.class.getPackage(), root).listFiles().length > 0;
}
+ @Test
+ public void testJarProduction() throws Exception
+ {
+ WarArtifactDescriptor war = new WarArtifactDescriptor(null, null);
+ war.getClasses().add(Cow.class);
+ JarInputStream is = war.asJar();
+ JarEntry entry;
+ List<String> fileNames = new ArrayList<String>();
+ while ((entry = is.getNextJarEntry()) != null)
+ {
+ fileNames.add(entry.getName());
+ }
+ assert fileNames.contains("META-INF/beans.xml");
+ assert fileNames.contains("WEB-INF/web.xml");
+ assert fileNames.contains("org/jboss/webbeans/tck/impl/test/packaging/Cow.class");
+ assert fileNames.contains("org/jboss/webbeans/tck/AbstractTest.class");
+ assert fileNames.contains("org/jboss/webbeans/tck/impl/util/Reflections.class");
+ }
+
}
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1410 - doc/trunk/reference/it-IT.
by webbeans-commits@lists.jboss.org
Author: nico.ben
Date: 2009-02-04 12:19:36 -0500 (Wed, 04 Feb 2009)
New Revision: 1410
Modified:
doc/trunk/reference/it-IT/Author_Group.po
Log:
Italian translation
Modified: doc/trunk/reference/it-IT/Author_Group.po
===================================================================
--- doc/trunk/reference/it-IT/Author_Group.po 2009-02-04 17:10:43 UTC (rev 1409)
+++ doc/trunk/reference/it-IT/Author_Group.po 2009-02-04 17:19:36 UTC (rev 1410)
@@ -6,7 +6,7 @@
"Project-Id-Version: Introduction_to_Web_Beans VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2009-02-01 21:16+0000\n"
-"PO-Revision-Date: 2009-02-01 22:19+0100\n"
+"PO-Revision-Date: 2009-02-04 18:19+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -48,7 +48,7 @@
#: Author_Group.xml:53
#, no-c-format
msgid "Italian Translation"
-msgstr "Italian Translation"
+msgstr "Traduzione italiana"
#. Tag: othercredit
#: Author_Group.xml:26
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1409 - in tck/trunk: impl/src/main/java/org/jboss/webbeans/tck/impl and 31 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-02-04 12:10:43 -0500 (Wed, 04 Feb 2009)
New Revision: 1409
Added:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Classes.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/DeclarativeArtifactProcessor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/EjbArtifact.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/IntegrationTest.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Packaging.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/PackagingType.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resource.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resources.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/BeansXml.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/JSR299ArtifactDescriptor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/TCKArtifactDescriptor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifactDescriptor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WebXml.java
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/jsr299/
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/jsr299/default/
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/jsr299/default/beans.xml
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/default/
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/default/web.xml
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/Cow.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/ArtifactTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Cow.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyClassesSpecifiedTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyCustomBeansXmlTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyEjbTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyIntegrationTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyResourcesSpecifiedTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyWarUnitTest_Broken.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Fox.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/pests/
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/pests/Rat.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/ArtifactTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Cow.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyCustomWebXmlTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Fox.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java
tck/trunk/impl/src/test/resources/org/
tck/trunk/impl/src/test/resources/org/jboss/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/foo/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/foo/foo.xml
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/my-web-beans.xml
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/
tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/my-web.xml
Removed:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/TCKArtifact.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/standard/war/
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifact.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessorFactory.java
tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/standard/war/
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/defined/
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ResourceDescriptor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Reflections.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Strings.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/AbstractArtifactTest.java
tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/all/ArtifactTest.java
tck/trunk/pom.xml
Log:
Support for declarative definiton of artifacts
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/IntegratedContainers.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -6,7 +6,7 @@
import javax.inject.manager.Manager;
-import org.jboss.webbeans.tck.impl.packaging.standard.war.WarArtifact;
+import org.jboss.webbeans.tck.impl.packaging.jsr299.TCKArtifactDescriptor;
import org.jboss.webbeans.tck.spi.Containers;
import org.jboss.webbeans.tck.spi.StandaloneContainers;
import org.jboss.webbeans.tck.spi.helpers.ForwardingContainers;
@@ -39,7 +39,7 @@
{
try
{
- return deploy(WarArtifact.of(classes).asJar());
+ return deploy(new TCKArtifactDescriptor(null).asJar());
}
catch (IOException e)
{
@@ -51,7 +51,7 @@
{
try
{
- return deploy(enabledDeploymentTypes, WarArtifact.of(classes).asJar());
+ return deploy(enabledDeploymentTypes, new TCKArtifactDescriptor(null).asJar());
}
catch (IOException e)
{
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,217 +0,0 @@
-package org.jboss.webbeans.tck.impl.packaging;
-
-import static org.jboss.webbeans.tck.impl.util.Reflections.loadResourceAsStream;
-import static org.jboss.webbeans.tck.impl.util.Reflections.loadResources;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLDecoder;
-import java.util.HashSet;
-import java.util.Random;
-import java.util.Set;
-import java.util.jar.JarInputStream;
-
-import org.apache.log4j.Logger;
-
-public class Artifact
-{
-
- /**
- * Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
- *
- * @author Thomas Heute
- * @author Gavin King
- * @author Norman Richards
- * @author Pete Muir
- *
- */
- private static class URLPackageScanner
- {
- private static final Logger log = Logger.getLogger(URLPackageScanner.class);
-
- private final Package pkg;
-
- private final Set<String> classes = new HashSet<String>();
-
- public URLPackageScanner(Package pkg)
- {
- this.pkg = pkg;
- }
-
- private void scanPackage()
- {
- try
- {
- Set<String> paths = new HashSet<String>();
- String packageName = pkg.getName().replace(".", "/");
- for (URL url : loadResources(packageName))
- {
- String urlPath = url.getFile();
- urlPath = URLDecoder.decode(urlPath, "UTF-8");
- if ( urlPath.startsWith("file:") )
- {
- urlPath = urlPath.substring(5);
- }
- if ( urlPath.indexOf('!')>0 )
- {
- urlPath = urlPath.substring(0, urlPath.indexOf('!'));
- }
- paths.add(urlPath);
- }
- handle(paths);
- }
- catch (IOException ioe)
- {
- log.warn("could not read: " + pkg.getName(), ioe);
- }
- }
-
- private void handle(Set<String> paths)
- {
- for ( String urlPath: paths )
- {
- log.trace("scanning: " + urlPath);
- File file = new File(urlPath);
- if ( file.isDirectory() )
- {
- for ( File child: file.listFiles() )
- {
- if ( !child.isDirectory() )
- {
- classes.add(pkg.getName() + "." + child.getName().substring(0, child.getName().lastIndexOf(".class")));
- }
- }
- }
- }
- }
-
- public Set<String> getClassNames()
- {
- scanPackage();
- return classes;
- }
-
- }
-
-
- public static final Random random = new Random(System.currentTimeMillis());
-
- private final Set<Class<?>> classes;
- private final Set<Package> packages;
- private final Set<ResourceDescriptor> resources;
-
- public Artifact()
- {
- classes = new HashSet<Class<?>>();
- resources = new HashSet<ResourceDescriptor>();
- packages = new HashSet<Package>();
- }
-
- public JarInputStream asJar() throws IOException
- {
- return new JarInputStream(create().toURL().openStream());
- }
-
- public File create() throws IOException
- {
- File root = new File(System.getProperty("java.io.tmpdir") + "/" + getClass().getName() + "." + random.nextInt());
- root.mkdir();
- root.deleteOnExit();
- for (Class<?> clazz : getClasses())
- {
- copyClass(clazz, root);
- }
- for (Package pkg : getPackages())
- {
- URLPackageScanner packageScanner = new URLPackageScanner(pkg);
- for (String className : packageScanner.getClassNames())
- {
- copyClass(className, root);
- }
- }
- for (ResourceDescriptor resourceDescriptor : getResources())
- {
- String directoryName = resourceDescriptor.getName().substring(0, resourceDescriptor.getName().lastIndexOf("/"));
- String fileName = resourceDescriptor.getName().substring(resourceDescriptor.getName().lastIndexOf("/") + 1);
- File directory = makeDirectoryStructure(root, directoryName);
- File file = new File(directory, fileName);
- file.createNewFile();
- file.deleteOnExit();
- copy(resourceDescriptor.getSource().openStream(), file);
- }
- return root;
- }
-
- private static void copyClass(Class<?> clazz, File root) throws IOException
- {
- copyClass(clazz.getName(), root);
- }
-
- private static void copyClass(String className, File root) throws IOException
- {
- String classFilePathName = getClassFileName(className);
- String directoryName = classFilePathName.substring(0, classFilePathName.lastIndexOf("/"));
- String classFileName = classFilePathName.substring(classFilePathName.lastIndexOf("/") + 1);
- File packageDirectory = makeDirectoryStructure(root, directoryName);
- File classFile = new File(packageDirectory, classFileName);
- classFile.createNewFile();
- classFile.deleteOnExit();
- copy(loadResourceAsStream(classFilePathName), classFile);
- }
-
- private static File makeDirectoryStructure(File root, String directoryName)
- {
- for (String directory : directoryName.split("\\/"))
- {
- root = new File(root, directory);
- root.mkdir();
- root.deleteOnExit();
- }
- return root;
- }
-
- private static String getClassFileName(String className)
- {
- return className.replace('.', '/') + ".class";
- }
-
- private static void copy(InputStream inputStream, File file) throws IOException
- {
- OutputStream os = new FileOutputStream(file);
- try
- {
- byte[] buf = new byte[1024];
- int i = 0;
- while ((i = inputStream.read(buf)) != -1)
- {
- os.write(buf, 0, i);
- }
- }
- finally
- {
- os.close();
- }
-
- }
-
- public Set<Class<?>> getClasses()
- {
- return classes;
- }
-
- public Set<ResourceDescriptor> getResources()
- {
- return resources;
- }
-
- public Set<Package> getPackages()
- {
- return packages;
- }
-
-}
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Artifact
+{
+
+ boolean addCurrentPackage() default true;
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java (from rev 1408, tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Artifact.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,217 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static org.jboss.webbeans.tck.impl.util.Reflections.loadResourceAsStream;
+import static org.jboss.webbeans.tck.impl.util.Reflections.loadResources;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+import java.util.jar.JarInputStream;
+
+import org.apache.log4j.Logger;
+
+public class ArtifactDescriptor
+{
+
+ /**
+ * Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
+ *
+ * @author Thomas Heute
+ * @author Gavin King
+ * @author Norman Richards
+ * @author Pete Muir
+ *
+ */
+ private static class URLPackageScanner
+ {
+ private static final Logger log = Logger.getLogger(URLPackageScanner.class);
+
+ private final Package pkg;
+
+ private final Set<String> classes = new HashSet<String>();
+
+ public URLPackageScanner(Package pkg)
+ {
+ this.pkg = pkg;
+ }
+
+ private void scanPackage()
+ {
+ try
+ {
+ Set<String> paths = new HashSet<String>();
+ String packageName = pkg.getName().replace(".", "/");
+ for (URL url : loadResources(packageName))
+ {
+ String urlPath = url.getFile();
+ urlPath = URLDecoder.decode(urlPath, "UTF-8");
+ if ( urlPath.startsWith("file:") )
+ {
+ urlPath = urlPath.substring(5);
+ }
+ if ( urlPath.indexOf('!')>0 )
+ {
+ urlPath = urlPath.substring(0, urlPath.indexOf('!'));
+ }
+ paths.add(urlPath);
+ }
+ handle(paths);
+ }
+ catch (IOException ioe)
+ {
+ log.warn("could not read: " + pkg.getName(), ioe);
+ }
+ }
+
+ private void handle(Set<String> paths)
+ {
+ for ( String urlPath: paths )
+ {
+ log.trace("scanning: " + urlPath);
+ File file = new File(urlPath);
+ if ( file.isDirectory() )
+ {
+ for ( File child: file.listFiles() )
+ {
+ if ( !child.isDirectory() && child.getName().endsWith(".class"))
+ {
+ classes.add(pkg.getName() + "." + child.getName().substring(0, child.getName().lastIndexOf(".class")));
+ }
+ }
+ }
+ }
+ }
+
+ public Set<String> getClassNames()
+ {
+ scanPackage();
+ return classes;
+ }
+
+ }
+
+
+ public static final Random random = new Random(System.currentTimeMillis());
+
+ private final Set<Class<?>> classes;
+ private final Set<Package> packages;
+ private final Set<ResourceDescriptor> resources;
+
+ public ArtifactDescriptor()
+ {
+ classes = new HashSet<Class<?>>();
+ resources = new HashSet<ResourceDescriptor>();
+ packages = new HashSet<Package>();
+ }
+
+ public JarInputStream asJar() throws IOException
+ {
+ return new JarInputStream(create().toURL().openStream());
+ }
+
+ public File create() throws IOException
+ {
+ File root = new File(System.getProperty("java.io.tmpdir") + "/" + getClass().getName() + "." + random.nextInt());
+ root.mkdir();
+ root.deleteOnExit();
+ for (Class<?> clazz : getClasses())
+ {
+ copyClass(clazz, root);
+ }
+ for (Package pkg : getPackages())
+ {
+ URLPackageScanner packageScanner = new URLPackageScanner(pkg);
+ for (String className : packageScanner.getClassNames())
+ {
+ copyClass(className, root);
+ }
+ }
+ for (ResourceDescriptor resourceDescriptor : getResources())
+ {
+ String directoryName = resourceDescriptor.getName().substring(0, resourceDescriptor.getName().lastIndexOf("/"));
+ String fileName = resourceDescriptor.getName().substring(resourceDescriptor.getName().lastIndexOf("/") + 1);
+ File directory = makeDirectoryStructure(root, directoryName);
+ File file = new File(directory, fileName);
+ file.createNewFile();
+ file.deleteOnExit();
+ copy(resourceDescriptor.getSource().openStream(), file);
+ }
+ return root;
+ }
+
+ private static void copyClass(Class<?> clazz, File root) throws IOException
+ {
+ copyClass(clazz.getName(), root);
+ }
+
+ private static void copyClass(String className, File root) throws IOException
+ {
+ String classFilePathName = getClassFileName(className);
+ String directoryName = classFilePathName.substring(0, classFilePathName.lastIndexOf("/"));
+ String classFileName = classFilePathName.substring(classFilePathName.lastIndexOf("/") + 1);
+ File packageDirectory = makeDirectoryStructure(root, directoryName);
+ File classFile = new File(packageDirectory, classFileName);
+ classFile.createNewFile();
+ classFile.deleteOnExit();
+ copy(loadResourceAsStream(classFilePathName), classFile);
+ }
+
+ private static File makeDirectoryStructure(File root, String directoryName)
+ {
+ for (String directory : directoryName.split("\\/"))
+ {
+ root = new File(root, directory);
+ root.mkdir();
+ root.deleteOnExit();
+ }
+ return root;
+ }
+
+ private static String getClassFileName(String className)
+ {
+ return className.replace('.', '/') + ".class";
+ }
+
+ private static void copy(InputStream inputStream, File file) throws IOException
+ {
+ OutputStream os = new FileOutputStream(file);
+ try
+ {
+ byte[] buf = new byte[1024];
+ int i = 0;
+ while ((i = inputStream.read(buf)) != -1)
+ {
+ os.write(buf, 0, i);
+ }
+ }
+ finally
+ {
+ os.close();
+ }
+
+ }
+
+ public Set<Class<?>> getClasses()
+ {
+ return classes;
+ }
+
+ public Set<ResourceDescriptor> getResources()
+ {
+ return resources;
+ }
+
+ public Set<Package> getPackages()
+ {
+ return packages;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ArtifactDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Classes.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Classes.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Classes.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Classes
+{
+
+ Class<?>[] value();
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Classes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/DeclarativeArtifactProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/DeclarativeArtifactProcessor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/DeclarativeArtifactProcessor.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,165 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static org.jboss.webbeans.tck.impl.packaging.PackagingType.EAR;
+import static org.jboss.webbeans.tck.impl.packaging.PackagingType.UNSPECIFIED;
+import static org.jboss.webbeans.tck.impl.packaging.PackagingType.WAR;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.webbeans.tck.impl.packaging.jsr299.BeansXml;
+import org.jboss.webbeans.tck.impl.packaging.jsr299.TCKArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.packaging.war.WarArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.packaging.war.WebXml;
+
+public class DeclarativeArtifactProcessor
+{
+
+ private final boolean unit;
+ private final boolean ejbs;
+ private final boolean addDeclaringPackage;
+ private final String beansXml;
+ private final String webXml;
+ private final PackagingType packagingType;
+ private final Collection<ResourceDescriptor> resources;
+ private final Collection<Class<?>> classes;
+
+ private Class<?> declaringClass;
+
+ public DeclarativeArtifactProcessor(Class<?> declaringClass)
+ {
+ this.declaringClass = declaringClass;
+
+ if (declaringClass.isAnnotationPresent(Artifact.class))
+ {
+ this.addDeclaringPackage = declaringClass.getAnnotation(Artifact.class).addCurrentPackage();
+ this.ejbs = false;
+ }
+ else if (declaringClass.isAnnotationPresent(EjbArtifact.class))
+ {
+ this.addDeclaringPackage = declaringClass.getAnnotation(EjbArtifact.class).addCurrentPackage();
+ this.ejbs = true;
+ }
+ else
+ {
+ throw new IllegalStateException("Unable to find @Artifact on " + declaringClass);
+ }
+
+ if (declaringClass.isAnnotationPresent(BeansXml.class))
+ {
+ this.beansXml = asAbsolutePath(declaringClass.getAnnotation(BeansXml.class).value());
+ }
+ else
+ {
+ this.beansXml = null;
+ }
+
+ if (declaringClass.isAnnotationPresent(Packaging.class))
+ {
+ this.packagingType = declaringClass.getAnnotation(Packaging.class).value();
+ }
+ else
+ {
+ this.packagingType = UNSPECIFIED;
+ }
+
+ if (declaringClass.isAnnotationPresent(IntegrationTest.class))
+ {
+ this.unit = false;
+ }
+ else
+ {
+ this.unit = true;
+ }
+
+ if (unit && (packagingType.equals(WAR) || packagingType.equals(EAR)))
+ {
+ throw new IllegalArgumentException("Cannot specify @Packaging(WAR) or @Packaging(EAR) if @Integration test is not present");
+ }
+
+ if (declaringClass.isAnnotationPresent(WebXml.class))
+ {
+ if (packagingType == null)
+ {
+ throw new IllegalArgumentException("Cannot specify @WebXml for non-integration tests");
+ }
+ else
+ {
+ this.webXml = asAbsolutePath(declaringClass.getAnnotation(WebXml.class).value());
+ }
+ }
+ else
+ {
+ this.webXml = null;
+ }
+
+ if (declaringClass.isAnnotationPresent(Resources.class))
+ {
+ this.resources = asResourceDescriptors(declaringClass.getAnnotation(Resources.class).value());
+ }
+ else
+ {
+ this.resources = Collections.emptyList();
+ }
+
+ if (declaringClass.isAnnotationPresent(Classes.class))
+ {
+ this.classes = Arrays.asList(declaringClass.getAnnotation(Classes.class).value());
+ }
+ else
+ {
+ this.classes = Collections.emptyList();
+ }
+ }
+
+ public TCKArtifactDescriptor getArtifact()
+ {
+ final TCKArtifactDescriptor artifact;
+ switch (packagingType)
+ {
+ case WAR:
+ artifact = new WarArtifactDescriptor(beansXml, webXml);
+ break;
+ case EAR:
+ throw new UnsupportedOperationException();
+ default:
+ artifact = new TCKArtifactDescriptor(beansXml);
+ break;
+ }
+ if (addDeclaringPackage)
+ {
+ artifact.getPackages().add(declaringClass.getPackage());
+ }
+ artifact.setEjbs(ejbs);
+ artifact.setUnit(unit);
+ artifact.getClasses().addAll(classes);
+ artifact.getResources().addAll(resources);
+ return artifact;
+ }
+
+ private Collection<ResourceDescriptor> asResourceDescriptors(Resource[] resources)
+ {
+ List<ResourceDescriptor> resourceDescriptors = new ArrayList<ResourceDescriptor>();
+ for (Resource resource : resources)
+ {
+ resourceDescriptors.add(new ResourceDescriptor(resource.destination(), asAbsolutePath(resource.source())));
+ }
+ return resourceDescriptors;
+ }
+
+ private String asAbsolutePath(String path)
+ {
+ if (path.startsWith("/"))
+ {
+ return path.substring(1);
+ }
+ else
+ {
+ return declaringClass.getPackage().getName().replace(".", "/") + "/" + path;
+ }
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/DeclarativeArtifactProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/EjbArtifact.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/EjbArtifact.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/EjbArtifact.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface EjbArtifact
+{
+
+ boolean addCurrentPackage() default true;
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/EjbArtifact.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/IntegrationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/IntegrationTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/IntegrationTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface IntegrationTest
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/IntegrationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Packaging.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Packaging.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Packaging.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Packaging
+{
+
+ PackagingType value() default PackagingType.UNSPECIFIED;
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Packaging.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/PackagingType.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/PackagingType.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/PackagingType.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,8 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+public enum PackagingType
+{
+
+ UNSPECIFIED, EAR, WAR;
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/PackagingType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resource.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resource.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resource.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Resource
+{
+
+ String source();
+
+ String destination();
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ResourceDescriptor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ResourceDescriptor.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/ResourceDescriptor.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.tck.impl.packaging;
+import static org.jboss.webbeans.tck.impl.util.Reflections.loadResource;
+
import java.net.URL;
public class ResourceDescriptor
@@ -14,6 +16,20 @@
this.source = source;
}
+ public ResourceDescriptor(String name, String source)
+ {
+ this.name = name;
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Unable to have a null resource");
+ }
+ this.source = loadResource(source);
+ if (this.source == null)
+ {
+ throw new IllegalArgumentException("Unable to load file for " + source);
+ }
+ }
+
public String getName()
{
return name;
@@ -24,4 +40,30 @@
return source;
}
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ResourceDescriptor)
+ {
+ ResourceDescriptor that = (ResourceDescriptor) obj;
+ return this.getName().equals(that.getName());
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return name + " (" + source.toString() + ")";
+ }
+
}
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resources.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resources.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resources.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.packaging;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Resources
+{
+
+ Resource[] value();
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/Resources.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/TCKArtifact.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/TCKArtifact.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/TCKArtifact.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,20 +0,0 @@
-package org.jboss.webbeans.tck.impl.packaging;
-
-import org.jboss.webbeans.tck.AbstractTest;
-import org.jboss.webbeans.tck.impl.util.Reflections;
-import org.jboss.webbeans.tck.literals.NewLiteral;
-
-public class TCKArtifact extends Artifact
-{
-
- public TCKArtifact()
- {
- super();
- getPackages().add(AbstractTest.class.getPackage());
- getPackages().add(NewLiteral.class.getPackage());
- getPackages().add(Reflections.class.getPackage());
- }
-
-
-
-}
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/BeansXml.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/BeansXml.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/BeansXml.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.packaging.jsr299;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface BeansXml
+{
+
+ String value();
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/BeansXml.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/JSR299ArtifactDescriptor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/JSR299ArtifactDescriptor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/JSR299ArtifactDescriptor.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.tck.impl.packaging.jsr299;
+
+import static org.jboss.webbeans.tck.impl.util.Strings.isEmpty;
+
+import org.jboss.webbeans.tck.impl.packaging.ArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.packaging.ResourceDescriptor;
+
+public class JSR299ArtifactDescriptor extends ArtifactDescriptor
+{
+
+ public static final String BEANS_XML_DESTINATION = "META-INF/beans.xml";
+ public static final String STANDARD_BEANS_XML_FILE_NAME = "org/jboss/webbeans/tck/impl/packaging/jsr299/default/beans.xml";
+
+ public JSR299ArtifactDescriptor(String beansXmlSourceFileName)
+ {
+ if (isEmpty(beansXmlSourceFileName))
+ {
+ beansXmlSourceFileName = STANDARD_BEANS_XML_FILE_NAME;
+ }
+ getResources().add(new ResourceDescriptor(BEANS_XML_DESTINATION, beansXmlSourceFileName));
+ }
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/TCKArtifactDescriptor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/TCKArtifactDescriptor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/jsr299/TCKArtifactDescriptor.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,41 @@
+package org.jboss.webbeans.tck.impl.packaging.jsr299;
+
+import org.jboss.webbeans.tck.AbstractTest;
+import org.jboss.webbeans.tck.impl.util.Reflections;
+import org.jboss.webbeans.tck.literals.NewLiteral;
+
+public class TCKArtifactDescriptor extends JSR299ArtifactDescriptor
+{
+
+ private boolean unit;
+ private boolean ejbs;
+
+ public TCKArtifactDescriptor(String beansXmlSourceFileName)
+ {
+ super(beansXmlSourceFileName);
+ getPackages().add(AbstractTest.class.getPackage());
+ getPackages().add(NewLiteral.class.getPackage());
+ getPackages().add(Reflections.class.getPackage());
+ }
+
+ public boolean isEjbs()
+ {
+ return ejbs;
+ }
+
+ public void setEjbs(boolean ejbs)
+ {
+ this.ejbs = ejbs;
+ }
+
+ public boolean isUnit()
+ {
+ return unit;
+ }
+
+ public void setUnit(boolean unit)
+ {
+ this.unit = unit;
+ }
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war (from rev 1408, tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/standard/war)
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifact.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/standard/war/WarArtifact.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifact.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,49 +0,0 @@
-package org.jboss.webbeans.tck.impl.packaging.standard.war;
-
-import static org.jboss.webbeans.tck.impl.util.Reflections.loadResource;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.webbeans.tck.impl.packaging.ResourceDescriptor;
-import org.jboss.webbeans.tck.impl.packaging.TCKArtifact;
-
-public class WarArtifact extends TCKArtifact
-{
-
- public static final String WEB_XML_DESTINATION = "WEB-INF/web.xml";
- public static final String STANDARD_WEB_XML_FILE_NAME = "org/jboss/webbeans/tck/impl/packaging/standard/war/web.xml";
-
- public static final String BEANS_XML_DESTINATION = "WEB-INF/beans.xml";
- public static final String STANDARD_BEANS_XML_FILE_NAME = "org/jboss/webbeans/tck/impl/packaging/standard/war/beans.xml";
-
- public static WarArtifact of(Class<?>... classes)
- {
- WarArtifact war = new WarArtifact();
- war.getClasses().addAll(new HashSet<Class<?>>(Arrays.asList(classes)));
- return war;
- }
-
- public WarArtifact()
- {
- Set<ResourceDescriptor> standardResources = new HashSet<ResourceDescriptor>();
- standardResources.add(new ResourceDescriptor(BEANS_XML_DESTINATION, getBeansXmlSource()));
- standardResources.add(new ResourceDescriptor(WEB_XML_DESTINATION, getWebXmlSource()));
- getResources().addAll((standardResources));
- }
-
- public URL getBeansXmlSource()
- {
- return loadResource(STANDARD_BEANS_XML_FILE_NAME);
- }
-
- public URL getWebXmlSource()
- {
- return loadResource(STANDARD_WEB_XML_FILE_NAME);
- }
-
-
-
-}
Copied: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifactDescriptor.java (from rev 1408, tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/standard/war/WarArtifact.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifactDescriptor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifactDescriptor.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.tck.impl.packaging.war;
+
+import static org.jboss.webbeans.tck.impl.util.Strings.isEmpty;
+
+import org.jboss.webbeans.tck.impl.packaging.ResourceDescriptor;
+import org.jboss.webbeans.tck.impl.packaging.jsr299.TCKArtifactDescriptor;
+
+public class WarArtifactDescriptor extends TCKArtifactDescriptor
+{
+
+ public static final String WEB_XML_DESTINATION = "WEB-INF/web.xml";
+ public static final String STANDARD_WEB_XML_FILE_NAME = "org/jboss/webbeans/tck/impl/packaging/war/default/web.xml";
+
+ public WarArtifactDescriptor(String beansXmlSourceFileName, String webXmlSourceFileName)
+ {
+ super(beansXmlSourceFileName);
+ if (isEmpty(webXmlSourceFileName))
+ {
+ webXmlSourceFileName = STANDARD_WEB_XML_FILE_NAME;
+ }
+ getResources().add(new ResourceDescriptor(WEB_XML_DESTINATION, webXmlSourceFileName));
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WarArtifactDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WebXml.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WebXml.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WebXml.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.packaging.war;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface WebXml
+{
+
+ String value();
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/packaging/war/WebXml.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,106 +0,0 @@
-package org.jboss.webbeans.tck.impl.report;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.webbeans.tck.SpecAssertion;
-import org.jboss.webbeans.tck.SpecAssertions;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.util.DeclarationVisitors;
-import com.sun.mirror.util.SimpleDeclarationVisitor;
-
-/**
- * Annotation processor for generating TCK coverage report
- *
- * @author Shane Bryzak
- */
-public class CoverageProcessor implements AnnotationProcessor
-{
- private static final String OUTDIR_OPTION_NAME = "-s";
- private static final String REPORT_FILE_NAME = "coverage.html";
-
- private static final String AUDIT_FILE_NAME = "tck-audit.xml";
-
- private final AnnotationProcessorEnvironment env;
- private final File baseDir;
-
- private final List<SpecReference> references = new ArrayList<SpecReference>();
-
- private AuditParser auditParser;
-
- public CoverageProcessor(AnnotationProcessorEnvironment env)
- {
- this.env = env;
- String baseDirName = env.getOptions().get( OUTDIR_OPTION_NAME );
- baseDir = new File( baseDirName );
- baseDir.mkdirs();
-
- try
- {
- auditParser = new AuditParser(new FileInputStream(AUDIT_FILE_NAME));
- auditParser.parse();
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Error parsing tck-audit.xml: " +
- ex.getClass().getName() + " - " + ex.getMessage(), ex);
- }
- }
-
- public void process()
- {
- AnnotationTypeDeclaration annotationType = (AnnotationTypeDeclaration)
- env.getTypeDeclaration(SpecAssertion.class.getCanonicalName());
-
- for (Declaration d : env.getDeclarationsAnnotatedWith(annotationType))
- {
- d.accept(DeclarationVisitors.getDeclarationScanner(
- new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
- }
-
- annotationType = (AnnotationTypeDeclaration)
- env.getTypeDeclaration(SpecAssertions.class.getCanonicalName());
- for (Declaration d : env.getDeclarationsAnnotatedWith(annotationType))
- {
- d.accept(DeclarationVisitors.getDeclarationScanner(
- new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
- }
-
-
- new CoverageReport(references, auditParser).writeToFile(new File(baseDir, REPORT_FILE_NAME));
- }
-
- private class CreateReferenceVisitor extends SimpleDeclarationVisitor
- {
- public void visitMethodDeclaration(MethodDeclaration d)
- {
- SpecAssertions assertions = d.getAnnotation ( SpecAssertions.class );
- if (assertions != null)
- {
- for (SpecAssertion assertion : assertions.value())
- {
- SpecReference ref = new SpecReference(
- assertion.section(), assertion.id(),
- d.getDeclaringType().getSimpleName(), d.getSimpleName());
- references.add( ref );
- }
- }
-
- SpecAssertion assertion = d.getAnnotation( SpecAssertion.class );
- if (assertion != null)
- {
- SpecReference ref = new SpecReference(
- assertion.section(), assertion.id(),
- d.getDeclaringType().getSimpleName(), d.getSimpleName());
- references.add( ref );
- }
- }
- }
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessorFactory.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessorFactory.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessorFactory.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,41 +0,0 @@
-package org.jboss.webbeans.tck.impl.report;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import org.jboss.webbeans.tck.SpecAssertion;
-import org.jboss.webbeans.tck.SpecAssertions;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class CoverageProcessorFactory implements AnnotationProcessorFactory
-{
- private static final Collection<String> supportedAnnotations = Collections.unmodifiableCollection(
- Arrays.asList(
- SpecAssertion.class.getCanonicalName(),
- SpecAssertions.class.getCanonicalName()
- )
- );
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> annotationTypeDeclarations,
- AnnotationProcessorEnvironment env)
- {
- return new CoverageProcessor(env);
- }
-
- public Collection<String> supportedAnnotationTypes()
- {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions()
- {
- return null;
- }
-
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Reflections.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Reflections.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Reflections.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -10,7 +10,7 @@
import java.util.List;
import java.util.Set;
-import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.ArtifactDescriptor;
/**
* Utility class for static reflection-type operations
@@ -54,7 +54,7 @@
}
if (is == null)
{
- is = Artifact.class.getResourceAsStream(name);
+ is = ArtifactDescriptor.class.getResourceAsStream(name);
}
return is;
}
@@ -68,7 +68,7 @@
}
if (url == null)
{
- url = Artifact.class.getResource(name);
+ url = ArtifactDescriptor.class.getResource(name);
}
return url;
}
@@ -82,7 +82,7 @@
}
if (urls == null)
{
- urls = Artifact.class.getClassLoader().getResources(name);
+ urls = ArtifactDescriptor.class.getClassLoader().getResources(name);
}
return new EnumerationIterable<URL>(urls);
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Strings.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Strings.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/util/Strings.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -2,9 +2,9 @@
import java.util.StringTokenizer;
-class Strings
+public class Strings
{
- public static String[] split(String strings, String delims)
+ static String[] split(String strings, String delims)
{
if (strings == null)
{
@@ -22,4 +22,9 @@
return result;
}
}
+
+ public static boolean isEmpty(String string)
+ {
+ return string == null || string.length() == 0;
+ }
}
Added: tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/jsr299/default/beans.xml
===================================================================
Copied: tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war (from rev 1408, tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/standard/war)
Added: tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/default/web.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/default/web.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/default/web.xml 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>JSR-299 TCK</display-name>
+
+</web-app>
Property changes on: tck/trunk/impl/src/main/resources/org/jboss/webbeans/tck/impl/packaging/war/default/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/AbstractArtifactTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/AbstractArtifactTest.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/AbstractArtifactTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,7 +1,12 @@
package org.jboss.webbeans.tck.impl.test.packaging;
+import java.io.BufferedInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.util.Arrays;
public abstract class AbstractArtifactTest
@@ -15,6 +20,14 @@
}
};
+ protected static final FilenameFilter META_INF_FILTER = new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("META-INF");
+ }
+ };
+
protected static final FilenameFilter BEANS_XML_FILTER = new FilenameFilter()
{
@@ -68,4 +81,24 @@
return root;
}
+ protected String readFile(File file) throws IOException
+ {
+ if (file.isFile())
+ {
+ Reader reader = new InputStreamReader(new BufferedInputStream(new FileInputStream(file)));
+ StringBuffer buffer = new StringBuffer(1024);
+ char[] bytes = new char[1024];
+ while (reader.read(bytes) > -1)
+ {
+ buffer.append(String.valueOf(bytes));
+ }
+ reader.close();
+ return buffer.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
}
Copied: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java (from rev 1408, tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/defined/ArtifactTest.java)
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,69 @@
+package org.jboss.webbeans.tck.impl.test.packaging;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.jboss.webbeans.tck.AbstractTest;
+import org.jboss.webbeans.tck.impl.packaging.ArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.packaging.jsr299.TCKArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.packaging.war.WarArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.util.Reflections;
+import org.jboss.webbeans.tck.literals.NewLiteral;
+import org.testng.annotations.Test;
+
+public class ArtifactTest extends AbstractArtifactTest
+{
+
+ @Test
+ public void testDefaultWar() throws Exception
+ {
+ WarArtifactDescriptor war = new WarArtifactDescriptor(null, null);
+ war.getClasses().add(Cow.class);
+ File root = war.create();
+ assert root.listFiles().length == 3;
+ assert root.isDirectory();
+ assert root.listFiles(WEB_INF_FILTER).length == 1;
+ File metaInf = root.listFiles(META_INF_FILTER)[0];
+ assert metaInf.getName().equals("META-INF");
+ assert metaInf.isDirectory();
+ assert metaInf.listFiles().length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER).length == 1;
+ File beansXml = metaInf.listFiles(BEANS_XML_FILTER)[0];
+ assert beansXml.isFile();
+ assert beansXml.getName().equals("beans.xml");
+ assert beansXml.length() == 0;
+ File webInf = root.listFiles(WEB_INF_FILTER)[0];
+ assert webInf.getName().equals("WEB-INF");
+ assert webInf.isDirectory();
+ assert webInf.listFiles().length == 1;
+ assert webInf.listFiles(WEB_XML_FILTER).length == 1;
+ File webXml = webInf.listFiles(WEB_XML_FILTER)[0];
+ assert webXml.isFile();
+ assert webXml.getName().equals("web.xml");
+ assert webXml.length() != 0;
+ File currentPackage = getCurrentPackageAsFile(root);
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+ }
+
+ @Test
+ public void testDefaultTCKArtifact() throws Exception
+ {
+ ArtifactDescriptor artifactDescriptor = new TCKArtifactDescriptor(null);
+ File root = artifactDescriptor.create();
+ assert getPackageAsFile(Reflections.class.getPackage(), root).listFiles().length > 0;
+ assert getPackageAsFile(NewLiteral.class.getPackage(), root).listFiles().length > 0;
+ assert getPackageAsFile(AbstractTest.class.getPackage(), root).listFiles().length > 0;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/ArtifactTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/Cow.java (from rev 1408, tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/defined/Cow.java)
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/Cow.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/Cow.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.impl.test.packaging;
+
+class Cow
+{
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/Cow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/all/ArtifactTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/all/ArtifactTest.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/all/ArtifactTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -2,9 +2,8 @@
import java.io.File;
import java.io.FilenameFilter;
-import java.util.Arrays;
-import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.ArtifactDescriptor;
import org.jboss.webbeans.tck.impl.test.packaging.AbstractArtifactTest;
import org.testng.annotations.Test;
@@ -14,11 +13,10 @@
@Test
public void testAllClassesInPackage() throws Exception
{
- Artifact artifact = new Artifact();
- artifact.getPackages().add(ArtifactTest.class.getPackage());
- File root = artifact.create();
+ ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor();
+ artifactDescriptor.getPackages().add(ArtifactTest.class.getPackage());
+ File root = artifactDescriptor.create();
File currentPackage = getCurrentPackageAsFile(root);
- System.out.println(Arrays.asList(currentPackage.listFiles()));
assert currentPackage.listFiles().length == 6;
File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
{
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/ArtifactTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/ArtifactTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/ArtifactTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,144 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.jboss.webbeans.tck.impl.packaging.DeclarativeArtifactProcessor;
+import org.jboss.webbeans.tck.impl.packaging.jsr299.TCKArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.test.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class ArtifactTest extends AbstractArtifactTest
+{
+
+ @Test
+ public void testDefaultDeclartiveArtifact() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyTest.class);
+ TCKArtifactDescriptor artifact = declarativeArtifactProcessor.getArtifact();
+ assert !artifact.isEjbs();
+ assert artifact.isUnit();
+ File root = artifact.create();
+ File currentPackage = getCurrentPackageAsFile(root);
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+ File[] foxClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Fox.class");
+ }
+
+ });
+ assert foxClasses.length == 1;
+ assert foxClasses[0].getName().equals("Fox.class");
+ assert foxClasses[0].isFile();
+
+ File[] testClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("DummyTest");
+ }
+
+ });
+ assert testClasses.length == 1;
+
+ assert root.listFiles(META_INF_FILTER).length == 1;
+ File metaInf = root.listFiles(META_INF_FILTER)[0];
+ assert metaInf.listFiles().length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER).length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER)[0].length() == 0;
+ }
+
+ @Test
+ public void testClassesSpecifiedArtifact() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyClassesSpecifiedTest.class);
+ TCKArtifactDescriptor artifact = declarativeArtifactProcessor.getArtifact();
+ File root = artifact.create();
+ File currentPackage = getCurrentPackageAsFile(root);
+ assert currentPackage.listFiles().length == 1;
+ File[] pestPackages = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("pests");
+ }
+
+ });
+ assert pestPackages.length == 1;
+ File pestPackage = pestPackages[0];
+ assert pestPackage.listFiles().length == 1;
+ assert pestPackage.listFiles()[0].getName().equals("Rat.class");
+ }
+
+ @Test
+ public void testResourcesSpecifiedArtifact() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyResourcesSpecifiedTest.class);
+ TCKArtifactDescriptor artifact = declarativeArtifactProcessor.getArtifact();
+ File root = artifact.create();
+ assert root.listFiles(META_INF_FILTER).length == 1;
+ File metaInf = root.listFiles(META_INF_FILTER)[0];
+ assert metaInf.listFiles().length == 2;
+ assert metaInf.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("bar.xml");
+ }
+
+ }).length == 1;
+ }
+
+ @Test
+ public void testIntegrationTestDeclartiveArtifact() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyIntegrationTest.class);
+ assert !declarativeArtifactProcessor.getArtifact().isUnit();
+ }
+
+ @Test
+ public void testCustomBeansXml() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyCustomBeansXmlTest.class);
+ TCKArtifactDescriptor artifact = declarativeArtifactProcessor.getArtifact();
+ File root = artifact.create();
+ assert root.listFiles(META_INF_FILTER).length == 1;
+ File metaInf = root.listFiles(META_INF_FILTER)[0];
+ assert metaInf.listFiles().length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER).length == 1;
+ assert metaInf.listFiles(BEANS_XML_FILTER)[0].length() != 0;
+ String beans = readFile(metaInf.listFiles(BEANS_XML_FILTER)[0]);
+ assert beans.startsWith("<my></my>");
+ }
+
+ @Test
+ public void testEjbTestDeclartiveArtifact() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyEjbTest.class);
+ assert declarativeArtifactProcessor.getArtifact().isEjbs();
+ }
+
+ @Test(expectedExceptions=IllegalArgumentException.class)
+ public void testWrongPackaging()
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyWarUnitTest_Broken.class);
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/ArtifactTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Cow.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Cow.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Cow.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+class Cow
+{
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Cow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyClassesSpecifiedTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyClassesSpecifiedTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyClassesSpecifiedTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.Classes;
+import org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified.pests.Rat;
+
+
+@Artifact(addCurrentPackage=false)
+(a)Classes(Rat.class)
+class DummyClassesSpecifiedTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyClassesSpecifiedTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyCustomBeansXmlTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyCustomBeansXmlTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyCustomBeansXmlTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.jsr299.BeansXml;
+
+
+@Artifact @BeansXml(value="my-web-beans.xml")
+class DummyCustomBeansXmlTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyCustomBeansXmlTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyEjbTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyEjbTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyEjbTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import org.jboss.webbeans.tck.impl.packaging.EjbArtifact;
+
+
+@EjbArtifact
+class DummyEjbTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyEjbTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyIntegrationTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyIntegrationTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyIntegrationTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.IntegrationTest;
+
+
+@Artifact
+@IntegrationTest
+class DummyIntegrationTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyIntegrationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyResourcesSpecifiedTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyResourcesSpecifiedTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyResourcesSpecifiedTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.Resource;
+import org.jboss.webbeans.tck.impl.packaging.Resources;
+
+
+@Artifact(addCurrentPackage=false)
+@Resources(value=@Resource(destination = "/META-INF/bar.xml", source="foo/foo.xml"))
+class DummyResourcesSpecifiedTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyResourcesSpecifiedTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+
+
+@Artifact
+class DummyTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyWarUnitTest_Broken.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyWarUnitTest_Broken.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyWarUnitTest_Broken.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.Packaging;
+import org.jboss.webbeans.tck.impl.packaging.PackagingType;
+
+
+@Artifact
+(a)Packaging(PackagingType.WAR)
+class DummyWarUnitTest_Broken
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/DummyWarUnitTest_Broken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Fox.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Fox.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Fox.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified;
+
+class Fox
+{
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/Fox.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/pests/Rat.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/pests/Rat.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/pests/Rat.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.unspecified.pests;
+
+public class Rat
+{
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/pests/Rat.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/ArtifactTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/ArtifactTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/ArtifactTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,49 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.war;
+
+import java.io.File;
+
+import org.jboss.webbeans.tck.impl.packaging.DeclarativeArtifactProcessor;
+import org.jboss.webbeans.tck.impl.packaging.jsr299.TCKArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.test.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class ArtifactTest extends AbstractArtifactTest
+{
+
+ @Test
+ public void testDefaultWebXml() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyTest.class);
+ TCKArtifactDescriptor artifact = declarativeArtifactProcessor.getArtifact();
+ File root = artifact.create();
+ assert root.listFiles(WEB_INF_FILTER).length == 1;
+ File webInf = root.listFiles(WEB_INF_FILTER)[0];
+ assert webInf.getName().equals("WEB-INF");
+ assert webInf.isDirectory();
+ assert webInf.listFiles().length == 1;
+ assert webInf.listFiles(WEB_XML_FILTER).length == 1;
+ File webXml = webInf.listFiles(WEB_XML_FILTER)[0];
+ assert webXml.isFile();
+ assert webXml.getName().equals("web.xml");
+ assert webXml.length() != 0;
+ }
+
+ @Test
+ public void testCustomWebXml() throws Exception
+ {
+ DeclarativeArtifactProcessor declarativeArtifactProcessor = new DeclarativeArtifactProcessor(DummyCustomWebXmlTest.class);
+ TCKArtifactDescriptor artifact = declarativeArtifactProcessor.getArtifact();
+ File root = artifact.create();
+ assert root.listFiles(WEB_INF_FILTER).length == 1;
+ File webInf = root.listFiles(WEB_INF_FILTER)[0];
+ assert webInf.getName().equals("WEB-INF");
+ assert webInf.isDirectory();
+ assert webInf.listFiles().length == 1;
+ assert webInf.listFiles(WEB_XML_FILTER).length == 1;
+ File webXml = webInf.listFiles(WEB_XML_FILTER)[0];
+ assert webXml.isFile();
+ assert webXml.getName().equals("web.xml");
+ assert readFile(webXml).startsWith("<web></web>");
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/ArtifactTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Cow.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Cow.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Cow.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.war;
+
+class Cow
+{
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Cow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyCustomWebXmlTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyCustomWebXmlTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyCustomWebXmlTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.war;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.IntegrationTest;
+import org.jboss.webbeans.tck.impl.packaging.Packaging;
+import org.jboss.webbeans.tck.impl.packaging.PackagingType;
+import org.jboss.webbeans.tck.impl.packaging.war.WebXml;
+
+
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.WAR)
+@WebXml("my-web.xml")
+class DummyCustomWebXmlTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyCustomWebXmlTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.war;
+
+import org.jboss.webbeans.tck.impl.packaging.Artifact;
+import org.jboss.webbeans.tck.impl.packaging.IntegrationTest;
+import org.jboss.webbeans.tck.impl.packaging.Packaging;
+import org.jboss.webbeans.tck.impl.packaging.PackagingType;
+
+
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.WAR)
+class DummyTest
+{
+
+ public void test()
+ {
+ assert true;
+ }
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/DummyTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Fox.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Fox.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Fox.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.impl.test.packaging.declarativeArtifact.war;
+
+class Fox
+{
+
+}
Property changes on: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/Fox.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,46 +0,0 @@
-package org.jboss.webbeans.tck.impl.test.packaging.subpackages;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.jboss.webbeans.tck.impl.packaging.Artifact;
-import org.jboss.webbeans.tck.impl.test.packaging.AbstractArtifactTest;
-import org.testng.annotations.Test;
-
-public class ArtifactTest extends AbstractArtifactTest
-{
-
- @Test
- public void testAllClassesInPackageAndNotSubPackages() throws Exception
- {
- Artifact artifact = new Artifact();
- artifact.getPackages().add(ArtifactTest.class.getPackage());
- File root = artifact.create();
- File currentPackage = getCurrentPackageAsFile(root);
- assert currentPackage.listFiles().length == 4;
- File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.equals("Cow.class");
- }
-
- });
- assert cowClasses.length == 1;
- assert cowClasses[0].getName().equals("Cow.class");
- assert cowClasses[0].isFile();
-
- File[] testClasses = currentPackage.listFiles(new FilenameFilter()
- {
-
- public boolean accept(File dir, String name)
- {
- return name.startsWith("ArtifactTest");
- }
-
- });
- assert testClasses.length == 3;
- }
-
-}
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/ArtifactTest.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,46 @@
+package org.jboss.webbeans.tck.impl.test.packaging.subpackages;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.jboss.webbeans.tck.impl.packaging.ArtifactDescriptor;
+import org.jboss.webbeans.tck.impl.test.packaging.AbstractArtifactTest;
+import org.testng.annotations.Test;
+
+public class ArtifactTest extends AbstractArtifactTest
+{
+
+ @Test
+ public void testAllClassesInPackageAndNotSubPackages() throws Exception
+ {
+ ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor();
+ artifactDescriptor.getPackages().add(ArtifactTest.class.getPackage());
+ File root = artifactDescriptor.create();
+ File currentPackage = getCurrentPackageAsFile(root);
+ assert currentPackage.listFiles().length == 4;
+ File[] cowClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.equals("Cow.class");
+ }
+
+ });
+ assert cowClasses.length == 1;
+ assert cowClasses[0].getName().equals("Cow.class");
+ assert cowClasses[0].isFile();
+
+ File[] testClasses = currentPackage.listFiles(new FilenameFilter()
+ {
+
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("ArtifactTest");
+ }
+
+ });
+ assert testClasses.length == 3;
+ }
+
+}
Deleted: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -1,6 +0,0 @@
-package org.jboss.webbeans.tck.impl.test.packaging.subpackages;
-
-class Cow
-{
-
-}
Added: tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java
===================================================================
--- tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java (rev 0)
+++ tck/trunk/impl/src/test/java/org/jboss/webbeans/tck/impl/test/packaging/subpackages/Cow.java 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.tck.impl.test.packaging.subpackages;
+
+class Cow
+{
+
+}
Added: tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/foo/foo.xml
===================================================================
Property changes on: tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/foo/foo.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/my-web-beans.xml
===================================================================
--- tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/my-web-beans.xml (rev 0)
+++ tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/my-web-beans.xml 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1 @@
+<my></my>
\ No newline at end of file
Property changes on: tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/unspecified/my-web-beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/my-web.xml
===================================================================
--- tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/my-web.xml (rev 0)
+++ tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/my-web.xml 2009-02-04 17:10:43 UTC (rev 1409)
@@ -0,0 +1 @@
+<web></web>
\ No newline at end of file
Property changes on: tck/trunk/impl/src/test/resources/org/jboss/webbeans/tck/impl/test/packaging/declarativeArtifact/war/my-web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/pom.xml
===================================================================
--- tck/trunk/pom.xml 2009-02-04 08:27:17 UTC (rev 1408)
+++ tck/trunk/pom.xml 2009-02-04 17:10:43 UTC (rev 1409)
@@ -157,20 +157,6 @@
</executions>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>apt-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-process</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <testOutputDirectory>${project.build.directory}/site</testOutputDirectory>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-8</version>
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1408 - doc/trunk/reference/zh-CN.
by webbeans-commits@lists.jboss.org
Author: alartin
Date: 2009-02-04 03:27:17 -0500 (Wed, 04 Feb 2009)
New Revision: 1408
Modified:
doc/trunk/reference/zh-CN/Author_Group.po
Log:
Modified: doc/trunk/reference/zh-CN/Author_Group.po
===================================================================
--- doc/trunk/reference/zh-CN/Author_Group.po 2009-02-04 08:21:25 UTC (rev 1407)
+++ doc/trunk/reference/zh-CN/Author_Group.po 2009-02-04 08:27:17 UTC (rev 1408)
@@ -6,8 +6,8 @@
"Project-Id-Version: Introduction_to_Web_Beans VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2009-02-01 21:16+0000\n"
-"PO-Revision-Date: 2009-01-04 23:18+0000\n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2009-02-04 15:30+0800\n"
+"Last-Translator: Sean Wu <alartin(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -17,86 +17,86 @@
#: Author_Group.xml:4
#, no-c-format
msgid "<firstname>Gavin</firstname> <surname>King</surname>"
-msgstr ""
+msgstr "<firstname>Gavin</firstname> <surname>King</surname>"
#. Tag: affiliation
#: Author_Group.xml:7
#, no-c-format
-msgid ""
-"<jobtitle>JSR-299 specification lead</jobtitle> <orgname>Red Hat Middleware "
-"LLC</orgname>"
-msgstr ""
+msgid "<jobtitle>JSR-299 specification lead</jobtitle> <orgname>Red Hat Middleware LLC</orgname>"
+msgstr "<jobtitle>JSR-299规范领导者</jobtitle> <orgname>红帽中间件有限责任公司</orgname>"
#. Tag: author
#: Author_Group.xml:12
#, no-c-format
msgid "<firstname>Pete</firstname> <surname>Muir</surname>"
-msgstr ""
+msgstr "<firstname>Pete</firstname> <surname>Muir</surname>"
#. Tag: affiliation
#: Author_Group.xml:15
#, no-c-format
-msgid ""
-"<jobtitle>Web Beans (JSR-299 Reference Implementation) lead </jobtitle> "
-"<orgname>Red Hat Middleware LLC</orgname>"
-msgstr ""
+msgid "<jobtitle>Web Beans (JSR-299 Reference Implementation) lead </jobtitle> <orgname>Red Hat Middleware LLC</orgname>"
+msgstr "<jobtitle>Web Beans (JSR-299参考实现) 领导者 </jobtitle> <orgname>红帽中间件有限责任公司</orgname>"
#. Tag: othercredit
#: Author_Group.xml:21
#, no-c-format
msgid "<firstname>Nicola</firstname> <surname>Benaglia</surname>"
-msgstr ""
+msgstr "<firstname>Nicola</firstname> <surname>Benaglia</surname>"
#. Tag: contrib
-#: Author_Group.xml:24 Author_Group.xml:53
+#: Author_Group.xml:24
+#: Author_Group.xml:53
#, no-c-format
msgid "Italian Translation"
-msgstr ""
+msgstr "意大利文翻译"
#. Tag: othercredit
#: Author_Group.xml:26
#, no-c-format
msgid "<firstname>Gladys</firstname> <surname>Guerrero</surname>"
-msgstr ""
+msgstr "<firstname>Gladys</firstname> <surname>Guerrero</surname>"
#. Tag: contrib
#: Author_Group.xml:29
#, no-c-format
msgid "Spanish Translation"
-msgstr ""
+msgstr "西班牙语翻译"
#. Tag: orgname
-#: Author_Group.xml:31 Author_Group.xml:39 Author_Group.xml:47
+#: Author_Group.xml:31
+#: Author_Group.xml:39
+#: Author_Group.xml:47
#, no-c-format
msgid "Red Hat Middleware LLC"
-msgstr ""
+msgstr "红帽中间件有限责任公司"
#. Tag: othercredit
#: Author_Group.xml:34
#, no-c-format
msgid "<firstname>Eun-Ju</firstname> <surname>Ki,</surname>"
-msgstr ""
+msgstr "<firstname>Eun-Ju</firstname> <surname>Ki,</surname>"
#. Tag: contrib
#: Author_Group.xml:37
#, no-c-format
msgid "Korean Translation"
-msgstr ""
+msgstr "韩国语翻译"
#. Tag: othercredit
#: Author_Group.xml:42
#, no-c-format
msgid "<firstname>Terry</firstname> <surname>Chuang</surname>"
-msgstr ""
+msgstr "<firstname>Terry</firstname> <surname>Chuang</surname>"
#. Tag: contrib
#: Author_Group.xml:45
#, no-c-format
msgid "Traditional Chinese Translation"
-msgstr ""
+msgstr "繁体中文翻译"
#. Tag: othercredit
#: Author_Group.xml:50
#, no-c-format
msgid "<firstname>Francesco</firstname> <surname>Milesi</surname>"
-msgstr ""
+msgstr "<firstname>Francesco</firstname> <surname>Milesi</surname>"
+
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1407 - tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-02-04 03:21:25 -0500 (Wed, 04 Feb 2009)
New Revision: 1407
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
Log:
fix section ordering, include @SpecAssertions
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java 2009-02-04 07:47:37 UTC (rev 1406)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java 2009-02-04 08:21:25 UTC (rev 1407)
@@ -3,6 +3,7 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -51,6 +52,49 @@
return assertions;
}
+ public List<String> getSectionIds()
+ {
+ List<String> sectionIds = new ArrayList<String>(assertions.keySet());
+
+ Collections.sort(sectionIds, new Comparator<String>() {
+ public int compare(String value1, String value2)
+ {
+ String[] parts1 = value1.split("[.]");
+ String[] parts2 = value2.split("[.]");
+
+ for (int i = 0;;i++)
+ {
+ if (parts1.length < (i + 1))
+ {
+ return parts2.length < (i + 1) ? 0 : 0;
+ }
+ else if (parts2.length < (i + 1))
+ {
+ return parts1.length < (i + 1) ? 0 : 1;
+ }
+
+ try
+ {
+ int val1 = Integer.parseInt(parts1[i]);
+ int val2 = Integer.parseInt(parts2[i]);
+
+ if (val1 != val2) return val1 - val2;
+ }
+ catch (NumberFormatException ex)
+ {
+ int comp = parts1[i].compareTo(parts2[i]);
+ if (comp != 0)
+ {
+ return comp;
+ }
+ }
+ }
+ }
+ });
+
+ return sectionIds;
+ }
+
/**
* Returns a sorted list of assertions for the specified section ID
*
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 07:47:37 UTC (rev 1406)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 08:21:25 UTC (rev 1407)
@@ -6,6 +6,7 @@
import java.util.List;
import org.jboss.webbeans.tck.SpecAssertion;
+import org.jboss.webbeans.tck.SpecAssertions;
import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
@@ -64,6 +65,15 @@
new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
}
+ annotationType = (AnnotationTypeDeclaration)
+ env.getTypeDeclaration(SpecAssertions.class.getCanonicalName());
+ for (Declaration d : env.getDeclarationsAnnotatedWith(annotationType))
+ {
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
+ }
+
+
new CoverageReport(references, auditParser).writeToFile(new File(baseDir, REPORT_FILE_NAME));
}
@@ -71,11 +81,26 @@
{
public void visitMethodDeclaration(MethodDeclaration d)
{
- SpecAssertion annotation = d.getAnnotation( SpecAssertion.class );
- SpecReference ref = new SpecReference(
- annotation.section(), annotation.id(),
- d.getDeclaringType().getSimpleName(), d.getSimpleName());
- references.add( ref );
+ SpecAssertions assertions = d.getAnnotation ( SpecAssertions.class );
+ if (assertions != null)
+ {
+ for (SpecAssertion assertion : assertions.value())
+ {
+ SpecReference ref = new SpecReference(
+ assertion.section(), assertion.id(),
+ d.getDeclaringType().getSimpleName(), d.getSimpleName());
+ references.add( ref );
+ }
+ }
+
+ SpecAssertion assertion = d.getAnnotation( SpecAssertion.class );
+ if (assertion != null)
+ {
+ SpecReference ref = new SpecReference(
+ assertion.section(), assertion.id(),
+ d.getDeclaringType().getSimpleName(), d.getSimpleName());
+ references.add( ref );
+ }
}
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 07:47:37 UTC (rev 1406)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 08:21:25 UTC (rev 1407)
@@ -101,14 +101,11 @@
}
private void writeCoverage(OutputStream out) throws IOException
- {
- List<String> sectionIds = new ArrayList<String>(auditParser.getAssertions().keySet());
- Collections.sort(sectionIds);
-
- for (String sectionId : sectionIds)
+ {
+ for (String sectionId : auditParser.getSectionIds())
{
- out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " + auditParser.getSectionTitle(sectionId) +
- "</div>\n").getBytes());
+ out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " +
+ auditParser.getSectionTitle(sectionId) + "</div>\n").getBytes());
List<AuditAssertion> sectionAssertions = auditParser.getAssertionsForSection(sectionId);
@@ -180,7 +177,8 @@
StringBuilder sb = new StringBuilder();
sb.append("<h3>Unmatched tests</h3>\n");
- sb.append("<p>The following tests do not match any known assertions</p>");
+ sb.append(String.format("<p>The following %d tests do not match any known assertions:</p>",
+ unmatched.size()));
sb.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n");
sb.append(" <tr><th>Section</th><th>Assertion</th><th>Test Class</th><th>Test Method</th></tr>\n");
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1406 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: conversation and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-02-04 02:47:37 -0500 (Wed, 04 Feb 2009)
New Revision: 1406
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
Log:
New theory on conversation handling for Pete to review (missing e.g. thread safety stuff )
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -36,6 +36,7 @@
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.servlet.SessionManager;
import org.jboss.webbeans.transaction.Transaction;
/**
@@ -103,6 +104,7 @@
beanDeployer.addClass(DefaultConversationManager.class);
beanDeployer.addClass(JavaSEConversationTerminator.class);
beanDeployer.addClass(NumericConversationIdGenerator.class);
+ beanDeployer.addClass(SessionManager.class);
beanDeployer.deploy();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -1,6 +1,23 @@
+/*
+ * 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.conversation;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import javax.servlet.http.HttpSession;
@@ -8,42 +25,99 @@
import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.servlet.ConversationBeanMap;
+/**
+ * Represents a long-running conversation entry
+ *
+ * @author Nicklas Karlsson
+ */
public class ConversationEntry
{
+ // The conversation ID
private String cid;
+ // The handle to the asynchronous timeout task
private Future<?> terminationHandle;
+ // The lock for concurrent access prevention
private ReentrantLock concurrencyLock;
+ /**
+ * Creates a new conversation entry
+ *
+ * @param cid The conversation ID
+ * @param terminationHandle The timeout termination handle
+ */
protected ConversationEntry(String cid, Future<?> terminationHandle)
{
this.cid = cid;
this.terminationHandle = terminationHandle;
- this.concurrencyLock = new ReentrantLock(true);
+ this.concurrencyLock = new ReentrantLock();
}
+ /**
+ * Factory method
+ *
+ * @param cid The conversation ID
+ * @param terminationHandle The timeout termination handle
+ * @return A new conversation entry
+ */
public static ConversationEntry of(String cid, Future<?> terminationHandle)
{
return new ConversationEntry(cid, terminationHandle);
}
+ /**
+ * Cancels the timeout termination
+ *
+ * @return True if successful, false otherwise
+ */
public boolean cancelTermination()
{
return terminationHandle.cancel(false);
}
+ /**
+ * Destroys the conversation and it's associated conversational context
+ *
+ * @param session The HTTP session for the backing context beanmap
+ */
public void destroy(HttpSession session)
{
+ if (!terminationHandle.isCancelled())
+ {
+ cancelTermination();
+ }
ConversationContext terminationContext = new ConversationContext();
terminationContext.setBeanMap(new ConversationBeanMap(session, cid));
terminationContext.destroy();
}
-
- public void lock() {
- concurrencyLock.lock();
+
+ /**
+ * Attempts to lock the conversation for exclusive usage
+ *
+ * @param timeoutInMilliseconds The time in milliseconds to wait on the lock
+ * @return True if lock was successful, false otherwise
+ * @throws InterruptedException If the lock operation was unsuccessful
+ */
+ public boolean lock(long timeoutInMilliseconds) throws InterruptedException
+ {
+ return concurrencyLock.tryLock(timeoutInMilliseconds, TimeUnit.MILLISECONDS);
}
-
- public void unlock() {
+
+ /**
+ * Attempts to unlock the conversation
+ */
+ public void unlock()
+ {
concurrencyLock.unlock();
}
+ /**
+ * Re-schedules timeout termination
+ *
+ * @param terminationHandle The fresh timeout termination handle
+ */
+ public void reScheduleTermination(Future<?> terminationHandle)
+ {
+ this.terminationHandle = terminationHandle;
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationIdGenerator.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -16,7 +16,17 @@
*/
package org.jboss.webbeans.conversation;
+/**
+ * Generates conversation ID:s for the conversation manager
+ *
+ * @author Nicklas Karlsson
+ * @see org.jboss.webbeans.conversation.ConversationManager#beginConversation(String)
+ */
public interface ConversationIdGenerator
{
+ /**
+ * Gets the next ID for a new conversation
+ * @return The ID
+ */
public abstract String nextId();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -17,25 +17,46 @@
package org.jboss.webbeans.conversation;
+import javax.annotation.Named;
import javax.context.Conversation;
import javax.context.RequestScoped;
+/**
+ * The current conversation implementation
+ *
+ * @author Nicklas Karlsson
+ * @see javax.context.Conversation
+ */
@RequestScoped
+@Named("conversation")
public class ConversationImpl implements Conversation
{
+ // The conversation ID
private String cid;
+ // Is the conversation long-running?
private boolean longRunning;
+ // The inactivity timeout in milliseconds
private long timeoutInMilliseconds;
- public ConversationImpl() {
- }
-
+ /**
+ * Creates a new conversation
+ *
+ * @param cid The conversation ID
+ * @param timeoutInMilliseconds The inactivity timeout in milliseconds
+ */
protected ConversationImpl(String cid, long timeoutInMilliseconds)
{
this.timeoutInMilliseconds = timeoutInMilliseconds;
this.cid = cid;
}
+ /**
+ * Factory method
+ *
+ * @param cid The conversation ID
+ * @param timeoutInMilliseconds The inactivity timeout in milliseconds
+ * @return A new conversation
+ */
public static ConversationImpl of(String cid, long timeoutInMilliseconds)
{
return new ConversationImpl(cid, timeoutInMilliseconds);
@@ -77,11 +98,18 @@
this.timeoutInMilliseconds = timeout;
}
- public void become(String cid, boolean longRunning, long timeout)
+ /**
+ * Assumes the identity of another conversation
+ *
+ * @param cid The new conversation ID
+ * @param longRunning The new long-running status
+ * @param timeout The new inactivity timeout in milliseconds
+ */
+ public void become(String cid, boolean longRunning, long timeoutInMilliseconds)
{
this.cid = cid;
this.longRunning = longRunning;
- this.timeoutInMilliseconds = timeout;
+ this.timeoutInMilliseconds = timeoutInMilliseconds;
}
@Override
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationManager.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -16,9 +16,43 @@
*/
package org.jboss.webbeans.conversation;
+/**
+ * A conversation manager responsible for starting, resuming and ending conversations
+ *
+ * @author Nicklas Karlsson
+ * @see org.jboss.webbeans.conversation.ConversationManager
+ */
public interface ConversationManager
{
+ /**
+ * Begins a conversation
+ *
+ * @param cid The incoming conversation ID. Can be null in cases of transient conversations
+ */
public abstract void beginConversation(String cid);
+
+ /**
+ * Ends the current conversation
+ */
public abstract void endConversation();
+
+ /**
+ * Destroys all long-running conversations
+ */
public abstract void destroyAllConversations();
+
+ /**
+ * Gets The inactivity timeout
+ *
+ * @return The timeout in milliseconds
+ */
+ public abstract long getInactivityTimeoutInMilliseconds();
+
+ /**
+ * Gets The concurrent access timeout
+ *
+ * @return The timeout in milliseconds
+ */
+ public abstract long getConcurrentAccessTimeoutInMilliseconds();
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/ConversationTerminator.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -18,8 +18,21 @@
import java.util.concurrent.Future;
+/**
+ * A conversation terminator for scheduling inactivity timeout destructions
+ *
+ * @author Nicklas Karlsson
+ *
+ */
public interface ConversationTerminator
{
- public abstract Future<?> scheduleForTermination(Runnable task);
- public abstract long getTimeout();
+ /**
+ * Schedules a termination
+ *
+ * @param terminationTask The termination task to run
+ * @param timeoutInMilliseconds The timeout in milliseconds
+ *
+ * @return A handle for manipulating the task later on
+ */
+ public abstract Future<?> scheduleForTermination(Runnable terminationTask, long timeoutInMilliseconds);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/DefaultConversationManager.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -22,6 +22,7 @@
import java.util.concurrent.Future;
import javax.context.Conversation;
+import javax.context.RequestScoped;
import javax.context.SessionScoped;
import javax.inject.Current;
import javax.inject.Produces;
@@ -31,96 +32,180 @@
import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.servlet.ConversationBeanMap;
+/**
+ * The default conversation manager
+ *
+ * @author Nicklas Karlsson
+ *
+ */
@SessionScoped
public class DefaultConversationManager implements ConversationManager, Serializable
{
private static LogProvider log = Logging.getLogProvider(WebBeansBootstrap.class);
+ // The conversation id generator
@Current
private ConversationIdGenerator conversationIdGenerator;
+
+ // The conversation terminator
@Current
private ConversationTerminator conversationTerminator;
+
+ // The current conversation
@Current
private Conversation currentConversation;
- private Map<String, ConversationEntry> longRunningConversations;
+ // The current HTTP session
+ @Current
private HttpSession session;
- protected DefaultConversationManager()
+ // A map of current active long-running conversation entries
+ private Map<String, ConversationEntry> longRunningConversations;
+
+ /**
+ * Creates a new conversation manager
+ */
+ public DefaultConversationManager()
{
log.trace("Created " + getClass());
longRunningConversations = new ConcurrentHashMap<String, ConversationEntry>();
- session = null;
}
+ /**
+ * Producer method for transient conversations
+ *
+ * @return A new transient conversation
+ */
@Produces
+ @RequestScoped
public Conversation produceNewTransientConversation()
{
- Conversation conversation = ConversationImpl.of(conversationIdGenerator.nextId(), conversationTerminator.getTimeout());
+ Conversation conversation = ConversationImpl.of(conversationIdGenerator.nextId(), getInactivityTimeoutInMilliseconds());
log.trace("Produced a new conversation: " + conversation);
return conversation;
}
- public void setSession(HttpSession session)
- {
- log.trace("Conversation manager got session " + session.getId());
- this.session = session;
- }
-
public void beginConversation(String cid)
{
if (cid == null)
{
+ // No incoming conversation ID, nothing to do here, Conversation
+ // factory will produce new transient conversation
return;
}
if (!longRunningConversations.containsKey(cid))
{
+ // We got an incoming conversation ID but it was not in the map of
+ // known ones, nothing to do, factory to the rescue
log.info("Could not restore long-running conversation " + cid);
return;
}
- if (!longRunningConversations.remove(cid).cancelTermination())
+ // Try to get a lock to the requested conversation, return and fall back
+ // to new transient conversation from factory
+ // if we fail
+ try
{
+ if (!longRunningConversations.get(cid).lock(getConcurrentAccessTimeoutInMilliseconds()))
+ {
+ log.info("Could not acquire conversation lock in " + getConcurrentAccessTimeoutInMilliseconds() + "ms, giving up");
+ return;
+ }
+ }
+ catch (InterruptedException e)
+ {
+ log.info("Interrupted while trying to acquire lock");
+ return;
+ }
+ // If we can't cancel the termination, release the lock, return and fall
+ // back to new transient conversation from factory
+ if (!longRunningConversations.get(cid).cancelTermination())
+ {
+ longRunningConversations.get(cid).unlock();
log.info("Failed to cancel termination of conversation " + cid);
}
else
{
- ((ConversationImpl) currentConversation).become(cid, true, conversationTerminator.getTimeout());
+ // If all goes well, set the identity of the current conversation to
+ // match the fetched long-running one
+ ((ConversationImpl) currentConversation).become(cid, true, getInactivityTimeoutInMilliseconds());
}
}
public void endConversation()
{
+ String cid = currentConversation.getId();
if (currentConversation.isLongRunning())
{
- Runnable terminationTask = new TerminationTask(currentConversation.getId());
- Future<?> terminationHandle = conversationTerminator.scheduleForTermination(terminationTask);
- String cid = currentConversation.getId();
- ConversationEntry conversationEntry = ConversationEntry.of(cid, terminationHandle);
- longRunningConversations.put(cid, conversationEntry);
+ Future<?> terminationHandle = scheduleForTermination(cid);
+ // When the conversation ends, a long-running conversation needs to
+ // start its self-destruct. We can have the case where the conversation
+ // is a previously known conversation (that had it's termination canceled in the
+ // beginConversation) or the case where we have a completely new long-running conversation.
+ if (longRunningConversations.containsKey(currentConversation.getId()))
+ {
+ longRunningConversations.get(currentConversation.getId()).unlock();
+ longRunningConversations.get(currentConversation.getId()).reScheduleTermination(terminationHandle);
+ }
+ else
+ {
+ ConversationEntry conversationEntry = ConversationEntry.of(cid, terminationHandle);
+ longRunningConversations.put(cid, conversationEntry);
+ }
log.trace("Scheduling " + currentConversation + " for termination");
}
else
{
+ // If the conversation is not long-running it can be a transient
+ // conversation that has been so from the start or it can be a
+ // long-running conversation that has been demoted during the request
log.trace("Destroying transient conversation " + currentConversation);
+ if (longRunningConversations.containsKey(cid))
+ {
+ if (!longRunningConversations.get(cid).cancelTermination())
+ {
+ log.info("Failed to cancel termination of conversation " + cid);
+ }
+ longRunningConversations.get(cid).unlock();
+ }
ConversationContext.INSTANCE.destroy();
}
}
+ private Future<?> scheduleForTermination(String cid)
+ {
+ Runnable terminationTask = new TerminationTask(cid);
+ return conversationTerminator.scheduleForTermination(terminationTask, getInactivityTimeoutInMilliseconds());
+ }
+
+ /**
+ * A termination task that destroys the conversation entry
+ *
+ * @author Nicklas Karlsson
+ *
+ */
private class TerminationTask implements Runnable
{
+ // The conversation ID to terminate
private String cid;
+ /**
+ * Creates a new termination task
+ *
+ * @param cid The conversation ID
+ */
public TerminationTask(String cid)
{
this.cid = cid;
}
+ /**
+ * Executes the termination
+ */
public void run()
{
log.trace("Conversation " + cid + " timed out and was terminated");
- longRunningConversations.get(cid).destroy(session);
+ longRunningConversations.remove(cid).destroy(session);
}
}
@@ -128,10 +213,19 @@
{
for (ConversationEntry conversationEntry : longRunningConversations.values())
{
- conversationEntry.cancelTermination();
conversationEntry.destroy(session);
}
longRunningConversations.clear();
}
+ public long getConcurrentAccessTimeoutInMilliseconds()
+ {
+ return 1000;
+ }
+
+ public long getInactivityTimeoutInMilliseconds()
+ {
+ return 10 * 60 * 1000;
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/JavaSEConversationTerminator.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -24,19 +24,20 @@
import javax.context.SessionScoped;
+/**
+ * A ConversationTerminator implementation using Java SE scheduling
+ *
+ * @author Nicklas Karlsson
+ * @see org.jboss.webbeans.conversation.ConversationTerminator
+ */
@SessionScoped
public class JavaSEConversationTerminator implements ConversationTerminator, Serializable
{
private ScheduledExecutorService terminator = Executors.newScheduledThreadPool(1);
- public Future<?> scheduleForTermination(Runnable terminationTask)
+ public Future<?> scheduleForTermination(Runnable terminationTask, long timeoutInMilliseconds)
{
- return terminator.schedule(terminationTask, getTimeout(), TimeUnit.MILLISECONDS);
+ return terminator.schedule(terminationTask, timeoutInMilliseconds, TimeUnit.MILLISECONDS);
}
- public long getTimeout()
- {
- return 10 * 60 * 1000;
- }
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/conversation/NumericConversationIdGenerator.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -21,11 +21,21 @@
import javax.context.ApplicationScoped;
+/**
+ * A ConversationIdGenerator implementation using running numerical values
+ *
+ * @author Nicklas Karlsson
+ *
+ */
@ApplicationScoped
public class NumericConversationIdGenerator implements ConversationIdGenerator, Serializable
{
+ // The next conversation ID
private AtomicInteger id;
+ /**
+ * Creates a new conversation ID generator
+ */
public NumericConversationIdGenerator()
{
id = new AtomicInteger(1);
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-02-04 07:25:42 UTC (rev 1405)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -29,7 +29,6 @@
import org.jboss.webbeans.context.RequestContext;
import org.jboss.webbeans.context.SessionContext;
import org.jboss.webbeans.conversation.ConversationManager;
-import org.jboss.webbeans.conversation.DefaultConversationManager;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -96,6 +95,7 @@
*/
public static void beginRequest(HttpServletRequest request)
{
+ CurrentManager.rootManager().getInstanceByType(SessionManager.class).setSession(request.getSession());
SessionContext.INSTANCE.setBeanMap(new SessionBeanMap(request.getSession()));
beginConversation(request);
DependentContext.INSTANCE.setActive(true);
@@ -104,10 +104,6 @@
private static void beginConversation(HttpServletRequest request)
{
ConversationManager conversationManager = CurrentManager.rootManager().getInstanceByType(ConversationManager.class);
- if (conversationManager instanceof DefaultConversationManager)
- {
- ((DefaultConversationManager) conversationManager).setSession(request.getSession());
- }
conversationManager.beginConversation(request.getParameter("cid"));
Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
ConversationContext.INSTANCE.setBeanMap(new ConversationBeanMap(request.getSession(), conversation.getId()));
@@ -125,6 +121,7 @@
SessionContext.INSTANCE.setBeanMap(null);
endConversation();
ConversationContext.INSTANCE.setBeanMap(null);
+ CurrentManager.rootManager().getInstanceByType(SessionManager.class).setSession(null);
}
private static void endConversation()
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java 2009-02-04 07:47:37 UTC (rev 1406)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.servlet;
+
+import javax.context.RequestScoped;
+import javax.inject.Produces;
+import javax.servlet.http.HttpSession;
+
+@RequestScoped
+public class SessionManager
+{
+ private HttpSession session;
+
+ public void setSession(HttpSession session)
+ {
+ this.session = session;
+ }
+
+ @Produces
+ @RequestScoped
+ HttpSession produceSession()
+ {
+ return session;
+ }
+
+}
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1405 - doc/trunk/reference/zh-CN.
by webbeans-commits@lists.jboss.org
Author: alartin
Date: 2009-02-04 02:25:42 -0500 (Wed, 04 Feb 2009)
New Revision: 1405
Modified:
doc/trunk/reference/zh-CN/scopescontexts.po
Log:
Modified: doc/trunk/reference/zh-CN/scopescontexts.po
===================================================================
--- doc/trunk/reference/zh-CN/scopescontexts.po 2009-02-04 04:38:21 UTC (rev 1404)
+++ doc/trunk/reference/zh-CN/scopescontexts.po 2009-02-04 07:25:42 UTC (rev 1405)
@@ -3,11 +3,11 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: master.xml \n"
+"Project-Id-Version: master.xml\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-12-19 20:26+0000\n"
-"PO-Revision-Date: 2008-12-19 20:26+0000\n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2009-02-04 15:24+0800\n"
+"Last-Translator: Sean Wu <alartin(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -17,63 +17,49 @@
#: scopescontexts.xml:4
#, no-c-format
msgid "Scopes and contexts"
-msgstr ""
+msgstr "范围和上下文"
#. Tag: para
#: scopescontexts.xml:6
#, no-c-format
-msgid ""
-"So far, we've seen a few examples of <emphasis>scope type annotations</"
-"emphasis>. The scope of a Web Bean determines the lifecycle of instances of "
-"the Web Bean. The scope also determines which clients refer to which "
-"instances of the Web Bean. According to the Web Beans specification, a scope "
-"determines:"
-msgstr ""
+msgid "So far, we've seen a few examples of <emphasis>scope type annotations</emphasis>. The scope of a Web Bean determines the lifecycle of instances of the Web Bean. The scope also determines which clients refer to which instances of the Web Bean. According to the Web Beans specification, a scope determines:"
+msgstr "目前为止,我们已经看到了几个 <emphasis>范围类型注释</emphasis>的例子。Web Bean的范围决定了Web Bean实例的生命周期。范围还决定了哪个客户端引用了哪个Web Bean实例。根据Web Beans规范,一个范围决定:"
#. Tag: para
#: scopescontexts.xml:14
#, no-c-format
msgid "When a new instance of any Web Bean with that scope is created"
-msgstr ""
+msgstr "该范围的Web Bean的一个实例何时被创建"
#. Tag: para
#: scopescontexts.xml:17
#, no-c-format
msgid "When an existing instance of any Web Bean with that scope is destroyed"
-msgstr ""
+msgstr "该范围的Web Bean实例何时被销毁"
#. Tag: para
#: scopescontexts.xml:20
#, no-c-format
-msgid ""
-"Which injected references refer to any instance of a Web Bean with that scope"
-msgstr ""
+msgid "Which injected references refer to any instance of a Web Bean with that scope"
+msgstr "注入的引用指向该范围的Web Bean的哪个实例"
#. Tag: para
#: scopescontexts.xml:25
#, no-c-format
-msgid ""
-"For example, if we have a session scoped Web Bean, <literal>CurrentUser</"
-"literal>, all Web Beans that are called in the context of the same "
-"<literal>HttpSession</literal> will see the same instance of "
-"<literal>CurrentUser</literal>. This instance will be automatically created "
-"the first time a <literal>CurrentUser</literal> is needed in that session, "
-"and automatically destroyed when the session ends."
-msgstr ""
+msgid "For example, if we have a session scoped Web Bean, <literal>CurrentUser</literal>, all Web Beans that are called in the context of the same <literal>HttpSession</literal> will see the same instance of <literal>CurrentUser</literal>. This instance will be automatically created the first time a <literal>CurrentUser</literal> is needed in that session, and automatically destroyed when the session ends."
+msgstr "例如,如果我们有一个会话范围的Web Bean:<literal>CurrentUser</literal>。那么在同一个<literal>HttpSession</literal>的上下文中调用的所有的Web Bean都将看到同一个<literal>CurrentUser</literal>实例。这个实例在会话第一次需要<literal>CurrentUser</literal>时被自动创建,在会话结束时被自动销毁。"
#. Tag: title
#: scopescontexts.xml:32
#, no-c-format
msgid "Scope types"
-msgstr ""
+msgstr "范围类型"
#. Tag: para
#: scopescontexts.xml:34
#, no-c-format
-msgid ""
-"Web Beans features an <emphasis>extensible context model</emphasis>. It is "
-"possible to define new scopes by creating a new scope type annotation:"
-msgstr ""
+msgid "Web Beans features an <emphasis>extensible context model</emphasis>. It is possible to define new scopes by creating a new scope type annotation:"
+msgstr "Web Bean有一个特性是<emphasis>可扩展的上下文模型</emphasis>。我们可以创建一个新的范围类型注释来定一个新的范围:"
#. Tag: programlisting
#: scopescontexts.xml:37
@@ -84,24 +70,22 @@
"@ScopeType\n"
"public @interface ClusterScoped {}]]>"
msgstr ""
+"<![CDATA[@Retention(RUNTIME)\n"
+"@Target({TYPE, METHOD})\n"
+"@ScopeType\n"
+"public @interface ClusterScoped {}]]>"
#. Tag: para
#: scopescontexts.xml:39
#, no-c-format
-msgid ""
-"Of course, that's the easy part of the job. For this scope type to be "
-"useful, we will also need to define a <literal>Context</literal> object that "
-"implements the scope! Implementing a <literal>Context</literal> is usually a "
-"very technical task, intended for framework development only."
-msgstr ""
+msgid "Of course, that's the easy part of the job. For this scope type to be useful, we will also need to define a <literal>Context</literal> object that implements the scope! Implementing a <literal>Context</literal> is usually a very technical task, intended for framework development only."
+msgstr "当然,这是这项工作最简单的部分。为了让这个范围类型可以使用,我们还需要定义一个<literal>Context(上下文)</literal>对象来实现这个范围!实现上下文通常是一个非常具备挑战的技术任务,这常常只能由开发编程框架的专家完成。"
#. Tag: para
#: scopescontexts.xml:44
#, no-c-format
-msgid ""
-"We can apply a scope type annotation to a Web Bean implementation class to "
-"specify the scope of the Web Bean:"
-msgstr ""
+msgid "We can apply a scope type annotation to a Web Bean implementation class to specify the scope of the Web Bean:"
+msgstr "我们可以在Web Bean实现类中应用范围类型注释来指定Web Bean的范围:"
#. Tag: programlisting
#: scopescontexts.xml:47
@@ -110,206 +94,176 @@
"<![CDATA[@ClusterScoped\n"
"public class SecondLevelCache { ... }]]>"
msgstr ""
+"<![CDATA[@ClusterScoped\n"
+"public class SecondLevelCache { ... }]]>"
#. Tag: para
#: scopescontexts.xml:58
#, no-c-format
msgid "Usually, you'll use one of Web Beans' built-in scopes."
-msgstr ""
+msgstr "通常,你将会使用一个Web Bean内置的范围。"
#. Tag: title
#: scopescontexts.xml:63
#, no-c-format
msgid "Built-in scopes"
-msgstr ""
+msgstr "内置范围"
#. Tag: para
#: scopescontexts.xml:65
#, no-c-format
msgid "Web Beans defines four built-in scopes:"
-msgstr ""
+msgstr "Web Beans定义了四个内置范围:"
#. Tag: literal
#: scopescontexts.xml:69
#, no-c-format
msgid "@RequestScoped"
-msgstr ""
+msgstr "@RequestScoped"
#. Tag: literal
#: scopescontexts.xml:72
#, no-c-format
msgid "@SessionScoped"
-msgstr ""
+msgstr "@SessionScoped"
#. Tag: literal
#: scopescontexts.xml:75
#, no-c-format
msgid "@ApplicationScoped"
-msgstr ""
+msgstr "@ApplicationScoped"
#. Tag: literal
#: scopescontexts.xml:78
#, no-c-format
msgid "@ConversationScoped"
-msgstr ""
+msgstr "@ConversationScoped"
#. Tag: para
#: scopescontexts.xml:82
#, no-c-format
msgid "For a web application that uses Web Beans:"
-msgstr ""
+msgstr "对于使用Web Beans的Web应用:"
#. Tag: para
#: scopescontexts.xml:86
#, no-c-format
-msgid ""
-"any servlet request has access to active request, session and application "
-"scopes, and, additionally"
-msgstr ""
+msgid "any servlet request has access to active request, session and application scopes, and, additionally"
+msgstr "任何Servlet请求可以访问激活的请求,会话和应用范围,并且"
#. Tag: para
#: scopescontexts.xml:90
#, no-c-format
msgid "any JSF request has access to an active conversation scope."
-msgstr ""
+msgstr "任何JSF请求可以访问一个激活的对话范围"
#. Tag: para
#: scopescontexts.xml:94
#, no-c-format
msgid "The request and application scopes are also active:"
-msgstr ""
+msgstr "在下列情况下请求和应用范围是激活的:"
#. Tag: para
#: scopescontexts.xml:98
#, no-c-format
msgid "during invocations of EJB remote methods,"
-msgstr ""
+msgstr "在EJB远程方法调用期间,"
#. Tag: para
#: scopescontexts.xml:101
#, no-c-format
msgid "during EJB timeouts,"
-msgstr ""
+msgstr "在EJB超时期间,"
#. Tag: para
#: scopescontexts.xml:104
#, no-c-format
msgid "during message delivery to a message-driven bean, and"
-msgstr ""
+msgstr "在消息发送给消息驱动Bean的期间,"
#. Tag: para
#: scopescontexts.xml:107
#, no-c-format
msgid "during web service invocations."
-msgstr ""
+msgstr "在Web Service调用期间。"
#. Tag: para
#: scopescontexts.xml:111
#, no-c-format
-msgid ""
-"If the application tries to invoke a Web Bean with a scope that does not "
-"have an active context, a <literal>ContextNotActiveException</literal> is "
-"thrown by the Web Bean manager at runtime."
-msgstr ""
+msgid "If the application tries to invoke a Web Bean with a scope that does not have an active context, a <literal>ContextNotActiveException</literal> is thrown by the Web Bean manager at runtime."
+msgstr "如果应用试图调用一个Web Bean,而对应的范围上下文没有处于激活状态时,Web Bean管理器在运行时将抛出一个<literal>ContextNotActiveException</literal>异常。"
#. Tag: para
#: scopescontexts.xml:115
#, no-c-format
-msgid ""
-"Three of the four built-in scopes should be extremely familiar to every Java "
-"EE developer, so let's not waste time discussing them here. One of the "
-"scopes, however, is new."
-msgstr ""
+msgid "Three of the four built-in scopes should be extremely familiar to every Java EE developer, so let's not waste time discussing them here. One of the scopes, however, is new."
+msgstr "这四个内置范围的其中三个对于每个Java EE程序员来说都非常熟悉,所以让我们别浪费时间来讨论他们。不过有一个范围是新的。"
#. Tag: title
#: scopescontexts.xml:122
#, no-c-format
msgid "The conversation scope"
-msgstr ""
+msgstr "对话范围"
#. Tag: para
#: scopescontexts.xml:124
#, no-c-format
-msgid ""
-"The Web Beans conversation scope is a bit like the traditional session scope "
-"in that it holds state associated with a user of the system, and spans "
-"multiple requests to the server. However, unlike the session scope, the "
-"conversation scope:"
-msgstr ""
+msgid "The Web Beans conversation scope is a bit like the traditional session scope in that it holds state associated with a user of the system, and spans multiple requests to the server. However, unlike the session scope, the conversation scope:"
+msgstr "Web Beans的对话(Conversation)范围有点类似与传统的会话范围(Session),传统的会话范围常常用来存储和系统用户相关的状态,并且能够跨越多个请求。然而,对话范围还有很多地方和会话范围不一样:"
#. Tag: para
#: scopescontexts.xml:130
#, no-c-format
msgid "is demarcated explicitly by the application, and"
-msgstr ""
+msgstr "它通过应用显式地声明,并且"
#. Tag: para
#: scopescontexts.xml:133
#, no-c-format
-msgid ""
-"holds state associated with a particular web browser tab in a JSF "
-"application."
-msgstr ""
+msgid "holds state associated with a particular web browser tab in a JSF application."
+msgstr "在一个JSF应用中持有与一个特定的Web浏览标签页关联的状态。"
#. Tag: para
#: scopescontexts.xml:138
#, no-c-format
-msgid ""
-"A conversation represents a task, a unit of work from the point of view of "
-"the user. The conversation context holds state associated with what the user "
-"is currently working on. If the user is doing multiple things at the same "
-"time, there are multiple conversations."
-msgstr ""
+msgid "A conversation represents a task, a unit of work from the point of view of the user. The conversation context holds state associated with what the user is currently working on. If the user is doing multiple things at the same time, there are multiple conversations."
+msgstr "从用户角度出发,一个对话代表一个任务,或者一个工作单元。用户当前工作相关的状态由对话上下文维护。如果用户同时处理多个事情,就会有多个对话与之对应。"
#. Tag: para
#: scopescontexts.xml:143
#, no-c-format
-msgid ""
-"The conversation context is active during any JSF request. However, most "
-"conversations are destroyed at the end of the request. If a conversation "
-"should hold state across multiple requests, it must be explicitly promoted "
-"to a <emphasis>long-running conversation</emphasis>."
-msgstr ""
+msgid "The conversation context is active during any JSF request. However, most conversations are destroyed at the end of the request. If a conversation should hold state across multiple requests, it must be explicitly promoted to a <emphasis>long-running conversation</emphasis>."
+msgstr "一个对话上下文在任何JSF请求中都是激活的。但是,大部分对话都在请求结束的时候被销毁了。如果一个对话需要跨越多个请求来维护状态的话,它必须显式地升级为<emphasis>长时对话</emphasis>。"
#. Tag: title
#: scopescontexts.xml:149
#, no-c-format
msgid "Conversation demarcation"
-msgstr ""
+msgstr "对话划分"
#. Tag: para
#: scopescontexts.xml:151
#, no-c-format
-msgid ""
-"Web Beans provides a built-in Web Bean for controlling the lifecyle of "
-"conversations in a JSF application. This Web Bean may be obtained by "
-"injection:"
-msgstr ""
+msgid "Web Beans provides a built-in Web Bean for controlling the lifecyle of conversations in a JSF application. This Web Bean may be obtained by injection:"
+msgstr "Web Beans提供了一个内置的Web Bean来在控制一个JSF应用中对话的生命周期。这个Web Bean可以通过注入来获得:"
#. Tag: programlisting
#: scopescontexts.xml:154
#, no-c-format
msgid "@Current Conversation conversation;"
-msgstr ""
+msgstr "@Current Conversation conversation;"
#. Tag: para
#: scopescontexts.xml:156
#, no-c-format
-msgid ""
-"To promote the conversation associated with the current request to a long-"
-"running conversation, call the <literal>begin()</literal> method from "
-"application code. To schedule the current long-running conversation context "
-"for destruction at the end of the current request, call <literal>end()</"
-"literal>."
-msgstr ""
+msgid "To promote the conversation associated with the current request to a long-running conversation, call the <literal>begin()</literal> method from application code. To schedule the current long-running conversation context for destruction at the end of the current request, call <literal>end()</literal>."
+msgstr "将当前请求关联的对话升级为长时对话的方法是从应用代码中调用 <literal>begin()</literal>方法。将当前长时对话上下文在当前请求结束时销毁的方法是调用<literal>end()</literal>方法。"
#. Tag: para
#: scopescontexts.xml:161
#, no-c-format
-msgid ""
-"In the following example, a conversation-scoped Web Bean controls the "
-"conversation with which it is associated:"
-msgstr ""
+msgid "In the following example, a conversation-scoped Web Bean controls the conversation with which it is associated:"
+msgstr "在下面的例子中,一个对话范围的Web Bean控制和它关联的对话:"
#. Tag: programlisting
#: scopescontexts.xml:164
@@ -346,194 +300,174 @@
" \n"
"}"
msgstr ""
+"@ConversationScoped @Stateful\n"
+"public class OrderBuilder {\n"
+"\n"
+" private Order order;\n"
+" private @Current Conversation conversation;\n"
+" private @PersistenceContext(type=EXTENDED) EntityManager em;\n"
+" \n"
+" @Produces public Order getOrder() {\n"
+" return order;\n"
+" }\n"
+"\n"
+" public Order createOrder() {\n"
+" order = new Order();\n"
+" conversation.begin();\n"
+" return order;\n"
+" }\n"
+" \n"
+" public void addLineItem(Product product, int quantity) {\n"
+" order.add( new LineItem(product, quantity) );\n"
+" }\n"
+"\n"
+" public void saveOrder(Order order) {\n"
+" em.persist(order);\n"
+" conversation.end();\n"
+" }\n"
+" \n"
+" @Remove\n"
+" public void destroy() {}\n"
+" \n"
+"}"
#. Tag: para
#: scopescontexts.xml:166
#, no-c-format
-msgid ""
-"This Web Bean is able to control its own lifecycle through use of the "
-"<literal>Conversation</literal> API. But some other Web Beans have a "
-"lifecycle which depends completely upon another object."
-msgstr ""
+msgid "This Web Bean is able to control its own lifecycle through use of the <literal>Conversation</literal> API. But some other Web Beans have a lifecycle which depends completely upon another object."
+msgstr "Web Bean可以通过<literal>Conversation</literal>接口控制自己的生命周期。但是其他一些Web Bean的生命周期完全依赖与其他对象。"
#. Tag: title
#: scopescontexts.xml:173
#, no-c-format
msgid "Conversation propagation"
-msgstr ""
+msgstr "对话的传播"
#. Tag: para
#: scopescontexts.xml:175
#, no-c-format
-msgid ""
-"The conversation context automatically propagates with any JSF faces request "
-"(JSF form submission). It does not automatically propagate with non-faces "
-"requests, for example, navigation via a link."
-msgstr ""
+msgid "The conversation context automatically propagates with any JSF faces request (JSF form submission). It does not automatically propagate with non-faces requests, for example, navigation via a link."
+msgstr "对话上下文在任何JSF faces请求中自动传播(JSF表单提交)。在非faces请求中,对话上下文将不会自动传播,例如通过一个链接来导航。"
#. Tag: para
#: scopescontexts.xml:179
#, no-c-format
-msgid ""
-"We can force the conversation to propagate with a non-faces request by "
-"including the unique identifier of the conversation as a request parameter. "
-"The Web Beans specification reserves the request parameter named "
-"<literal>cid</literal> for this use. The unique identifier of the "
-"conversation may be obtained from the <literal>Conversation</literal> "
-"object, which has the Web Beans name <literal>conversation</literal>."
-msgstr ""
+msgid "We can force the conversation to propagate with a non-faces request by including the unique identifier of the conversation as a request parameter. The Web Beans specification reserves the request parameter named <literal>cid</literal> for this use. The unique identifier of the conversation may be obtained from the <literal>Conversation</literal> object, which has the Web Beans name <literal>conversation</literal>."
+msgstr "我们可以强迫在非faces请求中传播对话,方法是在请求参数中包含一个对话的唯一标识符即可。Web Beans规范为此保留了一个请求参数关键字<literal>cid</literal>。对话的唯一标识符可以通过<literal>Conversation</literal>对象获得,它拥有Web Beans的名字<literal>conversation</literal>。"
#. Tag: para
#: scopescontexts.xml:186
#, no-c-format
msgid "Therefore, the following link propagates the conversation:"
-msgstr ""
+msgstr "因此,下面的链接能够传播对话:"
#. Tag: programlisting
#: scopescontexts.xml:188
#, no-c-format
-msgid ""
-"<![CDATA[<a href=\"/addProduct.jsp?cid=#{conversation.id}\">Add Product</a>]]"
-">"
-msgstr ""
+msgid "<![CDATA[<a href=\"/addProduct.jsp?cid=#{conversation.id}\">Add Product</a>]]>"
+msgstr "<![CDATA[<a href=\"/addProduct.jsp?cid=#{conversation.id}\">Add Product</a>]]>"
#. Tag: para
#: scopescontexts.xml:190
#, no-c-format
-msgid ""
-"The Web Bean manager is also required to propagate conversations across any "
-"redirect, even if the conversation is not marked long-running. This makes it "
-"very easy to implement the common POST-then-redirect pattern, without resort "
-"to fragile constructs such as a \"flash\" object. In this case, the Web Bean "
-"manager automatically adds a request parameter to the redirect URL."
-msgstr ""
+msgid "The Web Bean manager is also required to propagate conversations across any redirect, even if the conversation is not marked long-running. This makes it very easy to implement the common POST-then-redirect pattern, without resort to fragile constructs such as a \"flash\" object. In this case, the Web Bean manager automatically adds a request parameter to the redirect URL."
+msgstr "Web Bean管理器也需要能够跨越任何重定向来传播对话,甚至这个对话没有被升级为长时对话。这样我们就能很容易实现常用的POST-then-redirect模式,而不需要构建一个脆弱的 \"闪存\"对象。在这个例子中,Web Bean管理器自动向重定向URL中添加一个请求参数。"
#. Tag: title
#: scopescontexts.xml:200
#, no-c-format
msgid "Conversation timeout"
-msgstr ""
+msgstr "对话超时"
#. Tag: para
#: scopescontexts.xml:202
#, no-c-format
-msgid ""
-"The Web Bean manager is permitted to destroy a conversation and all state "
-"held in its context at any time in order to preserve resources. A Web Bean "
-"manager implementation will normally do this on the basis of some kind of "
-"timeout — though this is not required by the Web Beans specification. The "
-"timeout is the period of inactivity before the conversation is destroyed."
-msgstr ""
+msgid "The Web Bean manager is permitted to destroy a conversation and all state held in its context at any time in order to preserve resources. A Web Bean manager implementation will normally do this on the basis of some kind of timeout—though this is not required by the Web Beans specification. The timeout is the period of inactivity before the conversation is destroyed."
+msgstr "Web Bean管理器可以在任何时候销毁一个对话及其上下文中维护的所有状态,这样的设计可以降低资源的消耗。一个Web Bean管理器的实现将根据超时—设置自动的完成上述任务,虽然这个特性在Web Bean规范中没有要求。超时指的是对话被销毁前的非激活时间。"
#. Tag: para
#: scopescontexts.xml:208
#, no-c-format
-msgid ""
-"The <literal>Conversation</literal> object provides a method to set the "
-"timeout. This is a hint to the Web Bean manager, which is free to ignore the "
-"setting."
-msgstr ""
+msgid "The <literal>Conversation</literal> object provides a method to set the timeout. This is a hint to the Web Bean manager, which is free to ignore the setting."
+msgstr "<literal>Conversation</literal>对象提供一个方法来设置超时。这个方法可以让Web Bean管理器忽略原来的配置。"
#. Tag: programlisting
#: scopescontexts.xml:212
#, no-c-format
msgid "conversation.setTimeout(timeoutInMillis);"
-msgstr ""
+msgstr "conversation.setTimeout(timeoutInMillis);"
#. Tag: title
#: scopescontexts.xml:219
#, no-c-format
msgid "The dependent pseudo-scope"
-msgstr ""
+msgstr "依赖的伪范围"
#. Tag: para
#: scopescontexts.xml:221
#, no-c-format
-msgid ""
-"In addition to the four built-in scopes, Web Beans features the so-called "
-"<emphasis>dependent pseudo-scope</emphasis>. This is the default scope for a "
-"Web Bean which does not explicitly declare a scope type."
-msgstr ""
+msgid "In addition to the four built-in scopes, Web Beans features the so-called <emphasis>dependent pseudo-scope</emphasis>. This is the default scope for a Web Bean which does not explicitly declare a scope type."
+msgstr "除了内置的四个范围,Web Beans还提供了一个<emphasis>依赖的伪范围</emphasis>。这个范围是没有显式设置范围类型的Web Bean的默认范围。"
#. Tag: para
#: scopescontexts.xml:225
#, no-c-format
-msgid ""
-"For example, this Web Bean has the scope type <literal>@Dependent</literal>:"
-msgstr ""
+msgid "For example, this Web Bean has the scope type <literal>@Dependent</literal>:"
+msgstr "例如,这个Web Bean有一个范围类型<literal>@Dependent</literal>:"
#. Tag: programlisting
#: scopescontexts.xml:227
#, no-c-format
msgid "<![CDATA[public class Calculator { ... }]]>"
-msgstr ""
+msgstr "<![CDATA[public class Calculator { ... }]]>"
#. Tag: para
#: scopescontexts.xml:229
#, no-c-format
-msgid ""
-"When an injection point of a Web Bean resolves to a dependent Web Bean, a "
-"new instance of the dependent Web Bean is created every time the first Web "
-"Bean is instantiated. Instances of dependent Web Beans are never shared "
-"between different Web Beans or different injection points. They are "
-"<emphasis>dependent objects</emphasis> of some other Web Bean instance."
-msgstr ""
+msgid "When an injection point of a Web Bean resolves to a dependent Web Bean, a new instance of the dependent Web Bean is created every time the first Web Bean is instantiated. Instances of dependent Web Beans are never shared between different Web Beans or different injection points. They are <emphasis>dependent objects</emphasis> of some other Web Bean instance."
+msgstr "当一个注入点被解析为一个依赖的Web Bean之后,每当第一个Web Bean被初始化时,都会创建一个依赖的Web Bean实例。不同的Web Beans或者不同的注入点的依赖的Web Beans的实例都不会被共享。它们是其它Web Bean实例的<emphasis>依赖的对象</emphasis>。"
#. Tag: para
#: scopescontexts.xml:235
#, no-c-format
-msgid ""
-"Dependent Web Bean instances are destroyed when the instance they depend "
-"upon is destroyed."
-msgstr ""
+msgid "Dependent Web Bean instances are destroyed when the instance they depend upon is destroyed."
+msgstr "依赖的Web Bean实例在它们所依赖对象实例销毁的时候被销毁。"
#. Tag: para
#: scopescontexts.xml:243
#, no-c-format
-msgid ""
-"Web Beans makes it easy to obtain a dependent instance of a Java class or "
-"EJB bean, even if the class or EJB bean is already declared as a Web Bean "
-"with some other scope type."
-msgstr ""
+msgid "Web Beans makes it easy to obtain a dependent instance of a Java class or EJB bean, even if the class or EJB bean is already declared as a Web Bean with some other scope type."
+msgstr "Web Bean能够让我们轻松获得一个Java类或者EJB Bean的依赖实例,甚至这个类或者EJB Bean已经被声明为一个其他范围的Web Bean也没问题。"
#. Tag: title
#: scopescontexts.xml:248
#, no-c-format
msgid "The <literal>@New</literal> annotation"
-msgstr ""
+msgstr "<literal>@New</literal>注释"
#. Tag: para
#: scopescontexts.xml:250
#, no-c-format
-msgid ""
-"The built-in <literal>@New</literal> binding annotation allows "
-"<emphasis>implicit</emphasis> definition of a dependent Web Bean at an "
-"injection point. Suppose we declare the following injected field:"
-msgstr ""
+msgid "The built-in <literal>@New</literal> binding annotation allows <emphasis>implicit</emphasis> definition of a dependent Web Bean at an injection point. Suppose we declare the following injected field:"
+msgstr "内置的<literal>@New</literal>绑定注释允许在注入点<emphasis>隐式</emphasis>地定义一个依赖的Web Bean。假设我们需要声明下面的注入域:"
#. Tag: programlisting
#: scopescontexts.xml:254
#, no-c-format
msgid "<![CDATA[@New Calculator calculator;]]>"
-msgstr ""
+msgstr "<![CDATA[@New Calculator calculator;]]>"
#. Tag: para
#: scopescontexts.xml:256
#, no-c-format
-msgid ""
-"Then a Web Bean with scope <literal>@Dependent</literal>, binding type "
-"<literal>@New</literal>, API type <literal>Calculator</literal>, "
-"implementation class <literal>Calculator</literal> and deployment type "
-"<literal>@Standard</literal> is implicitly defined."
-msgstr ""
+msgid "Then a Web Bean with scope <literal>@Dependent</literal>, binding type <literal>@New</literal>, API type <literal>Calculator</literal>, implementation class <literal>Calculator</literal> and deployment type <literal>@Standard</literal> is implicitly defined."
+msgstr "这个Web Bean被隐式地定义为范围为<literal>@Dependent</literal>,绑定类型为<literal>@New</literal>,API类型为<literal>Calculator</literal>,实现了<literal>Calculator</literal>类,部署类型为<literal>@Standard</literal>。"
#. Tag: para
#: scopescontexts.xml:261
#, no-c-format
-msgid ""
-"This is true even if <literal>Calculator</literal> is <emphasis>already</"
-"emphasis> declared with a different scope type, for example:"
-msgstr ""
+msgid "This is true even if <literal>Calculator</literal> is <emphasis>already</emphasis> declared with a different scope type, for example:"
+msgstr "甚至在<literal>Calculator</literal><emphasis>已经</emphasis>通过不同的范围类型声明过的情况下也是如此。例如:"
#. Tag: programlisting
#: scopescontexts.xml:264
@@ -542,14 +476,14 @@
"<![CDATA[@ConversationScoped\n"
"public class Calculator { ... }]]>"
msgstr ""
+"<![CDATA[@ConversationScoped\n"
+"public class Calculator { ... }]]>"
#. Tag: para
#: scopescontexts.xml:266
#, no-c-format
-msgid ""
-"So the following injected attributes each get a different instance of "
-"<literal>Calculator</literal>:"
-msgstr ""
+msgid "So the following injected attributes each get a different instance of <literal>Calculator</literal>:"
+msgstr "所以下面注入的属性,每个都获得一个不同的 <literal>Calculator</literal>实例:"
#. Tag: programlisting
#: scopescontexts.xml:269
@@ -562,21 +496,22 @@
"\n"
"}]]>"
msgstr ""
+"<![CDATA[public class PaymentCalc {\n"
+"\n"
+" @Current Calculator calculator;\n"
+" @New Calculator newCalculator;\n"
+"\n"
+"}]]>"
#. Tag: para
#: scopescontexts.xml:271
#, no-c-format
-msgid ""
-"The <literal>calculator</literal> field has a conversation-scoped instance "
-"of <literal>Calculator</literal> injected. The <literal>newCalculator</"
-"literal> field has a new instance of <literal>Calculator</literal> injected, "
-"with a lifecycle that is bound to the owning <literal>PaymentCalc</literal>."
-msgstr ""
+msgid "The <literal>calculator</literal> field has a conversation-scoped instance of <literal>Calculator</literal> injected. The <literal>newCalculator</literal> field has a new instance of <literal>Calculator</literal> injected, with a lifecycle that is bound to the owning <literal>PaymentCalc</literal>."
+msgstr "<literal>calculator</literal>域有一个对话范围的<literal>Calculator</literal>实例注入。<literal>newCalculator</literal>域有一个新的<literal>Calculator</literal>实例注入,这个实例的生命周期绑定在其拥有者<literal>PaymentCalc</literal>类上。"
#. Tag: para
#: scopescontexts.xml:276
#, no-c-format
-msgid ""
-"This feature is particularly useful with producer methods, as we'll see in "
-"the next chapter."
-msgstr ""
+msgid "This feature is particularly useful with producer methods, as we'll see in the next chapter."
+msgstr "这个特性对于生产者方法来说特别有用,我们将在下一章看到。"
+
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1404 - tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-02-03 23:38:21 -0500 (Tue, 03 Feb 2009)
New Revision: 1404
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
Log:
unmatched tests
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java 2009-02-04 04:10:08 UTC (rev 1403)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java 2009-02-04 04:38:21 UTC (rev 1404)
@@ -65,6 +65,24 @@
}
/**
+ *
+ * @param sectionId
+ * @param assertionId
+ * @return
+ */
+ public boolean hasAssertion(String sectionId, String assertionId)
+ {
+ if (!assertions.containsKey(sectionId)) return false;
+
+ for (AuditAssertion assertion : assertions.get(sectionId))
+ {
+ if (assertion.getId().equals(assertionId)) return true;
+ }
+
+ return false;
+ }
+
+ /**
* Load the spec assertions defined in tck-audit.xml
*/
public void parse() throws Exception
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 04:10:08 UTC (rev 1403)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 04:38:21 UTC (rev 1404)
@@ -162,14 +162,52 @@
private void writeUnmatched(OutputStream out) throws IOException
{
+ List<SpecReference> unmatched = new ArrayList<SpecReference>();
+
+ for (String sectionId : references.keySet())
+ {
+ for (SpecReference ref : references.get(sectionId))
+ {
+ if (!auditParser.hasAssertion(ref.getSection(), ref.getAssertion()))
+ {
+ unmatched.add(ref);
+ }
+ }
+ }
+
+ if (unmatched.isEmpty()) return;
+
StringBuilder sb = new StringBuilder();
sb.append("<h3>Unmatched tests</h3>\n");
sb.append("<p>The following tests do not match any known assertions</p>");
-
- sb.append("<table>\n");
+
+ sb.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n");
sb.append(" <tr><th>Section</th><th>Assertion</th><th>Test Class</th><th>Test Method</th></tr>\n");
+ for (SpecReference ref : unmatched)
+ {
+ sb.append("<tr>");
+
+ sb.append("<td>");
+ sb.append(ref.getSection());
+ sb.append("</td>");
+
+ sb.append("<td>");
+ sb.append(ref.getAssertion());
+ sb.append("</td>");
+
+ sb.append("<td>");
+ sb.append(ref.getClassName());
+ sb.append("</td>");
+
+ sb.append("<td>");
+ sb.append(ref.getMethodName());
+ sb.append("()");
+ sb.append("</td>");
+
+ sb.append("</tr>");
+ }
sb.append("</table>");
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1403 - doc/trunk/reference/zh-CN.
by webbeans-commits@lists.jboss.org
Author: alartin
Date: 2009-02-03 23:10:08 -0500 (Tue, 03 Feb 2009)
New Revision: 1403
Modified:
doc/trunk/reference/zh-CN/intro.po
doc/trunk/reference/zh-CN/ri-spi.po
doc/trunk/reference/zh-CN/ri.po
Log:
Modified: doc/trunk/reference/zh-CN/intro.po
===================================================================
--- doc/trunk/reference/zh-CN/intro.po 2009-02-04 04:09:41 UTC (rev 1402)
+++ doc/trunk/reference/zh-CN/intro.po 2009-02-04 04:10:08 UTC (rev 1403)
@@ -6,7 +6,7 @@
"Project-Id-Version: master.xml\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-12-19 20:26+0000\n"
-"PO-Revision-Date: 2008-12-23 16:43+0800\n"
+"PO-Revision-Date: 2009-02-03 15:24+0800\n"
"Last-Translator: Sean Wu <alartin(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -34,7 +34,7 @@
#. Tag: para
#: intro.xml:15
#, no-c-format
-msgid "With certain, very special exceptions, every Java class with a constructor that accepts no parameters is a Web Bean. That includes every JavaBean. Furthermore, every EJB 3-style session bean is a Web Bean. Sure, the JavaBeans and EJBs you've been writing every day have not been able to take advantage of the new services defined by the Web Beans specification, but you'll be able to use every one of them as Web Beans — injecting them into other Web Beans, configuring them via the Web Beans XML configuration facility, even adding interceptors and decorators to them — without touching your existing code."
+msgid "With certain, very special exceptions, every Java class with a constructor that accepts no parameters is a Web Bean. That includes every JavaBean. Furthermore, every EJB 3-style session bean is a Web Bean. Sure, the JavaBeans and EJBs you've been writing every day have not been able to take advantage of the new services defined by the Web Beans specification, but you'll be able to use every one of them as Web Beans—injecting them into other Web Beans, configuring them via the Web Beans XML configuration facility, even adding interceptors and decorators to them—without touching your existing code."
msgstr "除非特殊情况,每个具有一个非参构造器的Java类都可以是一个Web Bean。这包括了每个JavaBean, 并且每个EJB3的会话Bean都是一个Web Bean。当然,你每天已经写过的JavaBean和EJB无法使用Web Beans规范定义的新服务,但是你能够通过Web Beans的XML配置将这些组件配置为Web Bean,然后将其注入到其他Web Bean中。你甚至可以不用修改已有代码就可以为其添加拦截器和装饰器。"
#. Tag: para
@@ -194,8 +194,8 @@
#. Tag: para
#: intro.xml:68
#, no-c-format
-msgid "At system initialization time, the Web Bean manager must validate that exactly one Web Bean exists which satisfies each injection point. In our example, if no implementation of <literal>Translator</literal> available — if the <literal>SentenceTranslator</literal> EJB was not deployed — the Web Bean manager would throw an <literal>UnsatisfiedDependencyException</literal>. If more than one implementation of <literal>Translator</literal> was available, the Web Bean manager would throw an <literal>AmbiguousDependencyException</literal>."
-msgstr "在系统初始化的时候,Web Bean管理器必须验证只存在一个Web Bean能够满足每个注入点。在我们的例子中,如果没有<literal>Translator</literal>实现 — 如果<literal>SentenceTranslator</literal> EJB没有被部署 — Web Bean管理器将会抛出一个<literal>UnsatisfiedDependencyException</literal>异常。如果多于一个<literal>Translator</literal>实现,Web Bean管理器将会抛出一个<literal>AmbiguousDependencyException</literal>异常。"
+msgid "At system initialization time, the Web Bean manager must validate that exactly one Web Bean exists which satisfies each injection point. In our example, if no implementation of <literal>Translator</literal> available—if the <literal>SentenceTranslator</literal> EJB was not deployed—the Web Bean manager would throw an <literal>UnsatisfiedDependencyException</literal>. If more than one implementation of <literal>Translator</literal> was available, the Web Bean manager would throw an <literal>AmbiguousDependencyException</literal>."
+msgstr "在系统初始化的时候,Web Bean管理器必须验证只存在一个Web Bean能够满足每个注入点。在我们的例子中,如果没有<literal>Translator</literal>实现—如果<literal>SentenceTranslator</literal> EJB没有被部署—Web Bean管理器将会抛出一个<literal>UnsatisfiedDependencyException</literal>异常。如果多于一个<literal>Translator</literal>实现,Web Bean管理器将会抛出一个<literal>AmbiguousDependencyException</literal>异常。"
#. Tag: title
#: intro.xml:80
@@ -278,8 +278,8 @@
#. Tag: para
#: intro.xml:145
#, no-c-format
-msgid "Note that not all clients of a Web Bean are Web Beans. Other objects such as Servlets or Message-Driven Beans — which are by nature not injectable, contextual objects — may also obtain references to Web Beans by injection."
-msgstr "需要注意的是并非所有的Web Bean的客户端都是Web Bean。其他对象诸如Servlet或者消息驱动Bean#151;天生不可注入的, 具备上下文的对象 — 也可以通过注入获得Web Bean的引用。"
+msgid "Note that not all clients of a Web Bean are Web Beans. Other objects such as Servlets or Message-Driven Beans—which are by nature not injectable, contextual objects—may also obtain references to Web Beans by injection."
+msgstr "需要注意的是并非所有的Web Bean的客户端都是Web Bean。其他对象诸如Servlet或者消息驱动Bean#151;天生不可注入的, 具备上下文的对象—也可以通过注入获得Web Bean的引用。"
#. Tag: para
#: intro.xml:149
@@ -584,8 +584,8 @@
#. Tag: para
#: intro.xml:289
#, no-c-format
-msgid "In this case, the name defaults to <literal>shoppingCart</literal> — the unqualified class name, with the first character changed to lowercase."
-msgstr "在这种情况下,Web Bean的名字默认为<literal>shoppingCart</literal> — 非完整的类名,首字母改为小写"
+msgid "In this case, the name defaults to <literal>shoppingCart</literal>—the unqualified class name, with the first character changed to lowercase."
+msgstr "在这种情况下,Web Bean的名字默认为<literal>shoppingCart</literal>—非完整的类名,首字母改为小写"
#. Tag: title
#: intro.xml:295
@@ -673,7 +673,7 @@
#: intro.xml:338
#, no-c-format
msgid "it is not a non-static static inner class,"
-msgstr "她不是一个非静态的静态内嵌类,"
+msgstr "它不是一个非静态的静态内嵌类,"
#. Tag: para
#: intro.xml:341
@@ -708,8 +708,8 @@
#. Tag: para
#: intro.xml:360
#, no-c-format
-msgid "The specification says that all EJB 3-style session and singleton beans are <emphasis>enterprise</emphasis> Web Beans. Message driven beans are not Web Beans — since they are not intended to be injected into other objects — but they can take advantage of most of the functionality of Web Beans, including dependency injection and interceptors."
-msgstr "规范指出所有EJB3类型的会话Bean或者单例Bean都是<emphasis>企业级</emphasis>Web Bean。消息驱动Bean不是Web Beans — 因为它们不能被注入到其他对象中#151;但是它们可以使用大部分Web Bean的功能,包括依赖注入和拦截器。"
+msgid "The specification says that all EJB 3-style session and singleton beans are <emphasis>enterprise</emphasis> Web Beans. Message driven beans are not Web Beans—since they are not intended to be injected into other objects—but they can take advantage of most of the functionality of Web Beans, including dependency injection and interceptors."
+msgstr "规范指出所有EJB3类型的会话Bean或者单例Bean都是<emphasis>企业级</emphasis>Web Bean。消息驱动Bean不是Web Beans—因为它们不能被注入到其他对象中#151;但是它们可以使用大部分Web Bean的功能,包括依赖注入和拦截器。"
#. Tag: para
#: intro.xml:366
Modified: doc/trunk/reference/zh-CN/ri-spi.po
===================================================================
--- doc/trunk/reference/zh-CN/ri-spi.po 2009-02-04 04:09:41 UTC (rev 1402)
+++ doc/trunk/reference/zh-CN/ri-spi.po 2009-02-04 04:10:08 UTC (rev 1403)
@@ -3,11 +3,11 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: master.xml \n"
+"Project-Id-Version: master.xml\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
-"POT-Creation-Date: 2009-02-01 21:16+0000\n"
-"PO-Revision-Date: 2008-12-20 22:07+0000\n"
-"Last-Translator: Automatically generated\n"
+"POT-Creation-Date: 2008-12-20 22:07+0000\n"
+"PO-Revision-Date: 2008-12-23 18:18+0800\n"
+"Last-Translator: Sean Wu <alartin(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -17,77 +17,45 @@
#: ri-spi.xml:4
#, no-c-format
msgid "Integrating the Web Beans RI into other environments"
-msgstr ""
+msgstr "将Web Bean参考实现整合到其他环境中"
#. Tag: para
#: ri-spi.xml:6
#, no-c-format
-msgid ""
-"Currently the Web Beans RI only runs in JBoss AS 5; integrating the RI into "
-"other EE environments (for example another application server like "
-"Glassfish), into a servlet container (like Tomcat), or with an Embedded "
-"EJB3.1 implementation is fairly easy. In this Appendix we will briefly "
-"discuss the steps needed."
-msgstr ""
+msgid "Currently the Web Beans RI only runs in JBoss AS 5; integrating the RI into other EE environments (for example another application server like Glassfish), into a servlet container (like Tomcat), or with an Embedded EJB3.1 implementation is fairly easy. In this Appendix we will briefly discuss the steps needed."
+msgstr "目前,Web Bean的参考实现只能运行在JBoss AS5中;将参考实现整合到其他EE环境中(例如像Glassfish的其他的应用服务器)以及一个Servlet容器(像Tomcat)中或者一个内嵌的EJB3.1实现中相当容易。在附录中我们将简要的讨论所需的步骤。"
#. Tag: para
#: ri-spi.xml:15
#, no-c-format
-msgid ""
-"It should be possible to run Web Beans in an SE environment, but you'll to "
-"do more work, adding your own contexts and lifecycle. The Web Beans RI "
-"currently doesn't expose lifecycle extension points, so you would have to "
-"code directly against Web Beans RI classes."
-msgstr ""
+msgid "It should be possible to run Web Beans in an SE environment, but you'll to do more work, adding your own contexts and lifecycle. The Web Beans RI currently doesn't expose lifecycle extension points, so you would have to code directly against Web Beans RI classes."
+msgstr "Web Bean可以在SE环境中运行,但是你需要做更多的工作,添加你自己的上下文和生命周期。Web Bean参考实现目前没有暴露生命周期扩展点,所以你不得不直接编写Web Bean参考实现的类。"
#. Tag: title
#: ri-spi.xml:24
#, no-c-format
msgid "The Web Beans RI SPI"
-msgstr ""
+msgstr "Web Bean的参考实现SPI"
#. Tag: para
#: ri-spi.xml:26
#, no-c-format
-msgid ""
-"The Web Beans SPI is located in <literal>webbeans-ri-spi</literal> module, "
-"and packaged as <literal>webbeans-ri-spi.jar</literal>. Some SPIs are "
-"optional, if you need to override the default behavior, others are required."
-msgstr ""
+msgid "The Web Beans SPI is located in <literal>webbeans-ri-spi</literal> module, and packaged as <literal>webbeans-ri-spi.jar</literal>."
+msgstr "Web Bean的SPI位于<literal>webbeans-ri-spi</literal>模块中,打包为<literal>webbeans-ri-spi.jar</literal>。"
#. Tag: para
-#: ri-spi.xml:33
+#: ri-spi.xml:31
#, no-c-format
-msgid ""
-"You can specify the implementation of an SPI either as a system property, or "
-"in a properties file <literal>META-INF/web-beans-ri.properties</literal>. "
-"All property names are the fully qualified class name of the implemented "
-"interface; all property values are the fully qualified class name of the "
-"implementation class."
-msgstr ""
+msgid "Currently, the only SPI to implement is the bootstrap spi:"
+msgstr "目前,只有bootstrap SPI可以实现:"
-#. Tag: para
-#: ri-spi.xml:42
-#, no-c-format
-msgid ""
-"All interfaces in the SPI support the decorator pattern and provide a "
-"<literal>Forwarding</literal> class."
-msgstr ""
-
-#. Tag: title
-#: ri-spi.xml:48
-#, no-c-format
-msgid "Web Bean Discovery"
-msgstr ""
-
#. Tag: programlisting
-#: ri-spi.xml:50
+#: ri-spi.xml:35
#, no-c-format
msgid ""
"<![CDATA[public interface WebBeanDiscovery {\n"
" /**\n"
-" * Gets list of all classes in classpath archives with web-beans.xml "
-"files\n"
+" * Gets list of all classes in classpath archives with web-beans.xml files\n"
" * \n"
" * @return An iterable over the classes \n"
" */\n"
@@ -100,84 +68,31 @@
" */\n"
" public Iterable<URL> discoverWebBeansXml();\n"
" \n"
+" /**\n"
+" * Gets a descriptor for each EJB in the application\n"
+" * \n"
+" * @return The bean class to descriptor map \n"
+" */\n"
+" public Iterable<EjbDescriptor<?>> discoverEjbs();\n"
+" \n"
"}]]>"
msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:52
-#, no-c-format
-msgid ""
-"The discovery of Web Bean classes and <literal>web-bean.xml</literal> files "
-"is self-explanatory (the algorithm is described in Section 11.1 of the JSR-"
-"299 specification, and isn't repeated here)."
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:58
-#, no-c-format
-msgid ""
-"The Web Beans RI can be told to load your implementation of "
-"<literal>WebBeanDiscovery</literal> using the property <literal>org.jboss."
-"webbeans.bootstrap.spi.WebBeanDiscovery</literal> with the fully qualified "
-"class name as the value. For example:"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:65
-#, no-c-format
-msgid ""
-"org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery= \\ \n"
-" org.jboss.webbeans.integration.jbossas.WebBeanDiscoveryImpl"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:67 ri-spi.xml:113 ri-spi.xml:146 ri-spi.xml:179
-#, no-c-format
-msgid ""
-"If the Web Beans RI is being used in a servlet container, it expects a "
-"constructor of the form:"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:72
-#, no-c-format
-msgid ""
-"<![CDATA[public WebBeanDiscoveryImpl(ServletContext servletContext) {}]]>"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:74
-#, no-c-format
-msgid ""
-"The servlet context can be used to allow your implementation of "
-"<literal>WebBeanDiscovery</literal> to interact with the container."
-msgstr ""
-
-#. Tag: title
-#: ri-spi.xml:82
-#, no-c-format
-msgid "EJB Discovery"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:84
-#, no-c-format
-msgid ""
-"The Web Beans RI also delegates EJB3 bean discovery to the container so that "
-"it doesn't have to scan for EJB3 annotations or parse <literal>ejb-jar.xml</"
-"literal>. For each EJB in the application an EJBDescriptor should be "
-"discovered:"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:91
-#, no-c-format
-msgid ""
-"<![CDATA[public interface EjbDiscovery\n"
-"{\n"
-" public static final String PROPERTY_NAME = EjbDiscovery.class.getName();\n"
+"<![CDATA[public interface WebBeanDiscovery {\n"
+" /**\n"
+" * Gets list of all classes in classpath archives with web-beans.xml files\n"
+" * \n"
+" * @return An iterable over the classes \n"
+" */\n"
+" public Iterable<Class<?>> discoverWebBeanClasses();\n"
" \n"
" /**\n"
+" * Gets a list of all web-beans.xml files in the app classpath\n"
+" * \n"
+" * @return An iterable over the web-beans.xml files \n"
+" */\n"
+" public Iterable<URL> discoverWebBeansXml();\n"
+" \n"
+" /**\n"
" * Gets a descriptor for each EJB in the application\n"
" * \n"
" * @return The bean class to descriptor map \n"
@@ -185,10 +100,21 @@
" public Iterable<EjbDescriptor<?>> discoverEjbs();\n"
" \n"
"}]]>"
+
+#. Tag: para
+#: ri-spi.xml:37
+#, no-c-format
+msgid "The discovery of Web Bean classes and <literal>web-bean.xml</literal> files is self-explanatory (the algorithm is described in Section 11.1 of the JSR-299 specification, and isn't repeated here)."
msgstr ""
+#. Tag: para
+#: ri-spi.xml:43
+#, no-c-format
+msgid "The Web Beans RI also delegates EJB3 bean discovery to the container so that it doesn't have to scan for EJB3 annotations or parse <literal>ejb-jar.xml</literal>. For each EJB in the application an EJBDescriptor should be discovered:"
+msgstr ""
+
#. Tag: programlisting
-#: ri-spi.xml:93
+#: ri-spi.xml:50
#, no-c-format
msgid ""
"<![CDATA[public interface EjbDescriptor<T> {\n"
@@ -205,23 +131,21 @@
" * \n"
" * @return An iterator over the local business interfaces\n"
" */\n"
-" public Iterable<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces"
-"();\n"
+" public Iterable<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces();\n"
" \n"
" /**\n"
" * Gets the remote business interfaces of the EJB\n"
" * \n"
" * @return An iterator over the remote business interfaces\n"
" */\n"
-" public Iterable<BusinessInterfaceDescriptor<?>> "
-"getRemoteBusinessInterfaces();\n"
+" public Iterable<BusinessInterfaceDescriptor<?>> getRemoteBusinessInterfaces();\n"
" \n"
" /**\n"
" * Get the remove methods of the EJB\n"
" * \n"
" * @return An iterator over the remove methods\n"
" */\n"
-" public Iterable<Method> getRemoveMethods();\n"
+" public Iterable<MethodDescriptor> getRemoveMethods();\n"
"\n"
" /**\n"
" * Indicates if the bean is stateless\n"
@@ -258,270 +182,73 @@
" */\n"
" public String getEjbName();\n"
" \n"
-" \n"
-"}]]>"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:95
-#, no-c-format
-msgid ""
-"The <literal>EjbDescriptor</literal> is fairly self-explanatory, and should "
-"return the relevant metadata as defined in the EJB specification. In "
-"addition to these two interfaces, there is "
-"<literal>BusinessInterfaceDescriptor</literal> which represents a local "
-"business interface (encapsulating the interface class and jndi name used to "
-"look up an instance of the EJB)."
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:104
-#, no-c-format
-msgid ""
-"The Web Beans RI can be told to load your implementation of "
-"<literal>EjbDiscovery</literal> using the property <literal>org.jboss."
-"webbeans.bootstrap.spi.EjbDiscovery</literal> with the fully qualified class "
-"name as the value. For example:"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:111
-#, no-c-format
-msgid ""
-"org.jboss.webbeans.bootstrap.spi.EjbDiscovery= \\\n"
-" org.jboss.webbeans.integration.jbossas.EjbDiscoveryImpl"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:118
-#, no-c-format
-msgid "<![CDATA[public EjbDiscoveryImpl(ServletContext servletContext) {}]]>"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:120
-#, no-c-format
-msgid ""
-"The servlet context can be used to allow your implementation of "
-"<literal>EjbDiscovery</literal> to interact with the container."
-msgstr ""
-
-#. Tag: title
-#: ri-spi.xml:128
-#, no-c-format
-msgid "JNDI"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:130
-#, no-c-format
-msgid ""
-"The Web Beans RI implements JNDI binding and lookup according to standards, "
-"however you may want to alter the binding and lookup (for example in an "
-"environment where JNDI isn't available). To do this, implement <literal>org."
-"jboss.webbeans.spi.resources.NamingContext</literal>:"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:138
-#, no-c-format
-msgid ""
-"<![CDATA[public interface NamingContext extends Serializable {\n"
-" \n"
" /**\n"
-" * Typed JNDI lookup\n"
+" * @return The JNDI string which can be used to lookup a proxy which \n"
+" * implements all local business interfaces \n"
" * \n"
-" * @param <T> The type\n"
-" * @param name The JNDI name\n"
-" * @param expectedType The expected type\n"
-" * @return The object\n"
" */\n"
-" public <T> T lookup(String name, Class<? extends T> expectedType);\n"
-"\n"
-" /**\n"
-" * Binds an item to JNDI\n"
-" * \n"
-" * @param name The key to bind under\n"
-" * @param value The item to bind\n"
-" */\n"
-" public void bind(String name, Object value);\n"
+" public String getLocalJndiName();\n"
" \n"
"}]]>"
msgstr ""
#. Tag: para
-#: ri-spi.xml:140 ri-spi.xml:173
+#: ri-spi.xml:52
#, no-c-format
-msgid "and tell the RI to use it:"
+msgid "The contract described the JavaDoc is enough to implement an EJBDescriptor. In addition to these two interfaces, there is <literal>BusinessInterfaceDescriptor</literal> which represents a local business interface (encapsulating the interface class and jndi name), and <literal>MethodDescriptor</literal> which encapsulates the method name and parameter types (allowing it to be invoked on any instance of the EJB, proxy or otherwise)."
msgstr ""
-#. Tag: programlisting
-#: ri-spi.xml:144
-#, no-c-format
-msgid "org.jboss.webbeans.resources.spi.NamingContext=com.acme.MyNamingContext"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:151
-#, no-c-format
-msgid "<![CDATA[public MyNamingContext(ServletContext servletContext) {}]]>"
-msgstr ""
-
#. Tag: para
-#: ri-spi.xml:153
+#: ri-spi.xml:62
#, no-c-format
-msgid ""
-"The servlet context can be used to allow your implementation of "
-"<literal>NamingContext</literal> to interact with the container."
+msgid "The Web Beans RI can be told to load your implementation of <literal>WebBeanDiscovery</literal> using the property <literal>org.jboss.webbeans.bootstrap.webBeanDiscovery</literal> with the fully qualified class name as the value. For example:"
msgstr ""
-#. Tag: title
-#: ri-spi.xml:161
-#, no-c-format
-msgid "Resource loading"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:163
-#, no-c-format
-msgid ""
-"The Web Beans RI needs to load classes and resources from the classpath at "
-"various times. By default, they are loaded from the same classloader that "
-"was used to load the RI, however this may not be correct for some "
-"environments. If this is case, you can implement <literal>org.jboss.webbeans."
-"spi.ResourceLoader</literal>:"
-msgstr ""
-
#. Tag: programlisting
-#: ri-spi.xml:171
+#: ri-spi.xml:69
#, no-c-format
-msgid ""
-"<![CDATA[\n"
-" public interface ResourceLoader {\n"
-" \n"
-" /**\n"
-" * Creates a class from a given FQCN\n"
-" * \n"
-" * @param name The name of the clsas\n"
-" * @return The class\n"
-" */\n"
-" public Class<?> classForName(String name);\n"
-" \n"
-" /**\n"
-" * Gets a resource as a URL by name\n"
-" * \n"
-" * @param name The name of the resource\n"
-" * @return An URL to the resource\n"
-" */\n"
-" public URL getResource(String name);\n"
-" \n"
-" /**\n"
-" * Gets resources as URLs by name\n"
-" * \n"
-" * @param name The name of the resource\n"
-" * @return An iterable reference to the URLS\n"
-" */\n"
-" public Iterable<URL> getResources(String name);\n"
-" \n"
-"}\n"
-" ]]>"
+msgid "org.jboss.webbeans.bootstrap.webBeanDiscovery=org.jboss.webbeans.integration.jbossas.WebBeanDiscoveryImpl"
msgstr ""
-#. Tag: programlisting
-#: ri-spi.xml:177
-#, no-c-format
-msgid "org.jboss.webbeans.resources.spi.ResourceLoader=com.acme.ResourceLoader"
-msgstr ""
-
-#. Tag: programlisting
-#: ri-spi.xml:184
-#, no-c-format
-msgid "<![CDATA[public MyResourceLoader(ServletContext servletContext) {}]]>"
-msgstr ""
-
#. Tag: para
-#: ri-spi.xml:186
+#: ri-spi.xml:71
#, no-c-format
-msgid ""
-"The servlet context can be used to allow your implementation of "
-"<literal>ResourceLoader</literal> to interact with the container."
+msgid "The property can either be specified as a system property, or in a properties file <literal>META-INF/web-beans-ri.properties</literal>."
msgstr ""
#. Tag: title
-#: ri-spi.xml:196
+#: ri-spi.xml:79
#, no-c-format
msgid "The contract with the container"
msgstr ""
#. Tag: para
-#: ri-spi.xml:198
+#: ri-spi.xml:81
#, no-c-format
-msgid ""
-"There are a number of requirements that the Web Beans RI places on the "
-"container for correct functioning that fall outside implementation of APIs"
+msgid "There are a number of requirements that the Web Beans RI places on the container for correct functioning that fall outside implementation of APIs"
msgstr ""
#. Tag: term
-#: ri-spi.xml:206
+#: ri-spi.xml:89
#, no-c-format
msgid "Classloader isolation"
msgstr ""
#. Tag: para
-#: ri-spi.xml:210
+#: ri-spi.xml:93
#, no-c-format
-msgid ""
-"If you are integrating the Web Beans RI into an environment that supports "
-"deployment of multiple applications, you must enable, automatically, or "
-"through user configuation, classloader isolation for each Web Beans "
-"application."
+msgid "If you are integrating the Web Beans into an environment that supports deployment of applications, you must enable, automatically, or through user configuation, classloader isolation for each Web Beans application"
msgstr ""
#. Tag: term
-#: ri-spi.xml:219
+#: ri-spi.xml:102
#, no-c-format
-msgid "Servlet listener"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:223
-#, no-c-format
-msgid ""
-"If you are integrating the Web Beans into a Servlet environment you must "
-"register <literal>org.jboss.webbeans.servlet.WebBeansListener</literal> as a "
-"Servlet listener, either automatically, or through user configuration, for "
-"each Web Beans application which uses Servlet."
-msgstr ""
-
-#. Tag: term
-#: ri-spi.xml:234
-#, no-c-format
-msgid "Session Bean Interceptor"
-msgstr ""
-
-#. Tag: para
-#: ri-spi.xml:238
-#, no-c-format
-msgid ""
-"If you are integrating the Web Beans into an EJB environment you must "
-"register <literal>org.jboss.webbeans.ejb.SessionBeanInterceptor</literal> as "
-"a EJB interceptor for all EJBs in the application, either automatically, or "
-"through user configuration, for each Web Beans application which uses "
-"enterprise beans."
-msgstr ""
-
-#. Tag: term
-#: ri-spi.xml:249
-#, no-c-format
msgid "The <literal>webbeans-ri.jar</literal>"
msgstr ""
#. Tag: para
-#: ri-spi.xml:253
+#: ri-spi.xml:106
#, no-c-format
-msgid ""
-"If you are integrating the Web Beans into an environment that supports "
-"deployment of applications, you must insert the <literal>webbeans-ri.jar</"
-"literal> into the applications isolated classloader. It cannot be loaded "
-"from a shared classloader."
+msgid "If you are integrating the Web Beans into an environment that supports deployment of applications, you must insert the <literal>webbeans-ri.jar</literal> into the applications isolated classloader. It cannot be loaded from a shared classloader."
msgstr ""
+
Modified: doc/trunk/reference/zh-CN/ri.po
===================================================================
--- doc/trunk/reference/zh-CN/ri.po 2009-02-04 04:09:41 UTC (rev 1402)
+++ doc/trunk/reference/zh-CN/ri.po 2009-02-04 04:10:08 UTC (rev 1403)
@@ -3,11 +3,11 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: master.xml \n"
+"Project-Id-Version: master.xml\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
-"POT-Creation-Date: 2009-02-01 21:16+0000\n"
-"PO-Revision-Date: 2008-12-19 20:26+0000\n"
-"Last-Translator: Automatically generated\n"
+"POT-Creation-Date: 2008-12-20 22:08+0000\n"
+"PO-Revision-Date: 2009-02-04 11:41+0800\n"
+"Last-Translator: Sean Wu <alartin(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -16,303 +16,222 @@
#. Tag: title
#: ri.xml:4
#, no-c-format
-msgid "The Web Beans Reference Implementation"
-msgstr ""
+msgid "Using the Web Beans Reference Implementation"
+msgstr "使用Web Beans的参考实现"
#. Tag: para
#: ri.xml:6
#, no-c-format
-msgid ""
-"The Web Beans Reference Implementation is being developed at <ulink url="
-"\"http://seamframework.org/WebBeans\">the Seam project</ulink>. You can "
-"download the latest developer release of Web Beans from the <ulink url="
-"\"http://seamframework.org/Download\">the downloads page</ulink>."
-msgstr ""
+msgid "The Web Beans RI comes with a two examples, <literal>webbeans-numberguess</literal> (a war example, containing only simple beans) and <literal>webbeans-translator</literal> (an ear example, containing enterprise beans)."
+msgstr "Web Beans RI自带了两个例子:<literal>webbeans-numberguess</literal> (一个仅包含一个简单Bean的WAR应用例子)和<literal>webbeans-translator</literal> (一个包含企业Bean的EAR应用例子)。"
#. Tag: para
#: ri.xml:13
#, no-c-format
-msgid ""
-"The Web Beans RI comes with a two deployable example applications: "
-"<literal>webbeans-numberguess</literal>, a war example, containing only "
-"simple beans, and <literal>webbeans-translator</literal> an ear example, "
-"containing enterprise beans. To run the examples you'll need the following:"
-msgstr ""
+msgid "Currently, the Web Beans RI only runs on JBoss Application Server 5. You'll need to download JBoss AS 5.0.0.GA from <ulink url=\"http://www.jboss.org/jbossas/downloads/\">jboss.org</ulink>, and unzip it. For example:"
+msgstr "当前,Web Beans参考实现只能运行在JBoss AS 5之上。你需要从<ulink url=\"http://www.jboss.org/jbossas/downloads/\">jboss.org</ulink>下载JBoss AS 5.0.0.GA, 然后解压。例如:"
-#. Tag: para
-#: ri.xml:22
-#, no-c-format
-msgid "the latest release of the Web Beans RI,"
-msgstr ""
-
-#. Tag: para
-#: ri.xml:25
-#, no-c-format
-msgid "JBoss AS 5.0.0.GA, and"
-msgstr ""
-
-#. Tag: para
-#: ri.xml:28
-#, no-c-format
-msgid "Ant 1.7.0."
-msgstr ""
-
-#. Tag: para
-#: ri.xml:32
-#, no-c-format
-msgid ""
-"Currently, the Web Beans RI only runs on JBoss Application Server 5. You'll "
-"need to download JBoss AS 5.0.0.GA from <ulink url=\"http://www.jboss.org/"
-"jbossas/downloads/\">jboss.org</ulink>, and unzip it. For example:"
-msgstr ""
-
#. Tag: programlisting
-#: ri.xml:39
+#: ri.xml:20
#, no-c-format
msgid ""
"<![CDATA[$ cd /Applications\n"
"$ unzip ~/jboss-5.0.0.GA.zip]]>"
msgstr ""
+"<![CDATA[$ cd /Applications\n"
+"$ unzip ~/jboss-5.0.0.GA.zip]]>"
#. Tag: para
-#: ri.xml:41
+#: ri.xml:22
#, no-c-format
-msgid ""
-"Next, download the Web Beans RI from <ulink url=\"http://seamframework.org/"
-"Download\">seamframework.org</ulink>, and unzip it. For example"
-msgstr ""
+msgid "Next, download the Web Beans RI from <ulink url=\"http://seamframework.org/WebBeans\">seamframework.org</ulink>, and unzip it. For example"
+msgstr "然后从<ulink url=\"http://seamframework.org/WebBeans\">seamframework.org</ulink>下载Web Beans的参考实现,然后解压。例如:"
#. Tag: programlisting
-#: ri.xml:47
+#: ri.xml:28
#, no-c-format
msgid ""
"<![CDATA[$ cd ~/\n"
-"$ unzip ~/webbeans-$VERSION.zip]]>"
+"$ unzip ~/webbeans-1.0.0.ALPHA1.zip]]>"
msgstr ""
+"<![CDATA[$ cd ~/\n"
+"$ unzip ~/webbeans-1.0.0.ALPHA1.zip]]>"
#. Tag: para
-#: ri.xml:50
+#: ri.xml:31
#, no-c-format
-msgid ""
-"Next, we need to tell Web Beans where JBoss is located. Edit <literal>jboss-"
-"as/build.properties</literal> and set the <literal>jboss.home</literal> "
-"property. For example:"
-msgstr ""
+msgid "Next, we need to tell Web Beans where JBoss is located. Edit <literal>jboss-as/build.properties</literal> and set the <literal>jboss.home</literal> property. For example:"
+msgstr "然后,我们需要告诉Web Beans JBoss的位置。编辑<literal>jboss-as/build.properties</literal>,设置<literal>jboss.home</literal>属性。例如:"
#. Tag: programlisting
-#: ri.xml:56
+#: ri.xml:37
#, no-c-format
msgid "jboss.home=/Applications/jboss-5.0.0.GA"
-msgstr ""
+msgstr "jboss.home=/Applications/jboss-5.0.0.GA"
#. Tag: para
-#: ri.xml:58
+#: ri.xml:39
#, no-c-format
-msgid ""
-"As Web Beans is a new piece of software, you need to update JBoss AS to run "
-"the Web Beans RI. Future versions of JBoss AS will include these updates, "
-"and this step won't be necessary."
-msgstr ""
+msgid "As Web Beans is a new piece of software, you need to update JBoss AS to run the Web Beans RI. Future versions of JBoss AS will include these updates, and this step won't be necessary."
+msgstr "因为Web Beans是新的软件,你需要更新JBoss AS来运行Web Beans的参考实现。JBoss AS未来的版本将包括这些更新,这些步骤将不再是必须的。"
#. Tag: para
-#: ri.xml:65
+#: ri.xml:46
#, no-c-format
-msgid ""
-"Currently, two updates are needed. Firstly, a new deployer, "
-"<literal>webbeans.deployer</literal> is added. This adds supports for Web "
-"Bean archives to JBoss AS, and allows the Web Beans RI to query the EJB3 "
-"container and discover which EJBs are installed in your application. "
-"Secondly, an update to JBoss EJB3 is needed."
-msgstr ""
+msgid "Currently, two updates are needed. Firstly, a new deployer, <literal>webbeans.deployer</literal> is added. This adds supports for Web Bean archives to JBoss AS, and allows the Web Beans RI to query the EJB3 container and discover which EJBs are installed in your application. Secondly, an update to JBoss EJB3 is needed."
+msgstr "当前,我们需要两个更新。首先,需要添加一个新的部署器<literal>webbeans.deployer</literal>。这个部署器提供JBoss AS对Web Bean档案包的支持,能够让Web Beans参考实现查询EJB3容器,发现应用中安装的EJB。第二,需要更新JBoss EJB3。"
#. Tag: para
-#: ri.xml:74
+#: ri.xml:55
#, no-c-format
-msgid ""
-"To install the update, you'll need Ant 1.7.0 installed, and the "
-"<literal>ANT_HOME</literal> environment variable set. For example:"
-msgstr ""
+msgid "To install the update, you'll need ant 1.7.0 installed, and the <literal>ANT_HOME</literal> environment variable set. For example:"
+msgstr "为了安装更新,你需要安装Ant 1.7.0,设置<literal>ANT_HOME</literal>环境变量。例如:"
#. Tag: programlisting
-#: ri.xml:79
+#: ri.xml:60
#, no-c-format
msgid ""
"$ unzip apache-ant-1.7.0.zip\n"
"$ export ANT_HOME=~/apache-ant-1.7.0"
msgstr ""
+"$ unzip apache-ant-1.7.0.zip\n"
+"$ export ANT_HOME=~/apache-ant-1.7.0"
#. Tag: para
-#: ri.xml:81
+#: ri.xml:62
#, no-c-format
-msgid ""
-"Then, you can install the update. The update script will use Maven to "
-"download the Web Beans and EJB3 automatically."
-msgstr ""
+msgid "Then, you can install the update. The update script will use Maven to download the Web Beans and EJB3 automatically."
+msgstr "然后,你需要安装更新,更新脚本使用Maven来自动下载Web Beans和EJB3。"
#. Tag: programlisting
-#: ri.xml:86
+#: ri.xml:67
#, no-c-format
msgid ""
-"$ cd webbeans-$VERSION/jboss-as\n"
+"$ cd webbeans-1.0.0.ALPHA1/jboss-as\n"
"$ ant update"
msgstr ""
+"$ cd webbeans-1.0.0.ALPHA1/jboss-as\n"
+"$ ant update"
#. Tag: para
-#: ri.xml:88
+#: ri.xml:69
#, no-c-format
msgid "Now, you're ready to deploy your first example!"
-msgstr ""
+msgstr "现在,你可以部署你的第一个例子了!"
#. Tag: para
-#: ri.xml:93
+#: ri.xml:74
#, no-c-format
-msgid ""
-"The build scripts for the examples offer a number of targets, these are:"
-msgstr ""
+msgid "The build scripts for the examples offer a number of targets, these are:"
+msgstr "例子的构建脚本包含多个目标:"
#. Tag: para
-#: ri.xml:99
+#: ri.xml:80
#, no-c-format
msgid "<literal>ant restart</literal> - deploy the example in exploded format"
-msgstr ""
+msgstr "<literal>ant restart</literal> - 以exploded形式部署例子"
#. Tag: para
-#: ri.xml:105
+#: ri.xml:86
#, no-c-format
-msgid ""
-"<literal>ant explode</literal> - update an exploded example, without "
-"restarting the deployment"
-msgstr ""
+msgid "<literal>ant explode</literal> - update an exploded example, without restarting the deployment"
+msgstr "<literal>ant explode</literal> - 无需重新部署,更新一个exploded形式部署的例子"
#. Tag: para
-#: ri.xml:111
+#: ri.xml:92
#, no-c-format
-msgid ""
-"<literal>ant deploy</literal> - deploy the example in compressed jar format"
-msgstr ""
+msgid "<literal>ant deploy</literal> - deploy the example in compressed jar format"
+msgstr "<literal>ant deploy</literal> - 以压缩jar包形式部署例子"
#. Tag: para
-#: ri.xml:116
+#: ri.xml:97
#, no-c-format
msgid "<literal>ant undeploy</literal> - remove the example from the server"
-msgstr ""
+msgstr "<literal>ant undeploy</literal> - 将例子从服务器中移除"
#. Tag: para
-#: ri.xml:121
+#: ri.xml:102
#, no-c-format
msgid "<literal>ant clean</literal> - clean the example"
-msgstr ""
+msgstr "<literal>ant clean</literal> - 清除例子"
#. Tag: para
-#: ri.xml:128
+#: ri.xml:109
#, no-c-format
msgid "To deploy the numberguess example:"
-msgstr ""
+msgstr "部署猜数字(numberguess)例子:"
#. Tag: programlisting
-#: ri.xml:132
+#: ri.xml:113
#, no-c-format
msgid ""
"$ cd examples/numberguess\n"
"ant deploy"
msgstr ""
+"$ cd examples/numberguess\n"
+"ant deploy"
#. Tag: para
-#: ri.xml:134
+#: ri.xml:115
#, no-c-format
-msgid "Start JBoss AS:"
-msgstr ""
+msgid "Wait for the application to deploy, and enjoy hours of fun at <ulink url=\"http://localhost:8080/webbeans-numberguess\"></ulink>!"
+msgstr "等待应用部署完毕,好好体验一下<ulink url=\"http://localhost:8080/webbeans-numberguess\"></ulink>!"
-#. Tag: programlisting
-#: ri.xml:138
-#, no-c-format
-msgid "$ /Application/jboss-5.0.0.GA/bin/run.sh"
-msgstr ""
-
#. Tag: para
-#: ri.xml:141
+#: ri.xml:120
#, no-c-format
-msgid "If you use Windows, use the <literal>run.bat</literal>script."
-msgstr ""
+msgid "The Web Beans RI includes a second simple example that will translate your text into Latin. The numberguess example is a war example, and uses only simple beans; the translator example is an ear example, and includes enterprise beans, packaged in an EJB module. To try it out:"
+msgstr "Web Bean参考实现的第二个简单例子能够将你的文本翻译为拉丁文。猜数字例子是一个WAR应用,仅仅使用了一个简单Beans;翻译器例子是一个EAR应用,包含了打包在EJB模块中的企业Beans。试一下:"
-#. Tag: para
-#: ri.xml:146
-#, no-c-format
-msgid ""
-"Wait for the application to deploy, and enjoy hours of fun at <ulink url="
-"\"http://localhost:8080/webbeans-numberguess\"></ulink>!"
-msgstr ""
-
-#. Tag: para
-#: ri.xml:151
-#, no-c-format
-msgid ""
-"The Web Beans RI includes a second simple example that will translate your "
-"text into Latin. The numberguess example is a war example, and uses only "
-"simple beans; the translator example is an ear example, and includes "
-"enterprise beans, packaged in an EJB module. To try it out:"
-msgstr ""
-
#. Tag: programlisting
-#: ri.xml:158
+#: ri.xml:127
#, no-c-format
msgid ""
-"$ cd examples/translator\n"
+"$ cd examples/traslator\n"
"ant deploy"
msgstr ""
+"$ cd examples/traslator\n"
+"ant deploy"
#. Tag: para
-#: ri.xml:160
+#: ri.xml:129
#, no-c-format
-msgid ""
-"Wait for the application to deploy, and visit <ulink url=\"http://"
-"localhost:8080/webbeans-translator\"></ulink>!"
-msgstr ""
+msgid "Wait for the application to deploy, and visit <ulink url=\"http://localhost:8080/webbeans-translator\"></ulink>!"
+msgstr "等待应用部署,试一下<ulink url=\"http://localhost:8080/webbeans-translator\"></ulink>!"
#. Tag: title
-#: ri.xml:166
+#: ri.xml:135
#, no-c-format
msgid "The numberguess example"
-msgstr ""
+msgstr "猜数字例子"
#. Tag: para
-#: ri.xml:168
+#: ri.xml:137
#, no-c-format
-msgid ""
-"In the numberguess application you get given 10 attempts to guess a number "
-"between 1 and 100. After each attempt, you will be told whether you are too "
-"high, or too low."
-msgstr ""
+msgid "In the numberguess application you get given 10 attempts to guess a number between 1 and 100. After each attempt, you will be told whether you are too high, or too low."
+msgstr "在猜数字应用中,你有十次机会来猜一个1到100之间的数字。每次猜测之后,应用都会告诉你你猜的数字是高了还是低了。"
#. Tag: para
-#: ri.xml:174
+#: ri.xml:143
#, no-c-format
-msgid ""
-"The numberguess example is comprised of a number of Web Beans, configuration "
-"files, and Facelet JSF pages, packaged as a war. Let's start with the "
-"configuration files."
-msgstr ""
+msgid "The numberguess example is comprised of a number of Web Beans, configuration files, and Facelet JSF pages, packaged as a war. Let's start with the configuration files."
+msgstr "猜数字应用由Web Beans,配置文件,Facelete JSF页面组成,打包为一个WAR。我们先看一下配置文件。"
#. Tag: para
-#: ri.xml:180
+#: ri.xml:149
#, no-c-format
-msgid ""
-"All the configuration files for this example are located in <literal>WEB-INF/"
-"</literal>, which is stored in <literal>WebContent</literal> in the source "
-"tree. First, we have <literal>faces-config.xml</literal>, in which we tell "
-"JSF to use Facelets:"
-msgstr ""
+msgid "All the configuration files for this example are located in <literal>WEB-INF/</literal>, which is stored in <literal>WebContent</literal> in the source tree. First, we have <literal>faces-config.xml</literal>, in which we tell JSF to use Facelets:"
+msgstr "猜数字应用的所有的配置文件位于<literal>WEB-INF/</literal>,这个目录位于源码树的<literal>WebContent</literal>中。首先,我们在faces-config.xml文件中告诉JSF使用Faceletes:"
#. Tag: programlisting
-#: ri.xml:188
+#: ri.xml:157
#, no-c-format
msgid ""
"<![CDATA[<?xml version='1.0' encoding='UTF-8'?>\n"
"<faces-config version=\"1.2\"\n"
" xmlns=\"http://java.sun.com/xml/ns/javaee\"\n"
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
-" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://"
-"java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd\">\n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd\">\n"
" \n"
" <application>\n"
" <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>\n"
@@ -320,36 +239,40 @@
"\n"
"</faces-config>]]>"
msgstr ""
+"<![CDATA[<?xml version='1.0' encoding='UTF-8'?>\n"
+"<faces-config version=\"1.2\"\n"
+" xmlns=\"http://java.sun.com/xml/ns/javaee\"\n"
+" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd\">\n"
+" \n"
+" <application>\n"
+" <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>\n"
+" </application>\n"
+"\n"
+"</faces-config>]]>"
#. Tag: para
-#: ri.xml:190
+#: ri.xml:159
#, no-c-format
-msgid ""
-"There is an empty <literal>web-beans.xml</literal> file, which marks this "
-"application as a Web Beans application."
-msgstr ""
+msgid "There is an empty <literal>web-beans.xml</literal> file, which marks this application as a Web Beans application."
+msgstr "这有一个空的<literal>web-beans.xml</literal>文件,标识这个应用是一个Web Beans应用。"
#. Tag: para
-#: ri.xml:195
+#: ri.xml:164
#, no-c-format
msgid "Finally there is <literal>web.xml</literal>:"
-msgstr ""
+msgstr "最后,这有一个 <literal>web.xml</literal>:"
#. Tag: section
-#: ri.xml:197
+#: ri.xml:166
#, no-c-format
msgid ""
-"<programlistingco> <areaspec> <area id=\"faces.servlet\" coords=\"12\"/> "
-"<area id=\"faces.servlet.mapping\" coords=\"18\"/> <area id=\"faces.default."
-"suffix\" coords=\"23\"/> <area id=\"session.timeout\" coords=\"28\"/> <area "
-"id=\"webbeans.listener\" coords=\"32\"/> </areaspec> <programlisting><![CDATA"
-"[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<programlistingco> <areaspec> <area id=\"faces.servlet\" coords=\"12\"/> <area id=\"faces.servlet.mapping\" coords=\"18\"/> <area id=\"faces.default.suffix\" coords=\"23\"/> <area id=\"session.timeout\" coords=\"28\"/> <area id=\"webbeans.listener\" coords=\"32\"/> </areaspec> <programlisting><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"\n"
"<web-app version=\"2.5\"\n"
" xmlns=\"http://java.sun.com/xml/ns/javaee\"\n"
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
-" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun."
-"com/xml/ns/javaee/web-app_2_5.xsd\">\n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\">\n"
" \n"
" <display-name>Web Beans Numbergues example</display-name>\n"
"\n"
@@ -374,24 +297,12 @@
" <session-config>\n"
" <session-timeout>10</session-timeout>\n"
" </session-config>\n"
+" \n"
+" <listener>\n"
+" <listener-class>org.jboss.webbeans.servlet.WebBeansListener</listener-class>\n"
+" </listener>\n"
"\n"
-"</web-app>]]></programlisting> <calloutlist> <callout arearefs=\"faces."
-"servlet\"> <para> Enable and load the JSF servlet </para> </callout> "
-"<callout arearefs=\"faces.servlet.mapping\"> <para> Configure requests to "
-"<literal>.jsf</literal> pages to be handled by JSF </para> </callout> "
-"<callout arearefs=\"faces.default.suffix\"> <para> Tell JSF that we will be "
-"giving our source files (facelets) an extension of <literal>.jsf</literal> </"
-"para> </callout> <callout arearefs=\"session.timeout\"> <para> Configure a "
-"session timeout of 10 minutes </para> </callout> </calloutlist> </"
-"programlistingco> <note> <para> Whilst this demo is a JSF demo, you can use "
-"the Web Beans RI with any Servlet based web framework. </para> </note> "
-"<para> Let's take a look at the Facelet view: </para> <programlistingco> "
-"<areaspec> <area id=\"template\" coords=\"8\"/> <area id=\"messages\" coords="
-"\"12\"/> <area id=\"instructions\" coords=\"19\"/> <area id=\"guess\" coords="
-"\"25\"/> <area id=\"validator\" coords=\"30\"/> <area id=\"submit\" coords="
-"\"33\"/> </areaspec> <programlisting><![CDATA[<!DOCTYPE html PUBLIC \"-//"
-"W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/"
-"xhtml1-transitional.dtd\">\n"
+"</web-app>]]></programlisting> <calloutlist> <callout arearefs=\"faces.servlet\"> <para> Enable and load the JSF servlet </para> </callout> <callout arearefs=\"faces.servlet.mapping\"> <para> Configure requests to <literal>.jsf</literal> pages to be handled by JSF </para> </callout> <callout arearefs=\"faces.default.suffix\"> <para> Tell JSF that we will be giving our source files (facelets) an extension of <literal>.jsf</literal> </para> </callout> <callout arearefs=\"session.timeout\"> <para> Configure a session timeout of 10 minutes </para> </callout> <callout arearefs=\"webbeans.listener\"> <para> Configure the Web Beans listener, so that Web Beans services can be used in the servlet request </para> </callout> </calloutlist> </programlistingco> <note> <para> The only configuration required by the Web Beans RI in <literal>web.xml</literal> is to add the Web Beans listener. </para> <para> Whilst this demo is a JSF demo, you can use the Web Beans RI with any Servlet based!
web framework; just configure the Web Beans listener. </para> </note> <para> Let's take a look at the Facelet view: </para> <programlistingco> <areaspec> <area id=\"template\" coords=\"8\"/> <area id=\"messages\" coords=\"12\"/> <area id=\"instructions\" coords=\"19\"/> <area id=\"guess\" coords=\"25\"/> <area id=\"validator\" coords=\"29\"/> <area id=\"submit\" coords=\"32\"/> </areaspec> <programlisting><![CDATA[<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
"<html xmlns=\"http://www.w3.org/1999/xhtml\"\n"
" xmlns:ui=\"http://java.sun.com/jsf/facelets\"\n"
" xmlns:h=\"http://java.sun.com/jsf/html\"\n"
@@ -404,15 +315,12 @@
" <h:form id=\"NumberGuessMain\">\n"
" <div style=\"color: red\">\n"
" <h:messages id=\"messages\" globalOnly=\"false\"/>\n"
-" <h:outputText id=\"Higher\" value=\"Higher!\" rendered=\"#{game."
-"number gt game.guess and game.guess ne 0}\"/>\n"
-" <h:outputText id=\"Lower\" value=\"Lower!\" rendered=\"#{game."
-"number lt game.guess and game.guess ne 0}\"/>\n"
+" <h:outputText id=\"Higher\" value=\"Higher!\" rendered=\"#{game.number gt game.guess}\"/>\n"
+" <h:outputText id=\"Lower\" value=\"Lower!\" rendered=\"#{game.number lt game.guess}\"/>\n"
" </div>\n"
" \n"
" <div>\n"
-" I'm thinking of a number between #{game.smallest} and #{game."
-"biggest}.\n"
+" I'm thinking of a number between #{game.smallest} and #{game.biggest}.\n"
" You have #{game.remainingGuesses} guesses.\n"
" </div>\n"
" \n"
@@ -421,53 +329,104 @@
" <h:inputText id=\"inputGuess\" \n"
" value=\"#{game.guess}\" \n"
" required=\"true\" \n"
-" size=\"3\" \n"
-" disabled=\"#{game.number eq game.guess}\">\n"
+" size=\"3\">\n"
" <f:validateLongRange maximum=\"#{game.biggest}\" \n"
" minimum=\"#{game.smallest}\"/>\n"
" </h:inputText>\n"
-" <h:commandButton id=\"GuessButton\" \n"
+" <h:commandButton id=\"GuessButton\" \n"
" value=\"Guess\" \n"
-" action=\"#{game.check}\" \n"
-" disabled=\"#{game.number eq game.guess}\"/>\n"
+" action=\"#{game.check}\"/>\n"
" </div>\n"
+" \n"
+" </h:form>\n"
+" </ui:define>\n"
+" </ui:composition>\n"
+"</html>]]></programlisting> <calloutlist> <callout arearefs=\"template\"> <para> Facelets is a templating language for JSF, here we are wrapping our page in a template which defines the header. </para> </callout> <callout arearefs=\"messages\"> <para> There are a number of messages which can be sent to the user, \"Higher!\", \"Lower!\" and \"Correct!\" </para> </callout> <callout arearefs=\"instructions\"> <para> As the user guesses, the range of numbers they can guess gets smaller - this sentance changes to make sure they know what range to guess in. </para> </callout> <callout arearefs=\"guess\"> <para> This input field is bound to a Web Bean, using the value expression. </para> </callout> <callout arearefs=\"validator\"> <para> A range validator is used to make sure the user doesn't accidentally input a number outside of the range in which they can guess - if the validator wasn't here, the user might use up a guess on an out of range number. </para> </callout> <callout !
arearefs=\"submit\"> <para> And, of course, there must be a way for the user to send their guess to the server. Here we bind to an action method on the Web Bean. </para> </callout> </calloutlist> </programlistingco>"
+msgstr ""
+"<programlistingco> <areaspec> <area id=\"faces.servlet\" coords=\"12\"/> <area id=\"faces.servlet.mapping\" coords=\"18\"/> <area id=\"faces.default.suffix\" coords=\"23\"/> <area id=\"session.timeout\" coords=\"28\"/> <area id=\"webbeans.listener\" coords=\"32\"/> </areaspec> <programlisting><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"\n"
+"<web-app version=\"2.5\"\n"
+" xmlns=\"http://java.sun.com/xml/ns/javaee\"\n"
+" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\">\n"
+" \n"
+" <display-name>Web Beans Numbergues example</display-name>\n"
+"\n"
+" <!-- JSF -->\n"
+"\n"
+" <servlet>\n"
+" <servlet-name>Faces Servlet</servlet-name>\n"
+" <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>\n"
+" <load-on-startup>1</load-on-startup>\n"
+" </servlet>\n"
+"\n"
+" <servlet-mapping>\n"
+" <servlet-name>Faces Servlet</servlet-name>\n"
+" <url-pattern>*.jsf</url-pattern>\n"
+" </servlet-mapping>\n"
+" \n"
+" <context-param>\n"
+" <param-name>javax.faces.DEFAULT_SUFFIX</param-name>\n"
+" <param-value>.xhtml</param-value>\n"
+" </context-param>\n"
+"\n"
+" <session-config>\n"
+" <session-timeout>10</session-timeout>\n"
+" </session-config>\n"
+" \n"
+" <listener>\n"
+" <listener-class>org.jboss.webbeans.servlet.WebBeansListener</listener-class>\n"
+" </listener>\n"
+"\n"
+"</web-app>]]></programlisting> <calloutlist> <callout arearefs=\"faces.servlet\"> <para> Enable and load the JSF servlet </para> </callout> <callout arearefs=\"faces.servlet.mapping\"> <para> Configure requests to <literal>.jsf</literal> pages to be handled by JSF </para> </callout> <callout arearefs=\"faces.default.suffix\"> <para> Tell JSF that we will be giving our source files (facelets) an extension of <literal>.jsf</literal> </para> </callout> <callout arearefs=\"session.timeout\"> <para> Configure a session timeout of 10 minutes </para> </callout> <callout arearefs=\"webbeans.listener\"> <para> Configure the Web Beans listener, so that Web Beans services can be used in the servlet request </para> </callout> </calloutlist> </programlistingco> <note> <para> The only configuration required by the Web Beans RI in <literal>web.xml</literal> is to add the Web Beans listener. </para> <para> Whilst this demo is a JSF demo, you can use the Web Beans RI with any Servlet based!
web framework; just configure the Web Beans listener. </para> </note> <para> Let's take a look at the Facelet view: </para> <programlistingco> <areaspec> <area id=\"template\" coords=\"8\"/> <area id=\"messages\" coords=\"12\"/> <area id=\"instructions\" coords=\"19\"/> <area id=\"guess\" coords=\"25\"/> <area id=\"validator\" coords=\"29\"/> <area id=\"submit\" coords=\"32\"/> </areaspec> <programlisting><![CDATA[<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
+"<html xmlns=\"http://www.w3.org/1999/xhtml\"\n"
+" xmlns:ui=\"http://java.sun.com/jsf/facelets\"\n"
+" xmlns:h=\"http://java.sun.com/jsf/html\"\n"
+" xmlns:f=\"http://java.sun.com/jsf/core\"\n"
+" xmlns:s=\"http://jboss.com/products/seam/taglib\">\n"
+"\n"
+" <ui:composition template=\"template.xhtml\">\n"
+" <ui:define name=\"content\">\n"
+" <h1>Guess a number...</h1>\n"
+" <h:form id=\"NumberGuessMain\">\n"
+" <div style=\"color: red\">\n"
+" <h:messages id=\"messages\" globalOnly=\"false\"/>\n"
+" <h:outputText id=\"Higher\" value=\"Higher!\" rendered=\"#{game.number gt game.guess}\"/>\n"
+" <h:outputText id=\"Lower\" value=\"Lower!\" rendered=\"#{game.number lt game.guess}\"/>\n"
+" </div>\n"
+" \n"
" <div>\n"
-" <h:commandButton id=\"RestartButton\" value=\"Reset\" action=\"#"
-"{game.reset}\" immediate=\"true\" />\n"
+" I'm thinking of a number between #{game.smallest} and #{game.biggest}.\n"
+" You have #{game.remainingGuesses} guesses.\n"
" </div>\n"
+" \n"
+" <div>\n"
+" Your guess: \n"
+" <h:inputText id=\"inputGuess\" \n"
+" value=\"#{game.guess}\" \n"
+" required=\"true\" \n"
+" size=\"3\">\n"
+" <f:validateLongRange maximum=\"#{game.biggest}\" \n"
+" minimum=\"#{game.smallest}\"/>\n"
+" </h:inputText>\n"
+" <h:commandButton id=\"GuessButton\" \n"
+" value=\"Guess\" \n"
+" action=\"#{game.check}\"/>\n"
+" </div>\n"
+" \n"
" </h:form>\n"
" </ui:define>\n"
" </ui:composition>\n"
-"</html>]]></programlisting> <calloutlist> <callout arearefs=\"template\"> "
-"<para> Facelets is a templating language for JSF, here we are wrapping our "
-"page in a template which defines the header. </para> </callout> <callout "
-"arearefs=\"messages\"> <para> There are a number of messages which can be "
-"sent to the user, \"Higher!\", \"Lower!\" and \"Correct!\" </para> </"
-"callout> <callout arearefs=\"instructions\"> <para> As the user guesses, the "
-"range of numbers they can guess gets smaller - this sentance changes to make "
-"sure they know what range to guess in. </para> </callout> <callout arearefs="
-"\"guess\"> <para> This input field is bound to a Web Bean, using the value "
-"expression. </para> </callout> <callout arearefs=\"validator\"> <para> A "
-"range validator is used to make sure the user doesn't accidentally input a "
-"number outside of the range in which they can guess - if the validator "
-"wasn't here, the user might use up a guess on an out of range number. </"
-"para> </callout> <callout arearefs=\"submit\"> <para> And, of course, there "
-"must be a way for the user to send their guess to the server. Here we bind "
-"to an action method on the Web Bean. </para> </callout> </calloutlist> </"
-"programlistingco>"
-msgstr ""
+"</html>]]></programlisting> <calloutlist> <callout arearefs=\"template\"> <para> Facelets is a templating language for JSF, here we are wrapping our page in a template which defines the header. </para> </callout> <callout arearefs=\"messages\"> <para> There are a number of messages which can be sent to the user, \"Higher!\", \"Lower!\" and \"Correct!\" </para> </callout> <callout arearefs=\"instructions\"> <para> As the user guesses, the range of numbers they can guess gets smaller - this sentance changes to make sure they know what range to guess in. </para> </callout> <callout arearefs=\"guess\"> <para> This input field is bound to a Web Bean, using the value expression. </para> </callout> <callout arearefs=\"validator\"> <para> A range validator is used to make sure the user doesn't accidentally input a number outside of the range in which they can guess - if the validator wasn't here, the user might use up a guess on an out of range number. </para> </callout> <callout !
arearefs=\"submit\"> <para> And, of course, there must be a way for the user to send their guess to the server. Here we bind to an action method on the Web Bean. </para> </callout> </calloutlist> </programlistingco>"
#. Tag: para
-#: ri.xml:299
+#: ri.xml:279
#, no-c-format
-msgid ""
-"The example exists of 4 classes, the first two of which are binding types. "
-"First, there is the <literal>@Random</literal> binding type, used for "
-"injecting a random number:"
-msgstr ""
+msgid "The example exists of 4 classes, the first two of which are binding types. First, there is the <literal>@Random</literal> binding type, used for injecting a random number:"
+msgstr "这个例子包括4个类,前面两个是绑定类型。首先,这有一个<literal>@Random</literal>绑定类型,用来注入一个随机数:"
#. Tag: programlisting
-#: ri.xml:305
+#: ri.xml:285
#, no-c-format
msgid ""
"<![CDATA[@Target( { TYPE, METHOD, PARAMETER, FIELD })\n"
@@ -476,17 +435,20 @@
"@BindingType\n"
"public @interface Random {}]]>"
msgstr ""
+"<![CDATA[@Target( { TYPE, METHOD, PARAMETER, FIELD })\n"
+"@Retention(RUNTIME)\n"
+"@Documented\n"
+"@BindingType\n"
+"public @interface Random {}]]>"
#. Tag: para
-#: ri.xml:307
+#: ri.xml:287
#, no-c-format
-msgid ""
-"There is also the <literal>@MaxNumber</literal> binding type, used for "
-"injecting the maximum number that can be injected:"
-msgstr ""
+msgid "There is also the <literal>@MaxNumber</literal> binding type, used for injecting the maximum number that can be injected:"
+msgstr "这还有一个<literal>@MaxNumber</literal>绑定类型,用来注入一个最大值:"
#. Tag: programlisting
-#: ri.xml:312
+#: ri.xml:292
#, no-c-format
msgid ""
"<![CDATA[@Target( { TYPE, METHOD, PARAMETER, FIELD })\n"
@@ -496,25 +458,27 @@
"public @interface MaxNumber {}\n"
"]]>"
msgstr ""
+"<![CDATA[@Target( { TYPE, METHOD, PARAMETER, FIELD })\n"
+"@Retention(RUNTIME)\n"
+"@Documented\n"
+"@BindingType\n"
+"public @interface MaxNumber {}\n"
+"]]>"
#. Tag: para
-#: ri.xml:314
+#: ri.xml:294
#, no-c-format
-msgid ""
-"The <literal>Generator</literal> class is responsible for creating the "
-"random number, via a producer method. It also exposes the maximum possible "
-"number via a producer method:"
-msgstr ""
+msgid "The <literal>Generator</literal> class is responsible for creating the random number, via a producer method. It also exposes the maximum possible number via a producer method:"
+msgstr "<literal>Generator</literal>类通过一个生产者(producer)方法创建一个随机数。它也通过一个生产者方法暴露可能的最大值:"
#. Tag: programlisting
-#: ri.xml:320
+#: ri.xml:300
#, no-c-format
msgid ""
"<![CDATA[@ApplicationScoped\n"
"public class Generator {\n"
" \n"
-" private java.util.Random random = new java.util.Random( System."
-"currentTimeMillis() );\n"
+" private java.util.Random random = new java.util.Random( System.currentTimeMillis() );\n"
" \n"
" private int maxNumber = 100;\n"
" \n"
@@ -534,55 +498,54 @@
"\n"
"}]]>"
msgstr ""
+"<![CDATA[@ApplicationScoped\n"
+"public class Generator {\n"
+" \n"
+" private java.util.Random random = new java.util.Random( System.currentTimeMillis() );\n"
+" \n"
+" private int maxNumber = 100;\n"
+" \n"
+" java.util.Random getRandom()\n"
+" {\n"
+" return random;\n"
+" }\n"
+" \n"
+" @Produces @Random int next() { \n"
+" return getRandom().nextInt(maxNumber); \n"
+" }\n"
+" \n"
+" @Produces @MaxNumber int getMaxNumber()\n"
+" {\n"
+" return maxNumber;\n"
+" }\n"
+"\n"
+"}]]>"
#. Tag: para
-#: ri.xml:322
+#: ri.xml:302
#, no-c-format
-msgid ""
-"You'll notice that the <literal>Generator</literal> is application scoped; "
-"therefore we don't get a different random each time."
-msgstr ""
+msgid "You'll notice that the <literal>Generator</literal> is application scoped; therefore we don't get a different random each time."
+msgstr "你会注意到<literal>Generator</literal>是应用范围的;因此我们不会每次都得到一个不同的随机对象。"
#. Tag: para
-#: ri.xml:327
+#: ri.xml:307
#, no-c-format
-msgid ""
-"The final Web Bean in the application is the session scoped <literal>Game</"
-"literal>."
-msgstr ""
+msgid "The final Web Bean in the application is the session scoped <literal>Game</literal>. By making <literal>Game</literal> session scoped, you can only play the game once per browser session. You could easily add a reset button - a good exercise for the reader :-)"
+msgstr "最后,应用的Web Bean是会话范围的 <literal>Game</literal>。通过将 <literal>Game</literal>的范围设为会话范围,你可以为每个浏览器会话启动一个猜数字游戏。你可以简单地添加一个复位按钮-对于读者来说是一个很好的练习 :)"
#. Tag: para
-#: ri.xml:332
+#: ri.xml:314
#, no-c-format
-msgid ""
-"You'll note that we've used the <literal>@Named</literal> annotation, so "
-"that we can use the bean through EL in the JSF page. Finally, we've used "
-"constructor injection to initialize the game with a random number. And of "
-"course, we need to tell the player when they've won, so we give feedback "
-"with a <literal>FacesMessage</literal>."
-msgstr ""
+msgid "You'll also note that we've used the <literal>@Named</literal> annotation, so that we can use the bean through EL in the JSF page. Finally, we've used constructor injection to initialize the game with a random number. And of course, we need to tell the player when they've won, so we give feedback with a <literal>FacesMessage</literal>."
+msgstr "你也许注意到我们使用了 <literal>@Named</literal>注释,以便我们能够通过EL(表达式语言)在JSF页面中使用Bean。最后,我们通过构造器注入来初始化猜数字游戏并给它设一个随机数。当然,在玩家猜对数字后,我们需要告诉玩家他赢了,所以我们通过<literal>FacesMessage</literal>反馈给玩家一条信息。"
#. Tag: programlisting
-#: ri.xml:340
+#: ri.xml:322
#, no-c-format
msgid ""
-"<![CDATA[package org.jboss.webbeans.examples.numberguess;\n"
-"\n"
-"\n"
-"import javax.annotation.PostConstruct;\n"
-"import javax.faces.application.FacesMessage;\n"
-"import javax.faces.context.FacesContext;\n"
-"import javax.webbeans.AnnotationLiteral;\n"
-"import javax.webbeans.Current;\n"
-"import javax.webbeans.Initializer;\n"
-"import javax.webbeans.Named;\n"
-"import javax.webbeans.SessionScoped;\n"
-"import javax.webbeans.manager.Manager;\n"
-"\n"
-"@Named\n"
+"<![CDATA[@Named\n"
"@SessionScoped\n"
-"public class Game\n"
-"{\n"
+"public class Game {\n"
" private int number;\n"
" \n"
" private int guess;\n"
@@ -590,121 +553,104 @@
" private int biggest;\n"
" private int remainingGuesses;\n"
" \n"
-" @Current Manager manager;\n"
+" public Game() {}\n"
" \n"
-" public Game()\n"
-" {\n"
-" }\n"
-" \n"
" @Initializer\n"
-" Game(@MaxNumber int maxNumber)\n"
-" { \n"
+" Game(@Random int number, @MaxNumber int maxNumber) {\n"
+" this.number = number;\n"
+" this.smallest = 1;\n"
" this.biggest = maxNumber;\n"
+" this.remainingGuesses = 10;\n"
" }\n"
"\n"
-" public int getNumber()\n"
-" {\n"
-" return number;\n"
-" }\n"
+" // Getters and setters for fields\n"
" \n"
-" public int getGuess()\n"
-" {\n"
-" return guess;\n"
+" public String check() {\n"
+" if (guess>number) {\n"
+" biggest = guess - 1;\n"
+" }\n"
+" if (guess<number) {\n"
+" smallest = guess + 1;\n"
+" }\n"
+" if (guess == number) {\n"
+" FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(\"Correct!\"));\n"
+" }\n"
+" remainingGuesses--;\n"
+" return null;\n"
" }\n"
" \n"
-" public void setGuess(int guess)\n"
-" {\n"
-" this.guess = guess;\n"
-" }\n"
+"}]]>"
+msgstr ""
+"<![CDATA[@Named\n"
+"@SessionScoped\n"
+"public class Game {\n"
+" private int number;\n"
" \n"
-" public int getSmallest()\n"
-" {\n"
-" return smallest;\n"
-" }\n"
+" private int guess;\n"
+" private int smallest;\n"
+" private int biggest;\n"
+" private int remainingGuesses;\n"
" \n"
-" public int getBiggest()\n"
-" {\n"
-" return biggest;\n"
-" }\n"
+" public Game() {}\n"
" \n"
-" public int getRemainingGuesses()\n"
-" {\n"
-" return remainingGuesses;\n"
+" @Initializer\n"
+" Game(@Random int number, @MaxNumber int maxNumber) {\n"
+" this.number = number;\n"
+" this.smallest = 1;\n"
+" this.biggest = maxNumber;\n"
+" this.remainingGuesses = 10;\n"
" }\n"
+"\n"
+" // Getters and setters for fields\n"
" \n"
-" public String check()\n"
-" {\n"
-" if (guess>number)\n"
-" {\n"
+" public String check() {\n"
+" if (guess>number) {\n"
" biggest = guess - 1;\n"
" }\n"
-" if (guess<number)\n"
-" {\n"
+" if (guess<number) {\n"
" smallest = guess + 1;\n"
" }\n"
-" if (guess == number)\n"
-" {\n"
-" FacesContext.getCurrentInstance().addMessage(null, new FacesMessage"
-"(\"Correct!\"));\n"
+" if (guess == number) {\n"
+" FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(\"Correct!\"));\n"
" }\n"
" remainingGuesses--;\n"
" return null;\n"
" }\n"
" \n"
-" @PostConstruct\n"
-" public void reset()\n"
-" {\n"
-" this.smallest = 0;\n"
-" this.guess = 0;\n"
-" this.remainingGuesses = 10;\n"
-" this.number = manager.getInstanceByType(Integer.class, new "
-"AnnotationLiteral<Random>(){});\n"
-" }\n"
-" \n"
"}]]>"
-msgstr ""
#. Tag: title
-#: ri.xml:344
+#: ri.xml:326
#, no-c-format
msgid "The translator example"
-msgstr ""
+msgstr "翻译器例子"
#. Tag: para
-#: ri.xml:346
+#: ri.xml:328
#, no-c-format
-msgid ""
-"The translator example will take any sentences you enter, and translate them "
-"to Latin."
-msgstr ""
+msgid "The translator example will take any sentences you enter, and translate them to Latin."
+msgstr "翻译器例子能够将你输入的句子翻译为拉丁文。"
#. Tag: para
-#: ri.xml:351
+#: ri.xml:333
#, no-c-format
-msgid ""
-"The translator example is built as an ear, and contains EJBs. As a result, "
-"it's structure is more complex than the numberguess example."
-msgstr ""
+msgid "The translator example is built as an ear, and contains EJBs and enterprise beans. As a result, it's structure is more complex than the numberguess example."
+msgstr "翻译器例子是一个EAR应用,包含EJBs和企业Beans。因此,它的结构比猜数字例子复杂。"
#. Tag: para
-#: ri.xml:357
+#: ri.xml:340
#, no-c-format
-msgid ""
-"EJB 3.1 and Jave EE 6 allow you to package EJBs in a war, which will make "
-"this structure much simpler!"
-msgstr ""
+msgid "EJB 3.1 and Jave EE 6 allow you to package EJBs in a war, which will make this structure much simpler!"
+msgstr "EJB3.1和Java EE 6允许你在WAR包中打包EJBs, 这将让这个结构更加简单!"
#. Tag: para
-#: ri.xml:363
+#: ri.xml:346
#, no-c-format
-msgid ""
-"First, let's take a look at the ear aggregator, which is located in "
-"<literal>webbeans-translator-ear</literal> module. Maven automatically "
-"generates the <literal>application.xml</literal> for us:"
-msgstr ""
+msgid "First, let's take a look at the ear aggregator, which is located in <literal>webbeans-translator-ear</literal> module. Maven automatically generates the <literal>application.xml</literal> and <literal>jboss-app.xml</literal> for us:"
+msgstr "首先,让我们看一下EAR聚合器,它位于<literal>webbeans-translator-ear</literal>模块下。Maven将为我们自动生成<literal>application.xml</literal>和<literal>jboss-app.xml</literal>文件:"
#. Tag: programlisting
-#: ri.xml:369
+#: ri.xml:353
#, no-c-format
msgid ""
"<![CDATA[<plugin>\n"
@@ -718,40 +664,78 @@
" <contextRoot>/webbeans-translator</contextRoot>\n"
" </webModule>\n"
" </modules>\n"
+" <jboss>\n"
+" <loader-repository>webbeans.jboss.org:loader=webbeans-translator</loader-repository>\n"
+" </jboss>\n"
" </configuration>\n"
"</plugin>]]>"
msgstr ""
+"<![CDATA[<plugin>\n"
+" <groupId>org.apache.maven.plugins</groupId>\n"
+" <artifactId>maven-ear-plugin</artifactId>\n"
+" <configuration>\n"
+" <modules>\n"
+" <webModule>\n"
+" <groupId>org.jboss.webbeans.examples.translator</groupId>\n"
+" <artifactId>webbeans-translator-war</artifactId>\n"
+" <contextRoot>/webbeans-translator</contextRoot>\n"
+" </webModule>\n"
+" </modules>\n"
+" <jboss>\n"
+" <loader-repository>webbeans.jboss.org:loader=webbeans-translator</loader-repository>\n"
+" </jboss>\n"
+" </configuration>\n"
+"</plugin>]]>"
#. Tag: para
-#: ri.xml:371
+#: ri.xml:355
#, no-c-format
-msgid ""
-"Here we set the context path, which gives us a nice url (<ulink url=\"http://"
-"localhost:8080/webbeans-translator\">http://localhost:8080/webbeans-"
-"translator</ulink>)."
-msgstr ""
+msgid "We're doing a couple of things here - firstly we set the context path, which gives us a nice url (<ulink url=\"http://localhost:8080/webbeans-translator\">http://localhost:8080/webbeans-translator</ulink>) and we also enable class loader isolation for JBoss AS."
+msgstr "我们需要在这里做些事情-首先我们需要设置上下文路径为一个不错的URL(<ulink url=\"http://localhost:8080/webbeans-translator\">http://localhost:8080/webbeans-translator</ulink>),我们还需要将JBoss AS的类加载器隔离配置激活。"
#. Tag: para
-#: ri.xml:377
+#: ri.xml:363
#, no-c-format
+msgid "If you aren't using Maven to generate these files, you would need <literal>META-INF/jboss-app.xml</literal>:"
+msgstr "如果你不使用Maven来生成这些文件,你将需要<literal>META-INF/jboss-app.xml</literal>:"
+
+#. Tag: programlisting
+#: ri.xml:368
+#, no-c-format
msgid ""
-"If you aren't using Maven to generate these files, you would need "
-"<literal>META-INF/application.xml</literal>:"
+"<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<!DOCTYPE jboss-app\n"
+" PUBLIC \"-//JBoss//DTD J2EE Application 4.2//EN\"\n"
+" \"http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd\">\n"
+"<jboss-app>\n"
+" <loader-repository>webbeans.jboss.org:loader=webbeans-translator</loader-repository>\n"
+"</jboss-app>]]>"
msgstr ""
+"<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<!DOCTYPE jboss-app\n"
+" PUBLIC \"-//JBoss//DTD J2EE Application 4.2//EN\"\n"
+" \"http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd\">\n"
+"<jboss-app>\n"
+" <loader-repository>webbeans.jboss.org:loader=webbeans-translator</loader-repository>\n"
+"</jboss-app>]]>"
+#. Tag: para
+#: ri.xml:370
+#, no-c-format
+msgid "and <literal>META-INF/application.xml</literal>:"
+msgstr "和 <literal>META-INF/application.xml</literal>:"
+
#. Tag: programlisting
-#: ri.xml:382
+#: ri.xml:374
#, no-c-format
msgid ""
"<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<application xmlns=\"http://java.sun.com/xml/ns/javaee\" \n"
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
-" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://"
-"java.sun.com/xml/ns/javaee/application_5.xsd\"\n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd\"\n"
" version=\"5\">\n"
" <display-name>webbeans-translator-ear</display-name>\n"
-" <description>Ear Example for the reference implementation of JSR 299: Web "
-"Beans</description>\n"
+" <description>Ear Example for the reference implementation of JSR 299: Web Beans</description>\n"
" \n"
" <module>\n"
" <web>\n"
@@ -764,27 +748,39 @@
" </module>\n"
"</application>]]>"
msgstr ""
+"<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<application xmlns=\"http://java.sun.com/xml/ns/javaee\" \n"
+" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd\"\n"
+" version=\"5\">\n"
+" <display-name>webbeans-translator-ear</display-name>\n"
+" <description>Ear Example for the reference implementation of JSR 299: Web Beans</description>\n"
+" \n"
+" <module>\n"
+" <web>\n"
+" <web-uri>webbeans-translator.war</web-uri>\n"
+" <context-root>/webbeans-translator</context-root>\n"
+" </web>\n"
+" </module>\n"
+" <module>\n"
+" <ejb>webbeans-translator.jar</ejb>\n"
+" </module>\n"
+"</application>]]>"
#. Tag: para
-#: ri.xml:385
+#: ri.xml:377
#, no-c-format
-msgid ""
-"Next, lets look at the war. Just as in the numberguess example, we have a "
-"<literal>faces-config.xml</literal> (to enabled Facelets) and a <literal>web."
-"xml</literal> (to enable JSF) in <literal>WebContent/WEB-INF</literal>."
-msgstr ""
+msgid "Next, lets look at the war. Just as in the numberguess example, we have a <literal>faces-config.xml</literal> (to enabled Facelets) and a <literal>web.xml</literal> (to enable JSF and attach Web Beans services to the servlet container) in <literal>WebContent/WEB-INF</literal>."
+msgstr "然后,我们看一下WAR包。在猜数字例子中,我们需要<literal>faces-config.xml</literal>(配置Facelets)和一个位于<literal>WebContent/WEB-INF</literal>下的<literal>web.xml</literal>(配置JSF并将Web Beans服务加入Servlet容器中)。"
#. Tag: para
-#: ri.xml:392
+#: ri.xml:384
#, no-c-format
-msgid ""
-"More intersting is the facelet used to translate text. Just as in the "
-"numberguess example we have a template, which surrounds the form (ommitted "
-"here for brevity):"
-msgstr ""
+msgid "More intersting is the facelet used to translate text. Just as in the numberguess example we have a template, which surrounds the form (ommitted here for brevity):"
+msgstr "更有意思的是用来翻译文本的facelet。在猜数字应用中我们有一个模板,这个模板套着表单(省略了表单):"
#. Tag: programlisting
-#: ri.xml:398
+#: ri.xml:390
#, no-c-format
msgid ""
"<![CDATA[<h:form id=\"NumberGuessMain\">\n"
@@ -800,8 +796,7 @@
" </tr>\n"
" <tr>\n"
" <td>\n"
-" <h:inputTextarea id=\"text\" value=\"#{translator.text}\" "
-"required=\"true\" rows=\"5\" cols=\"80\" />\n"
+" <h:inputTextarea id=\"text\" value=\"#{translator.text}\" required=\"true\" rows=\"5\" cols=\"80\" />\n"
" </td>\n"
" <td>\n"
" <h:outputText value=\"#{translator.translatedText}\" />\n"
@@ -809,54 +804,109 @@
" </tr>\n"
" </table>\n"
" <div>\n"
-" <h:commandButton id=\"button\" value=\"Translate\" action=\"#"
-"{translator.translate}\"/>\n"
+" <h:commandButton id=\"button\" value=\"Translate\" action=\"#{translator.translate}\"/>\n"
" </div>\n"
" \n"
"</h:form>]]>"
msgstr ""
+"<![CDATA[<h:form id=\"NumberGuessMain\">\n"
+" \n"
+" <table>\n"
+" <tr align=\"center\" style=\"font-weight: bold\" >\n"
+" <td>\n"
+" Your text\n"
+" </td>\n"
+" <td>\n"
+" Translation\n"
+" </td>\n"
+" </tr>\n"
+" <tr>\n"
+" <td>\n"
+" <h:inputTextarea id=\"text\" value=\"#{translator.text}\" required=\"true\" rows=\"5\" cols=\"80\" />\n"
+" </td>\n"
+" <td>\n"
+" <h:outputText value=\"#{translator.translatedText}\" />\n"
+" </td>\n"
+" </tr>\n"
+" </table>\n"
+" <div>\n"
+" <h:commandButton id=\"button\" value=\"Translate\" action=\"#{translator.translate}\"/>\n"
+" </div>\n"
+" \n"
+"</h:form>]]>"
#. Tag: para
-#: ri.xml:400
+#: ri.xml:392
#, no-c-format
-msgid ""
-"The user can enter some text in the lefthand textarea, and hit the translate "
-"button to see the result to the right."
-msgstr ""
+msgid "The user can enter some text in the lefthand textarea, and hit the translate button to see the result to the right."
+msgstr "用户可以在左手边的文本区输入一些文本,点击翻译按钮查看右边的翻译结果。"
#. Tag: para
-#: ri.xml:405
+#: ri.xml:397
#, no-c-format
+msgid "Finally, let's look at the ejb module, <literal>webbeans-translator-ejb</literal>. There are two configuration files in <literal>src/main/resources/META-INF</literal>, an empty <literal>web-beans.xml</literal>, used to mark the archive as containing Web Beans, and <literal>ejb-jar.xml</literal>. Web Beans provides injection and initializtion services for all EJBs, and uses <literal>ejb-jar.xml</literal> to enable this, you'll need this in any EJB project which uses Web Beans:"
+msgstr "最后,我们看一下EJB模块,<literal>webbeans-translator-ejb</literal>。在<literal>src/main/resources/META-INF</literal>下有两个配置文件,一个是空的<literal>web-beans.xml</literal>,用来标识这个档案包包含Web Beans,一个是<literal>ejb-jar.xml</literal>。Web Beans为所有的EJB提供注入和初始化服务,使用<literal>ejb-jar.xml</literal>文件来配置。你将在使用Web Beans的EJB项目中需要这些配置:"
+
+#. Tag: programlisting
+#: ri.xml:409
+#, no-c-format
msgid ""
-"Finally, let's look at the ejb module, <literal>webbeans-translator-ejb</"
-"literal>. In <literal>src/main/resources/META-INF</literal> there is just an "
-"empty <literal>web-beans.xml</literal>, used to mark the archive as "
-"containing Web Beans."
+"<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<ejb-jar xmlns=\"http://java.sun.com/xml/ns/javaee\" \n"
+" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd\"\n"
+" version=\"3.0\">\n"
+" \n"
+" <interceptors>\n"
+" <interceptor>\n"
+" <interceptor-class>org.jboss.webbeans.ejb.SessionBeanInterceptor</interceptor-class>\n"
+" </interceptor>\n"
+" </interceptors>\n"
+" \n"
+" <assembly-descriptor>\n"
+" <interceptor-binding>\n"
+" <ejb-name>*</ejb-name>\n"
+" <interceptor-class>org.jboss.webbeans.ejb.SessionBeanInterceptor</interceptor-class>\n"
+" </interceptor-binding>\n"
+" </assembly-descriptor>\n"
+" \n"
+"</ejb-jar>]]>"
msgstr ""
+"<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<ejb-jar xmlns=\"http://java.sun.com/xml/ns/javaee\" \n"
+" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
+" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd\"\n"
+" version=\"3.0\">\n"
+" \n"
+" <interceptors>\n"
+" <interceptor>\n"
+" <interceptor-class>org.jboss.webbeans.ejb.SessionBeanInterceptor</interceptor-class>\n"
+" </interceptor>\n"
+" </interceptors>\n"
+" \n"
+" <assembly-descriptor>\n"
+" <interceptor-binding>\n"
+" <ejb-name>*</ejb-name>\n"
+" <interceptor-class>org.jboss.webbeans.ejb.SessionBeanInterceptor</interceptor-class>\n"
+" </interceptor-binding>\n"
+" </assembly-descriptor>\n"
+" \n"
+"</ejb-jar>]]>"
#. Tag: para
-#: ri.xml:413
+#: ri.xml:411
#, no-c-format
-msgid ""
-"We've saved the most interesting bit to last, the code! The project has two "
-"simple beans, <literal>SentenceParser</literal> and <literal>TextTranslator</"
-"literal> and two enterprise beans, <literal>TranslatorControllerBean</"
-"literal> and <literal>SentenceTranslator</literal>. You should be getting "
-"quite familiar with what a Web Bean looks like by now, so we'll just "
-"highlight the most interesting bits here."
-msgstr ""
+msgid "We've saved the most interesting bit to last, the code! The project has two simple beans, <literal>SentanceParser</literal> and <literal>TextTranslator</literal> and two enterprise beans, <literal>TanslatorControllerBean</literal> and <literal>SentenceTranslator</literal>. You should be getting quite familiar with what a Web Bean looks like by now, so we'll just highlight the most interesting bits here."
+msgstr "我们将最有意思的部分放在最后,那就是代码!这个例子有两个简单Beans, <literal>SentanceParser</literal>和<literal>TextTranslator</literal>,还有两个企业Beans,<literal>TanslatorControllerBean</literal>和<literal>SentenceTranslator</literal>。现在你应该对Web Beans有点熟悉了,我们在这里着重最有意思的部分。"
#. Tag: para
-#: ri.xml:423
+#: ri.xml:421
#, no-c-format
-msgid ""
-"Both <literal>SentenceParser</literal> and <literal>TextTranslator</literal> "
-"are dependent beans, and <literal>TextTranslator</literal> uses constructor "
-"initialization:"
-msgstr ""
+msgid "Both <literal>SentanceParser</literal> and <literal>TextTranslator</literal> are dependent beans, and <literal>TextTranslator</literal> uses constructor initialization:"
+msgstr "<literal>SentanceParser</literal>和<literal>TextTranslator</literal>是相互依赖的Beans,<literal>TextTranslator</literal>使用构造器初始化:"
#. Tag: programlisting
-#: ri.xml:429
+#: ri.xml:427
#, no-c-format
msgid ""
"<![CDATA[public class TextTranslator { \n"
@@ -864,33 +914,35 @@
" private Translator sentenceTranslator; \n"
" \n"
" @Initializer\n"
-" TextTranslator(SentenceParser sentenceParser, Translator "
-"sentenceTranslator) \n"
+" TextTranslator(SentenceParser sentenceParser, Translator sentenceTranslator) \n"
" { \n"
" this.sentenceParser = sentenceParser; \n"
" this.sentenceTranslator = sentenceTranslator;]]>"
msgstr ""
+"<![CDATA[public class TextTranslator { \n"
+" private SentenceParser sentenceParser; \n"
+" private Translator sentenceTranslator; \n"
+" \n"
+" @Initializer\n"
+" TextTranslator(SentenceParser sentenceParser, Translator sentenceTranslator) \n"
+" { \n"
+" this.sentenceParser = sentenceParser; \n"
+" this.sentenceTranslator = sentenceTranslator;]]>"
#. Tag: para
-#: ri.xml:431
+#: ri.xml:429
#, no-c-format
-msgid ""
-"<literal>TextTranslator</literal> is a stateless bean (with a local business "
-"interface), where the magic happens - of course, we couldn't develop a full "
-"translator, but we gave it a good go!"
-msgstr ""
+msgid "<literal>TextTranslator</literal> is a stateless bean (with a local business interface), where the magic happens - of course, we couldn't develop a full translator, but we gave it a good go!"
+msgstr "<literal>TextTranslator</literal>是一个无状态Bean(拥有一个本地业务接口),这里是魔术展现的地方-当然,我们不会开发一个完整的翻译器,但我们可以开发一个不错的小玩意!"
#. Tag: para
-#: ri.xml:437
+#: ri.xml:435
#, no-c-format
-msgid ""
-"Finally, there is UI orientated controller, that collects the text from the "
-"user, and dispatches it to the translator. This is a request scoped, named, "
-"stateful session bean, which injects the translator."
-msgstr ""
+msgid "Finally, there is UI orientated controller, that collects the text from the user, and dispatches it to the translator. This is a request scoped, named, stateful session bean, which injects the translator."
+msgstr "最后,这里又要一个面向UI的控制器,从用户输入处搜集文本,转发给翻译器。这个控制器是请求范围的,具名的,有状态的会话Bean,它可以将翻译器注入进来。"
#. Tag: programlisting
-#: ri.xml:443
+#: ri.xml:441
#, no-c-format
msgid ""
"<![CDATA[@Stateful\n"
@@ -901,21 +953,28 @@
" \n"
" @Current TextTranslator translator;]]>"
msgstr ""
+"<![CDATA[@Stateful\n"
+"@RequestScoped\n"
+"@Named(\"translator\")\n"
+"public class TranslatorControllerBean implements TranslatorController\n"
+"{\n"
+" \n"
+" @Current TextTranslator translator;]]>"
#. Tag: para
-#: ri.xml:445
+#: ri.xml:443
#, no-c-format
msgid "The bean also has getters and setters for all the fields on the page."
-msgstr ""
+msgstr "这个Bean也拥有页面上所有域的getter和setter方法。"
#. Tag: para
-#: ri.xml:449
+#: ri.xml:447
#, no-c-format
msgid "As this is a stateful session bean, we have to have a remove method:"
-msgstr ""
+msgstr "这个Bean是有状态会话Bean,我们需要有一个remove方法:"
#. Tag: programlisting
-#: ri.xml:453
+#: ri.xml:451
#, no-c-format
msgid ""
"<![CDATA[ @Remove\n"
@@ -924,29 +983,27 @@
" \n"
" }]]>"
msgstr ""
+"<![CDATA[ @Remove\n"
+" public void remove()\n"
+" {\n"
+" \n"
+" }]]>"
#. Tag: para
-#: ri.xml:455
+#: ri.xml:453
#, no-c-format
-msgid ""
-"The Web Beans manager will call the remove method for you when the bean is "
-"destroyed; in this case at the end of the request."
-msgstr ""
+msgid "The Web Beans manager will call the remove method for you when the bean is destroyed; in this case at the end of the request."
+msgstr "Web Beans管理器在这个bean销毁的时候调用remove方法;在这个例子中是请求结束的时候。"
#. Tag: para
-#: ri.xml:461
+#: ri.xml:459
#, no-c-format
-msgid ""
-"That concludes our short tour of the Web Beans RI examples. For more on the "
-"RI, or to help out, please visit <ulink url=\"http://www.seamframework.org/"
-"WebBeans/Development\">http://www.seamframework.org/WebBeans/Development</"
-"ulink>."
-msgstr ""
+msgid "That concludes our short tour of the Web Beans RI examples. For more on the RI, or to help out, please visit <ulink url=\"http://www.seamframework.org/WebBeans/Development\">http://www.seamframework.org/WebBeans/Development</ulink>."
+msgstr "Web Beans参考实现的例子到此结束。想要获得关于参考实现更多的知识或者帮助,请访问<ulink url=\"http://www.seamframework.org/WebBeans/Development\">http://www.seamframework.org/WebBeans/Development</ulink>。"
#. Tag: para
-#: ri.xml:467
+#: ri.xml:465
#, no-c-format
-msgid ""
-"We need help in all areas - bug fixing, writing new features, writing "
-"examples and translating this reference guide."
-msgstr ""
+msgid "We need help in all areas - bug fixing, writing new features, writing examples and translating this reference guide."
+msgstr "我们在各个方面都需要帮助-bug修复,新特性开发,例子开发和参考指南的翻译等等。"
+
17 years, 2 months
[webbeans-commits] Webbeans SVN: r1402 - tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-02-03 23:09:41 -0500 (Tue, 03 Feb 2009)
New Revision: 1402
Added:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
Log:
refactored, report improvements
Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java 2009-02-04 04:09:41 UTC (rev 1402)
@@ -0,0 +1,138 @@
+package org.jboss.webbeans.tck.impl.report;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Parsing utilities for tck-audit.xml
+ *
+ * @author Shane Bryzak
+ *
+ */
+public class AuditParser
+{
+ private String version;
+
+ private Map<String,List<AuditAssertion>> assertions = new HashMap<String,List<AuditAssertion>>();
+
+ private Map<String,String> titles = new HashMap<String,String>();
+
+ private InputStream source;
+
+ public AuditParser(InputStream source)
+ {
+ this.source = source;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public String getSectionTitle(String sectionId)
+ {
+ return titles.get(sectionId);
+ }
+
+ public Map<String,List<AuditAssertion>> getAssertions()
+ {
+ return assertions;
+ }
+
+ /**
+ * Returns a sorted list of assertions for the specified section ID
+ *
+ * @param sectionId
+ * @return
+ */
+ public List<AuditAssertion> getAssertionsForSection(String sectionId)
+ {
+ List<AuditAssertion> sectionAssertions = new ArrayList<AuditAssertion>(assertions.get(sectionId));
+ Collections.sort(sectionAssertions);
+ return sectionAssertions;
+ }
+
+ /**
+ * Load the spec assertions defined in tck-audit.xml
+ */
+ public void parse() throws Exception
+ {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+
+ Document doc = builder.parse(source);
+ NodeList sectionNodes = doc.getDocumentElement().getChildNodes();
+
+ version = doc.getDocumentElement().getAttribute("version");
+
+ for (int i = 0; i < sectionNodes.getLength(); i++)
+ {
+ if (sectionNodes.item(i) instanceof Element &&
+ "section".equals(sectionNodes.item(i).getNodeName()))
+ {
+ processSectionNode((Element) sectionNodes.item(i));
+ }
+ }
+ }
+
+ private void processSectionNode(Element node)
+ {
+ String sectionId = node.getAttribute("id");
+ titles.put(sectionId, node.getAttribute("title"));
+
+ NodeList assertionNodes = node.getChildNodes();
+
+ for (int i = 0; i < assertionNodes.getLength(); i++)
+ {
+ if (assertionNodes.item(i) instanceof Element &&
+ "assertion".equals(assertionNodes.item(i).getNodeName()))
+ {
+ processAssertionNode(sectionId, (Element) assertionNodes.item(i));
+ }
+ }
+ }
+
+ private void processAssertionNode(String sectionId, Element node)
+ {
+ List<AuditAssertion> value = assertions.get(sectionId);
+ if (value == null)
+ {
+ value = new ArrayList<AuditAssertion>();
+ assertions.put(sectionId, value);
+ }
+
+ String text = null;
+ String note = null;
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++)
+ {
+ Node child = node.getChildNodes().item(i);
+
+ if (child instanceof Element)
+ {
+ if ("text".equals(child.getNodeName()))
+ {
+ text = child.getTextContent();
+ }
+ else if ("note".equals(child.getNodeName()))
+ {
+ note = child.getTextContent();
+ }
+ }
+ }
+
+ value.add(new AuditAssertion(node.getAttribute("section"),
+ node.getAttribute("id"), text, note));
+ }
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 00:24:32 UTC (rev 1401)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 04:09:41 UTC (rev 1402)
@@ -1,29 +1,18 @@
package org.jboss.webbeans.tck.impl.report;
-import com.sun.mirror.util.DeclarationVisitors;
-
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import org.jboss.webbeans.tck.SpecAssertion;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.Declaration;
import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.util.DeclarationVisitors;
import com.sun.mirror.util.SimpleDeclarationVisitor;
/**
@@ -37,15 +26,14 @@
private static final String REPORT_FILE_NAME = "coverage.html";
private static final String AUDIT_FILE_NAME = "tck-audit.xml";
-
- private Map<String,List<AuditAssertion>> assertions = new HashMap<String,List<AuditAssertion>>();
- private Map<String,String> sections = new HashMap<String,String>();
-
+
private final AnnotationProcessorEnvironment env;
private final File baseDir;
private final List<SpecReference> references = new ArrayList<SpecReference>();
+ private AuditParser auditParser;
+
public CoverageProcessor(AnnotationProcessorEnvironment env)
{
this.env = env;
@@ -55,7 +43,8 @@
try
{
- loadAssertions();
+ auditParser = new AuditParser(new FileInputStream(AUDIT_FILE_NAME));
+ auditParser.parse();
}
catch (Exception ex)
{
@@ -63,76 +52,6 @@
ex.getClass().getName() + " - " + ex.getMessage(), ex);
}
}
-
- /**
- * Load the spec assertions defined in tck-audit.xml
- */
- private void loadAssertions() throws Exception
- {
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-
- Document doc = builder.parse(new FileInputStream(AUDIT_FILE_NAME));
- NodeList sectionNodes = doc.getDocumentElement().getChildNodes();
-
- for (int i = 0; i < sectionNodes.getLength(); i++)
- {
- if (sectionNodes.item(i) instanceof Element &&
- "section".equals(sectionNodes.item(i).getNodeName()))
- {
- processSectionNode((Element) sectionNodes.item(i));
- }
- }
- }
-
- private void processSectionNode(Element node)
- {
- String sectionId = node.getAttribute("id");
- sections.put(sectionId, node.getAttribute("title"));
-
- NodeList assertionNodes = node.getChildNodes();
-
- for (int i = 0; i < assertionNodes.getLength(); i++)
- {
- if (assertionNodes.item(i) instanceof Element &&
- "assertion".equals(assertionNodes.item(i).getNodeName()))
- {
- processAssertionNode(sectionId, (Element) assertionNodes.item(i));
- }
- }
- }
-
- private void processAssertionNode(String sectionId, Element node)
- {
- List<AuditAssertion> value = assertions.get(sectionId);
- if (value == null)
- {
- value = new ArrayList<AuditAssertion>();
- assertions.put(sectionId, value);
- }
-
- String text = null;
- String note = null;
-
- for (int i = 0; i < node.getChildNodes().getLength(); i++)
- {
- Node child = node.getChildNodes().item(i);
-
- if (child instanceof Element)
- {
- if ("text".equals(child.getNodeName()))
- {
- text = child.getTextContent();
- }
- else if ("note".equals(child.getNodeName()))
- {
- note = child.getTextContent();
- }
- }
- }
-
- value.add(new AuditAssertion(node.getAttribute("section"),
- node.getAttribute("id"), text, note));
- }
public void process()
{
@@ -145,20 +64,7 @@
new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
}
- CoverageReport report = new CoverageReport(references, assertions, sections);
-
- try
- {
- File reportFile = new File(baseDir, REPORT_FILE_NAME);
- FileOutputStream out = new FileOutputStream(reportFile);
- report.generate(out);
- out.flush();
- out.close();
- }
- catch (IOException ex)
- {
- throw new RuntimeException("Error generating report file", ex);
- }
+ new CoverageReport(references, auditParser).writeToFile(new File(baseDir, REPORT_FILE_NAME));
}
private class CreateReferenceVisitor extends SimpleDeclarationVisitor
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 00:24:32 UTC (rev 1401)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 04:09:41 UTC (rev 1402)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.tck.impl.report;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@@ -15,23 +17,14 @@
*/
public class CoverageReport
{
- /**
+ /*
* References to the spec assertions made by the tck tests
*/
private final Map<String,List<SpecReference>> references;
- /**
- * Assertions, mapped by section id
- */
- private final Map<String,List<AuditAssertion>> assertions;
+ private AuditParser auditParser;
- /*
- * Section titles
- */
- private final Map<String,String> sections;
-
- public CoverageReport(List<SpecReference> references, Map<String,List<AuditAssertion>> assertions,
- Map<String,String> sections)
+ public CoverageReport(List<SpecReference> references, AuditParser auditParser)
{
this.references = new HashMap<String,List<SpecReference>>();
@@ -45,14 +38,14 @@
this.references.get(ref.getSection()).add(ref);
}
- this.assertions = assertions;
- this.sections = sections;
+ this.auditParser = auditParser;
}
public void generate(OutputStream out) throws IOException
{
writeHeader(out);
- writeBody(out);
+ writeCoverage(out);
+ writeUnmatched(out);
writeFooter(out);
}
@@ -62,8 +55,9 @@
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sb.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n");
- sb.append("\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">");
- sb.append("<html><head><title>JSR-299 TCK Coverage Report</title>\n");
+ sb.append("\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
+ sb.append("<html>\n");
+ sb.append("<head><title>JSR-299 TCK Coverage Report</title>\n");
sb.append("<style type=\"text/css\">\n");
sb.append(" .code {\n");
@@ -74,40 +68,60 @@
sb.append(" height: 100%; }\n");
sb.append(" .results {\n");
sb.append(" margin-left: 50px; }\n");
- sb.append(" #pass {\n");
+ sb.append(" .description {\n");
+ sb.append(" margin-top: 2px;\n");
+ sb.append(" margin-bottom: 2px; }\n");
+ sb.append(" .sectionHeader {\n");
+ sb.append(" font-weight: bold; }\n");
+ sb.append(" .noCoverage {\n");
+ sb.append(" margin-top: 2px;\n");
+ sb.append(" margin-bottom: 2px;\n");
+ sb.append(" font-weight: bold;\n");
+ sb.append(" font-style: italic;\n");
+ sb.append(" color: #ff0000; }\n");
+ sb.append(" .coverageHeader {\n");
+ sb.append(" font-weight: bold;\n");
+ sb.append(" text-decoration: underline;\n");
+ sb.append(" margin-top: 2px;\n");
+ sb.append(" margin-bottom: 2px; }\n");
+ sb.append(" .pass {\n");
+ sb.append(" background-color: #dfd; }\n");
+ sb.append(" .fail {\n");
sb.append(" background-color: #fdd; }\n");
- sb.append(" #fail {\n");
- sb.append(" background-color: #dfd; }\n");
sb.append("</style>\n");
sb.append("</head><body>");
- sb.append("<h1>JSR-299 TCK Coverage</h1>");
+ sb.append("<h1>JSR-299 TCK Coverage</h1>");
+ sb.append("<h2>");
+ sb.append(auditParser.getVersion());
+ sb.append("</h2>\n");
out.write(sb.toString().getBytes());
}
- private void writeBody(OutputStream out) throws IOException
+ private void writeCoverage(OutputStream out) throws IOException
{
- List<String> keys = new ArrayList<String>(sections.keySet());
- Collections.sort(keys);
+ List<String> sectionIds = new ArrayList<String>(auditParser.getAssertions().keySet());
+ Collections.sort(sectionIds);
- for (String key : keys)
+ for (String sectionId : sectionIds)
{
- out.write(("<h2>Section " + key + " - " + sections.get(key) + "</h2>\n").getBytes());
+ out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " + auditParser.getSectionTitle(sectionId) +
+ "</div>\n").getBytes());
- List<AuditAssertion> sectionAssertions = assertions.get(key);
+ List<AuditAssertion> sectionAssertions = auditParser.getAssertionsForSection(sectionId);
if (sectionAssertions != null && !sectionAssertions.isEmpty())
- {
- Collections.sort(sectionAssertions);
-
+ {
StringBuilder sb = new StringBuilder();
for (AuditAssertion assertion : sectionAssertions)
{
- sb.append(" <div class=\"assertion\">\n");
+ List<SpecReference> coverage = getCoverageForAssertion(sectionId, assertion.getId());
+ sb.append(" <div class=\"" + (coverage.isEmpty() ? "fail" : "pass") + "\">\n");
+
sb.append(" <span class=\"code\">");
sb.append(assertion.getId());
sb.append(")");
@@ -119,11 +133,15 @@
sb.append("</p>\n");
sb.append(" <div class=\"coverage\">\n");
- sb.append(" <h4>Coverage</h4>\n");
+ sb.append(" <p class=\"coverageHeader\">Coverage</p>\n");
- if (references.get(key) != null)
+ if (coverage.isEmpty())
{
- for (SpecReference ref : references.get(key))
+ sb.append(" <p class=\"noCoverage\">No tests exist for this assertion</p>\n");
+ }
+ else
+ {
+ for (SpecReference ref : coverage)
{
sb.append(" <p>");
sb.append(ref.getClassName());
@@ -134,17 +152,66 @@
}
}
- sb.append(" </div>\n </div>\n");
+ sb.append(" </div>\n </div>\n</div>");
}
out.write(sb.toString().getBytes());
}
}
}
+
+ private void writeUnmatched(OutputStream out) throws IOException
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("<h3>Unmatched tests</h3>\n");
+ sb.append("<p>The following tests do not match any known assertions</p>");
+
+ sb.append("<table>\n");
+ sb.append(" <tr><th>Section</th><th>Assertion</th><th>Test Class</th><th>Test Method</th></tr>\n");
+
+
+ sb.append("</table>");
+
+ out.write(sb.toString().getBytes());
+ }
+
+ private List<SpecReference> getCoverageForAssertion(String sectionId, String assertionId)
+ {
+ List<SpecReference> refs = new ArrayList<SpecReference>();
+
+ if (references.containsKey(sectionId))
+ {
+ for (SpecReference ref : references.get(sectionId))
+ {
+ if (ref.getAssertion().equals(assertionId))
+ {
+ refs.add(ref);
+ }
+ }
+ }
+
+ return refs;
+ }
private void writeFooter(OutputStream out) throws IOException
{
out.write("</table>".getBytes());
out.write("</body></html>".getBytes());
}
+
+ public void writeToFile(File file)
+ {
+ try
+ {
+ FileOutputStream out = new FileOutputStream(file);
+ generate(out);
+ out.flush();
+ out.close();
+ }
+ catch (IOException ex)
+ {
+ throw new RuntimeException("Error generating report file", ex);
+ }
+ }
}
17 years, 2 months