On Tue, Dec 6, 2022 at 6:48 PM Konstantin Kolinko
<knst.koli...@gmail.com> wrote:
>
> пн, 5 дек. 2022 г. в 23:32, Christopher Schultz 
> <ch...@christopherschultz.net>:
> >
> > All,
> >
> > I've started looking at the migration path at $work for Jakarta EE and
> > while Tomcat 10 has some fantastic features to help with that (hot
> > migration is killer IMO), there are still some potential barriers I'm
> > seeing to "slowly" migrating $work applications from Java EE -> Jakarta EE.
> >
> > When I say "slowly", I mean "not having to write one or more large
> > revision-control changes to lock-step-upgrade from e.g. Tomcat 8/9 to
> > Tomcat 10.1."
> >
> > One specific example is that we use Apache Velocity as our
> > page-generation language and AIUI, these templates will not have their
> > text scanned and replaced with updated strings. For example:
> >
> > #if($request.getAttribute('javax.servlet.error.request_uri'))
> > ...
> > #end
> >
> > [... skipped]
> >
> > I can think of a few ways to facilitate a dual-deployment (Tomcat 8/9 vs
> > 10 aka Java EE vs Jakarta EE) application, at least for the specific
> > example I present above:
> >
> > [... skipped]
>
> 6. I think that Migration Tool can be updated to change string
> constants such as the above one.

It should do that here:
https://github.com/apache/tomcat-jakartaee-migration/blob/main/src/main/java/org/apache/tomcat/jakartaee/TextConverter.java
You can see the extensions that are processed in the source.

However, there are some limitations, like the string has to appear as
a whole in the file, and so on. Although not strictly compliant, it
could be worthwhile to consider attributes names starting with
"javax." as if they started with "jakarta.".

Rémy


> There is a limited set of those names, and I expect them to always
> appear as a whole string among string constants.
>
> Going into java/javax/servlet of Tomcat 9 and running a search for `"javax.`,
> except '.LocalStrings"' l10n resources names:
>
> grep --line-number --recursive '"javax.' | grep  --invert-match
> '.LocalStrings"' - >../found.txt
>
> I get the following 36 lines:
>
> [[[
> AsyncContext.java:30:            "javax.servlet.async.request_uri";
> AsyncContext.java:36:            "javax.servlet.async.context_path";
> AsyncContext.java:42:            "javax.servlet.async.mapping";
> AsyncContext.java:48:            "javax.servlet.async.path_info";
> AsyncContext.java:54:            "javax.servlet.async.servlet_path";
> AsyncContext.java:60:            "javax.servlet.async.query_string";
> jsp/PageContext.java:139:    public static final String PAGE =
> "javax.servlet.jsp.jspPage";
> jsp/PageContext.java:145:    public static final String PAGECONTEXT =
> "javax.servlet.jsp.jspPageContext";
> jsp/PageContext.java:151:    public static final String REQUEST =
> "javax.servlet.jsp.jspRequest";
> jsp/PageContext.java:157:    public static final String RESPONSE =
> "javax.servlet.jsp.jspResponse";
> jsp/PageContext.java:163:    public static final String CONFIG =
> "javax.servlet.jsp.jspConfig";
> jsp/PageContext.java:169:    public static final String SESSION =
> "javax.servlet.jsp.jspSession";
> jsp/PageContext.java:174:    public static final String OUT =
> "javax.servlet.jsp.jspOut";
> jsp/PageContext.java:180:    public static final String APPLICATION =
> "javax.servlet.jsp.jspApplication";
> jsp/PageContext.java:187:    public static final String EXCEPTION =
> "javax.servlet.jsp.jspException";
> RequestDispatcher.java:47:    static final String FORWARD_REQUEST_URI
> = "javax.servlet.forward.request_uri";
> RequestDispatcher.java:58:    static final String FORWARD_CONTEXT_PATH
> = "javax.servlet.forward.context_path";
> RequestDispatcher.java:69:    static final String FORWARD_MAPPING =
> "javax.servlet.forward.mapping";
> RequestDispatcher.java:80:    static final String FORWARD_PATH_INFO =
> "javax.servlet.forward.path_info";
> RequestDispatcher.java:91:    static final String FORWARD_SERVLET_PATH
> = "javax.servlet.forward.servlet_path";
> RequestDispatcher.java:102:    static final String
> FORWARD_QUERY_STRING = "javax.servlet.forward.query_string";
> RequestDispatcher.java:114:    static final String INCLUDE_REQUEST_URI
> = "javax.servlet.include.request_uri";
> RequestDispatcher.java:126:    static final String
> INCLUDE_CONTEXT_PATH = "javax.servlet.include.context_path";
> RequestDispatcher.java:138:    static final String INCLUDE_PATH_INFO =
> "javax.servlet.include.path_info";
> RequestDispatcher.java:150:    static final String INCLUDE_MAPPING =
> "javax.servlet.include.mapping";
> RequestDispatcher.java:162:    static final String
> INCLUDE_SERVLET_PATH = "javax.servlet.include.servlet_path";
> RequestDispatcher.java:174:    static final String
> INCLUDE_QUERY_STRING = "javax.servlet.include.query_string";
> RequestDispatcher.java:184:    public static final String
> ERROR_EXCEPTION = "javax.servlet.error.exception";
> RequestDispatcher.java:194:    public static final String
> ERROR_EXCEPTION_TYPE = "javax.servlet.error.exception_type";
> RequestDispatcher.java:204:    public static final String
> ERROR_MESSAGE = "javax.servlet.error.message";
> RequestDispatcher.java:214:    public static final String
> ERROR_REQUEST_URI = "javax.servlet.error.request_uri";
> RequestDispatcher.java:224:    public static final String
> ERROR_SERVLET_NAME = "javax.servlet.error.servlet_name";
> RequestDispatcher.java:234:    public static final String
> ERROR_STATUS_CODE = "javax.servlet.error.status_code";
> ServletContext.java:58:    public static final String TEMPDIR =
> "javax.servlet.context.tempdir";
> ServletContext.java:66:    public static final String ORDERED_LIBS =
> "javax.servlet.context.orderedLibs";
> ]]]
>
> 7. If you look into implementation of
> org.apache.catalina.connector.Request#getAttibute(...), you will see
> the following:
>
> [[[
>     public Object getAttribute(String name) {
>         // Special attributes
>         SpecialAttributeAdapter adapter = specialAttributes.get(name);
>         if (adapter != null) {
>             return adapter.get(this, name);
>         }
> ]]]
>
> I think that this feature could be leveraged to provide mappings for
> the legacy attribute names.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to