Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.

Commit 10b7023

Browse files
committed
Insert assertion labels and a new appendix that lists all the assertions.
1 parent 3e02975 commit 10b7023

File tree

11 files changed

+84
-26
lines changed

11 files changed

+84
-26
lines changed

spec/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ spec.synctex.gz
1818
styles/jsrfrontstyle.aux
1919
styles/jsrmainstyle.aux
2020
styles/macros.aux
21+
chapters/assertions.aux
22+
chapters/assertions.log
23+
spec.bbl
24+
spec.blg
25+
spec.ent
26+
spec.thm
27+
spec.toc

spec/chapters/applications.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ \section{\mvc\ Applications}
1111
\Controller\ and, just like \jaxrs\ applications, zero or more providers. If no
1212
resources are annotated with \Controller, then the resulting application is a \jaxrs\
1313
application instead. In general, everything that applies to a \jaxrs\ application
14-
also applies to an \mvc\ application.
14+
also applies to an \mvc\ application. Some \mvc\ applications may be {\em hybrid}
15+
and include a mix of \mvc\ controllers and \jaxrs\ resource methods.
1516

1617
The controllers and providers that make up an application are configured via an
1718
application-supplied subclass of \code{Application} from \jaxrs. An implementation
@@ -27,7 +28,7 @@ \section{\mvc\ Applications}
2728
be specified either using the \ApplicationPath\ annotation on the application
2829
subclass or in the web.xml as part of the \code{url-pattern} element. \mvc\
2930
applications MUST use a non-empty path or pattern: i.e., {\em "/"} or {\em "/*"} are
30-
invalid in \mvc\ applications.
31+
invalid in \mvc\ applications \assertref{application-path}.
3132

3233
The reason for this is that \mvc\ implementations
3334
often forward requests to the Servlet container, and the use of these

spec/chapters/assertions.tex

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
\chapter{Summary of Assertions}
2+
\label{assertions}
3+
4+
\begin{description}
5+
\assert{controller} Controller methods are JAX-RS resource methods annotated with \code{@Controller}.
6+
\assert{all-controllers} All resource methods in a class annotated with \code{@Controller} must
7+
be controllers.
8+
\assert{controller-types} A controller's return type is limited as described in Section
9+
\ref{controllers}.
10+
\assert{void-controllers} Controller methods that return void must be annotated with \code{@View}.
11+
\assert{cdi-beans} MVC beans are managed by CDI.
12+
\assert{per-request} Default scope for MVC beans is request scope.
13+
\assert{validation-result} If validation fails, controller methods must still be called if a
14+
\code{ValidationResult} field or property is defined.
15+
\assert{event-firing} All events in \code{javax.mvc.event} must be fired. See Javadoc for more
16+
information on each event in that package.
17+
\assert{application-path} The application's path must be non-empty.
18+
\assert{builtin-engines} Implementations must provide support for JSPs and Facelets.
19+
\assert{extension-engines} CDI beans that implement \code{javax.mvc.engine.ViewEngine} provide
20+
an extension mechanism for view engines.
21+
\assert{selection-algorithm} Implementations must use algorithm in Section \ref{selection_algorithm}
22+
to select view engines.
23+
\assert{request-forward} Forward request for which no view engine is found.
24+
\assert{exception-wrap} Exceptions thrown during view processing must be wrapped.
25+
\assert{view-resolution} Relative paths to views must be resolved as explained in
26+
Section \ref{selection_algorithm}.
27+
\end{description}

spec/chapters/controllers.tex

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ \section{Controllers}
88
\label{controllers}
99

1010
An {\em MVC controller} is a \jaxrs\ \cite{jaxrs} resource method decorated by
11-
an \Controller\ annotation. If
12-
this annotation is applied to a class, then all methods in it are regarded as controllers.
11+
an \Controller\ annotation \assertref{controller}.
12+
If this annotation is applied to a class, then all methods in it are regarded as controllers
13+
\assertref{all-controllers}.
1314
Using the \Controller\ annotation on a subset of methods defines a hybrid class in which
1415
certain methods are controllers and others are traditional \jaxrs\ resource methods.
1516

