Seam SVN: r10645 - modules/trunk/el.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-27 00:15:21 -0400 (Mon, 27 Apr 2009)
New Revision: 10645
Modified:
modules/trunk/el/
Log:
ignores
Property changes on: modules/trunk/el
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
15 years
Seam SVN: r10644 - in modules/trunk: el and 8 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-27 00:13:09 -0400 (Mon, 27 Apr 2009)
New Revision: 10644
Added:
modules/trunk/el/
modules/trunk/el/pom.xml
modules/trunk/el/src/
modules/trunk/el/src/main/
modules/trunk/el/src/main/java/
modules/trunk/el/src/main/java/org/
modules/trunk/el/src/main/java/org/jboss/
modules/trunk/el/src/main/java/org/jboss/seam/
modules/trunk/el/src/main/java/org/jboss/seam/el/
modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java
modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java
modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java
modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java
modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java
modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java
Modified:
modules/trunk/version-matrix/pom.xml
Log:
initial import of el module
Added: modules/trunk/el/pom.xml
===================================================================
--- modules/trunk/el/pom.xml (rev 0)
+++ modules/trunk/el/pom.xml 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,36 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>seam-parent</artifactId>
+ <groupId>org.jboss.seam</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-el</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>Seam EL</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>jsr299-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,143 @@
+package org.jboss.seam.el;
+
+import java.util.Locale;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.ResourceBundleELResolver;
+import javax.el.VariableMapper;
+
+import org.jboss.el.ExpressionFactoryImpl;
+import org.jboss.el.lang.FunctionMapperImpl;
+import org.jboss.el.lang.VariableMapperImpl;
+
+/**
+ * An instance of JBoss EL.
+ *
+ * @author Gavin King
+ *
+ */
+public class EL
+{
+ public static final ELResolver EL_RESOLVER = createELResolver();
+ //ELContext instances should not be shared between threads
+ //public static final ELContext EL_CONTEXT = createELContext( EL_RESOLVER, new FunctionMapperImpl() );
+
+ public static final ExpressionFactory EXPRESSION_FACTORY = new ExpressionFactoryImpl();
+
+ private static ELResolver createELResolver()
+ {
+ CompositeELResolver resolver = new CompositeELResolver();
+ resolver.add( new SeamELResolver() );
+ resolver.add( new MapELResolver() );
+ resolver.add( new ListELResolver() );
+ resolver.add( new ArrayELResolver() );
+ resolver.add( new ResourceBundleELResolver() );
+ resolver.add( new BeanELResolver() );
+ return resolver;
+ }
+
+ public static ELContext createELContext() {
+ return createELContext( EL_RESOLVER, new FunctionMapperImpl() );
+ }
+
+ public static ELContext createELContext(final ELResolver resolver, final FunctionMapper functionMapper)
+ {
+ return new ELContext()
+ {
+ final VariableMapperImpl variableMapper = new VariableMapperImpl();
+
+ @Override
+ public ELResolver getELResolver()
+ {
+ return resolver;
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper()
+ {
+ return functionMapper;
+ }
+
+ @Override
+ public VariableMapper getVariableMapper()
+ {
+ return variableMapper;
+ }
+
+ };
+ }
+
+ public static ELContext createELContext(final ELContext context, final ELResolver resolver)
+ {
+ return new ELContext()
+ {
+
+ @Override
+ public Locale getLocale()
+ {
+ return context.getLocale();
+ }
+
+ @Override
+ public void setPropertyResolved(boolean value)
+ {
+ super.setPropertyResolved(value);
+ context.setPropertyResolved(value);
+ }
+
+ /*@Override
+ public boolean isPropertyResolved()
+ {
+ return super.isPropertyResolved();
+ }*/
+
+ @Override
+ public void putContext(Class clazz, Object object)
+ {
+ super.putContext(clazz, object);
+ context.putContext(clazz, object);
+ }
+
+ @Override
+ public Object getContext(Class clazz)
+ {
+ return context.getContext(clazz);
+ }
+
+ @Override
+ public void setLocale(Locale locale)
+ {
+ super.setLocale(locale);
+ context.setLocale(locale);
+ }
+
+ @Override
+ public ELResolver getELResolver()
+ {
+ return resolver;
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper()
+ {
+ return context.getFunctionMapper();
+ }
+
+ @Override
+ public VariableMapper getVariableMapper()
+ {
+ return context.getVariableMapper();
+ }
+
+ };
+ }
+
+}
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,220 @@
+package org.jboss.seam.el;
+
+import java.io.Serializable;
+
+import javax.context.ApplicationScoped;
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+
+import org.jboss.seam.el.EL;
+import org.jboss.seam.el.SeamExpressionFactory;
+
+/**
+ * Factory for EL method and value expressions.
+ *
+ * This default implementation uses JBoss EL.
+ *
+ * @author Gavin King
+ */
+@ApplicationScoped
+public class Expressions implements Serializable
+{
+ private static final long serialVersionUID = 7420955152664486125L;
+
+ /**
+ * Get the JBoss EL ExpressionFactory
+ */
+ public ExpressionFactory getExpressionFactory()
+ {
+ return SeamExpressionFactory.INSTANCE;
+ }
+
+ /**
+ * Get an appropriate ELContext. If there is an active JSF request,
+ * use JSF's ELContext. Otherwise, use one that we create.
+ */
+ public ELContext getELContext() {
+ return EL.createELContext();
+ }
+
+ /**
+ * Create a value expression.
+ *
+ * @param expression a JBoss EL value expression
+ */
+ public ValueExpression<Object> createValueExpression(String expression)
+ {
+ return createValueExpression(expression, Object.class);
+ }
+
+ /**
+ * Create a method expression.
+ *
+ * @param expression a JBoss EL method expression
+ */
+ public MethodExpression<Object> createMethodExpression(String expression)
+ {
+ return createMethodExpression(expression, Object.class);
+ }
+
+ /**
+ * Create a value expression.
+ *
+ * @param expression a JBoss EL value expression
+ * @param type the type of the value
+ */
+ public <T> ValueExpression<T> createValueExpression(final String expression, final Class<T> type)
+ {
+
+ return new ValueExpression<T>()
+ {
+ private javax.el.ValueExpression facesValueExpression;
+ private javax.el.ValueExpression seamValueExpression;
+
+ public javax.el.ValueExpression toUnifiedValueExpression()
+ {
+ if ( isFacesContextActive() )
+ {
+ if (facesValueExpression==null)
+ {
+ facesValueExpression = createExpression();
+ }
+ return facesValueExpression;
+ }
+ else
+ {
+ if (seamValueExpression==null)
+ {
+ seamValueExpression = createExpression();
+ }
+ return seamValueExpression;
+ }
+ }
+
+ private javax.el.ValueExpression createExpression()
+ {
+ return getExpressionFactory().createValueExpression( getELContext(), expression, type );
+ }
+
+ public T getValue()
+ {
+ return (T) toUnifiedValueExpression().getValue( getELContext() );
+ }
+
+ public void setValue(T value)
+ {
+ toUnifiedValueExpression().setValue( getELContext(), value );
+ }
+
+ public String getExpressionString()
+ {
+ return expression;
+ }
+
+ public Class<T> getType()
+ {
+ // QUESTION shouldn't we use the type provided in the constructor?
+ return (Class<T>) toUnifiedValueExpression().getType( getELContext() );
+ }
+
+ };
+ }
+
+ /**
+ * Create a method expression.
+ *
+ * @param expression a JBoss EL method expression
+ * @param type the method return type
+ * @param argTypes the method parameter types
+ */
+ public <T> MethodExpression<T> createMethodExpression(final String expression, final Class<T> type, final Class... argTypes)
+ {
+ return new MethodExpression<T>()
+ {
+ private javax.el.MethodExpression facesMethodExpression;
+ private javax.el.MethodExpression seamMethodExpression;
+
+ public javax.el.MethodExpression toUnifiedMethodExpression()
+ {
+ if ( isFacesContextActive() )
+ {
+ if (facesMethodExpression==null)
+ {
+ facesMethodExpression = createExpression();
+ }
+ return facesMethodExpression;
+ }
+ else
+ {
+ if (seamMethodExpression==null)
+ {
+ seamMethodExpression = createExpression();
+ }
+ return seamMethodExpression;
+ }
+ }
+
+ private javax.el.MethodExpression createExpression()
+ {
+ return getExpressionFactory().createMethodExpression( getELContext(), expression, type, argTypes );
+ }
+
+ public T invoke(Object... args)
+ {
+ return (T) toUnifiedMethodExpression().invoke( getELContext(), args );
+ }
+
+ public String getExpressionString()
+ {
+ return expression;
+ }
+
+ };
+ }
+
+ /**
+ * A value expression - an EL expression that evaluates to
+ * an attribute getter or get/set pair. This interface
+ * is just a genericized version of the Unified EL ValueExpression
+ * interface.
+ *
+ * @author Gavin King
+ *
+ * @param <T> the type of the value
+ */
+ public static interface ValueExpression<T> extends Serializable
+ {
+ public T getValue();
+ public void setValue(T value);
+ public String getExpressionString();
+ public Class<T> getType();
+ /**
+ * @return the underlying Unified EL ValueExpression
+ */
+ public javax.el.ValueExpression toUnifiedValueExpression();
+ }
+
+ /**
+ * A method expression - an EL expression that evaluates to
+ * a method. This interface is just a genericized version of
+ * the Unified EL ValueExpression interface.
+ *
+ * @author Gavin King
+ *
+ * @param <T> the method return type
+ */
+ public static interface MethodExpression<T> extends Serializable
+ {
+ public T invoke(Object... args);
+ public String getExpressionString();
+ /**
+ * @return the underlying Unified EL MethodExpression
+ */
+ public javax.el.MethodExpression toUnifiedMethodExpression();
+ }
+
+ protected boolean isFacesContextActive()
+ {
+ return false;
+ }
+}
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,23 @@
+package org.jboss.seam.el;
+
+import javax.annotation.PreDestroy;
+import javax.context.ApplicationScoped;
+import javax.inject.Initializer;
+
+import org.jboss.el.util.ReflectionUtil;
+
+@ApplicationScoped
+public class JBossELReferenceCache
+{
+ @Initializer
+ public void start()
+ {
+ ReflectionUtil.startup();
+ }
+
+ @PreDestroy
+ public void stop()
+ {
+ ReflectionUtil.shutdown();
+ }
+}
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package org.jboss.seam.el;
+
+import javax.el.ELContext;
+import javax.el.MethodExpression;
+import javax.el.MethodInfo;
+import javax.el.MethodNotFoundException;
+
+/**
+ *
+ * @author Gavin King
+ *
+ */
+class OptionalParameterMethodExpression extends MethodExpression
+{
+
+ private MethodExpression withParam;
+ private MethodExpression withNoParam;
+
+ public OptionalParameterMethodExpression(MethodExpression withParam, MethodExpression withNoParam)
+ {
+ this.withParam = withParam;
+ this.withNoParam = withNoParam;
+ }
+
+ @Override
+ public MethodInfo getMethodInfo(ELContext ctx)
+ {
+ return withParam.getMethodInfo(ctx);
+ }
+
+ @Override
+ public Object invoke(ELContext ctx, Object[] args)
+ {
+ try
+ {
+ return withParam.invoke(ctx, args);
+ }
+ catch (MethodNotFoundException mnfe)
+ {
+ try
+ {
+ return withNoParam.invoke(ctx, new Object[0]);
+ }
+ catch (MethodNotFoundException mnfe2)
+ {
+ throw mnfe;
+ }
+ }
+ }
+
+ @Override
+ public String getExpressionString()
+ {
+ return withParam.getExpressionString();
+ }
+
+ @Override
+ public boolean isLiteralText()
+ {
+ return withParam.isLiteralText();
+ }
+
+ @Override
+ public boolean equals(Object object)
+ {
+ if ( !(object instanceof OptionalParameterMethodExpression) ) return false;
+ OptionalParameterMethodExpression other = (OptionalParameterMethodExpression) object;
+ return withParam.equals(other.withParam);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return withParam.hashCode();
+ }
+
+ }
\ No newline at end of file
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamELResolver.java 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,189 @@
+package org.jboss.seam.el;
+
+import org.jboss.seam.util.JSF;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+import org.jboss.seam.Namespace;
+import org.jboss.seam.contexts.Context;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Init;
+
+/**
+ * Resolves Seam components and namespaces. Also
+ * allows the use of #{dataModel.size}, #{dataModel.empty},
+ * #{collection.size}, #{map.size}, #{map.values}, #{map.keySet},
+ * and #{map.entrySet}. Also allows #{sessionContext['name']}.
+ *
+ * @author Gavin King
+ *
+ */
+public class SeamELResolver extends ELResolver
+{
+
+ @Override
+ public Class getCommonPropertyType(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ @Override
+ public Iterator getFeatureDescriptors(ELContext context, Object base)
+ {
+ return null;
+ }
+
+ @Override
+ public Class getType(ELContext context, Object base, Object property)
+ {
+ return null;
+ }
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property)
+ {
+ if (base == null) {
+ return resolveBase(context, property);
+
+ } else if (base instanceof Namespace) {
+ return resolveInNamespace(context, (Namespace) base, property);
+
+ } else if (JSF.DATA_MODEL.isInstance(base)) {
+ return resolveInDataModel(context, base, property);
+
+ } else if (base instanceof Collection) {
+ return resolveInCollection(context, (Collection) base, property);
+
+ } else if (base instanceof Map) {
+ return resolveInMap(context, (Map) base, property);
+
+ } else if (base instanceof Context) {
+ return resolveInContextObject(context, (Context) base, property);
+
+ } else {
+ return null;
+ }
+ }
+
+ private Object resolveInContextObject(ELContext context, Context seamContext, Object property)
+ {
+ if (seamContext.isSet((String) property)) {
+ context.setPropertyResolved(true);
+ return seamContext.get((String) property);
+ } else {
+ return null;
+ }
+ }
+
+ private Object resolveInMap(ELContext context, Map map, Object property) {
+ try {
+ if (map.containsKey(property)) {
+ return null;
+ }
+ } catch (UnsupportedOperationException e) {
+ // eat it
+ }
+
+ if ("size".equals(property)) {
+ context.setPropertyResolved(true);
+ return map.size();
+
+ } else if ("values".equals(property)) {
+ context.setPropertyResolved(true);
+ return map.values();
+
+ } else if ("keySet".equals(property)) {
+ context.setPropertyResolved(true);
+ return map.keySet();
+
+ } else if ("entrySet".equals(property)) {
+ context.setPropertyResolved(true);
+ return map.entrySet();
+
+ } else {
+ return null;
+ }
+ }
+
+ private Object resolveInCollection(ELContext context, Collection collection, Object property)
+ {
+ if ("size".equals(property)) {
+ context.setPropertyResolved(true);
+ return collection.size();
+ } else {
+ return null;
+ }
+ }
+
+ private Object resolveInDataModel(ELContext context, Object base, Object property)
+ {
+ if ("size".equals(property)) {
+ context.setPropertyResolved(true);
+ return JSF.getRowCount(base);
+ } else if ("empty".equals(property)) {
+ context.setPropertyResolved(true);
+ return JSF.getRowCount(base) == 0;
+ } else {
+ return null;
+ }
+ }
+
+ private Object resolveBase(ELContext context, Object property)
+ {
+ if (!Contexts.isApplicationContextActive()) {
+ // if no Seam contexts, bypass straight through to JSF
+ return null;
+ }
+
+ String key = (String) property;
+ Init init = Init.instance();
+
+ // look for a component in the root namespace
+ Object result = init.getRootNamespace().getComponentInstance(key);
+ if (result != null) {
+ context.setPropertyResolved(true);
+ return result;
+ } else {
+ // look for a component in the imported namespaces
+ for (Namespace ns : init.getGlobalImports()) {
+ result = ns.getComponentInstance(key);
+ if (result != null) {
+ context.setPropertyResolved(true);
+ return result;
+ }
+ }
+ }
+
+ // look for a namespace
+ Namespace namespace = init.getRootNamespace().getChild(key);
+ if (namespace != null) {
+ context.setPropertyResolved(true);
+ }
+ return namespace;
+ }
+
+ private Object resolveInNamespace(ELContext context, Namespace namespace, Object property) {
+ Object result = namespace.get((String) property);
+ // JBSEAM-3077 if the result is null, it means that there is no component instance bound to this qualified name
+ context.setPropertyResolved(true);
+ return result;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ {
+ return base != null
+ && (JSF.DATA_MODEL.isInstance(base) || (base instanceof Collection) || (base instanceof Map));
+ }
+
+ @Override
+ public void setValue(ELContext context, Object base, Object property, Object value)
+ {
+ }
+
+}
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.el;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+import org.jboss.el.lang.EvaluationContext;
+import org.jboss.seam.util.JSF;
+
+/**
+ * Allows JSF action listener methods to not declare the
+ * totally useless ActionEvent parameter if they don't
+ * want to.
+ *
+ * @author Gavin King
+ */
+public class SeamExpressionFactory extends ExpressionFactory
+{
+ public static final ExpressionFactory INSTANCE = new SeamExpressionFactory(EL.EXPRESSION_FACTORY);
+
+ private static final Class[] NO_CLASSES = {};
+
+ private final ExpressionFactory expressionFactory;
+
+ SeamExpressionFactory(ExpressionFactory expressionFactory)
+ {
+ this.expressionFactory = expressionFactory;
+ }
+
+ /**
+ * Wrap the base ELContext, adding Seam's FunctionMapper.
+ *
+ * Thus, any expressions with s:hasRole, s:hasPermission
+ * must be evaluated either via Facelets/JSP (since they
+ * are declared in the tld/taglib.xml or via the
+ * Expressions component.
+ *
+ * @param context the JSF ELContext
+ */
+ private static EvaluationContext decorateELContext(ELContext context)
+ {
+ return new EvaluationContext( context, new SeamFunctionMapper( context.getFunctionMapper() ), context.getVariableMapper() );
+ }
+
+ @Override
+ public Object coerceToType(Object obj, Class targetType)
+ {
+ return expressionFactory.coerceToType(obj, targetType);
+ }
+
+ @Override
+ public MethodExpression createMethodExpression(ELContext elContext, String expression, Class returnType, Class[] paramTypes)
+ {
+ if ( paramTypes.length==1 && JSF.FACES_EVENT.isAssignableFrom( paramTypes[0] ) )
+ {
+ return new OptionalParameterMethodExpression(
+ expressionFactory.createMethodExpression( decorateELContext(elContext), expression, returnType, paramTypes ),
+ expressionFactory.createMethodExpression( decorateELContext(elContext), expression, returnType, NO_CLASSES )
+ );
+ }
+ else
+ {
+ return expressionFactory.createMethodExpression( decorateELContext(elContext), expression, returnType, paramTypes );
+ }
+ }
+
+ @Override
+ public ValueExpression createValueExpression(Object instance, Class expectedType)
+ {
+ return expressionFactory.createValueExpression(instance, expectedType);
+ }
+
+ @Override
+ public ValueExpression createValueExpression(ELContext elContext, String expression, Class expectedType)
+ {
+ return expressionFactory.createValueExpression( decorateELContext(elContext), expression, expectedType );
+ }
+
+}
\ No newline at end of file
Added: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java (rev 0)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamFunctionMapper.java 2009-04-27 04:13:09 UTC (rev 10644)
@@ -0,0 +1,114 @@
+package org.jboss.seam.el;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.el.FunctionMapper;
+
+import org.jboss.el.lang.ExtendedFunctionMapper;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.seam.security.SecurityFunctions;
+
+/**
+ * Resolves Seam Security EL functions, s:hasRole() and s:hasPermission()
+ * by decorating a delegate Unified EL FunctionMapper
+ *
+ * @author Shane Bryzak
+ */
+public class SeamFunctionMapper extends ExtendedFunctionMapper
+{
+ private static Map<String,List<Method>> methodCache = new HashMap<String,List<Method>>();
+
+ private static final LogProvider log = Logging.getLogProvider(SeamFunctionMapper.class);
+
+ private FunctionMapper functionMapper;
+
+ public SeamFunctionMapper(FunctionMapper functionMapper)
+ {
+ this.functionMapper = functionMapper;
+ }
+
+ static
+ {
+ cacheMethod("hasPermission", SecurityFunctions.class, "hasPermission",
+ new Class[] {String.class, String.class, Object.class});
+ cacheMethod("hasPermission", SecurityFunctions.class, "hasPermission",
+ new Class[] {Object.class, String.class});
+ cacheMethod("hasRole", SecurityFunctions.class, "hasRole",
+ new Class[] { String.class });
+ }
+
+ @Override
+ public Method resolveFunction(String prefix, String localName)
+ {
+ if ( "s".equals(prefix) )
+ {
+ List<Method> methods = methodCache.get(localName);
+ return methods != null ? methods.get(0) : null;
+ }
+ else if (functionMapper != null)
+ {
+ return functionMapper.resolveFunction(prefix, localName);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public Method resolveFunction(String prefix, String localName, int paramCount)
+ {
+ if ( "s".equals(prefix) )
+ {
+ List<Method> methods = methodCache.get(localName);
+ if (methods != null)
+ {
+ for (Method m : methods)
+ {
+ if (m.getParameterTypes().length == paramCount) return m;
+ }
+ }
+
+ return null;
+ }
+ else if (functionMapper != null)
+ {
+ return functionMapper.resolveFunction(prefix, localName);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private static void cacheMethod(String localName, Class cls, String name, Class[] params)
+ {
+ try
+ {
+ Method m = cls.getMethod(name, params);
+
+ List<Method> methods;
+ if (methodCache.containsKey(localName))
+ {
+ methods = methodCache.get(localName);
+ }
+ else
+ {
+ methods = new ArrayList<Method>();
+ methodCache.put(localName, methods);
+ }
+
+ methods.add(m);
+ }
+ catch (NoSuchMethodException ex)
+ {
+ log.warn(String.format("Method %s.%s could not be cached", cls.getName(), name));
+ }
+ }
+
+}
Modified: modules/trunk/version-matrix/pom.xml
===================================================================
--- modules/trunk/version-matrix/pom.xml 2009-04-25 19:53:01 UTC (rev 10643)
+++ modules/trunk/version-matrix/pom.xml 2009-04-27 04:13:09 UTC (rev 10644)
@@ -132,7 +132,7 @@
<dependency>
<groupId>org.jboss.el</groupId>
<artifactId>jboss-el</artifactId>
- <version>1.0_02.CR2</version>
+ <version>1.0_02.CR4</version>
</dependency>
<dependency>
@@ -154,6 +154,12 @@
</dependency>
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <version>3.2.4.sp1</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>jsr299-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
15 years
Seam SVN: r10643 - branches/community/Seam_2_1/src/resteasy/org/jboss/seam/resteasy.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-04-25 15:53:01 -0400 (Sat, 25 Apr 2009)
New Revision: 10643
Modified:
branches/community/Seam_2_1/src/resteasy/org/jboss/seam/resteasy/ResourceHome.java
Log:
JBSEAM-3987 minor
Modified: branches/community/Seam_2_1/src/resteasy/org/jboss/seam/resteasy/ResourceHome.java
===================================================================
--- branches/community/Seam_2_1/src/resteasy/org/jboss/seam/resteasy/ResourceHome.java 2009-04-25 19:45:30 UTC (rev 10642)
+++ branches/community/Seam_2_1/src/resteasy/org/jboss/seam/resteasy/ResourceHome.java 2009-04-25 19:53:01 UTC (rev 10643)
@@ -207,17 +207,18 @@
return Response.status(BAD_REQUEST).build();
}
- updateEntity(entity);
+ updateEntity(entity, id);
return Response.noContent().build();
}
/**
* Merge the state of the database entity with the entity passed as a
- * parameter.
+ * parameter. Override to customize the update strategy - for instance to
+ * update specific fields only instead of a full merge.
*
* @param entity
*/
- public void updateEntity(T entity)
+ public void updateEntity(T entity, T2 id)
{
entityHome.merge(entity);
}
15 years
Seam SVN: r10642 - branches/community/Seam_2_1/build.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-04-25 15:45:30 -0400 (Sat, 25 Apr 2009)
New Revision: 10642
Modified:
branches/community/Seam_2_1/build/root.pom.xml
Log:
removed jettison exclusion (needed by resteasy-jaxb-provider during embedded container testing)
Modified: branches/community/Seam_2_1/build/root.pom.xml
===================================================================
--- branches/community/Seam_2_1/build/root.pom.xml 2009-04-25 18:14:11 UTC (rev 10641)
+++ branches/community/Seam_2_1/build/root.pom.xml 2009-04-25 19:45:30 UTC (rev 10642)
@@ -311,10 +311,6 @@
<artifactId>jaxb-impl</artifactId>
</exclusion>
<exclusion>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- </exclusion>
- <exclusion>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</exclusion>
@@ -350,10 +346,6 @@
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
- <exclusion>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- </exclusion>
</exclusions>
</dependency>
15 years
Seam SVN: r10641 - branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT.
by seam-commits@lists.jboss.org
Author: nico.ben
Date: 2009-04-25 14:14:11 -0400 (Sat, 25 Apr 2009)
New Revision: 10641
Modified:
branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Concepts.po
branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Events.po
Log:
JBSEAM-3767: Italian translation of Seam guide
Modified: branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Concepts.po
===================================================================
--- branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Concepts.po 2009-04-25 12:20:06 UTC (rev 10640)
+++ branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Concepts.po 2009-04-25 18:14:11 UTC (rev 10641)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2009-01-18 15:00+0000\n"
-"PO-Revision-Date: 2009-04-23 20:57+0100\n"
+"PO-Revision-Date: 2009-04-25 20:06+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -490,31 +490,31 @@
#: Concepts.xml:384
#, no-c-format
msgid "Entity bean components do not support bijection or context demarcation. Nor does invocation of an entity bean trigger validation."
-msgstr ""
+msgstr "I componenti entity bean non supportano la bijection o la demarcazione di contesto. E neppure l'invocazione della validazione dell'entity bean (trigger)."
#. Tag: para
#: Concepts.xml:388
#, no-c-format
msgid "Entity beans are not usually used as JSF action listeners, but do often function as backing beans that provide properties to JSF components for display or form submission. In particular, it is common to use an entity as a backing bean, together with a stateless session bean action listener to implement create/update/delete type functionality."
-msgstr ""
+msgstr "Gli entity bean non sono solitamente usati come action listener JSF, ma spesso funzionano come backing bean che forniscono proprietà ai componenti JSF per la visualizzazione o la sottomissione di una form. In particolare è comune usare un entity come backing bean, assieme ad un action listener bean di sessione stateless per implementare funzionalità di tipo crea/aggiorna/cancella."
#. Tag: para
#: Concepts.xml:394
#, no-c-format
msgid "By default, entity beans are bound to the conversation context. They may never be bound to the stateless context."
-msgstr ""
+msgstr "Di default gli entity bean sono associati al contesto conversazione. Non possono mai essere associati al contesto stateless."
#. Tag: para
#: Concepts.xml:398
#, no-c-format
msgid "Note that it in a clustered environment is somewhat less efficient to bind an entity bean directly to a conversation or session scoped Seam context variable than it would be to hold a reference to the entity bean in a stateful session bean. For this reason, not all Seam applications define entity beans to be Seam components."
-msgstr ""
+msgstr "Si noti che in un ambiente cluster è meno efficiente associare un entity bean direttamente ad una variabile di contesto con scope conversazione o sessione rispetto a come sarebbe mantenere un riferimento all'entity bean in un bean di sessione stateful. PEr questa ragione non tutte le applicazioni Seam definiscono entity bean come componenti Seam."
#. Tag: para
#: Concepts.xml:404
#, no-c-format
msgid "Seam entity bean components may be instantiated using <literal>Component.getInstance()</literal>, <literal>@In(create=true)</literal> or directly using the <literal>new</literal> operator."
-msgstr ""
+msgstr "I componenti entity bean di Seam possono essere istanziati usando <literal>Component.getInstance()</literal>, <literal>@In(create=true)</literal> o direttamente usando l'operatore <literal>new</literal>."
#. Tag: title
#: Concepts.xml:411
Modified: branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Events.po
===================================================================
--- branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Events.po 2009-04-25 12:20:06 UTC (rev 10640)
+++ branches/community/Seam_2_1/doc/Seam_Reference_Guide/it-IT/Events.po 2009-04-25 18:14:11 UTC (rev 10641)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2009-03-31 09:07+0000\n"
-"PO-Revision-Date: 2009-04-05 17:58+0100\n"
+"PO-Revision-Date: 2009-04-25 20:11+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -503,13 +503,13 @@
#: Events.xml:333
#, no-c-format
msgid "Conversion and Validation"
-msgstr ""
+msgstr "Conversione e validazione"
#. Tag: para
#: Events.xml:335
#, no-c-format
msgid "You can specify a JSF converter for complex model propreties:"
-msgstr ""
+msgstr "Si può specificare un convertitore JSF per proprietà di modelli complessi:"
#. Tag: programlisting
#: Events.xml:339
@@ -636,13 +636,13 @@
#: Events.xml:384
#, no-c-format
msgid "It is not possible to specify request parameters to be used when redirecting."
-msgstr ""
+msgstr "Non è possibile specificare i parametri di richiesta da usare in caso di redirection."
#. Tag: para
#: Events.xml:389
#, no-c-format
msgid "It is not possible to begin or end conversations from a rule."
-msgstr ""
+msgstr "Non è possibile iniziare o terminare le conversazione da una regola."
#. Tag: para
#: Events.xml:394
@@ -986,7 +986,7 @@
#: Events.xml:507
#, no-c-format
msgid "We specify event listeners (observers) in <literal>components.xml</literal>."
-msgstr ""
+msgstr "Si specificano gli event listener (observer) in <literal>components.xml</literal>."
#. Tag: programlisting
#: Events.xml:511
@@ -1010,7 +1010,7 @@
#: Events.xml:513
#, no-c-format
msgid "Where the <emphasis>event type</emphasis> is just an arbitrary string."
-msgstr ""
+msgstr "Dove il <emphasis>tipo di evento</emphasis> è solo una stringa arbitraria."
#. Tag: para
#: Events.xml:517
15 years
Seam SVN: r10640 - branches/community/Seam_2_1/build.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-04-25 08:20:06 -0400 (Sat, 25 Apr 2009)
New Revision: 10640
Modified:
branches/community/Seam_2_1/build/root.pom.xml
Log:
JBSEAM-3449 upgraded resteasy-jaxb-provider to 1.1-RC2
Modified: branches/community/Seam_2_1/build/root.pom.xml
===================================================================
--- branches/community/Seam_2_1/build/root.pom.xml 2009-04-25 06:28:36 UTC (rev 10639)
+++ branches/community/Seam_2_1/build/root.pom.xml 2009-04-25 12:20:06 UTC (rev 10640)
@@ -344,7 +344,7 @@
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
- <version>1.1-RC1</version>
+ <version>1.1-RC2</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
15 years
Seam SVN: r10639 - in modules/trunk/bpm: src/main/java/org/jboss/seam/bpm and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-25 02:28:36 -0400 (Sat, 25 Apr 2009)
New Revision: 10639
Added:
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/CreateProcessEvent.java
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndProcessEvent.java
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndTaskEvent.java
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitProcessEvent.java
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitTaskEvent.java
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/StartTaskEvent.java
Modified:
modules/trunk/bpm/pom.xml
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/BusinessProcess.java
modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/ManagedJbpmContext.java
Log:
added dependencies, bpm event types
Modified: modules/trunk/bpm/pom.xml
===================================================================
--- modules/trunk/bpm/pom.xml 2009-04-25 00:08:12 UTC (rev 10638)
+++ modules/trunk/bpm/pom.xml 2009-04-25 06:28:36 UTC (rev 10639)
@@ -26,7 +26,15 @@
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-jpdl</artifactId>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/BusinessProcess.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/BusinessProcess.java 2009-04-25 00:08:12 UTC (rev 10638)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/BusinessProcess.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -4,7 +4,15 @@
import javax.annotation.Named;
import javax.context.ConversationScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import org.jboss.seam.bpm.events.CreateProcessEvent;
+import org.jboss.seam.bpm.events.EndProcessEvent;
+import org.jboss.seam.bpm.events.EndTaskEvent;
+import org.jboss.seam.bpm.events.InitProcessEvent;
+import org.jboss.seam.bpm.events.InitTaskEvent;
+import org.jboss.seam.bpm.events.StartTaskEvent;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.international.StatusMessages;
import org.jbpm.graph.def.ProcessDefinition;
@@ -16,7 +24,7 @@
* and provides programmatic control over the business process.
*
* @author Gavin King
- *
+ * @author Shane Bryzak
*/
@Named
@ConversationScoped
@@ -24,18 +32,11 @@
{
private static final long serialVersionUID = 4722350870845851070L;
+ @Current Manager manager;
+
private Long processId;
private Long taskId;
- public static BusinessProcess instance()
- {
- if ( !Contexts.isConversationContextActive() )
- {
- throw new IllegalStateException("No active conversation context");
- }
- return (BusinessProcess) Component.getInstance(BusinessProcess.class, ScopeType.CONVERSATION);
- }
-
/**
* Is there a process instance associated with
* the current conversation?
@@ -151,7 +152,7 @@
process.signal();
}
- Events.instance().raiseEvent("org.jboss.seam.createProcess." + processDefinitionName);
+ manager.fireEvent(new CreateProcessEvent(processDefinitionName));
}
/**
@@ -172,7 +173,7 @@
task.start();
}
- Events.instance().raiseEvent("org.jboss.seam.startTask." + task.getTask().getName());
+ manager.fireEvent(new StartTaskEvent(task.getTask().getName()));
}
/**
@@ -206,11 +207,12 @@
setTaskId(null); //TODO: do I really need this???!
- Events.instance().raiseEvent("org.jboss.seam.endTask." + task.getTask().getName());
+ manager.fireEvent(new EndTaskEvent(task.getTask().getName()));
+
ProcessInstance process = org.jboss.seam.bpm.ProcessInstance.instance();
if ( process.hasEnded() )
{
- Events.instance().raiseEvent("org.jboss.seam.endProcess." + process.getProcessDefinition().getName());
+ manager.fireEvent(new EndProcessEvent(process.getProcessDefinition().getName()));
}
}
@@ -225,7 +227,7 @@
process.signal(transitionName);
if ( process.hasEnded() )
{
- Events.instance().raiseEvent("org.jboss.seam.endProcess." + process.getProcessDefinition().getName());
+ manager.fireEvent(new EndProcessEvent(process.getProcessDefinition().getName()));
}
}
@@ -253,7 +255,7 @@
else
{
setProcessId( task.getTaskMgmtInstance().getProcessInstance().getId() );
- Events.instance().raiseEvent("org.jboss.seam.initTask." + task.getTask().getName());
+ manager.fireEvent(new InitTaskEvent(task.getTask().getName()));
return true;
}
}
@@ -303,7 +305,7 @@
}
else
{
- Events.instance().raiseEvent("org.jboss.seam.initProcess." + process.getProcessDefinition().getName());
+ manager.fireEvent(new InitProcessEvent(process.getProcessDefinition().getName()));
return true;
}
}
@@ -322,7 +324,7 @@
}
else
{
- Events.instance().raiseEvent("org.jboss.seam.initProcess." + process.getProcessDefinition().getName());
+ manager.fireEvent(new InitProcessEvent(process.getProcessDefinition().getName()));
return true;
}
}
@@ -411,7 +413,6 @@
);
}
-
@Override
public String toString()
{
Modified: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/ManagedJbpmContext.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/ManagedJbpmContext.java 2009-04-25 00:08:12 UTC (rev 10638)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/ManagedJbpmContext.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -6,26 +6,19 @@
*/
package org.jboss.seam.bpm;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.inject.Initializer;
+import javax.inject.Produces;
import javax.naming.NamingException;
import javax.transaction.RollbackException;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Destroy;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Unwrap;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
import org.jboss.seam.transaction.Transaction;
import org.jboss.seam.transaction.UserTransaction;
import org.jbpm.JbpmContext;
@@ -38,10 +31,7 @@
* @author <a href="mailto:steve@hibernate.org">Steve Ebersole</a>
* @author Gavin King
*/
-(a)Scope(ScopeType.EVENT)
-@Name("org.jboss.seam.bpm.jbpmContext")
-@BypassInterceptors
-@Install(precedence=BUILT_IN, dependencies="org.jboss.seam.bpm.jbpm")
+@RequestScoped
public class ManagedJbpmContext implements Synchronization
{
private static final LogProvider log = Logging.getLogProvider(ManagedJbpmContext.class);
@@ -49,7 +39,7 @@
private JbpmContext jbpmContext;
private boolean synchronizationRegistered;
- @Create
+ @Initializer
public void create() throws NamingException, RollbackException, SystemException
{
jbpmContext = Jbpm.instance().getJbpmConfiguration().createJbpmContext();
@@ -67,7 +57,7 @@
}
}
- @Unwrap
+ @Produces
public JbpmContext getJbpmContext() throws NamingException, RollbackException, SystemException
{
joinTransaction();
@@ -132,7 +122,7 @@
}
}
- @Destroy
+ @PreDestroy
public void destroy()
{
if ( !synchronizationRegistered )
Added: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/CreateProcessEvent.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/CreateProcessEvent.java (rev 0)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/CreateProcessEvent.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -0,0 +1,21 @@
+package org.jboss.seam.bpm.events;
+
+/**
+ * This event is raised when a bpm process is created
+ *
+ * @author Shane Bryzak
+ */
+public class CreateProcessEvent
+{
+ private String processName;
+
+ public CreateProcessEvent(String processName)
+ {
+ this.processName = processName;
+ }
+
+ public String getProcessName()
+ {
+ return processName;
+ }
+}
Added: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndProcessEvent.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndProcessEvent.java (rev 0)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndProcessEvent.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -0,0 +1,22 @@
+package org.jboss.seam.bpm.events;
+
+/**
+ * This event is raised when a bpm process is ended
+ *
+ * @author Shane Bryzak
+ *
+ */
+public class EndProcessEvent
+{
+ private String processName;
+
+ public EndProcessEvent(String processName)
+ {
+ this.processName = processName;
+ }
+
+ public String getProcessName()
+ {
+ return processName;
+ }
+}
Added: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndTaskEvent.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndTaskEvent.java (rev 0)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/EndTaskEvent.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -0,0 +1,21 @@
+package org.jboss.seam.bpm.events;
+
+/**
+ * This event is raise when a bpm task ends
+ *
+ * @author Shane Bryzak
+ */
+public class EndTaskEvent
+{
+ private String taskName;
+
+ public EndTaskEvent(String taskName)
+ {
+ this.taskName = taskName;
+ }
+
+ public String getTaskName()
+ {
+ return taskName;
+ }
+}
Added: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitProcessEvent.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitProcessEvent.java (rev 0)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitProcessEvent.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -0,0 +1,21 @@
+package org.jboss.seam.bpm.events;
+
+/**
+ * This event is raised when a bpm process is initialized
+ *
+ * @author Shane Bryzak
+ */
+public class InitProcessEvent
+{
+ private String processName;
+
+ public InitProcessEvent(String processName)
+ {
+ this.processName = processName;
+ }
+
+ public String getProcessName()
+ {
+ return processName;
+ }
+}
Added: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitTaskEvent.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitTaskEvent.java (rev 0)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/InitTaskEvent.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -0,0 +1,21 @@
+package org.jboss.seam.bpm.events;
+
+/**
+ * This event is raised when a bpm task is initialized
+ *
+ * @author Shane Bryzak
+ */
+public class InitTaskEvent
+{
+ private String taskName;
+
+ public InitTaskEvent(String taskName)
+ {
+ this.taskName = taskName;
+ }
+
+ public String getTaskName()
+ {
+ return taskName;
+ }
+}
Added: modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/StartTaskEvent.java
===================================================================
--- modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/StartTaskEvent.java (rev 0)
+++ modules/trunk/bpm/src/main/java/org/jboss/seam/bpm/events/StartTaskEvent.java 2009-04-25 06:28:36 UTC (rev 10639)
@@ -0,0 +1,21 @@
+package org.jboss.seam.bpm.events;
+
+/**
+ * This event is raised when a bpm task is started
+ *
+ * @author Shane Bryzak
+ */
+public class StartTaskEvent
+{
+ private String taskName;
+
+ public StartTaskEvent(String taskName)
+ {
+ this.taskName = taskName;
+ }
+
+ public String getTaskName()
+ {
+ return taskName;
+ }
+}
15 years
Seam SVN: r10638 - in branches/community/Seam_2_1/examples/restbay: src/org/jboss/seam/example/restbay/resteasy and 1 other directories.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-04-24 20:08:12 -0400 (Fri, 24 Apr 2009)
New Revision: 10638
Added:
branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/Authenticator.java
branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java
branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
Modified:
branches/community/Seam_2_1/examples/restbay/resources/WEB-INF/components.xml
branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml
Log:
security test for restbay example
Modified: branches/community/Seam_2_1/examples/restbay/resources/WEB-INF/components.xml
===================================================================
--- branches/community/Seam_2_1/examples/restbay/resources/WEB-INF/components.xml 2009-04-24 23:28:28 UTC (rev 10637)
+++ branches/community/Seam_2_1/examples/restbay/resources/WEB-INF/components.xml 2009-04-25 00:08:12 UTC (rev 10638)
@@ -13,9 +13,9 @@
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
- http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.1.xsd
http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd
+ http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
http://jboss.com/products/seam/resteasy http://jboss.com/products/seam/resteasy-2.1.xsd
http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.1.xsd
http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd">
@@ -48,5 +48,10 @@
<resteasy:resource-query path="/configuredCategory" name="configuredCategoryResourceQuery"
entity-class="org.jboss.seam.example.restbay.Category"
media-types="application/xml application/json"/>
+
+ <web:authentication-filter url-pattern="/seam/resource/restv1/secured/*"
+ auth-type="basic" realm="Seam RestBay Application" />
+
+ <security:identity authenticate-method="#{authenticator.authenticate}" />
</components>
Added: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/Authenticator.java
===================================================================
--- branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/Authenticator.java (rev 0)
+++ branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/Authenticator.java 2009-04-25 00:08:12 UTC (rev 10638)
@@ -0,0 +1,39 @@
+package org.jboss.seam.example.restbay.resteasy;
+
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
+
+@Name("authenticator")
+(a)Scope(ScopeType.EVENT)
+public class Authenticator
+{
+
+ @In
+ private Identity identity;
+ @In
+ private Credentials credentials;
+ @Logger
+ private Log log;
+
+ public boolean authenticate()
+ {
+ if (credentials.getUsername().equals(credentials.getPassword())) {
+ log.info("Authenticated {0}", credentials.getUsername());
+
+ if (credentials.getUsername().equals("admin")) {
+ identity.addRole("admin");
+ log.info("Admin rights granted for {0}", credentials.getUsername());
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/Authenticator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java
===================================================================
--- branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java (rev 0)
+++ branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java 2009-04-25 00:08:12 UTC (rev 10638)
@@ -0,0 +1,46 @@
+package org.jboss.seam.example.restbay.resteasy;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.security.Identity;
+
+/**
+ *
+ * @author Jozef Hartinger
+ *
+ */
+
+@Path("/secured/resource")
+@Name("securedResource")
+@Produces("text/plain")
+public class SecuredResource
+{
+
+ @In
+ private Identity identity;
+
+ @GET
+ public String getHello()
+ {
+ return "Hello world!";
+ }
+
+ @GET
+ @Path("/admin")
+ public boolean isAdmin() {
+ return identity.hasRole("admin");
+ }
+
+ @GET
+ @Path("/restrictedAdmin")
+ @Restrict("#{s:hasRole('admin')}")
+ public boolean restrictedIsAdmin() {
+ return identity.hasRole("admin");
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
===================================================================
--- branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java (rev 0)
+++ branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java 2009-04-25 00:08:12 UTC (rev 10638)
@@ -0,0 +1,108 @@
+package org.jboss.seam.example.restbay.test;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jboss.seam.example.restbay.test.fwk.MockHttpServletRequest;
+import org.jboss.seam.example.restbay.test.fwk.MockHttpServletResponse;
+import org.jboss.seam.example.restbay.test.fwk.ResourceSeamTest;
+import org.testng.annotations.Test;
+
+/**
+ * This class tests RESTEasy integration with together with Seam Security
+ * @author Jozef Hartinger
+ *
+ */
+public class SecurityTest extends ResourceSeamTest
+{
+ @Test
+ public void basicAuthTest() throws Exception
+ {
+ new ResourceRequest(Method.GET, "/restv1/secured/resource/admin")
+ {
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "text/plain");
+ request.addHeader("Authorization", "BASIC ZGVtbzpkZW1v"); // demo:demo
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assertEquals(response.getContentAsString(), "false", "Unexpected response.");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void invalidCredentialsBasicAuthTest() throws Exception
+ {
+ new ResourceRequest(Method.GET, "/restv1/secured/resource")
+ {
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "text/plain");
+ request.addHeader("Authorization", "BASIC ZGVtbzpvbWVk"); // demo:omed
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ assertEquals(response.getStatus(), 403, "Unexpected response code.");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void adminRoleTest() throws Exception
+ {
+ new ResourceRequest(Method.GET, "/restv1/secured/resource/admin")
+ {
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "text/plain");
+ request.addHeader("Authorization", "BASIC YWRtaW46YWRtaW4="); // admin:admin
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assertEquals(response.getContentAsString(), "true");
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void adminRoleTestWithRestriction() throws Exception
+ {
+ new ResourceRequest(Method.GET, "/restv1/secured/resource/restrictedAdmin")
+ {
+ @Override
+ protected void prepareRequest(MockHttpServletRequest request)
+ {
+ super.prepareRequest(request);
+ request.addHeader("Accept", "text/plain");
+ request.addHeader("Authorization", "BASIC YWRtaW46YWRtaW4="); // admin:admin
+ }
+
+ @Override
+ protected void onResponse(MockHttpServletResponse response)
+ {
+ assertEquals(response.getStatus(), 200, "Unexpected response code.");
+ assertEquals(response.getContentAsString(), "true");
+ }
+
+ }.run();
+ }
+
+}
Property changes on: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml
===================================================================
--- branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml 2009-04-24 23:28:28 UTC (rev 10637)
+++ branches/community/Seam_2_1/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml 2009-04-25 00:08:12 UTC (rev 10638)
@@ -25,4 +25,10 @@
<class name="org.jboss.seam.example.restbay.test.ResourceQueryTest"/>
</classes>
</test>
+
+ <!-- <test name="RestBay: Security">
+ <classes>
+ <class name="org.jboss.seam.example.restbay.test.SecurityTest"/>
+ </classes>
+ </test>-->
</suite>
\ No newline at end of file
15 years
Seam SVN: r10637 - modules/trunk/faces/src/main/java/org/jboss/seam/faces.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-24 19:28:28 -0400 (Fri, 24 Apr 2009)
New Revision: 10637
Added:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java
Removed:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContext.java
Log:
renamed FacesContext to FacesContextProducer
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContext.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContext.java 2009-04-24 23:27:35 UTC (rev 10636)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContext.java 2009-04-24 23:28:28 UTC (rev 10637)
@@ -1,29 +0,0 @@
-//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
-package org.jboss.seam.faces;
-
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Unwrap;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-
-/**
- * Support for injecting the JSF FacesContext object
- *
- * @author Gavin King
- */
-(a)Scope(ScopeType.APPLICATION)
-@BypassInterceptors
-@Name("org.jboss.seam.faces.facesContext")
-@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-public class FacesContext
-{
- @Unwrap
- public javax.faces.context.FacesContext getContext()
- {
- return javax.faces.context.FacesContext.getCurrentInstance();
- }
-}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java 2009-04-24 23:28:28 UTC (rev 10637)
@@ -0,0 +1,21 @@
+//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
+package org.jboss.seam.faces;
+
+import javax.annotation.Named;
+import javax.context.ApplicationScoped;
+import javax.inject.Produces;
+import javax.faces.context.FacesContext;
+
+/**
+ * Support for injecting the JSF FacesContext object
+ *
+ * @author Gavin King
+ */
+@ApplicationScoped
+public class FacesContextProducer
+{
+ @Produces @Named public FacesContext getContext()
+ {
+ return FacesContext.getCurrentInstance();
+ }
+}
15 years
Seam SVN: r10636 - in modules/trunk/security: src/main/java/org/jboss/seam/security/management and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-24 19:27:35 -0400 (Fri, 24 Apr 2009)
New Revision: 10636
Modified:
modules/trunk/security/pom.xml
modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/PasswordHash.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ClassIdentifierStrategy.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/IdentifierPolicy.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionManager.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMetadata.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ResolverChain.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Log:
more porting of security module
Modified: modules/trunk/security/pom.xml
===================================================================
--- modules/trunk/security/pom.xml 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/pom.xml 2009-04-24 23:27:35 UTC (rev 10636)
@@ -31,6 +31,11 @@
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-drools</artifactId>
+ </dependency>
+
</dependencies>
</project>
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -31,9 +31,6 @@
import org.jboss.seam.security.annotations.management.UserPassword;
import org.jboss.seam.security.annotations.management.UserPrincipal;
import org.jboss.seam.security.annotations.management.UserRoles;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Expressions;
-import org.jboss.seam.core.Expressions.ValueExpression;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.seam.security.Identity;
@@ -63,7 +60,9 @@
private ValueExpression<EntityManager> entityManager;
private Bean<EntityManager> entityManagerBean;
+
@Current Manager manager;
+ @Current PasswordHash passwordHash;
private Class<?> userClass;
private Class<?> roleClass;
@@ -271,7 +270,7 @@
*/
public byte[] generateUserSalt(Object user)
{
- return PasswordHash.instance().generateRandomSalt();
+ return passwordHash.generateRandomSalt();
}
public boolean createUser(String username, String password)
@@ -744,7 +743,7 @@
{
try
{
- return PasswordHash.instance().createPasswordKey(password.toCharArray(), salt,
+ return passwordHash.createPasswordKey(password.toCharArray(), salt,
userPasswordProperty.getAnnotation().iterations());
}
catch (GeneralSecurityException ex)
@@ -771,11 +770,11 @@
{
if (salt == null || "".equals(salt))
{
- return PasswordHash.instance().generateHash(password);
+ return passwordHash.generateHash(password);
}
else
{
- return PasswordHash.instance().generateSaltedHash(password, salt);
+ return passwordHash.generateSaltedHash(password, salt);
}
}
else if ("none".equalsIgnoreCase(algorithm))
@@ -786,11 +785,11 @@
{
if (salt == null || "".equals(salt))
{
- return PasswordHash.instance().generateHash(password, algorithm);
+ return passwordHash.generateHash(password, algorithm);
}
else
{
- return PasswordHash.instance().generateSaltedHash(password, salt, algorithm);
+ return passwordHash.generateSaltedHash(password, salt, algorithm);
}
}
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/PasswordHash.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/PasswordHash.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/PasswordHash.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -1,37 +1,28 @@
package org.jboss.seam.security.management;
-import static org.jboss.seam.ScopeType.STATELESS;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.SecureRandom;
+import javax.annotation.Named;
+import javax.context.Dependent;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.security.crypto.BinTools;
import org.jboss.seam.security.crypto.PBKDF2;
import org.jboss.seam.security.crypto.PBKDF2Engine;
import org.jboss.seam.security.crypto.PBKDF2Parameters;
-import org.jboss.seam.util.Base64;
+import org.jboss.seam.security.util.Base64;
/**
* Password hashing utility functions
*
* @author Shane Bryzak
*/
-@Scope(STATELESS)
-@Name("org.jboss.seam.security.passwordHash")
-@Install(precedence = BUILT_IN)
-@BypassInterceptors
+@Named
+@Dependent
public class PasswordHash
{
public static final String ALGORITHM_MD5 = "MD5";
@@ -127,11 +118,6 @@
}
}
- public static PasswordHash instance()
- {
- return (PasswordHash) Component.getInstance(PasswordHash.class, ScopeType.STATELESS);
- }
-
public String getHashAlgorithm()
{
return hashAlgorithm;
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ClassIdentifierStrategy.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ClassIdentifierStrategy.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ClassIdentifierStrategy.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -3,14 +3,16 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.security.permission.Identifier;
+import javax.context.Dependent;
+import org.jboss.seam.security.annotations.permission.Identifier;
+
/**
* An Identifier strategy for class-based permission checks
*
* @author Shane Bryzak
*/
+@Dependent
public class ClassIdentifierStrategy implements IdentifierStrategy
{
private Map<Class,String> identifierNames = new ConcurrentHashMap<Class,String>();
@@ -47,11 +49,6 @@
if (name == null)
{
- name = Seam.getComponentName(cls);
- }
-
- if (name == null)
- {
name = cls.getName().substring(cls.getName().lastIndexOf('.') + 1);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -3,22 +3,22 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import javax.context.Dependent;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
-import org.jboss.seam.Component;
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.security.permission.Identifier;
+import org.jboss.seam.security.annotations.permission.Identifier;
import org.jboss.seam.core.Expressions;
import org.jboss.seam.core.Expressions.ValueExpression;
import org.jboss.seam.persistence.PersistenceProvider;
-import org.jboss.seam.util.Strings;
+import org.jboss.seam.security.util.Strings;
/**
* An Identifier strategy for entity-based permission checks
*
* @author Shane Bryzak
*/
+@Dependent
public class EntityIdentifierStrategy implements IdentifierStrategy
{
private ValueExpression<EntityManager> entityManager;
@@ -63,14 +63,9 @@
name = identifier.name();
}
}
-
+
if (name == null)
{
- name = Seam.getComponentName(cls);
- }
-
- if (name == null)
- {
name = cls.getName().substring(cls.getName().lastIndexOf('.') + 1);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/IdentifierPolicy.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/IdentifierPolicy.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/IdentifierPolicy.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -1,19 +1,15 @@
package org.jboss.seam.security.permission;
-import static org.jboss.seam.ScopeType.APPLICATION;
-
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.annotations.security.permission.Identifier;
+import javax.context.ApplicationScoped;
+import javax.inject.Initializer;
+import org.jboss.seam.security.annotations.permission.Identifier;
+
/**
* A policy for the generation of object "identifiers" - unique Strings that identify a specific
* instance of an object. A policy can consist of numerous identifier strategies, each with the
@@ -21,17 +17,14 @@
*
* @author Shane Bryzak
*/
-@Name("org.jboss.seam.security.identifierPolicy")
-@Scope(APPLICATION)
-@BypassInterceptors
-@Install(precedence = Install.BUILT_IN)
+@ApplicationScoped
public class IdentifierPolicy
{
private Map<Class,IdentifierStrategy> strategies = new ConcurrentHashMap<Class,IdentifierStrategy>();
private Set<IdentifierStrategy> registeredStrategies = new HashSet<IdentifierStrategy>();
- @Create
+ @Initializer
public void create()
{
if (registeredStrategies.isEmpty())
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionManager.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionManager.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionManager.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -1,21 +1,14 @@
package org.jboss.seam.security.permission;
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
import java.io.Serializable;
import java.util.List;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import javax.annotation.Named;
+import javax.inject.Current;
+
import org.jboss.seam.security.Identity;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
/**
* Permission management component, used to grant or revoke permissions on specific objects or of
@@ -23,56 +16,20 @@
*
* @author Shane Bryzak
*/
-@Scope(APPLICATION)
-@Name("org.jboss.seam.security.permissionManager")
-@Install(precedence = BUILT_IN)
+@Named
public class PermissionManager implements Serializable
{
- public static final String PERMISSION_STORE_COMPONENT_NAME = "org.jboss.seam.security.jpaPermissionStore";
+ private static final long serialVersionUID = -2694925751585231813L;
- public static final String PERMISSION_PERMISSION_NAME = "seam.permission";
-
public static final String PERMISSION_READ = "seam.read-permissions";
public static final String PERMISSION_GRANT = "seam.grant-permission";
public static final String PERMISSION_REVOKE = "seam.revoke-permission";
private static final LogProvider log = Logging.getLogProvider(PermissionManager.class);
- private PermissionStore permissionStore;
-
- @Create
- public void create()
- {
- if (permissionStore == null)
- {
- permissionStore = (PermissionStore) Component.getInstance(PERMISSION_STORE_COMPONENT_NAME, true);
- }
-
- if (permissionStore == null)
- {
- log.warn("no permission store available - please install a PermissionStore with the name '" +
- PERMISSION_STORE_COMPONENT_NAME + "' if permission management is required.");
- }
- }
-
- public static PermissionManager instance()
- {
- if ( !Contexts.isApplicationContextActive() )
- {
- throw new IllegalStateException("No active application context");
- }
-
- PermissionManager instance = (PermissionManager) Component.getInstance(
- PermissionManager.class, ScopeType.APPLICATION);
-
- if (instance == null)
- {
- throw new IllegalStateException("No PermissionManager could be created");
- }
-
- return instance;
- }
-
+ @Current PermissionStore permissionStore;
+ @Current Identity identity;
+
public PermissionStore getPermissionStore()
{
return permissionStore;
@@ -86,20 +43,20 @@
public List<Permission> listPermissions(Object target, String action)
{
if (target == null) return null;
- Identity.instance().checkPermission(target, PERMISSION_READ);
+ identity.checkPermission(target, PERMISSION_READ);
return permissionStore.listPermissions(target, action);
}
public List<Permission> listPermissions(Object target)
{
if (target == null) return null;
- Identity.instance().checkPermission(target, PERMISSION_READ);
+ identity.checkPermission(target, PERMISSION_READ);
return permissionStore.listPermissions(target);
}
public boolean grantPermission(Permission permission)
{
- Identity.instance().checkPermission(permission.getTarget(), PERMISSION_GRANT);
+ identity.checkPermission(permission.getTarget(), PERMISSION_GRANT);
return permissionStore.grantPermission(permission);
}
@@ -107,14 +64,14 @@
{
for (Permission permission : permissions)
{
- Identity.instance().checkPermission(permission.getTarget(), PERMISSION_GRANT);
+ identity.checkPermission(permission.getTarget(), PERMISSION_GRANT);
}
return permissionStore.grantPermissions(permissions);
}
public boolean revokePermission(Permission permission)
{
- Identity.instance().checkPermission(permission.getTarget(), PERMISSION_REVOKE);
+ identity.checkPermission(permission.getTarget(), PERMISSION_REVOKE);
return permissionStore.revokePermission(permission);
}
@@ -122,7 +79,7 @@
{
for (Permission permission : permissions)
{
- Identity.instance().checkPermission(permission.getTarget(), PERMISSION_REVOKE);
+ identity.checkPermission(permission.getTarget(), PERMISSION_REVOKE);
}
return permissionStore.revokePermissions(permissions);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -1,8 +1,5 @@
package org.jboss.seam.security.permission;
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
@@ -10,27 +7,14 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Events;
-import org.jboss.seam.core.Init;
+import javax.context.ApplicationScoped;
/**
* Maps permission checks to resolver chains
*
* @author Shane Bryzak
*/
-@Scope(APPLICATION)
-@Name("org.jboss.seam.security.permissionMapper")
-@Install(precedence = BUILT_IN)
-@BypassInterceptors
-@Startup
+@ApplicationScoped
public class PermissionMapper implements Serializable
{
public static final String DEFAULT_RESOLVER_CHAIN_CREATED = "org.jboss.seam.security.defaultResolverChainCreated";
@@ -168,22 +152,4 @@
return chain;
}
-
- public static PermissionMapper instance()
- {
- if ( !Contexts.isApplicationContextActive() )
- {
- throw new IllegalStateException("No active application context");
- }
-
- PermissionMapper instance = (PermissionMapper) Component.getInstance(
- PermissionMapper.class, ScopeType.APPLICATION);
-
- if (instance == null)
- {
- throw new IllegalStateException("No PermissionMapper could be created");
- }
-
- return instance;
- }
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMetadata.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMetadata.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMetadata.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -7,7 +7,7 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.seam.annotations.security.permission.Permissions;
+import org.jboss.seam.security.annotations.permission.Permissions;
/**
* Permission actions can either be persisted as a comma-separated list of values, or as a
@@ -33,10 +33,10 @@
Permissions p = (Permissions) cls.getAnnotation(Permissions.class);
if (p != null)
{
- org.jboss.seam.annotations.security.permission.Permission[] permissions = p.value();
+ org.jboss.seam.security.annotations.permission.Permission[] permissions = p.value();
if (permissions != null)
{
- for (org.jboss.seam.annotations.security.permission.Permission permission : permissions)
+ for (org.jboss.seam.security.annotations.permission.Permission permission : permissions)
{
actions.put(permission.action(), permission.mask());
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -1,23 +1,16 @@
package org.jboss.seam.security.permission;
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.jboss.seam.Component;
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import javax.inject.Current;
+import javax.inject.Initializer;
+import javax.inject.manager.Manager;
+
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.Role;
import org.jboss.seam.security.SimplePrincipal;
@@ -28,34 +21,28 @@
*
* @author Shane Bryzak
*/
-@Name("org.jboss.seam.security.persistentPermissionResolver")
-@Scope(APPLICATION)
-@BypassInterceptors
-@Install(precedence=BUILT_IN)
-@Startup
public class PersistentPermissionResolver implements PermissionResolver, Serializable
{
+ private static final long serialVersionUID = -603389172032219059L;
+
private PermissionStore permissionStore;
- private static final LogProvider log = Logging.getLogProvider(PersistentPermissionResolver.class);
+ private static final LogProvider log = Logging.getLogProvider(PersistentPermissionResolver.class);
- @Create
- public void create()
+ @Current Manager manager;
+ @Current Identity identity;
+
+ @Initializer
+ public void initPermissionStore()
{
- initPermissionStore();
- }
-
- protected void initPermissionStore()
- {
if (permissionStore == null)
- {
- permissionStore = (PermissionStore) Component.getInstance(JpaPermissionStore.class, true);
+ {
+ permissionStore = manager.getInstanceByType(JpaPermissionStore.class);
}
if (permissionStore == null)
{
- log.warn("no permission store available - please install a PermissionStore with the name '" +
- Seam.getComponentName(JpaPermissionStore.class) + "' if persistent permissions are required.");
+ log.warn("no permission store available - please install a PermissionStore if persistent permissions are required.");
}
}
@@ -72,9 +59,7 @@
public boolean hasPermission(Object target, String action)
{
if (permissionStore == null) return false;
-
- Identity identity = Identity.instance();
-
+
if (!identity.isLoggedIn()) return false;
List<Permission> permissions = permissionStore.listPermissions(target, action);
@@ -112,7 +97,6 @@
{
if (permissionStore == null) return;
- Identity identity = Identity.instance();
if (!identity.isLoggedIn()) return;
List<Permission> permissions = permissionStore.listPermissions(targets, action);
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ResolverChain.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ResolverChain.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ResolverChain.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -1,13 +1,10 @@
package org.jboss.seam.security.permission;
-import static org.jboss.seam.ScopeType.SESSION;
-
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import javax.context.SessionScoped;
/**
* A chain of permission resolvers. Specific permission checks are generally mapped to a
@@ -15,10 +12,11 @@
*
* @author Shane Bryzak
*/
-@Scope(SESSION)
-@BypassInterceptors
+@SessionScoped
public class ResolverChain implements Serializable
{
+ private static final long serialVersionUID = 4395507285094476740L;
+
private List<PermissionResolver> resolvers = new ArrayList<PermissionResolver>();
public List<PermissionResolver> getResolvers()
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2009-04-24 23:27:12 UTC (rev 10635)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2009-04-24 23:27:35 UTC (rev 10636)
@@ -12,26 +12,22 @@
import java.util.List;
import java.util.Set;
+import javax.context.SessionScoped;
+import javax.event.Observes;
+import javax.inject.manager.Initialized;
+
import org.drools.FactHandle;
import org.drools.RuleBase;
import org.drools.StatefulSession;
import org.drools.base.ClassObjectFilter;
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.drools.SeamGlobalResolver;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.Role;
+import org.jboss.seam.security.events.LoggedOutEvent;
+import org.jboss.seam.security.events.PostAuthenticateEvent;
import org.jboss.seam.security.management.JpaIdentityStore;
/**
@@ -39,11 +35,7 @@
*
* @author Shane Bryzak
*/
-@Name("org.jboss.seam.security.ruleBasedPermissionResolver")
-@Scope(SESSION)
-@BypassInterceptors
-@Install(precedence=BUILT_IN, classDependencies="org.drools.WorkingMemory")
-@Startup
+@SessionScoped
public class RuleBasedPermissionResolver implements PermissionResolver, Serializable
{
public static final String RULES_COMPONENT_NAME = "securityRules";
@@ -54,7 +46,9 @@
private RuleBase securityRules;
- @Create
+ @Current Identity identity;
+
+ @Initialized
public boolean create()
{
initSecurityContext();
@@ -202,8 +196,7 @@
}
@SuppressWarnings("unchecked")
- @Observer(Identity.EVENT_LOGGED_OUT)
- public void unAuthenticate()
+ public void unAuthenticate(@Observes LoggedOutEvent event)
{
if (getSecurityContext() != null)
{
@@ -217,9 +210,7 @@
* Synchronises the state of the security context with that of the subject
*/
private void synchronizeContext()
- {
- Identity identity = Identity.instance();
-
+ {
if (getSecurityContext() != null)
{
getSecurityContext().insert(identity.getPrincipal());
@@ -310,12 +301,11 @@
/**
* Post-authentication event observer
*/
- @Observer(Identity.EVENT_POST_AUTHENTICATE)
- public void setUserAccountInSecurityContext()
+ public void setUserAccountInSecurityContext(@Observes PostAuthenticateEvent event)
{
if (getSecurityContext() != null)
{
- getSecurityContext().insert(Identity.instance().getPrincipal());
+ getSecurityContext().insert(identity.getPrincipal());
// If we were authenticated with the JpaIdentityStore, then insert the authenticated
// UserAccount into the security context.
15 years