jstrachan 02/05/21 00:58:55
Added:
jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell
BeanShellExpressionFactory.java
JellyInterpreter.java BeanShellExpression.java
BeanShellTagLibrary.java
jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf
JPythonTagLibrary.java BSFExpressionFactory.java
BSFExpression.java JavaScriptTagLibrary.java
PNutsTagLibrary.java ContextRegistry.java
BSFTagLibrary.java
Log:
Ported the build system to Maven.
Also moved the non-core taglibs into src/taglibs where there will be seperate build
files for each optional taglib.
Revision Changes Path
1.1
jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java
Index: BeanShellExpressionFactory.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.beanshell;
import org.apache.commons.jelly.expression.Expression;
import org.apache.commons.jelly.expression.ExpressionFactory;
/** Represents a factory of <a href="http://www.beanshell.org">beanshell</a>
expressions
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BeanShellExpressionFactory implements ExpressionFactory {
/** The interpreter */
private JellyInterpreter interpreter = new JellyInterpreter();
// ExpressionFactory interface
//-------------------------------------------------------------------------
public Expression createExpression(String text) throws Exception {
return new BeanShellExpression(text, interpreter);
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/JellyInterpreter.java
Index: JellyInterpreter.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/JellyInterpreter.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: JellyInterpreter.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.beanshell;
import bsh.EvalError;
import bsh.Interpreter;
import java.util.Iterator;
import org.apache.commons.jelly.JellyContext;
/** Integrates BeanShell's interpreter with Jelly's JellyContext
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class JellyInterpreter extends Interpreter {
private JellyContext context;
public JellyInterpreter() {
}
public JellyContext getJellyContext() {
return context;
}
public void setJellyContext(JellyContext context) throws EvalError {
this.context = context;
// now pass in all the variables
for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) {
String name = (String) iter.next();
Object value = context.getVariable(name);
set( name, value );
}
}
/*
// the following code doesn't work - it seems that
// all variables must be passed into the Interpreter
// via set() method
public Object get(String name) throws EvalError {
if ( context != null ) {
Object answer = context.getVariable( name );
if ( answer != null ) {
return answer;
}
}
return super.get( name );
}
*/
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpression.java
Index: BeanShellExpression.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpression.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: BeanShellExpression.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.beanshell;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.expression.ExpressionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** Represents a <a href="http://www.beanshell.org">beanshell</a> expression
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BeanShellExpression extends ExpressionSupport {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog( BeanShellExpression.class );
/** The expression */
private String text;
/** The interpreter */
private JellyInterpreter interpreter = new JellyInterpreter();
public BeanShellExpression(String text, JellyInterpreter interpreter) {
this.text = text;
this.interpreter = interpreter;
}
// Expression interface
//-------------------------------------------------------------------------
public Object evaluate(JellyContext context) {
try {
interpreter.setJellyContext(context);
if ( log.isDebugEnabled() ) {
log.debug( "Evaluating EL: " + text );
}
return interpreter.eval( text );
}
catch (Exception e) {
log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e );
return null;
}
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellTagLibrary.java
Index: BeanShellTagLibrary.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellTagLibrary.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: BeanShellTagLibrary.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.beanshell;
import org.apache.commons.jelly.expression.ExpressionFactory;
import org.apache.commons.jelly.tags.core.CoreTagLibrary;
/** Describes the Taglib. This class could be generated by XDoclet
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BeanShellTagLibrary extends CoreTagLibrary {
private ExpressionFactory expressionFactory = new BeanShellExpressionFactory();
/** Allows derived tag libraries to use their own factory */
protected ExpressionFactory getExpressionFactory() {
return expressionFactory;
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/JPythonTagLibrary.java
Index: JPythonTagLibrary.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/JPythonTagLibrary.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: JPythonTagLibrary.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bsf;
/** Describes the Taglib. This class could be generated by XDoclet
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class JPythonTagLibrary extends BSFTagLibrary {
public JPythonTagLibrary() {
setLanguage( "jpython" );
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpressionFactory.java
Index: BSFExpressionFactory.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpressionFactory.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: BSFExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bsf;
import com.ibm.bsf.BSFEngine;
import com.ibm.bsf.BSFException;
import com.ibm.bsf.BSFManager;
import java.io.File;
import org.apache.commons.jelly.expression.Expression;
import org.apache.commons.jelly.expression.ExpressionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** Represents a factory of BSF expressions
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BSFExpressionFactory implements ExpressionFactory {
/** The logger of messages */
private Log log = LogFactory.getLog( getClass() );
private String language = "javascript";
private BSFManager manager;
private BSFEngine engine;
private JellyContextRegistry registry = new JellyContextRegistry();
public BSFExpressionFactory() {
}
// Properties
//-------------------------------------------------------------------------
/** @return the BSF language to be used */
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
/** @return the BSF Engine to be used by this expression factory */
public BSFEngine getBSFEngine() throws BSFException {
if ( engine == null ) {
engine = createBSFEngine();
}
return engine;
}
public void setBSFEngine(BSFEngine engine) {
this.engine = engine;
}
public BSFManager getBSFManager() {
if ( manager == null ) {
manager = createBSFManager();
manager.setObjectRegistry( registry );
}
return manager;
}
public void setBSFManager(BSFManager manager) {
this.manager = manager;
manager.setObjectRegistry( registry );
}
// ExpressionFactory interface
//-------------------------------------------------------------------------
public Expression createExpression(String text) throws Exception {
return new BSFExpression( text, getBSFEngine(), getBSFManager(), registry );
}
// Implementation methods
//-------------------------------------------------------------------------
/** Factory method */
protected BSFEngine createBSFEngine() throws BSFException {
return getBSFManager().loadScriptingEngine( getLanguage() );
}
/** Factory method */
protected BSFManager createBSFManager() {
BSFManager answer = new BSFManager();
return answer;
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpression.java
Index: BSFExpression.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpression.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: BSFExpression.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bsf;
import com.ibm.bsf.BSFEngine;
import com.ibm.bsf.BSFManager;
import java.util.Iterator;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.expression.ExpressionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** Represents a BSF expression
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BSFExpression extends ExpressionSupport {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog( BSFExpression.class );
/** The expression */
private String text;
/** The BSF Engine to evaluate expressions */
private BSFEngine engine;
/** The BSF Manager to evaluate expressions */
private BSFManager manager;
/** The adapter to BSF's ObjectRegistry that uses the JellyContext */
private JellyContextRegistry registry;
public BSFExpression(String text, BSFEngine engine, BSFManager manager,
JellyContextRegistry registry) {
this.text = text;
this.engine = engine;
this.manager = manager;
this.registry = registry;
}
// Expression interface
//-------------------------------------------------------------------------
public Object evaluate(JellyContext context) {
// XXXX: unfortunately we must sychronize evaluations
// so that we can swizzle in the context.
// maybe we could create an expression from a context
// (and so create a BSFManager for a context)
synchronized (registry) {
registry.setJellyContext(context);
try {
// XXXX: hack - there must be a better way!!!
for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) {
String name = (String) iter.next();
Object value = context.getVariable( name );
manager.declareBean( name, value, value.getClass() );
}
return engine.eval( text, -1, -1, text );
}
catch (Exception e) {
log.warn( "Caught exception evaluating: " + text + ". Reason: " + e,
e );
return null;
}
}
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/JavaScriptTagLibrary.java
Index: JavaScriptTagLibrary.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/JavaScriptTagLibrary.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: JavaScriptTagLibrary.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bsf;
/** Describes the Taglib. This class could be generated by XDoclet
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class JavaScriptTagLibrary extends BSFTagLibrary {
public JavaScriptTagLibrary() {
setLanguage( "javascript" );
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/PNutsTagLibrary.java
Index: PNutsTagLibrary.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/PNutsTagLibrary.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: PNutsTagLibrary.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bsf;
import com.ibm.bsf.BSFManager;
/** Describes the Taglib. This class could be generated by XDoclet
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class PNutsTagLibrary extends BSFTagLibrary {
public PNutsTagLibrary() {
BSFManager.registerScriptingEngine(
"pnuts",
"pnuts.ext.PnutsBSFEngine",
new String[]{"pnut"}
);
setLanguage( "pnuts" );
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/ContextRegistry.java
Index: ContextRegistry.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/ContextRegistry.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: ContextRegistry.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bsf;
import com.ibm.bsf.util.ObjectRegistry;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** A BSF ObjectRegistry which uses the Context to find and
* register objects
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class ContextRegistry extends ObjectRegistry {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(ContextRegistry.class);
/** The context */
private JellyContext context;
public ContextRegistry() {
}
public JellyContext getContext() {
return context;
}
public void setContext(JellyContext context) {
this.context = context;
}
// ObjectRegistry interface
//-------------------------------------------------------------------------
public Object lookup(String name) {
return context.getVariable(name);
}
public void register(String name, Object value) {
context.setVariable(name, value);
}
public void unregister(String name) {
context.removeVariable(name);
}
}
1.1
jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFTagLibrary.java
Index: BSFTagLibrary.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFTagLibrary.java,v
1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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 [EMAIL PROTECTED]
*
* 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/>.
*
* $Id: BSFTagLibrary.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bsf;
import org.apache.commons.jelly.expression.ExpressionFactory;
import org.apache.commons.jelly.tags.core.CoreTagLibrary;
/** Describes the Taglib. This class could be generated by XDoclet
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BSFTagLibrary extends CoreTagLibrary {
private BSFExpressionFactory expressionFactory = new BSFExpressionFactory();
public void setLanguage(String language) {
expressionFactory.setLanguage(language);
}
/** Allows derived tag libraries to use their own factory */
protected ExpressionFactory getExpressionFactory() {
return expressionFactory;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>