@@ -33,9 +34,11 @@ \section{Controllers}
3334
the default media type for a response is assumed to be \code{text/html}, but otherwise can
3435
be declared using \Produces\ just like in \jaxrs.
3536

36-
The return type of a controller method is restricted to be one of four possible types:
37+
The return type of a controller method is restricted to be one of four possible types
38+
\assertref{controller-types}:
3739
\begin{description}
38-
\item[void] A controller method that returns void is REQUIRED to be decorated by \View.
40+
\item[void] A controller method that returns void is REQUIRED to be decorated by \View
41+
\assertref{void-controllers}.
3942
\item[String] The string returned is interpreted as a path to a view.
4043
\item[Viewable] A \Viewable\ is a class that encapsulates information about a view and
4144
how it is processed.
@@ -84,10 +87,11 @@ \subsection{Controller Instances}
8487

8588
Unlike in \jaxrs\ where resource classes can be native (created and managed by \jaxrs),
8689
CDI beans, managed beans or EJBs, \mvc\ classes are REQUIRED to be CDI-managed beans
87-
only. It follows that a hybrid class that contains a mix of \jaxrs\ resource methods
88-
and \mvc\ controllers must also be CDI managed.
90+
only \assertref{cdi-beans}. It follows that a hybrid class that contains a mix
91+
of \jaxrs\ resource methods and \mvc\ controllers must also be CDI managed.
8992

90-
Like in \jaxrs, the default resource class instance lifecycle is {\em per-request}.
93+
Like in \jaxrs, the default resource class instance lifecycle is {\em per-request}
94+
\assertref{per-request}.
9195
That is, an instance of a controller class MUST be instantiated and initialized
9296
on every request. Implementations MAY support other lifecycles via CDI; the same caveats
9397
that apply to \jaxrs\ classes in other lifecycles applied to \mvc\ classes. In particular,
@@ -234,5 +238,3 @@ \section{Views}
234238
depending on which controller from Section \ref{models} triggered this view's
235239
processing.
236240
237-
%% CONTROLLERS
238-
%% Computation of Content-Type - Sectin 3.8 in JAX-RS

spec/chapters/engines.tex

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ \section{Introduction}
1313
(i) locating and loading a view (ii) preparing any required models and (iii) rendering the
1414
view and writing the result back to the client.
1515

16-
Implementations MUST provide built-in support for JSPs and Facelets view engines. Additional
16+
Implementations MUST provide built-in support for JSPs and Facelets view engines
17+
\assertref{builtin-engines}. Additional
1718
engines may be supported via an extension mechanism based on CDI. Namely, any CDI bean
1819
that implements the \code{javax.mvc.engine.ViewEngine} interface MUST be considered as
1920
a possible target for processing by calling its \code{support} method, discarding the
20-
engine if this method returns \code{false}.
21+
engine if this method returns \code{false} \assertref{extension-engines}.
2122

2223
This is the interface that must be implemented by all \mvc\ view engines:
2324

@@ -39,32 +40,34 @@ \section{Selection Algorithm}
3940
the following algorithm assumes only \Viewable\ as input.
4041

4142
Implementations should perform the following steps while trying to find
42-
a suitable view engine for a \Viewable.
43+
a suitable view engine for a \Viewable \assertref{selection-algorithm}.
4344

4445
\begin{enumerate}
4546
\item If calling \code{getViewEngine} on the \Viewable\ returns a non-null value, return
4647
that view engine.
47-
\item Otherwise, lookup all instances of \code{javax.mvc.engine.ViewEngine} available via CDI.~\footnote{The \code{@Any} annotation in CDI can be used for this purpose.}
48+
\item Otherwise, lookup all instances of \code{javax.mvc.engine.ViewEngine} available via
49+
CDI.~\footnote{The \code{@Any} annotation in CDI can be used for this purpose.}
4850
\item Call \code{supports} on every view engine found in the previous step, discarding
4951
those that return \code{false}.
5052
\item If the resulting set is empty, return \code{null}.
5153
\item Otherwise, sort the resulting set in descending order of priority using the integer value
52-
from the \Priority\ annotation decorating the view engine class or the default value \code{Priorities.DEFAULT} if the annotation is not present.
54+
from the \Priority\ annotation decorating the view engine class or the default value
55+
\code{Priorities.DEFAULT} if the annotation is not present.
5356
\item Return the first element in the resulting sorted set, that is, the view engine with
5457
the highest priority that supports the given \Viewable.
5558
\end{enumerate}
5659

