CVS: Tapestry/framework/src/net/sf/tapestry TapestryStrings.properties,1.36.2.5,1.36.2.6 RequestContext.java,1.18.2.1,1.18.2.2 INamespace.java,1.7.2.2,1.7.2.3 ApplicationServlet.java,1.16.2.1,1.16.2.2 ComponentResolver.java,1.1.2.3,NONE
Howard Lewis Ship <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry
In directory sc8-pr-cvs1:/tmp/cvs-serv23659/framework/src/net/sf/tapestry
Modified Files:
Tag: hship-2-3
TapestryStrings.properties RequestContext.java INamespace.java
ApplicationServlet.java
Removed Files:
Tag: hship-2-3
ComponentResolver.java
Log Message:
Allow searches for component specifications.
Allow application specification to be in WEB-INF instead of on classpath.
Allow application to run without an application specification.
Index: TapestryStrings.properties
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/TapestryStrings.properties,v
retrieving revision 1.36.2.5
retrieving revision 1.36.2.6
diff -C2 -d -r1.36.2.5 -r1.36.2.6
*** TapestryStrings.properties 11 Dec 2002 14:02:25 -0000 1.36.2.5
--- TapestryStrings.properties 15 Dec 2002 16:26:12 -0000 1.36.2.6
***************
*** 39,45 ****
ApplicationServlet.could-not-locate-engine=Could not locate an engine to service this request.
ApplicationServlet.could-not-parse-spec=Unable to parse application specification {0}.
- ApplicationServlet.no-engine-class=Application specification does not specify an engine class name.
ApplicationServlet.get-app-path-not-overriden=Application servlet {0} does not provide an implementation of method getApplicationServletPath().
! ApplicationServlet.app-spec-path-not-provided=Servlet init parameter ''{0}'' was not specified.
BaseComponent.undefined-embedded-component=Template for component {0} references undefined embedded component {1}.
--- 39,44 ----
ApplicationServlet.could-not-locate-engine=Could not locate an engine to service this request.
ApplicationServlet.could-not-parse-spec=Unable to parse application specification {0}.
ApplicationServlet.get-app-path-not-overriden=Application servlet {0} does not provide an implementation of method getApplicationServletPath().
! ApplicationServlet.no-application-specification=Running application without an application specification.
BaseComponent.undefined-embedded-component=Template for component {0} references undefined embedded component {1}.
***************
*** 56,62 ****
BodylessComponentException.message=This component may not have a body.
- ComponentResolver.invalid-library-id=Namespace {0} does not declare a library with id ''{1}''.
- ComponentResolver.invalid-type=Namespace {0} does not declare a component of type ''{1}''.
-
Gesture.unknown-parameter-name=Unknown parameter name ''{0}''.
--- 55,58 ----
***************
*** 149,153 ****
Namespace.no-such-page=Page ''{0}'' not found in {1}.
! Namespace.no-such-alias=Component ''{0}'' not found in {1}.
Namespace.application-namespace=application namespace
Namespace.framework-namespace=framework namespace
--- 145,149 ----
Namespace.no-such-page=Page ''{0}'' not found in {1}.
! Namespace.no-such-component-type=Component ''{0}'' not found in {1}.
Namespace.application-namespace=application namespace
Namespace.framework-namespace=framework namespace
Index: RequestContext.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/RequestContext.java,v
retrieving revision 1.18.2.1
retrieving revision 1.18.2.2
diff -C2 -d -r1.18.2.1 -r1.18.2.2
*** RequestContext.java 11 Dec 2002 14:02:25 -0000 1.18.2.1
--- RequestContext.java 15 Dec 2002 16:26:12 -0000 1.18.2.2
***************
*** 63,73 ****
* it simply invokes {@link #write(IMarkupWriter)} to display all debugging output.
*
- * <p>This class is derived from the original class
- * <code>com.primix.servlet.RequestContext</code>,
- * part of the <b>ServletUtils</b> framework available from
- * <a href="http://www.gjt.org/servlets/JCVSlet/list/gjt/com/primix/servlet">The Giant
- * Java Tree</a>.
- *
- *
* @version $Id$
* @author Howard Lewis Ship
--- 63,66 ----
Index: INamespace.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/INamespace.java,v
retrieving revision 1.7.2.2
retrieving revision 1.7.2.3
diff -C2 -d -r1.7.2.2 -r1.7.2.3
*** INamespace.java 11 Dec 2002 14:02:26 -0000 1.7.2.2
--- INamespace.java 15 Dec 2002 16:26:12 -0000 1.7.2.3
***************
*** 24,30 ****
*
**/
!
public static final String FRAMEWORK_NAMESPACE = "framework";
!
/**
* Character used to seperate the namespace prefix from the page name
--- 24,30 ----
*
**/
!
public static final String FRAMEWORK_NAMESPACE = "framework";
!
/**
* Character used to seperate the namespace prefix from the page name
***************
*** 34,40 ****
*
**/
!
public static final char SEPARATOR = ':';
!
/**
* Returns an identifier for the namespace. Identifiers
--- 34,40 ----
*
**/
!
public static final char SEPARATOR = ':';
!
/**
* Returns an identifier for the namespace. Identifiers
***************
*** 47,53 ****
*
**/
!
public String getId();
!
/**
* Returns the extended id for this namespace, which is
--- 47,53 ----
*
**/
!
public String getId();
!
/**
* Returns the extended id for this namespace, which is
***************
*** 55,61 ****
*
**/
!
public String getExtendedId();
!
/**
* Returns a version of the extended id appropriate for error
--- 55,61 ----
*
**/
!
public String getExtendedId();
!
/**
* Returns a version of the extended id appropriate for error
***************
*** 68,73 ****
*
**/
!
public String getNamespaceId();
/**
* Returns the parent namespace; the namespace which
--- 68,74 ----
*
**/
!
public String getNamespaceId();
+
/**
* Returns the parent namespace; the namespace which
***************
*** 79,86 ****
*
**/
!
public INamespace getParentNamespace();
!
!
/**
* Returns a namespace contained by this namespace.
--- 80,86 ----
*
**/
!
public INamespace getParentNamespace();
!
/**
* Returns a namespace contained by this namespace.
***************
*** 89,98 ****
* or a dot-seperarated name sequence.
* @return the child namespace
! * @throws ApplicationRuntimeException if not such namespace exist.
*
**/
!
public INamespace getChildNamespace(String id);
!
/**
* Returns a sorted, immutable list of the ids of the immediate
--- 89,98 ----
* or a dot-seperarated name sequence.
* @return the child namespace
! * @throws ApplicationRuntimeException if no such namespace exist.
*
**/
!
public INamespace getChildNamespace(String id);
!
/**
* Returns a sorted, immutable list of the ids of the immediate
***************
*** 101,107 ****
*
**/
!
public List getChildIds();
!
/**
* Returns the page specification of the named
--- 101,107 ----
*
**/
!
public List getChildIds();
!
/**
* Returns the page specification of the named
***************
*** 114,120 ****
*
**/
!
public ComponentSpecification getPageSpecification(String name);
!
/**
* Returns true if this namespace contains the specified
--- 114,120 ----
*
**/
!
public ComponentSpecification getPageSpecification(String name);
!
/**
* Returns true if this namespace contains the specified
***************
*** 122,128 ****
*
**/
!
public boolean containsPage(String name);
!
/**
* Returns a sorted list of page names. May return an empty
--- 122,128 ----
*
**/
!
public boolean containsPage(String name);
!
/**
* Returns a sorted list of page names. May return an empty
***************
*** 130,136 ****
*
**/
!
public List getPageNames();
!
/**
* Returns the path for the named component (within the namespace).
--- 130,136 ----
*
**/
!
public List getPageNames();
!
/**
* Returns the path for the named component (within the namespace).
***************
*** 142,232 ****
*
**/
!
! public ComponentSpecification getComponentSpecification(String alias);
!
!
! /**
! * Returns true if the namespace contains the indicated alias.
! *
! **/
!
! public boolean containsAlias(String alias);
!
! /**
! * Returns a sorted list of component aliases. May return
! * an empty list, but won't return null. The return list
! * is immutable.
! *
! **/
!
! public List getComponentAliases();
!
! /**
! * Returns the class name of a service provided by the
! * namespace.
! *
! * @param name the name of the service.
! * @return the complete class name of the service, or null
! * if the namespace does not contain the named service.
! *
! **/
!
! public String getServiceClassName(String name);
!
! /**
! * Returns the names of all services provided by the
! * namespace, as a sorted, immutable list. May return
! * the empty list, but won't return null.
! *
! **/
!
! public List getServiceNames();
!
! /**
! * Returns the {@link LibrarySpecification} from which
! * this namespace was created.
! *
! **/
!
! public ILibrarySpecification getSpecification();
!
! /**
! * Constructs a qualified name for the given simple page name by
! * applying the correct prefix (if any).
! *
! * @since 2.3
! *
! **/
!
! public String constructQualifiedName(String pageName);
!
! /**
! * Returns the location of the resource from which the
! * specification for this namespace was read.
! *
! **/
!
! public IResourceLocation getSpecificationLocation();
- /**
- * Returns true if the namespace is the special
- * application namespace.
- *
- * @since 2.4
- *
- **/
-
- public boolean isApplicationNamespace();
-
- /**
- * Used to specify additional pages beyond those that came from
- * the namespace's specification. This is used when pages
- * in the application namespace are dynamically discovered.
- *
- * @since 2.4
- *
- **/
-
- public void installPageSpecification(String pageName, ComponentSpecification specification);
}
--- 142,271 ----
*
**/
!
! public ComponentSpecification getComponentSpecification(String type);
!
! /**
! * Returns true if the namespace contains the indicated component type.
! *
! * @param type a simple component type (no namespace prefix is allowed)
! *
! * @deprecated use {@link #containsComponentType(String)} instead.
! *
! **/
!
! public boolean containsAlias(String type);
!
! /**
! * Returns true if the namespace contains the indicated component type.
! *
! * @param type a simple component type (no namespace prefix is allowed)
! *
! **/
!
! public boolean containsComponentType(String type);
!
! /**
! * Returns a sorted list of component aliases. May return
! * an empty list, but won't return null. The return list
! * is immutable.
! *
! * <p>Is this method even needed?
! *
! * @deprecated use {@link #getComponentTypes()} instead.
! *
! **/
!
! public List getComponentAliases();
!
! /**
! * Returns a sorted list of component aliases. May return
! * an empty list, but won't return null. The return list
! * is immutable.
! *
! * <p>Is this method even needed?
! *
! **/
!
! public List getComponentTypes();
!
! /**
! * Returns the class name of a service provided by the
! * namespace.
! *
! * @param name the name of the service.
! * @return the complete class name of the service, or null
! * if the namespace does not contain the named service.
! *
! **/
!
! public String getServiceClassName(String name);
!
! /**
! * Returns the names of all services provided by the
! * namespace, as a sorted, immutable list. May return
! * the empty list, but won't return null.
! *
! **/
!
! public List getServiceNames();
!
! /**
! * Returns the {@link LibrarySpecification} from which
! * this namespace was created.
! *
! **/
!
! public ILibrarySpecification getSpecification();
!
! /**
! * Constructs a qualified name for the given simple page name by
! * applying the correct prefix (if any).
! *
! * @since 2.3
! *
! **/
!
! public String constructQualifiedName(String pageName);
!
! /**
! * Returns the location of the resource from which the
! * specification for this namespace was read.
! *
! **/
!
! public IResourceLocation getSpecificationLocation();
!
! /**
! * Returns true if the namespace is the special
! * application namespace (which has special search rules
! * for handling undeclared pages and components).
! *
! * @since 2.4
! *
! **/
!
! public boolean isApplicationNamespace();
!
! /**
! * Used to specify additional pages beyond those that came from
! * the namespace's specification. This is used when pages
! * in the application namespace are dynamically discovered.
! *
! * @since 2.4
! *
! **/
!
! public void installPageSpecification(String pageName, ComponentSpecification specification);
+ /**
+ * Used to specify additional components beyond those that came from
+ * the namespace's specification. This is used when components
+ * in the application namespace are dynamically discovered.
+ *
+ * @since 2.4
+ *
+ **/
+
+ public void installComponentSpecification(String type, ComponentSpecification specification);
}
Index: ApplicationServlet.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/ApplicationServlet.java,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -C2 -d -r1.16.2.1 -r1.16.2.2
*** ApplicationServlet.java 7 Dec 2002 13:26:13 -0000 1.16.2.1
--- ApplicationServlet.java 15 Dec 2002 16:26:12 -0000 1.16.2.2
***************
*** 6,9 ****
--- 6,10 ----
import javax.servlet.ServletConfig;
+ import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
***************
*** 16,22 ****
--- 17,30 ----
import org.apache.commons.logging.LogFactory;
+ import net.sf.tapestry.engine.SimpleEngine;
import net.sf.tapestry.parse.SpecificationParser;
import net.sf.tapestry.resource.ClasspathResourceLocation;
+ import net.sf.tapestry.resource.ContextResourceLocation;
+ import net.sf.tapestry.spec.ApplicationSpecification;
import net.sf.tapestry.spec.IApplicationSpecification;
+ import net.sf.tapestry.util.DelegatingPropertySource;
+ import net.sf.tapestry.util.ServletContextPropertySource;
+ import net.sf.tapestry.util.ServletPropertySource;
+ import net.sf.tapestry.util.SystemPropertiesPropertySource;
import net.sf.tapestry.util.exception.ExceptionAnalyzer;
import net.sf.tapestry.util.pool.Pool;
***************
*** 57,68 ****
* locale information in a {@link Cookie}.
*
- * <p>This class is derived from the original class
- * <code>com.primix.servlet.GatewayServlet</code>,
- * part of the <b>ServletUtils</b> framework available from
- * <a href="http://www.gjt.org/servlets/JCVSlet/list/gjt/com/primix/servlet">The Giant
- * Java Tree</a>.
- *
* @version $Id$
* @author Howard Lewis Ship
**/
--- 65,71 ----
* locale information in a {@link Cookie}.
*
* @version $Id$
* @author Howard Lewis Ship
+ *
**/
***************
*** 108,111 ****
--- 111,133 ----
/**
+ * The resolved class name used to instantiate the engine.
+ *
+ * @since 2.4
+ *
+ **/
+
+ private String _engineClassName;
+
+ /**
+ * Used to search for configuration properties.
+ *
+ *
+ * @since 2.4
+ *
+ **/
+
+ private IPropertySource _propertySource;
+
+ /**
* Invokes {@link #doService(HttpServletRequest, HttpServletResponse)}.
*
***************
*** 429,435 ****
protected IApplicationSpecification constructApplicationSpecification() throws ServletException
{
! String path = getApplicationSpecificationPath();
! IResourceLocation specLocation = new ClasspathResourceLocation(_resolver, path);
if (LOG.isDebugEnabled())
--- 451,463 ----
protected IApplicationSpecification constructApplicationSpecification() throws ServletException
{
! IResourceLocation specLocation = getApplicationSpecificationLocation();
! if (specLocation == null)
! {
! if (LOG.isDebugEnabled())
! LOG.debug(Tapestry.getString("ApplicationServlet.no-application-specification"));
!
! return constructStandinSpecification();
! }
if (LOG.isDebugEnabled())
***************
*** 440,443 ****
--- 468,560 ----
/**
+ * Gets the location of the application specification, if there is one.
+ *
+ * <ul>
+ * <li>Invokes {@link #getApplicationSpecificationPath()} to get the
+ * location of the application specification on the classpath.
+ * <li>If that return null, search for the application specification:
+ * <ul>
+ * <li><i>name</i>.application in /WEB-INF/<i>name</i>/
+ * <li><i>name</i>.application in /WEB-INF/
+ * </ul>
+ * </ul>
+ *
+ * <p>Returns the location of the application specification, or null
+ * if not found.
+ *
+ * @since 2.4
+ *
+ **/
+
+ protected IResourceLocation getApplicationSpecificationLocation() throws ServletException
+ {
+ String path = getApplicationSpecificationPath();
+
+ if (path != null)
+ return new ClasspathResourceLocation(_resolver, path);
+
+ ServletContext context = getServletContext();
+ String servletName = getServletName();
+ String expectedName = servletName + ".application";
+
+ IResourceLocation webInfLocation = new ContextResourceLocation(context, "/WEB-INF/");
+ IResourceLocation webInfAppLocation = webInfLocation.getRelativeLocation(servletName + "/");
+
+ IResourceLocation result = check(webInfAppLocation, expectedName);
+ if (result != null)
+ return result;
+
+ return check(webInfLocation, expectedName);
+ }
+
+ /**
+ * Checks for the application specificaiton relative to the specified
+ * location.
+ *
+ * @since 2.4
+ *
+ **/
+
+ private IResourceLocation check(IResourceLocation location, String name)
+ {
+ IResourceLocation result = location.getRelativeLocation(name);
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Checking for existence of " + result);
+
+ if (result.getResourceURL() != null)
+ {
+ LOG.debug("Found.");
+ return result;
+ }
+
+ return null;
+ }
+
+ /**
+ * Invoked from {@link #constructApplicationSpecification()} when
+ * the application doesn't have an explicit specification. A
+ * simple specification is constructed and returned. This is useful
+ * for minimal applications and prototypes.
+ *
+ * @since 2.2
+ *
+ **/
+
+ protected IApplicationSpecification constructStandinSpecification()
+ {
+ ApplicationSpecification result = new ApplicationSpecification();
+
+ IResourceLocation virtualLocation = new ContextResourceLocation(getServletContext(), "/WEB-INF/");
+
+ result.setSpecificationLocation(virtualLocation);
+
+ result.setName(getServletName());
+ result.setResourceResolver(_resolver);
+
+ return result;
+ }
+
+ /**
* Invoked from {@link #constructApplicationSpecification()} to
* actually parse the stream (with content provided from the path)
***************
*** 485,502 ****
/**
* Reads the servlet init parameter
! * <code>net.sf.tapestry.application-specification</code> and
! * throws {@link ServletException} if it is null.
*
**/
protected String getApplicationSpecificationPath() throws ServletException
{
! String result = getInitParameter("net.sf.tapestry.application-specification");
!
! if (result == null)
! throw new ServletException(
! Tapestry.getString("ApplicationServlet.app-spec-path-not-provided", APP_SPEC_PATH_PARAM));
!
! return result;
}
--- 602,620 ----
/**
* Reads the servlet init parameter
! * <code>net.sf.tapestry.application-specification</code>, which
! * is the location, on the classpath, of the application specification.
*
+ * <p>
+ * If the parameter is not set, this method returns null, and a search
+ * for the application specification within the servlet context
+ * will begin.
+ *
+ * @see #getApplicationSpecificationLocation()
+ *
**/
protected String getApplicationSpecificationPath() throws ServletException
{
! return getInitParameter("net.sf.tapestry.application-specification");
}
***************
*** 510,515 ****
* {@link HttpSession}.
*
! * <p>This implementation instantiates a new engine as specified
! * by {@link ApplicationSpecification#getEngineClassName()}.
*
**/
--- 628,632 ----
* {@link HttpSession}.
*
! * @see #getEngineClassName()
*
**/
***************
*** 519,526 ****
try
{
! String className = _specification.getEngineClassName();
!
! if (className == null)
! throw new ServletException(Tapestry.getString("ApplicationServlet.no-engine-class"));
if (LOG.isDebugEnabled())
--- 636,640 ----
try
{
! String className = getEngineClassName();
if (LOG.isDebugEnabled())
***************
*** 540,543 ****
--- 654,730 ----
throw new ServletException(ex);
}
+ }
+
+ /**
+ *
+ * Returns the name of the class to use when instantiating
+ * an engine instance for this application.
+ * If the application specification
+ * provides a value, this is returned. Otherwise, a search for
+ * the configuration property
+ * <code>net.sf.tapestry.engine-class</code>
+ * occurs (see {@link #searchConfiguration(String)}).
+ *
+ * <p>If the search is still unsuccessful, then
+ * {@link net.sf.tapestry.engine.SimpleEngine} is used.
+ *
+ **/
+
+ protected String getEngineClassName()
+ {
+ if (_engineClassName != null)
+ return _engineClassName;
+
+ _engineClassName = _specification.getEngineClassName();
+
+ if (_engineClassName == null)
+ _engineClassName = searchConfiguration("net.sf.tapestry.engine-class");
+
+ if (_engineClassName == null)
+ _engineClassName = SimpleEngine.class.getName();
+
+ return _engineClassName;
+ }
+
+ /**
+ * Searches for a configuration property in:
+ * <ul>
+ * <li>The servlet's initial parameters
+ * <li>The servlet context's initial parameters
+ * <li>JVM system properties
+ * </ul>
+ *
+ * @see #createPropertySource()
+ * @since 2.4
+ *
+ **/
+
+ protected String searchConfiguration(String propertyName)
+ {
+ if (_propertySource == null)
+ _propertySource = createPropertySource();
+
+ return _propertySource.getPropertyValue(propertyName);
+ }
+
+ /**
+ * Creates an instance of {@link IPropertySource} used for
+ * searching of configuration values. Subclasses may override
+ * this method if they want to change the normal locations
+ * that properties are searched for within.
+ *
+ * @since 2.4
+ *
+ **/
+
+ protected IPropertySource createPropertySource()
+ {
+ DelegatingPropertySource result = new DelegatingPropertySource();
+
+ result.addSource(new ServletPropertySource(getServletConfig()));
+ result.addSource(new ServletContextPropertySource(getServletContext()));
+ result.addSource(SystemPropertiesPropertySource.getInstance());
+
+ return result;
}
--- ComponentResolver.java DELETED ---
-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/