Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4D889200C2C for ; Fri, 17 Feb 2017 00:08:35 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4C138160B72; Thu, 16 Feb 2017 23:08:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 20048160B61 for ; Fri, 17 Feb 2017 00:08:33 +0100 (CET) Received: (qmail 55716 invoked by uid 500); 16 Feb 2017 23:08:33 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 55707 invoked by uid 99); 16 Feb 2017 23:08:33 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2017 23:08:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id E3BAA1A0316 for ; Thu, 16 Feb 2017 23:08:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 1NT-Eo-H3Pma for ; Thu, 16 Feb 2017 23:08:29 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 5801660CF3 for ; Thu, 16 Feb 2017 23:08:27 +0000 (UTC) Received: (qmail 55497 invoked by uid 99); 16 Feb 2017 23:08:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2017 23:08:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 63D77E0FE7; Thu, 16 Feb 2017 23:08:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ddekany@apache.org To: notifications@freemarker.incubator.apache.org Date: Thu, 16 Feb 2017 23:08:43 -0000 Message-Id: <0535f3b39f76438781b8a1c471389d3e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [18/54] [partial] incubator-freemarker git commit: Top level package name change to org.apache.freemarker, and some of of the internal package structure changes. Other smaller cleanup. To be continued... archived-at: Thu, 16 Feb 2017 23:08:35 -0000 http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/ext/jsp/TaglibMethodUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/ext/jsp/TaglibMethodUtil.java b/src/main/java/freemarker/ext/jsp/TaglibMethodUtil.java deleted file mode 100644 index 3780bf5..0000000 --- a/src/main/java/freemarker/ext/jsp/TaglibMethodUtil.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 freemarker.ext.jsp; - -import java.lang.reflect.Method; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import freemarker.template.utility.ClassUtil; -import freemarker.template.utility.StringUtil; - -final class TaglibMethodUtil { - - private TaglibMethodUtil() { - // Not meant to be instantiated - } - - private static final Pattern FUNCTION_SIGNATURE_PATTERN = - Pattern.compile("^([\\w\\.]+(\\s*\\[\\s*\\])?)\\s+([\\w]+)\\s*\\((.*)\\)$"); - private static final Pattern FUNCTION_PARAMETER_PATTERN = - Pattern.compile("^([\\w\\.]+)(\\s*\\[\\s*\\])?$"); - - /** - * Finds method by function signature string which is compliant with - * Tag Library function signature in Java Server Page (TM) Specification. - * A function signature example is as follows: {@code java.lang.String nickName( java.lang.String, int)} - * - * @param clazz Class having the method. - * @param signature Java Server Page (TM) Specification compliant function signature string. - * @return method if found. - */ - public static Method getMethodByFunctionSignature(Class clazz, String signature) - throws SecurityException, NoSuchMethodException, ClassNotFoundException { - Matcher m1 = FUNCTION_SIGNATURE_PATTERN.matcher(signature); - - if (!m1.matches()) { - throw new IllegalArgumentException("Invalid function signature."); - } - - String methodName = m1.group(3); - String params = m1.group(4).trim(); - Class [] paramTypes = null; - - if ("".equals(params)) { - paramTypes = new Class[0]; - } else { - String [] paramsArray = StringUtil.split(params, ','); - paramTypes = new Class[paramsArray.length]; - String token = null; - String paramType = null; - boolean isPrimitive = false; - boolean isArrayType = false; - Matcher m2 = null; - - for (int i = 0; i < paramsArray.length; i++) { - token = paramsArray[i].trim(); - m2 = FUNCTION_PARAMETER_PATTERN.matcher(token); - - if (!m2.matches()) { - throw new IllegalArgumentException("Invalid argument signature: '" + token + "'."); - } - - paramType = m2.group(1); - isPrimitive = (paramType.indexOf('.') == -1); - isArrayType = (m2.group(2) != null); - - if (isPrimitive) { - if ("byte".equals(paramType)) { - paramTypes[i] = (isArrayType ? byte[].class : byte.class); - } else if ("short".equals(paramType)) { - paramTypes[i] = (isArrayType ? short[].class : short.class); - } else if ("int".equals(paramType)) { - paramTypes[i] = (isArrayType ? int[].class : int.class); - } else if ("long".equals(paramType)) { - paramTypes[i] = (isArrayType ? long[].class : long.class); - } else if ("float".equals(paramType)) { - paramTypes[i] = (isArrayType ? float[].class : float.class); - } else if ("double".equals(paramType)) { - paramTypes[i] = (isArrayType ? double[].class : double.class); - } else if ("boolean".equals(paramType)) { - paramTypes[i] = (isArrayType ? boolean[].class : boolean.class); - } else if ("char".equals(paramType)) { - paramTypes[i] = (isArrayType ? char[].class : char.class); - } else { - throw new IllegalArgumentException("Invalid primitive type: '" + paramType + "'."); - } - } else { - if (isArrayType) { - paramTypes[i] = ClassUtil.forName("[L" + paramType + ";"); - } else { - paramTypes[i] = ClassUtil.forName(paramType); - } - } - } - } - - return clazz.getMethod(methodName, paramTypes); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/ext/jsp/_FreeMarkerPageContext21.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/ext/jsp/_FreeMarkerPageContext21.java b/src/main/java/freemarker/ext/jsp/_FreeMarkerPageContext21.java deleted file mode 100644 index 172f8c5..0000000 --- a/src/main/java/freemarker/ext/jsp/_FreeMarkerPageContext21.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 freemarker.ext.jsp; - -import java.security.AccessController; -import java.security.PrivilegedAction; - -import javax.el.ELContext; -import javax.servlet.jsp.JspApplicationContext; -import javax.servlet.jsp.JspContext; -import javax.servlet.jsp.JspFactory; -import javax.servlet.jsp.PageContext; -import javax.servlet.jsp.el.ELException; -import javax.servlet.jsp.el.ExpressionEvaluator; -import javax.servlet.jsp.el.VariableResolver; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import freemarker.template.TemplateModelException; -import freemarker.template.utility.ClassUtil; - -/** - * Don't use this class; it's only public to work around Google App Engine Java - * compliance issues. FreeMarker developers only: treat this class as package-visible. - * - * Implementation of PageContext that contains all JSP 2.1 methods. - */ -public class _FreeMarkerPageContext21 extends FreeMarkerPageContext { - private static final Logger LOG = LoggerFactory.getLogger("freemarker.jsp"); - - static { - if (JspFactory.getDefaultFactory() == null) { - JspFactory.setDefaultFactory(new FreeMarkerJspFactory21()); - } - LOG.debug("Using JspFactory implementation class {}", - JspFactory.getDefaultFactory().getClass().getName()); - } - - public _FreeMarkerPageContext21() throws TemplateModelException { - super(); - } - - /** - * Attempts to locate and manufacture an expression evaulator instance. For this - * to work you must have the Apache Commons-EL package in the classpath. If - * Commons-EL is not available, this method will throw an UnsupportedOperationException. - */ - @Override - public ExpressionEvaluator getExpressionEvaluator() { - try { - Class type = ((ClassLoader) AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Object run() { - return Thread.currentThread().getContextClassLoader(); - } - })).loadClass - ("org.apache.commons.el.ExpressionEvaluatorImpl"); - return (ExpressionEvaluator) type.newInstance(); - } catch (Exception e) { - throw new UnsupportedOperationException("In order for the getExpressionEvaluator() " + - "method to work, you must have downloaded the apache commons-el jar and " + - "made it available in the classpath."); - } - } - - /** - * Returns a variable resolver that will resolve variables by searching through - * the page scope, request scope, session scope and application scope for an - * attribute with a matching name. - */ - @Override - public VariableResolver getVariableResolver() { - final PageContext ctx = this; - - return new VariableResolver() { - @Override - public Object resolveVariable(String name) throws ELException { - return ctx.findAttribute(name); - } - }; - } - - private ELContext elContext; - - @Override - public ELContext getELContext() { - if (elContext == null) { - JspApplicationContext jspctx = JspFactory.getDefaultFactory().getJspApplicationContext(getServletContext()); - if (jspctx instanceof FreeMarkerJspApplicationContext) { - elContext = ((FreeMarkerJspApplicationContext) jspctx).createNewELContext(this); - elContext.putContext(JspContext.class, this); - } else { - throw new UnsupportedOperationException( - "Can not create an ELContext using a foreign JspApplicationContext (of class " - + ClassUtil.getShortClassNameOfObject(jspctx) + ").\n" + - "Hint: The cause of this is often that you are trying to use JSTL tags/functions in FTL. " - + "In that case, know that that's not really suppored, and you are supposed to use FTL " - + "constrcuts instead, like #list instead of JSTL's forEach, etc."); - } - } - return elContext; - } -} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/ext/jsp/package.html ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/ext/jsp/package.html b/src/main/java/freemarker/ext/jsp/package.html deleted file mode 100644 index 23a891b..0000000 --- a/src/main/java/freemarker/ext/jsp/package.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - -

-Classes for two-way FreeMarker-JSP integration. It contains both a JSP -custom tag that allows embedding of FreeMarker templates inside JSP -pages, as well as the infrastructure that allows JSP custom tags to be -used inside FreeMarker templates. - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/ext/package.html ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/ext/package.html b/src/main/java/freemarker/ext/package.html deleted file mode 100644 index 0f45e3f..0000000 --- a/src/main/java/freemarker/ext/package.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - -

Extensions to FreeMarker's core functionality.

- - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/ecb4e230/src/main/java/freemarker/ext/servlet/AllHttpScopesHashModel.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/ext/servlet/AllHttpScopesHashModel.java b/src/main/java/freemarker/ext/servlet/AllHttpScopesHashModel.java deleted file mode 100644 index 8273521..0000000 --- a/src/main/java/freemarker/ext/servlet/AllHttpScopesHashModel.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 freemarker.ext.servlet; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -import freemarker.template.ObjectWrapper; -import freemarker.template.SimpleHash; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; - -/** - * An extension of SimpleHash that looks up keys in the hash, then in the - * request, session, and servlet context scopes. Makes "Application", "Session" - * and "Request" keys largely obsolete, however we keep them for backward - * compatibility (also, "Request" is required for proper operation of JSP - * taglibs). - * It is on purpose that we didn't override keys and values - * methods. That way, only those variables assigned into the hash directly by a - * subclass of FreemarkerServlet that overrides - * preTemplateProcess) are discovered as "page" variables by the FM - * JSP PageContext implementation. - */ -public class AllHttpScopesHashModel extends SimpleHash { - private final ServletContext context; - private final HttpServletRequest request; - private final Map unlistedModels = new HashMap(); - - /** - * Creates a new instance of AllHttpScopesHashModel for handling a single - * HTTP servlet request. - * @param wrapper the object wrapper to use - * @param context the servlet context of the web application - * @param request the HTTP servlet request being processed - */ - public AllHttpScopesHashModel(ObjectWrapper wrapper, - ServletContext context, HttpServletRequest request) { - setObjectWrapper(wrapper); - this.context = context; - this.request = request; - } - - /** - * Stores a model in the hash so that it doesn't show up in keys() - * and values() methods. Used to put the Application, Session, - * Request, RequestParameters and JspTaglibs objects. - * @param key the key under which the model is stored - * @param model the stored model - */ - public void putUnlistedModel(String key, TemplateModel model) { - unlistedModels.put(key, model); - } - - @Override - public TemplateModel get(String key) throws TemplateModelException { - // Lookup in page scope - TemplateModel model = super.get(key); - if (model != null) { - return model; - } - - // Look in unlisted models - model = (TemplateModel) unlistedModels.get(key); - if (model != null) { - return model; - } - - // Lookup in request scope - Object obj = request.getAttribute(key); - if (obj != null) { - return wrap(obj); - } - - // Lookup in session scope - HttpSession session = request.getSession(false); - if (session != null) { - obj = session.getAttribute(key); - if (obj != null) { - return wrap(obj); - } - } - - // Lookup in application scope - obj = context.getAttribute(key); - if (obj != null) { - return wrap(obj); - } - - // return wrapper's null object (probably null). - return wrap(null); - } -}