5760
If a view engine that can process a \Viewable\ is not found, as a fall-back attempt to
5861
process the view by other means, implementations are
5962
REQUIRED to forward the request-response pair back to the Servlet container using a
60-
\code{RequestDispatcher}.
63+
\code{RequestDispatcher} \assertref{request-forward}.
6164

6265
The \code{processView} method has all the information necessary for processing
6366
in the \code{ViewEngineContext},
6467
including the view, a reference to \Models, as well as the HTTP request and response
6568
from the underlying the Servlet container. Implementations MUST catch
6669
exceptions thrown during the execution of \code{processView} and re-throw them as
67-
\code{ViewEngineException}'s.
70+
\code{ViewEngineException}'s \assertref{exception-wrap}.
6871

6972
Prior to the view render phase, all entries available in \Models\ MUST be bound in
7073
such a way that they become available to the view being processed. The exact mechanism
@@ -73,9 +76,11 @@ \section{Selection Algorithm}
7376
\code{HttpServletRequest.setAttribute(String, Object)}; calling this method ensures
7477
access to the named models from EL expressions.
7578

76-
A view returned by a controller method represents a relative path within an
77-
application archive. Implementations MUST resolve view paths relative to
78-
\code{ViewEngine.DEFAULT\_VIEW\_FOLDER}, which is set to \code{/WEB-INF/views/}.
79-
Locating views under \code{WEB-INF} ensures that they are not
80-
directly accessible to clients as static resources.
79+
A view returned by a controller method represents a path within an
80+
application archive. If the path is relative, does not start with \code{/}, implementations
81+
MUST resolve view paths relative to \code{ViewEngine.DEFAULT\_VIEW\_FOLDER},
82+
which is set to \code{/WEB-INF/views/}. If the path is absolute, no further processing
83+
is required \assertref{view-resolution}. It is recommended to use relative paths and a
84+
location under \code{WEB-INF} to prevent direct access to views as static resources.
85+
8186

spec/chapters/events.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ \section{Observers}
1010
\label{observers}
1111

1212
The package \code{javax.mvc.event} defines a number of event types that MUST be
13-
fired by implementations during the processing of a request. Implementations MAY
13+
fired by implementations during the processing of a request \assertref{event-firing}.
14+
Implementations MAY
1415
extend this set and also provide additional information on any of the events defined
1516
by this specification. The reader is referred to the implementation's documentation
1617
for more information on event support.

spec/chapters/intro.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ \section{Terminology}
8787
\section{Conventions}
8888

8989
The keywords `MUST', `MUST NOT', `REQUIRED', `SHALL', `SHALL NOT', `SHOULD', `SHOULD NOT',
90-
`RECOMMENDED', `MAY', and `OPTIONAL' in this document are to be interpreted as described in RFC 2119\cite{rfc2119}.
90+
`RECOMMENDED', `MAY', and `OPTIONAL' in this document are to be interpreted as described in
91+
RFC 2119\cite{rfc2119}.
92+
93+
Assertions defined by this specification are formatted as {\textbf{\lllb{an-assertion}\rrrb}}
94+
using a descriptive name as the label and are all listed in Appendix \ref{assertions}.
9195

9296
Java code and sample data fragments are formatted as shown in figure \ref{ex1}:
9397

spec/chapters/validation.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ \section{Validation Exceptions}
9090
Implementations MUST introspect the controller bean for a field or a property of
9191
this type to determine the correct semantics; fields and property setters
9292
of this type MUST be annotated with \code{@Inject} to guarantee proper bean
93-
initialization.
93+
initialization \assertref{validation-result}.
9494

9595
Let us revisit the example from Section~\ref{exception_mappers},
9696
this time using the controller method as an exception handler:

spec/spec.pdf

15.7 KB
Binary file not shown.

spec/spec.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
\markboth{\appendixname
9393
\ \thechapter.\ #1}{}}
9494

95+
\include{chapters/assertions}
9596
\include{chapters/annotations}
9697
%\include{chapters/changes}
9798

0 commit comments

Comments
 (0)