tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [2/4] git commit: Get LibraryMapping documentation up to date Expose LibraryMapping final fields as public
Date Fri, 20 Jul 2012 18:23:56 GMT
Get LibraryMapping documentation up to date
Expose LibraryMapping final fields as public


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/fed5eb61
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/fed5eb61
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/fed5eb61

Branch: refs/heads/5.4-js-rewrite
Commit: fed5eb61de8d2682d75fdce31b68a026935ff570
Parents: 3888c23
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Fri Jul 20 10:56:51 2012 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Fri Jul 20 10:56:51 2012 -0700

----------------------------------------------------------------------
 .../services/ComponentClassResolverImpl.java       |   14 ++--
 .../apache/tapestry5/services/LibraryMapping.java  |   52 +++++++++------
 .../tapestry5/services/LibraryMappingTest.java     |    4 +-
 3 files changed, 39 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fed5eb61/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
index de8e5bd..0919e39 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
@@ -255,27 +255,25 @@ public class ComponentClassResolverImpl implements ComponentClassResolver,
Inval
 
         for (LibraryMapping mapping : mappings)
         {
-            String prefix = mapping.getPathPrefix();
+            String libraryName = mapping.libraryName;
 
-            String rootPackage = mapping.getRootPackage();
-
-            List<String> packages = this.mappings.get(prefix);
+            List<String> packages = this.mappings.get(libraryName);
 
             if (packages == null)
             {
                 packages = CollectionFactory.newList();
-                this.mappings.put(prefix, packages);
+                this.mappings.put(libraryName, packages);
             }
 
-            packages.add(rootPackage);
+            packages.add(mapping.rootPackage);
 
             // These packages, which will contain classes subject to class transformation,
             // must be registered with the component instantiator (which is responsible
             // for transformation).
 
-            addSubpackagesToPackageMapping(rootPackage);
+            addSubpackagesToPackageMapping(mapping.rootPackage);
 
-            packageToLibrary.put(rootPackage, prefix);
+            packageToLibrary.put(mapping.rootPackage, libraryName);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fed5eb61/tapestry-core/src/main/java/org/apache/tapestry5/services/LibraryMapping.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/LibraryMapping.java
b/tapestry-core/src/main/java/org/apache/tapestry5/services/LibraryMapping.java
index 8478a4d..476c187 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/LibraryMapping.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/LibraryMapping.java
@@ -1,4 +1,4 @@
-// Copyright 2006, 2010, 2011 The Apache Software Foundation
+// Copyright 2006, 2010, 2011, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -17,9 +17,8 @@ package org.apache.tapestry5.services;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 
 /**
- * Used to configure the {@link ComponentClassResolver}, to allow it to map prefixes to library
root packages (the
- * application namespace is a special case of this). In each case, a prefix on the path is
mapped to a package. Starting
- * with Tapestry 5.2, the path prefix may not contain a slash character.
+ * Used to configure the {@link ComponentClassResolver}, to allow it to map library names
to library root packages (the
+ * application namespace is a special case of this). In each case, a prefix on the path is
mapped to a package.
  * <p/>
  * The root package name should have a number of sub-packages:
  * <dl>
@@ -35,40 +34,51 @@ import org.apache.tapestry5.ioc.internal.util.InternalUtils;
  */
 public final class LibraryMapping
 {
-    private final String virtualFolderName, rootPackage;
+    public final String libraryName, rootPackage;
 
     /**
-     * Maps a virtual folder to a package that contains sub-packages for components, pages,
etc. The special pathPrefix
-     * "" (the empty string) identifies the application. Tapestry defines a special pathPrefix,
"core", for the core
-     * components.
+     * Identifies the root package of a library. The application has uses the library name
"" (the empty string).
+     * The special library "core" is all the built-in components.
      * <p/>
-     * Note that it <em>is</em> allowed to contribute mutiple LibraryMappings
with the same prefix to the
-     * {@link ComponentClassResolver}, and the results are merged (though conflicts, where
the same simple name appears
-     * under multiple root packages, is not currently checked for).
+     * The library name is sometimes referred to as the "path prefix" or the "virtual folder
name". This is for historical
+     * reasons, as the concept of a library and how it was defined and managed evolved from
release to release.
+     * <p/>
+     * The library name should be alpha numeric, and directly encodable into a URL. It may
contain slashes (though this is not
+     * used often), but may not start or end with one.
+     * <p/>
+     * Note that it <em>is</em> allowed to contribute multiple LibraryMappings
with the library name to the
+     * {@link ComponentClassResolver}, and the results are merged: the single library will
have multiple root packages.
+     * Be careful that <em>none</em> of the root packages overlap!
      *
-     * @param virtualFolderName identifies the virtual folder "containing" the pages and
components of the library. This may contain an embedded slash, but not a leading or trailing
slash.
-     * @param rootPackage       The root package to search.
+     * @param libraryName
+     *         the unique identifier for the library.
+     * @param rootPackage
+     *         The root package to search for classes; sub-packages will include ".pages",
".components", etc.
      */
-    public LibraryMapping(String virtualFolderName, String rootPackage)
+    public LibraryMapping(String libraryName, String rootPackage)
     {
+        assert libraryName != null;
         assert InternalUtils.isNonBlank(rootPackage);
 
-        if (virtualFolderName.startsWith("/") || virtualFolderName.endsWith("/"))
+        if (libraryName.startsWith("/") || libraryName.endsWith("/"))
         {
-            throw new RuntimeException(
-                    "LibraryMapping path prefixes may not start with or end with a slash.");
+            throw new IllegalArgumentException(
+                    "Library names may not start with or end with a slash.");
         }
 
-        this.virtualFolderName = virtualFolderName;
+        this.libraryName = libraryName;
         this.rootPackage = rootPackage;
     }
 
     /**
-     * Returns the virtual folder name (the odd name of this method reflects the evolution
of the framework).
+     * Returns the library name; the method is oddly named for historical reasons. The library
name is sometimes
+     * referred to as the virtual folder name.
+     *
+     * @deprecated In 5.4, use {@link #getLibraryName()} instead.
      */
     public String getPathPrefix()
     {
-        return virtualFolderName;
+        return libraryName;
     }
 
     public String getRootPackage()
@@ -79,6 +89,6 @@ public final class LibraryMapping
     @Override
     public String toString()
     {
-        return String.format("LibraryMapping[%s, %s]", virtualFolderName, rootPackage);
+        return String.format("LibraryMapping[%s, %s]", libraryName, rootPackage);
     }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fed5eb61/tapestry-core/src/test/java/org/apache/tapestry5/services/LibraryMappingTest.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/services/LibraryMappingTest.java
b/tapestry-core/src/test/java/org/apache/tapestry5/services/LibraryMappingTest.java
index 8b27f43..3066d3d 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/services/LibraryMappingTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/services/LibraryMappingTest.java
@@ -1,4 +1,4 @@
-// Copyright 2010, 2011 The Apache Software Foundation
+// Copyright 2010, 2011, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ public class LibraryMappingTest extends TestBase
             unreachable();
         } catch (RuntimeException ex)
         {
-            assertMessageContains(ex, "path prefixes may not start with or end with a slash");
+            assertMessageContains(ex, "Library names may not start with or end with a slash");
         }
     }
 }


Mime
View raw message