You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by dd...@apache.org on 2007/03/04 02:08:33 UTC
svn commit: r514307 - in /portals/pluto/trunk:
pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/
pluto-taglib/src/main/java/org/apache/pluto/tags/
pluto-taglib/src/main/java/org/apache/pluto/tags/el/
Author: ddewolf
Date: Sat Mar 3 17:08:33 2007
New Revision: 514307
URL: http://svn.apache.org/viewvc?view=rev&rev=514307
Log:
Removing explicit dependency on JSP 2.0 expression evaluators in ParamTag (el version)
Added:
portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ApacheTaglibStandardExpressionEvaluatorProxy.java (with props)
portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ExpressionEvaluatorProxy.java (with props)
portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP20ExpressionEvaluatorProxy.java (with props)
portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java (with props)
Modified:
portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java
portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java
portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ParamTag.java
Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java?view=diff&rev=514307&r1=514306&r2=514307
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java Sat Mar 3 17:08:33 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -33,7 +33,6 @@
import org.apache.pluto.driver.AttributeKeys;
import org.apache.pluto.driver.services.portal.PortletWindowConfig;
import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.config.DriverConfiguration;
import org.apache.pluto.driver.core.PortalRequestContext;
import org.apache.pluto.driver.core.PortalServletRequest;
import org.apache.pluto.driver.core.PortalServletResponse;
Modified: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java?view=diff&rev=514307&r1=514306&r2=514307
==============================================================================
--- portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java (original)
+++ portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java Sat Mar 3 17:08:33 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -16,15 +16,8 @@
*/
package org.apache.pluto.tags;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletModeException;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.RenderResponse;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
import javax.portlet.PortletURL;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
+import javax.portlet.RenderResponse;
/**
* Supporting class for the <CODE>renderURL</CODE> tag. Creates a url that
Added: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ApacheTaglibStandardExpressionEvaluatorProxy.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ApacheTaglibStandardExpressionEvaluatorProxy.java?view=auto&rev=514307
==============================================================================
--- portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ApacheTaglibStandardExpressionEvaluatorProxy.java (added)
+++ portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ApacheTaglibStandardExpressionEvaluatorProxy.java Sat Mar 3 17:08:33 2007
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.pluto.tags.el;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+
+class ApacheTaglibStandardExpressionEvaluatorProxy extends ExpressionEvaluatorProxy {
+
+ private static Method evaluateMethod;
+
+ static {
+ try {
+ Class expressionEvaluatorManagerClass = Class.forName("org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager");
+ evaluateMethod = expressionEvaluatorManagerClass.getMethod("evaluate", new Class[] { String.class, String.class, Class.class, PageContext.class});
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Unable to find ExpressionEvaluatorManager. Make sure standard.jar is in your classpath");
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Unable to fine method 'evaluate' on ExpressionEvaluatorManager");
+ }
+ }
+
+ public String evaluate(String value, PageContext pageContext) throws JspException {
+ try {
+ return (String)evaluateMethod.invoke(null, new Object[] { "attributeName", value, Object.class, pageContext});
+ } catch (IllegalAccessException e) {
+ throw new JspException(e);
+ } catch (InvocationTargetException e) {
+ throw new JspException(e);
+ }
+ }
+}
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ApacheTaglibStandardExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ApacheTaglibStandardExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ExpressionEvaluatorProxy.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ExpressionEvaluatorProxy.java?view=auto&rev=514307
==============================================================================
--- portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ExpressionEvaluatorProxy.java (added)
+++ portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ExpressionEvaluatorProxy.java Sat Mar 3 17:08:33 2007
@@ -0,0 +1,79 @@
+/*
+ * 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 org.apache.pluto.tags.el;
+
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.JspException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+
+public abstract class ExpressionEvaluatorProxy {
+
+ private static final Map FACTORIES = new HashMap();
+
+ private static ExpressionEvaluatorProxy proxy;
+
+ static {
+ FACTORIES.put("getELContext", "JSP21ExpressionEvaluatorProxy");
+ FACTORIES.put("getExpressionEvaluator", "JSP20ExpressionEvaluatorProxy");
+ // And finally, a default that should always be provided, but for which an additional jar is needed.
+ FACTORIES.put("getRequest", "ApacheTaglibStandardExpressionEvaluatorProxy");
+
+ Iterator entrySetIterator = FACTORIES.entrySet().iterator();
+ while(entrySetIterator.hasNext()) {
+ Map.Entry entry = (Map.Entry)entrySetIterator.next();
+ if(isPageContextMethodAvailable(entry.getKey().toString())) {
+ try {
+ Class proxyClass = Class.forName(
+ ExpressionEvaluatorProxy.class.getPackage().getName()+entry.getValue()
+ );
+ proxy = (ExpressionEvaluatorProxy)proxyClass.newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Unable to find ExpressionEvaluatorProxy '"+entry.getValue()+"'");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Unable to access ExpressionEvaluatorProxy '"+entry.getValue()+"'");
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Unable to instantiate ExpressionEvaluatorProxy '"+entry.getValue()+"'");
+ }
+ }
+ }
+ if(proxy == null) {
+ throw new RuntimeException("Unable to find a supported proxy");
+ }
+ }
+
+
+ public static ExpressionEvaluatorProxy getProxy() {
+ return proxy;
+ }
+
+ private static boolean isPageContextMethodAvailable(String signature) {
+ try {
+ Method method = PageContext.class.getMethod(signature, null);
+ return method != null;
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ }
+
+ public abstract String evaluate(String value, PageContext pageContext)
+ throws JspException;
+}
+
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP20ExpressionEvaluatorProxy.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP20ExpressionEvaluatorProxy.java?view=auto&rev=514307
==============================================================================
--- portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP20ExpressionEvaluatorProxy.java (added)
+++ portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP20ExpressionEvaluatorProxy.java Sat Mar 3 17:08:33 2007
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.pluto.tags.el;
+
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+import javax.servlet.jsp.el.ELException;
+
+class JSP20ExpressionEvaluatorProxy extends ExpressionEvaluatorProxy {
+
+
+ public String evaluate(String value, PageContext pageContext) throws JspException {
+ ExpressionEvaluator eval = pageContext.getExpressionEvaluator();
+
+ try {
+ Object evaluated = eval.evaluate(
+ value,
+ Object.class,
+ pageContext.getVariableResolver(),
+ null
+ );
+
+ if(evaluated != null) {
+ value = evaluated.toString();
+ }
+
+ }
+ catch(ELException el) {
+ throw new JspException(el);
+ }
+
+ return value;
+ }
+}
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP20ExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP20ExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java?view=auto&rev=514307
==============================================================================
--- portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java (added)
+++ portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java Sat Mar 3 17:08:33 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.pluto.tags.el;
+
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+import javax.servlet.jsp.el.ELException;
+
+class JSP21ExpressionEvaluatorProxy extends ExpressionEvaluatorProxy {
+
+ public String evaluate(String value, PageContext pageContext) throws JspException {
+ throw new RuntimeException("JSP 2.1 Not yet supported. Fall back to JSP 2.0");
+ }
+
+}
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/JSP21ExpressionEvaluatorProxy.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Modified: portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ParamTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ParamTag.java?view=diff&rev=514307&r1=514306&r2=514307
==============================================================================
--- portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ParamTag.java (original)
+++ portals/pluto/trunk/pluto-taglib/src/main/java/org/apache/pluto/tags/el/ParamTag.java Sat Mar 3 17:08:33 2007
@@ -1,9 +1,9 @@
/*
- * 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
+ * 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
@@ -24,27 +24,7 @@
public class ParamTag extends org.apache.pluto.tags.ParamTag {
public String getValue() throws JspException {
- String string = super.getValue();
-
- ExpressionEvaluator eval = pageContext.getExpressionEvaluator();
-
- try {
- Object evaluated = eval.evaluate(
- string,
- Object.class,
- pageContext.getVariableResolver(),
- null
- );
-
- if(evaluated != null) {
- string = evaluated.toString();
- }
-
- }
- catch(ELException el) {
- throw new JspException(el);
- }
- return string;
+ return ExpressionEvaluatorProxy.getProxy().evaluate(super.getValue(), pageContext);
}
}