pkg://jakarta-commons-el-1.0-2jpp_3fc.src.rpm:632472/commons-el-1.0-src.tar.gz
info downloads
commons-el-1.0-src/ 0040755 0072374 0000012 00000000000 07674117742 0014550 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/RELEASE-NOTES.txt 0100644 0072374 0000012 00000000752 07670211245 0017245 0 ustar 00luehe staff 0000371 0000056 $Id: RELEASE-NOTES.txt,v 1.1 2003/06/06 22:16:05 luehe Exp $
Commons EL Package
Version 1.0
Release Notes
Introduction
------------
This is the first release of the commons-el package, which provides an
implementation of the standard interfaces and abstract classes of the
javax.servlet.jsp.el package, which is part of the JSP 2.0
specification.
Bug Status
----------
There are no outstanding bugs.
commons-el-1.0-src/LICENSE.txt 0100644 0072374 0000012 00000005373 07617603700 0016367 0 ustar 00luehe staff 0000371 0000056 /*
* $Header: /home/cvs/jakarta-commons/el/LICENSE.txt,v 1.1.1.1 2003/02/04 00:22:24 luehe Exp $
* $Revision: 1.1.1.1 $
* $Date: 2003/02/04 00:22:24 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
commons-el-1.0-src/PROPOSAL.html 0100644 0072374 0000012 00000006775 07641672631 0016706 0 ustar 00luehe staff 0000371 0000056 <html>
<head>
<title>Proposal for JSP 2.0 Expression Language Interpreter Package</title>
</head>
<body bgcolor="white">
<div align="center">
<h1>Proposal for <em>JSP 2.0 Expression Language Interpreter</em> Package</h1>
</div>
<h3>(0) Rationale</h3>
<p>The JSP Standard Tag Library (JSTL), version 1.0, introduced the
concept of an Expression Language (EL), whose main goal is to provide
page authors with an easy way to access and manipulate application
data without requiring the use of scriptlets
<p>JSP 2.0 adopted the EL specification from JSTL, and expanded its
scope: EL expressions are no longer limited to JSTL action attributes,
but may be used in any standard or custom action attribute declared to
accept a runtime expression. In addition, EL expressions may now also
be used directly in template text outside of any actions. JSP 2.0 also
added an important feature to the EL specification: EL functions,
which allow page authors to invoke static methods in Java classes from
EL expressions. Additionally, JSP 2.0 allows programmatic access and
customization of the EL evaluator through a set of standard interfaces
and abstract classes.
<p>Currently, there are a number of projects (including Tomcat 5 and Java
Server Faces) that leverage the EL implementation of the Standard
Taglib. In addition, there seems to be interest in leveraging the EL
in the context of scripting workflow activities using custom tag
libraries.
<p>In order to make the EL implementation available to Tomcat 5, the
Tomcat team defined a new "ant" target for the Standard Taglib that
builds just the EL portion and packages it in a JAR file
("jsp20el.jar") which is stored in Tomcat's common/lib
directory. This approach has always been considered an interim
solution only, until the EL implementation would move from the
Standard Taglib to a more visible location such as jakarta-commons.
<h3>(1) Scope of the package</h3>
The package shall provide an implementation of the Expression Language
specification which is part of the JSP 2.0 standard.
<h3>(1.5) Interaction with other packages</h3>
The package shall provide an implementation of the standard interfaces
and abstract classes of the javax.servlet.jsp.el package, which is
defined in the JSP 2.0 specification.
<h3>(2) Identify the initial source for the package</h3>
The initial codebase will be taken from the Standard Taglib project
hosted at jakarta-taglibs. The source of the Standard Taglib is
available as part of the <a href="http://jakarta.apache.org/builds/jakarta-taglibs/nightly/src/">jakarta-taglibs nightly source distribution</a>.
<h3>(2.1) Identify the base name for the package</h3>
The base name of the package shall be org.apache.commons.el
<h3>(2.2) Identify the coding conventions for this package</h3>
The package follows <a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun's Java coding conventions</a>.
<h3>(3) Identify any Jakarta-Commons resources to be created</h3>
<h3>(3.1) Mailing list</h3>
The package shall use the jakarta-commons mailing list.
<h3>(3.2) CVS repositories</h3>
The package shall use a root branch of the jakarta-commons CVS.
<h3>(3.3) Bugzilla</h3>
The package shall be listed as the "EL" component under the "Commons"
project in Bugzilla.
<h3>(3.4) Jyve FAQ (when available)</h3>
n/a
<h3>(4) Initial Committers</h3>
<ul>
<li>Shawn Bayern</li>
<li>Nathan Abramson</li>
<li>Pierre Delisle</li>
<li>Hans Bergsten</li>
<li>Justyna Horwat</li>
<li>Craig R. McClanahan</li>
<li>Jan Luehe</li>
</ul>
</body>
</html>
commons-el-1.0-src/build.properties 0100755 0072374 0000012 00000000463 07642104426 0017756 0 ustar 00luehe staff 0000371 0000056 # The home directory for the Servlet 2.4 and JSP 2.0 classes distribution
api.home = ../../jakarta-servletapi-5
# The directory containing your binary distribution of JUnit,
# version 3.7 or later
junit.home = ../../junit3.7
# The pathname of the "junit.jar" JAR file
junit.jar = ${junit.home}/junit.jar
commons-el-1.0-src/STATUS.html 0100644 0072374 0000012 00000004435 07670203542 0016452 0 ustar 00luehe staff 0000371 0000056 <html>
<head>
<title>Status File for Jakarta Commons "EL" Component</title>
<head>
<body bgcolor="white">
<div align="center">
<h1>The Jakarta Commons <em>EL</em> Component</h1>
$Id: STATUS.html,v 1.1 2003/06/06 21:28:02 luehe Exp $<br />
<a href="#Introduction">[Introduction]</a>
<a href="#Dependencies">[Dependencies]</a>
<a href="#Release Info">[Release Info]</a>
<a href="#Committers">[Committers]</a>
<a href="#Action Items">[Action Items]</a>
<br /><br />
</div>
<a name="Introduction"></a>
<h3>1. INTRODUCTION</h3>
<p> The commons-el package provides an implementation of the standard interfaces and abstract classes of the javax.servlet.jsp.el package, which is part of the JSP 2.0 specification.
</p>
<p>The classes that are now released as commons-el used to be part of the JSTL 1.0 reference implementation. JSTL 1.0 originally introduced the concept of an Expression Language (EL). The EL has since been integrated into the JSP 2.0 specification, which also added new features to it, such as EL Functions.
</p>
<a name="Dependencies"></a>
<h3>2. DEPENDENCIES</h3>
<p>The <em>EL</em> component is dependent upon the following external
components for compilation:</p>
<ul>
<li><a href="http://java.sun.com/j2se">Java Development Kit</a>
(Version 1.3 or later)</li>
<li><a href="http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jspapi">JSP 2.0 API</a></li>
<li><a href="http://jakarta.apache.org/tomcat/tomcat-5.0-doc/servletapi/index.html">Servlet 2.4 API</a></li>
</ul>
<a name="Release Info"></a>
<h3>3. RELEASE INFO</h3>
<table border="1">
<tr>
<th width="50%">Version</th>
<th width="50%">Release Date</th>
</tr>
<tr>
<td><a href='http://jakarta.apache.org/builds/jakarta-commons/release/commons-el/v1.0'>
commons-el-1.0</td>
<td>7-Jun-2003</td>
</tr>
</table>
<p>Planned Next Release: TBD</p>
<a name="Committers"></a>
<h3>4. COMMITTERS</h3>
<ul>
<li>Shawn Bayern</li>
<li>Nathan Abramson</li>
<li>Pierre Delisle</li>
<li>Hans Bergsten</li>
<li>Mark Roth</li>
<li>Craig R. McClanahan</li>
<li>Kin-Man Chung</li>
<li>Jan Luehe</li>
</ul>
<a name="Action Items"></a>
<h3>5. ACTION ITEMS</h3>
<p>TO DO List:</p>
<table border="1">
<tr>
<th width="80%">Action Item</th>
<th width="20%">Volunteer</th>
</tr>
</table>
</body>
</html>
commons-el-1.0-src/src/ 0040755 0072374 0000012 00000000000 07674117666 0015344 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/src/conf/ 0040755 0072374 0000012 00000000000 07674117666 0016271 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/src/conf/MANIFEST.MF 0100644 0072374 0000012 00000000424 07670203663 0017705 0 ustar 00luehe staff 0000371 0000056 Extension-Name: org.apache.commons.el
Specification-Title: Jakarta Commons EL
Specification-Vendor: Apache Software Foundation
Specification-Version: 2.0
Implementation-Title: org.apache.commons.el
Implementation-Vendor: Apache Software Foundation
Implementation-Version: 1.0
commons-el-1.0-src/src/java/ 0040755 0072374 0000012 00000000000 07674117666 0016265 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/src/java/org/ 0040755 0072374 0000012 00000000000 07674117666 0017054 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/src/java/org/apache/ 0040755 0072374 0000012 00000000000 07674117667 0020276 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/src/java/org/apache/commons/ 0040755 0072374 0000012 00000000000 07674117667 0021751 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/src/java/org/apache/commons/el/ 0040755 0072374 0000012 00000000000 07674117675 0022350 5 ustar 00luehe staff 0000371 0000056 commons-el-1.0-src/src/java/org/apache/commons/el/ArithmeticOperator.java 0100644 0072374 0000012 00000010150 07674115771 0027005 0 ustar 00luehe staff 0000371 0000056 /*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.el;
import javax.servlet.jsp.el.ELException;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
*
* <p>This is the superclass for all binary arithmetic operators
*
* @author Nathan Abramson - Art Technology Group
* @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $
**/
public abstract class ArithmeticOperator
extends BinaryOperator
{
//-------------------------------------
/**
*
* Applies the operator to the given value
**/
public Object apply (Object pLeft,
Object pRight,
Logger pLogger)
throws ELException
{
return Coercions.applyArithmeticOperator (pLeft, pRight, this, pLogger);
}
//-------------------------------------
/**
*
* Applies the operator to the given double values, returning a double
**/
public abstract double apply (double pLeft, double pRight);
//-------------------------------------
/**
*
* Applies the operator to the given double values, returning a double
**/
public abstract long apply (long pLeft, long pRight);
//-------------------------------------
/**
*
* Applies the operator to the given BigDecimal values, returning a
* BigDecimal.
**/
public abstract BigDecimal apply(BigDecimal pLeft, BigDecimal pRight);
//-------------------------------------
/**
*
* Applies the operator to the given BigInteger values, returning a
* BigInteger.
**/
public abstract BigInteger apply(BigInteger pLeft, BigInteger pRight);
//-------------------------------------
}
commons-el-1.0-src/src/java/org/apache/commons/el/AndOperator.java 0100644 0072374 0000012 00000010700 07617603700 0025406 0 ustar 00luehe staff 0000371 0000056 /*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.el;
import javax.servlet.jsp.el.ELException;
/**
*
* <p>The implementation of the and operator
*
* @author Nathan Abramson - Art Technology Group
* @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $
**/
public class AndOperator
extends BinaryOperator
{
//-------------------------------------
// Singleton
//-------------------------------------
public static final AndOperator SINGLETON =
new AndOperator ();
//-------------------------------------
/**
*
* Constructor
**/
public AndOperator ()
{
}
//-------------------------------------
// Expression methods
//-------------------------------------
/**
*
* Returns the symbol representing the operator
**/
public String getOperatorSymbol ()
{
return "and";
}
//-------------------------------------
/**
*
* Applies the operator to the given value
**/
public Object apply (Object pLeft,
Object pRight,
Logger pLogger)
throws ELException
{
// Coerce the values to booleans
boolean left =
Coercions.coerceToBoolean (pLeft, pLogger).booleanValue ();
boolean right =
Coercions.coerceToBoolean (pRight, pLogger).booleanValue ();
return PrimitiveObjects.getBoolean (left && right);
}
//-------------------------------------
/**
*
* Returns true if evaluation is necessary given the specified Left
* value. The And/OrOperators make use of this
**/
public boolean shouldEvaluate (Object pLeft)
{
return
(pLeft instanceof Boolean) &&
((Boolean) pLeft).booleanValue () == true;
}
//-------------------------------------
/**
*
* Returns true if the operator expects its arguments to be coerced
* to Booleans. The And/Or operators set this to true.
**/
public boolean shouldCoerceToBoolean ()
{
return true;
}
//-------------------------------------
}
commons-el-1.0-src/src/java/org/apache/commons/el/BeanInfoManager.java 0100644 0072374 0000012 00000030755 07617603700 0026160 0 ustar 00luehe staff 0000371 0000056 /*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.el;
import java.beans.BeanInfo;
import java.beans.EventSetDescriptor;
import java.beans.IndexedPropertyDescriptor;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.jsp.el.ELException;
/**
*
* <p>Manages the BeanInfo for one class - contains the BeanInfo, and
* also a mapping from property name to BeanInfoProperty. There are
* also static methods for accessing the BeanInfoManager for a class -
* those mappings are cached permanently so that once the
* BeanInfoManager is calculated, it doesn't have to be calculated
* again.
*
* @author Nathan Abramson - Art Technology Group
* @version $Change: 181181 $$DateTime: 2001/06/26 09:55:09 $$Author: luehe $
**/
public class BeanInfoManager
{
//-------------------------------------
// Properties
//-------------------------------------
// property beanClass
Class mBeanClass;
public Class getBeanClass ()
{ return mBeanClass; }
//-------------------------------------
// Member variables
//-------------------------------------
// The BeanInfo
BeanInfo mBeanInfo;
// Mapping from property name to BeanInfoProperty
Map mPropertyByName;
// Mapping from property name to BeanInfoIndexedProperty
Map mIndexedPropertyByName;
// Mapping from event set name to event set descriptor
Map mEventSetByName;
// Flag if this is initialized
boolean mInitialized;
// The global mapping from class to BeanInfoManager
static Map mBeanInfoManagerByClass = new HashMap ();
//-------------------------------------
/**
*
* Constructor
**/
BeanInfoManager (Class pBeanClass)
{
mBeanClass = pBeanClass;
}
//-------------------------------------
/**
*
* Returns the BeanInfoManager for the specified class
**/
public static BeanInfoManager getBeanInfoManager (Class pClass)
{
BeanInfoManager ret = (BeanInfoManager)
mBeanInfoManagerByClass.get (pClass);
if (ret == null) {
ret = createBeanInfoManager (pClass);
}
return ret;
}
//-------------------------------------
/**
*
* Creates and registers the BeanInfoManager for the given class if
* it isn't already registered.
**/
static synchronized BeanInfoManager createBeanInfoManager (Class pClass)
{
// Because this method is synchronized statically, the
// BeanInfoManager is not initialized at this time (otherwise it
// could end up being a bottleneck for the entire system). It is
// put into the map in an uninitialized state. The first time
// someone tries to use it, it will be initialized (with proper
// synchronizations in place to make sure it is only initialized
// once).
BeanInfoManager ret = (BeanInfoManager)
mBeanInfoManagerByClass.get (pClass);
if (ret == null) {
ret = new BeanInfoManager (pClass);
mBeanInfoManagerByClass.put (pClass, ret);
}
return ret;
}
//-------------------------------------
/**
*
* Returns the BeanInfoProperty for the specified property in the
* given class, or null if not found.
**/
public static BeanInfoProperty getBeanInfoProperty
(Class pClass,
String pPropertyName,
Logger pLogger)
throws ELException
{
return getBeanInfoManager (pClass).getProperty (pPropertyName, pLogger);
}
//-------------------------------------
/**
*
* Returns the BeanInfoIndexedProperty for the specified property in
* the given class, or null if not found.
**/
public static BeanInfoIndexedProperty getBeanInfoIndexedProperty
(Class pClass,
String pIndexedPropertyName,
Logger pLogger)
throws ELException
{
return getBeanInfoManager
(pClass).getIndexedProperty (pIndexedPropertyName, pLogger);
}
//-------------------------------------
/**
*
* Makes sure that this class has been initialized, and synchronizes
* the initialization if it's required.
**/
void checkInitialized (Logger pLogger)
throws ELException
{
if (!mInitialized) {
synchronized (this) {
if (!mInitialized) {
initialize (pLogger);
mInitialized = true;
}
}
}
}
//-------------------------------------
/**
*
* Initializes by mapping property names to BeanInfoProperties
**/
void initialize (Logger pLogger)
throws ELException
{
try {
mBeanInfo = Introspector.getBeanInfo (mBeanClass);
mPropertyByName = new HashMap ();
mIndexedPropertyByName = new HashMap ();
PropertyDescriptor [] pds = mBeanInfo.getPropertyDescriptors ();
for (int i = 0; pds != null && i < pds.length; i++) {
// Treat as both an indexed property and a normal property
PropertyDescriptor pd = pds [i];
if (pd instanceof IndexedPropertyDescriptor) {
IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
Method readMethod = getPublicMethod (ipd.getIndexedReadMethod ());
Method writeMethod = getPublicMethod (ipd.getIndexedWriteMethod ());
BeanInfoIndexedProperty property = new BeanInfoIndexedProperty
(readMethod,
writeMethod,
ipd);
mIndexedPropertyByName.put (ipd.getName (), property);
}
Method readMethod = getPublicMethod (pd.getReadMethod ());
Method writeMethod = getPublicMethod (pd.getWriteMethod ());
BeanInfoProperty property = new BeanInfoProperty
(readMethod,
writeMethod,
pd);
mPropertyByName.put (pd.getName (), property);
}
mEventSetByName = new HashMap ();
EventSetDescriptor [] esds = mBeanInfo.getEventSetDescriptors ();
for (int i = 0; esds != null && i < esds.length; i++) {
EventSetDescriptor esd = esds [i];
mEventSetByName.put (esd.getName (), esd);
}
}
catch (IntrospectionException exc) {
if (pLogger.isLoggingWarning ()) {
pLogger.logWarning
(Constants.EXCEPTION_GETTING_BEANINFO,
exc,
mBeanClass.getName ());
}
}
}
//-------------------------------------
/**
*
* Returns the BeanInfo for the class
**/
BeanInfo getBeanInfo (Logger pLogger)
throws ELException
{
checkInitialized (pLogger);
return mBeanInfo;
}
//-------------------------------------
/**
*
* Returns the BeanInfoProperty for the given property name, or null
* if not found.
**/
public BeanInfoProperty getProperty (String pPropertyName,
Logger pLogger)
throws ELException
{
checkInitialized (pLogger);
return (BeanInfoProperty) mPropertyByName.get (pPropertyName);
}
//-------------------------------------
/**
*
* Returns the BeanInfoIndexedProperty for the given property name,
* or null if not found.
**/
public BeanInfoIndexedProperty getIndexedProperty
(String pIndexedPropertyName,
Logger pLogger)
throws ELException
{
checkInitialized (pLogger);
return (BeanInfoIndexedProperty)
mIndexedPropertyByName.get (pIndexedPropertyName);
}
//-------------------------------------
/**
*
* Returns the EventSetDescriptor for the given event set name, or
* null if not found.
**/
public EventSetDescriptor getEventSet (String pEventSetName,
Logger pLogger)
throws ELException
{
checkInitialized (pLogger);
return (EventSetDescriptor) mEventSetByName.get (pEventSetName);
}
//-------------------------------------
// Finding the public version of a method - if a PropertyDescriptor
// is obtained for a non-public class that implements a public
// interface, the read/write methods will be for the class, and
// therefore inaccessible. To correct this, a version of the same
// method must be found in a superclass or interface.
//-------------------------------------
/**
*
* Returns a publicly-accessible version of the given method, by
* searching for a public declaring class.
**/
static Method getPublicMethod (Method pMethod)
{
if (pMethod == null) {
return null;
}
// See if the method is already available from a public class
Class cl = pMethod.getDeclaringClass ();
if (Modifier.isPublic (cl.getModifiers ())) {
return pMethod;
}
// Otherwise, try to find a public class that declares the method
Method ret = getPublicMethod (cl, pMethod);
if (ret != null) {
return ret;
}
else {
return pMethod;
}
}
//-------------------------------------
/**
*
* If the given class is public and has a Method that declares the
* same name and arguments as the given method, then that method is
* returned. Otherwise the superclass and interfaces are searched
* recursively.
**/
static Method getPublicMethod (Class pClass,
Method pMethod)
{
// See if this is a public class declaring the method
if (Modifier.isPublic (pClass.getModifiers ())) {
try {
Method m;
try {
m = pClass.getDeclaredMethod (pMethod.getName (),
pMethod.getParameterTypes ());
} catch (java.security.AccessControlException ex) {
// kludge to accommodate J2EE RI's default settings
// TODO: see if we can simply replace
// getDeclaredMethod() with getMethod() ...?
m = pClass.getMethod(pMethod.getName (),
pMethod.getParameterTypes ());
}
if (Modifier.isPublic (m.getModifiers ())) {
return m;
}
}
catch (NoSuchMethodException exc) {}
}
// Search the interfaces
{
Class [] interfaces = pClass.getInterfaces ();
if (interfaces != null) {
for (int i = 0; i < interfaces.length; i++) {
Method m = getPublicMethod (interfaces [i], pMethod);
if (m != null) {
return m;
}
}
}
}
// Search the superclass
{
Class superclass = pClass.getSuperclass ();
if (superclass != null) {
Method m = getPublicMethod (superclass, pMethod);
if (m != null) {
return m;
}
}
}
return null;
}
//-------------------------------------
}
see
* <http://wwwcommons-el-1.0-src/src/java/org/apache/commons/el/ArraySuffix.java