Seam SVN: r10997 - modules/trunk/international.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 12:26:13 -0400 (Tue, 26 May 2009)
New Revision: 10997
Modified:
modules/trunk/international/
Log:
ignore attic
Property changes on: modules/trunk/international
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
nb-configuration.xml
target
temp-testng-customsuite.xml
test-output
+ .classpath
.project
.settings
attic
nb-configuration.xml
target
temp-testng-customsuite.xml
test-output
15 years, 6 months
Seam SVN: r10995 - modules/trunk/faces.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 12:25:21 -0400 (Tue, 26 May 2009)
New Revision: 10995
Modified:
modules/trunk/faces/
Log:
ignore attic folder
Property changes on: modules/trunk/faces
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
nb-configuration.xml
target
temp-testng-customsuite.xml
test-output
+ .classpath
.project
.settings
attic
nb-configuration.xml
target
temp-testng-customsuite.xml
test-output
15 years, 6 months
Seam SVN: r10994 - modules/trunk/faces.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 12:24:39 -0400 (Tue, 26 May 2009)
New Revision: 10994
Removed:
modules/trunk/faces/attic/
Log:
nuke
15 years, 6 months
Seam SVN: r10993 - in modules/trunk: bridge-api/src/main/java/org/jboss/seam/bridge/spi and 24 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 12:23:09 -0400 (Tue, 26 May 2009)
New Revision: 10993
Added:
modules/trunk/faces/attic/
modules/trunk/faces/attic/DataModels.java
modules/trunk/faces/attic/DateConverter.java
modules/trunk/faces/attic/FacesContextProducer.java
modules/trunk/faces/attic/FacesExpressions.java
modules/trunk/faces/attic/FacesManager.java
modules/trunk/faces/attic/FacesMessages.java
modules/trunk/faces/attic/FacesPage.java
modules/trunk/faces/attic/HttpError.java
modules/trunk/faces/attic/IsUserInRole.java
modules/trunk/faces/attic/Navigator.java
modules/trunk/faces/attic/Parameters.java
modules/trunk/faces/attic/Redirect.java
modules/trunk/faces/attic/RedirectException.java
modules/trunk/faces/attic/Renderer.java
modules/trunk/faces/attic/ResourceLoader.java
modules/trunk/faces/attic/Selector.java
modules/trunk/faces/attic/Switcher.java
modules/trunk/faces/attic/UiComponent.java
modules/trunk/faces/attic/UserPrincipal.java
modules/trunk/faces/attic/Validation.java
modules/trunk/international/attic/
modules/trunk/international/attic/LocaleSelector.java
modules/trunk/international/attic/ResourceBundleProducer.java
modules/trunk/international/attic/SeamResourceBundle.java
modules/trunk/international/attic/TimeZoneSelector.java
Modified:
modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java
modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleAgent.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.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/faces/src/main/java/org/jboss/seam/faces/Faces.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/AfterPhase.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/BeforePhase.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ManagedSeamPhaseListener.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/Transaction.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java
modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java
modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java
modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java
modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java
modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java
modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java
modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZones.java
modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java
modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java
modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java
modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java
modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java
modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java
modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java
modules/trunk/security/src/main/java/org/jboss/seam/security/RequestSecurityState.java
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStoreEntityClasses.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStoreConfig.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/PasswordHash.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.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/JpaPermissionStore.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/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
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java
modules/trunk/web/src/main/java/org/jboss/seam/web/HttpSessionManager.java
modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java
modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java
Log:
reflect package changes in JSR-299 API
Modified: modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java
===================================================================
--- modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,8 +1,8 @@
package org.jboss.seam.bridge;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.BeanManager;
import javax.event.Observes;
-import javax.inject.manager.Deployed;
-import javax.inject.manager.Manager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.webbeans.log.LogProvider;
@@ -27,7 +27,7 @@
// QUESTION: should this be a String, Class, or instance?
private Class<? extends ManagerProviderResolver> resolverClass = ServiceLoaderManagerProviderResolver.class;
- private static Class<? extends Manager> managerImplClass;
+ private static Class<? extends BeanManager> managerImplClass;
public Class<? extends ManagerProviderResolver> getResolverClass()
{
@@ -89,7 +89,7 @@
*
* @param manager The deployed Manager instance
*/
- public void onManagerDeployed(@Observes @Deployed Manager manager)
+ public void onManagerDeployed(@Observes @AfterBeanDiscovery BeanManager manager)
{
// intended for a mock environment, skip discovery
if (!discover)
Modified: modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java
===================================================================
--- modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,7 +1,8 @@
package org.jboss.seam.bridge.spi;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.spi.BeanManager;
+
/**
* A contract between the provider engine and the JCDI bootstrap mechanism to
* return the current Manager instance.
@@ -10,5 +11,5 @@
*/
public interface ManagerProvider
{
- Manager getCurrentManager();
+ BeanManager getCurrentManager();
}
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -2,7 +2,7 @@
import static org.testng.Assert.assertSame;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.testng.annotations.Test;
@@ -33,7 +33,7 @@
class MockManagerProvider implements ManagerProvider
{
- public Manager getCurrentManager()
+ public BeanManager getCurrentManager()
{
return null;
}
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,8 +3,8 @@
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
-import javax.context.RequestScoped;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.seam.bridge.stubs.ManagerProviderStub;
@@ -45,7 +45,7 @@
ManagerProvider provider = ManagerBridge.getProvider();
assertTrue(provider instanceof ManagerProviderStub);
assertSame(provider.getCurrentManager(), getCurrentManager());
- Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
+ BeanManager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
assertSame(provider.getCurrentManager(), currentManager);
}
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,8 +3,8 @@
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
-import javax.context.RequestScoped;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.seam.bridge.stubs.IncorrectManagerProviderResolverStub;
@@ -49,7 +49,7 @@
ManagerProvider provider = ManagerBridge.getProvider();
assertTrue(provider instanceof ManagerProviderStub);
assertSame(provider.getCurrentManager(), getCurrentManager());
- Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
+ BeanManager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
assertSame(provider.getCurrentManager(), currentManager);
}
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,6 +1,6 @@
package org.jboss.seam.bridge.stubs;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.webbeans.CurrentManager;
@@ -11,7 +11,7 @@
/**
* Just return something bogus.
*/
- public Manager getCurrentManager()
+ public BeanManager getCurrentManager()
{
return ManagerImpl.newChildManager(CurrentManager.rootManager());
}
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,13 +1,13 @@
package org.jboss.seam.bridge.stubs;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.webbeans.CurrentManager;
public class ManagerProviderStub implements ManagerProvider
{
- public Manager getCurrentManager()
+ public BeanManager getCurrentManager()
{
return CurrentManager.rootManager().getCurrent();
}
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,15 +3,14 @@
import java.io.Serializable;
import javax.annotation.PreDestroy;
-import javax.context.ConversationScoped;
-import javax.inject.Current;
-import javax.inject.Produces;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
import org.drools.RuleBase;
import org.drools.StatefulSession;
import org.drools.spi.GlobalResolver;
-//import org.jboss.seam.core.Mutable;
import org.jboss.seam.el.Expressions.ValueExpression;
/**
@@ -30,7 +29,7 @@
private StatefulSession statefulSession;
private ValueExpression<RuleBase> ruleBase;
- @Current Manager manager;
+ @Current BeanManager manager;
public boolean clearDirty()
{
@@ -81,7 +80,7 @@
}
else if (ruleBaseName!=null)
{
- //deprecated stuff
+ //deprecated stuff
ruleBase = (RuleBase) manager.getInstanceByName(ruleBaseName);
}
else
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleAgent.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleAgent.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleAgent.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,9 +4,9 @@
import java.io.InputStream;
import java.util.Properties;
-import javax.context.ApplicationScoped;
-import javax.inject.Initializer;
-import javax.inject.Produces;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Produces;
import org.jboss.seam.drools.util.Resources;
import org.jboss.webbeans.log.LogProvider;
@@ -21,7 +21,7 @@
private static final LogProvider log = Logging.getLogProvider(RuleAgent.class);
private org.drools.agent.RuleAgent agent;
- private String configurationFile;
+ private String configurationFile;
private String newInstance;
private String files;
@@ -32,13 +32,13 @@
@Initializer
public void createAgent() throws Exception
- {
+ {
Properties properties = new Properties();
loadFromPath(properties, configurationFile);
setLocalProperties(properties);
- agent = org.drools.agent.RuleAgent.newRuleAgent(properties);
+ agent = org.drools.agent.RuleAgent.newRuleAgent(properties);
log.debug("Creating new rules agent");
}
@@ -75,7 +75,7 @@
properties.load(inputStream);
} finally {
inputStream.close();
- }
+ }
}
}
}
@@ -83,7 +83,7 @@
@Produces
public org.drools.RuleBase getRuleBase()
{
- return agent.getRuleBase();
+ return agent.getRuleBase();
}
public String getNewInstance()
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,10 +4,10 @@
import java.io.InputStreamReader;
import java.io.Reader;
-import javax.context.ApplicationScoped;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.Produces;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Produces;
import javax.servlet.ServletContext;
import org.drools.RuleBaseFactory;
@@ -57,7 +57,7 @@
if (dslFile==null)
{
- builder.addPackageFromDrl(drlReader);
+ builder.addPackageFromDrl(drlReader);
}
else
{
@@ -67,17 +67,17 @@
if ( builder.hasErrors() )
{
- log.error("errors parsing rules in: " + ruleFile);
+ log.error("errors parsing rules in: " + ruleFile);
for ( DroolsError error: builder.getErrors().getErrors() )
{
if (error instanceof RuleError)
{
RuleError ruleError = (RuleError) error;
- log.error( ruleError.getMessage() + " (" + ruleFile + ':' + ruleError.getLine() + ')' );
+ log.error( ruleError.getMessage() + " (" + ruleFile + ':' + ruleError.getLine() + ')' );
}
else
{
- log.error( error.getMessage() + " (" + ruleFile + ')' );
+ log.error( error.getMessage() + " (" + ruleFile + ')' );
}
}
}
@@ -118,5 +118,5 @@
public InputStream getResourceAsStream(String resource)
{
return Resources.getResourceAsStream( resource, servletContext );
- }
+ }
}
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
@@ -25,9 +25,9 @@
import java.io.Serializable;
-import javax.context.ApplicationScoped;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
+import javax.enterprise.context.ApplicationScoped;
/**
* Factory for EL method and value expressions.
@@ -134,7 +134,7 @@
* Create a value expression.
*
* @param expression a JBoss EL value expression
- * @param type the type of the value
+ * @param type the type of the value
*/
public <T> ValueExpression<T> createValueExpression(final String expression, final Class<T> type)
{
@@ -173,7 +173,7 @@
public T getValue()
{
return (T) toUnifiedValueExpression().getValue( getELContext() );
- }
+ }
public void setValue(T value)
{
@@ -189,7 +189,7 @@
public Class<T> getType()
{
// QUESTION shouldn't we use the type provided in the constructor?
- return (Class<T>) toUnifiedValueExpression().getType( getELContext() );
+ return toUnifiedValueExpression().getType( getELContext() );
}
};
@@ -271,7 +271,7 @@
/**
* A method expression - an EL expression that evaluates to
- * a method. This interface is just a genericized version of
+ * a method. This interface is just a genericized version of
* the Unified EL ValueExpression interface.
*
* @author Gavin King
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/JBossELReferenceCache.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
@@ -24,22 +24,22 @@
package org.jboss.seam.el;
import javax.annotation.PreDestroy;
-import javax.context.ApplicationScoped;
-import javax.inject.Initializer;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Initializer;
import org.jboss.el.util.ReflectionUtil;
@ApplicationScoped
-public class JBossELReferenceCache
+public class JBossELReferenceCache
{
@Initializer
- public void start()
+ public void start()
{
ReflectionUtil.startup();
}
@PreDestroy
- public void stop()
+ public void stop()
{
ReflectionUtil.shutdown();
}
Added: modules/trunk/faces/attic/DataModels.java
===================================================================
--- modules/trunk/faces/attic/DataModels.java (rev 0)
+++ modules/trunk/faces/attic/DataModels.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,59 @@
+package org.jboss.seam.faces;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.model.DataModel;
+import org.jboss.seam.faces.model.ArrayDataModel;
+import org.jboss.seam.faces.model.ListDataModel;
+import org.jboss.seam.faces.model.MapDataModel;
+import org.jboss.seam.faces.model.SetDataModel;
+
+//import org.jboss.seam.framework.Query;
+/**
+ * Wraps a collection as a JSF {@link DataModel}. May be overridden
+ * and extended if you don't like the built in collections
+ * which are supported: list, map, set, array.
+ *
+ * @author pmuir
+ */
+public class DataModels
+{
+ /**
+ * Wrap the value in a DataModel
+ *
+ * This implementation supports {@link List}, {@link Map}, {@link Set} and
+ * arrays
+ */
+ public DataModel getDataModel(Object value)
+ {
+ if (value instanceof List)
+ {
+ return new ListDataModel((List) value);
+ }
+ else if (value instanceof Object[])
+ {
+ return new ArrayDataModel((Object[]) value);
+ }
+ else if (value instanceof Map)
+ {
+ return new MapDataModel((Map) value);
+ }
+ else if (value instanceof Set)
+ {
+ return new SetDataModel((Set) value);
+ }
+ else
+ {
+ throw new IllegalArgumentException("unknown collection type: " + value.getClass());
+ }
+ }
+ /**
+ * Wrap the the Seam Framework {@link Query} in a JSF DataModel
+ */
+// public DataModel getDataModel(Query query)
+// {
+// return getDataModel( query.getResultList() );
+// }
+}
Added: modules/trunk/faces/attic/DateConverter.java
===================================================================
--- modules/trunk/faces/attic/DateConverter.java (rev 0)
+++ modules/trunk/faces/attic/DateConverter.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,120 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.ConverterException;
+
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.faces.Converter;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.log.Logging;
+
+/**
+ * Provides a default JSF converter for properties of type java.util.Date.
+ *
+ * <p>This converter is provided to save a developer from having to specify
+ * a DateTimeConverter on an input field or page parameter. By default, it
+ * assumes the type to be a date (as opposed to a time or date plus time) and
+ * uses the short input style adjusted to the Locale of the user. For Locale.US,
+ * the input pattern is mm/DD/yy. However, to comply with Y2K, the year is changed
+ * from two digits to four (e.g., mm/DD/yyyy).</p>
+ * <p>It's possible to override the input pattern globally using component configuration.
+ * Here is an example of changing the style to both and setting the date and
+ * time style to medium.</p>
+ * <pre>
+ * org.jboss.seam.faces.dateConverter.type=both
+ * org.jboss.seam.faces.dateConverter.dateStyle=medium
+ * org.jboss.seam.faces.dateConverter.timeStyle=medium
+ * </pre>
+ * <p>Alternatively, a fixed pattern can be specified.</p>
+ * <pre>
+ * org.jboss.seam.faces.dateConverter.pattern=yyyy-mm-DD
+ * </pre>
+ *
+ * @author Dan Allen
+ */
+@Converter(forClass = Date.class)
+@Name("org.jboss.seam.faces.dateConverter")
+@Install(precedence = BUILT_IN, classDependencies = "javax.faces.context.FacesContext")
+@BypassInterceptors
+public class DateConverter extends javax.faces.convert.DateTimeConverter {
+
+ private Log log = Logging.getLog(DateConverter.class);
+
+ private static final String TYPE_DATE = "date";
+ private static final String STYLE_SHORT = "short";
+ private static final String TWO_DIGIT_YEAR_PATTERN = "yy";
+ private static final String FOUR_DIGIT_YEAR_PATTERN = "yyyy";
+
+ // constructor is used to initialize converter to allow these values to be overridden using component properties
+ public DateConverter() {
+ super();
+ setType(TYPE_DATE);
+ setDateStyle(STYLE_SHORT);
+ setTimeStyle(STYLE_SHORT); // default in case developer overrides type to be time or both
+ }
+
+ @Create
+ public void create() {
+ // TODO make this work if using "both" for type; requires more analysis of time style
+ if (TYPE_DATE.equals(getType()) && STYLE_SHORT.equals(getDateStyle()) && getPattern() == null) {
+ // attempt to make the pattern Y2K compliant, which it isn't by default
+ DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, getLocale());
+ if (dateFormat instanceof SimpleDateFormat) {
+ setPattern(((SimpleDateFormat) dateFormat).toPattern().replace(TWO_DIGIT_YEAR_PATTERN, FOUR_DIGIT_YEAR_PATTERN));
+ }
+ }
+ // required since the superclass may access the fields directly
+ setTimeZone(getTimeZone());
+ setLocale(getLocale());
+ }
+
+ @Override
+ public TimeZone getTimeZone() {
+ if (Contexts.isApplicationContextActive()) {
+ return org.jboss.seam.international.TimeZone.instance();
+ } else {
+ // we don't want to use JSF's braindead default (maybe in JSF 2)
+ return TimeZone.getDefault();
+ }
+ }
+
+ @Override
+ public Locale getLocale() {
+ if (Contexts.isApplicationContextActive()) {
+ return org.jboss.seam.international.Locale.instance();
+ } else {
+ return super.getLocale();
+ }
+ }
+
+ @Override
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException {
+ if (log.isDebugEnabled()) {
+ log.debug("Converting string '#0' to date for clientId '#1' using Seam's built-in JSF date converter", value, component.getClientId(context));
+ }
+ return super.getAsObject(context, component, value);
+ }
+
+ @Override
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException {
+ if (log.isDebugEnabled()) {
+ log.debug("Converting date '#0' to string for clientId '#1' using Seam's built-in JSF date converter", value, component.getClientId(context));
+ }
+ return super.getAsString(context, component, value);
+ }
+}
Added: modules/trunk/faces/attic/FacesContextProducer.java
===================================================================
--- modules/trunk/faces/attic/FacesContextProducer.java (rev 0)
+++ modules/trunk/faces/attic/FacesContextProducer.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -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();
+ }
+}
Added: modules/trunk/faces/attic/FacesExpressions.java
===================================================================
--- modules/trunk/faces/attic/FacesExpressions.java (rev 0)
+++ modules/trunk/faces/attic/FacesExpressions.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,36 @@
+//$Id: FacesExpressions.java 9684 2008-12-01 21:41:20Z dan.j.allen $
+package org.jboss.seam.faces;
+
+import javax.annotation.Named;
+import javax.context.ApplicationScoped;
+import javax.el.ELContext;
+import javax.faces.context.FacesContext;
+import org.jboss.seam.el.Expressions;
+
+/**
+ * Factory for method and value bindings in a JSF environment.
+ *
+ * @author Gavin King
+ */
+public
+@Named
+@ApplicationScoped
+class FacesExpressions extends Expressions
+{
+ /**
+ * Get an appropriate ELContext. If there is an active JSF request,
+ * use JSF's ELContext. Otherwise, use one that we created.
+ */
+ @Override
+ public ELContext getELContext()
+ {
+ return isFacesContextActive() ? FacesContext.getCurrentInstance().getELContext() : super.getELContext();
+ }
+
+ @Override
+ protected boolean isFacesContextActive()
+ {
+ return FacesContext.getCurrentInstance() != null && FacesContext.getCurrentInstance().getCurrentPhaseId() != null;
+ }
+
+}
\ No newline at end of file
Added: modules/trunk/faces/attic/FacesManager.java
===================================================================
--- modules/trunk/faces/attic/FacesManager.java (rev 0)
+++ modules/trunk/faces/attic/FacesManager.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,316 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseId;
+
+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.contexts.Contexts;
+import org.jboss.seam.contexts.FacesLifecycle;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.navigation.ConversationIdParameter;
+import org.jboss.seam.navigation.Pages;
+import org.jboss.seam.pageflow.Pageflow;
+
+/**
+ * An extended conversation manager for the JSF environment.
+ *
+ * @author Gavin King
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ */
+(a)Scope(ScopeType.EVENT)
+@Name("org.jboss.seam.core.manager")
+@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
+@BypassInterceptors
+public class FacesManager extends Manager
+{
+ private static final LogProvider log = Logging.getLogProvider(FacesManager.class);
+
+
+
+ private boolean controllingRedirect;
+
+ /**
+ * Temporarily promote a temporary conversation to
+ * a long running conversation for the duration of
+ * a browser redirect. After the redirect, the
+ * conversation will be demoted back to a temporary
+ * conversation. Handle any changes to the conversation
+ * id, due to propagation via natural id.
+ */
+ public void beforeRedirect(String viewId)
+ {
+ beforeRedirect();
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ String currentViewId = Pages.getViewId(facesContext);
+ if ( viewId!=null && currentViewId!=null )
+ {
+ ConversationIdParameter currentPage = Pages.instance().getPage(currentViewId).getConversationIdParameter();
+ ConversationIdParameter targetPage = Pages.instance().getPage(viewId).getConversationIdParameter();
+ if ( isDifferentConversationId(currentPage, targetPage) )
+ {
+ updateCurrentConversationId( targetPage.getConversationId() );
+ }
+ }
+ }
+
+ public void interpolateAndRedirect(String url)
+ {
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ int loc = url.indexOf('?');
+ if (loc>0)
+ {
+ StringTokenizer tokens = new StringTokenizer( url.substring(loc), "?=&" );
+ while ( tokens.hasMoreTokens() )
+ {
+ String name = tokens.nextToken();
+ String value = Interpolator.instance().interpolate( tokens.nextToken() );
+ parameters.put(name, value);
+ }
+ url = url.substring(0, loc);
+ }
+ redirect(url, parameters, true, true);
+ }
+
+ @Override
+ protected void storeConversationToViewRootIfNecessary()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if ( facesContext!=null && FacesLifecycle.getPhaseId()==PhaseId.RENDER_RESPONSE )
+ {
+ FacesPage.instance().storeConversation();
+ }
+ }
+
+ @Override
+ protected String generateInitialConversationId()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ String viewId = Pages.getViewId(facesContext);
+ if ( viewId!=null )
+ {
+ return Pages.instance().getPage(viewId)
+ .getConversationIdParameter()
+ .getInitialConversationId( facesContext.getExternalContext().getRequestParameterMap() );
+ }
+ else
+ {
+ return super.generateInitialConversationId();
+ }
+ }
+
+ public void redirectToExternalURL(String url) {
+ try {
+ FacesContext.getCurrentInstance().getExternalContext().redirect(url);
+ } catch (IOException e) {
+ throw new RedirectException(e);
+ }
+ }
+
+ /**
+ * Redirect to the given view id, encoding the conversation id
+ * into the request URL.
+ *
+ * @param viewId the JSF view id
+ */
+ @Override
+ public void redirect(String viewId)
+ {
+ redirect(viewId, null, true, true);
+ }
+
+ public void redirect(String viewId, Map<String, Object> parameters,
+ boolean includeConversationId)
+ {
+ redirect(viewId, parameters, includeConversationId, true);
+ }
+
+ /**
+ * Redirect to the given view id, after encoding parameters and conversation
+ * id into the request URL.
+ *
+ * @param viewId the JSF view id
+ * @param parameters request parameters to be encoded (possibly null)
+ * @param includeConversationId determines if the conversation id is to be encoded
+ */
+ public void redirect(String viewId, Map<String, Object> parameters,
+ boolean includeConversationId, boolean includePageParams)
+ {
+ if (viewId == null)
+ {
+ throw new RedirectException("cannot redirect to a null viewId");
+ }
+ FacesContext context = FacesContext.getCurrentInstance();
+ String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
+ if (parameters!=null)
+ {
+ url = encodeParameters(url, parameters);
+ }
+
+ if (includePageParams)
+ {
+ url = Pages.instance().encodePageParameters(FacesContext.getCurrentInstance(),
+ url, viewId, parameters==null ? Collections.EMPTY_SET : parameters.keySet());
+ }
+
+ if (includeConversationId)
+ {
+ beforeRedirect(viewId);
+ url = encodeConversationId(url, viewId);
+ }
+ redirect(viewId, context, url);
+ }
+
+ /**
+ * Redirect to the given view id, after encoding the given conversation
+ * id into the request URL.
+ *
+ * @param viewId the JSF view id
+ * @param conversationId an id of a long-running conversation
+ */
+ @Override
+ public void redirect(String viewId, String conversationId)
+ {
+ if (viewId == null)
+ {
+ throw new RedirectException("cannot redirect to a null viewId");
+ }
+ FacesContext context = FacesContext.getCurrentInstance();
+ String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
+ url = encodeConversationId(url, viewId, conversationId);
+ redirect(viewId, context, url);
+ }
+
+ private void redirect(String viewId, FacesContext context, String url)
+ {
+ url = Pages.instance().encodeScheme(viewId, context, url);
+ if ( log.isDebugEnabled() )
+ {
+ log.debug("redirecting to: " + url);
+ }
+ ExternalContext externalContext = context.getExternalContext();
+ controllingRedirect = true;
+ try
+ {
+ Contexts.getEventContext().set(REDIRECT_FROM_MANAGER, "");
+ externalContext.redirect( externalContext.encodeActionURL(url) );
+ }
+ catch (IOException ioe)
+ {
+ throw new RedirectException(ioe);
+ }
+ finally
+ {
+ Contexts.getEventContext().remove(REDIRECT_FROM_MANAGER);
+ controllingRedirect = false;
+ }
+ context.responseComplete();
+ }
+
+ /**
+ * Called by the Seam Redirect Filter when a redirect is called.
+ * Appends the conversationId parameter if necessary.
+ *
+ * @param url the requested URL
+ * @return the resulting URL with the conversationId appended
+ */
+ public String appendConversationIdFromRedirectFilter(String url, String viewId)
+ {
+ boolean appendConversationId = !controllingRedirect;
+ if (appendConversationId)
+ {
+ beforeRedirect(viewId);
+ url = encodeConversationId(url, viewId);
+ }
+ return url;
+ }
+
+ /**
+ * If a page description is defined, remember the description and
+ * view id for the current page, to support conversation switching.
+ * Called just before the render phase.
+ */
+ public void prepareBackswitch(FacesContext facesContext)
+ {
+
+ Conversation conversation = Conversation.instance();
+
+ //stuff from jPDL takes precedence
+ org.jboss.seam.pageflow.Page page =
+ Manager.instance().isLongRunningConversation() &&
+ Init.instance().isJbpmInstalled() &&
+ Pageflow.instance().isInProcess() && Pageflow.instance().isStarted() ?
+ Pageflow.instance().getPage() : null;
+
+ if (page==null)
+ {
+ //handle stuff defined in pages.xml
+ Pages pages = Pages.instance();
+ if (pages!=null) //for tests
+ {
+ String viewId = Pages.getViewId(facesContext);
+ org.jboss.seam.navigation.Page pageEntry = pages.getPage(viewId);
+ if ( pageEntry.isSwitchEnabled() )
+ {
+ conversation.setViewId(viewId);
+ }
+ if ( pageEntry.hasDescription() )
+ {
+ conversation.setDescription( pageEntry.renderDescription() );
+ }
+ else if(pages.hasDescription(viewId))
+ {
+ conversation.setDescription( pages.renderDescription(viewId) );
+ }
+ conversation.setTimeout( pages.getTimeout(viewId) );
+ conversation.setConcurrentRequestTimeout( pages.getConcurrentRequestTimeout(viewId) );
+ }
+ }
+ else
+ {
+ //use stuff from the pageflow definition
+ if ( page.isSwitchEnabled() )
+ {
+ conversation.setViewId( Pageflow.instance().getPageViewId() );
+ }
+ if ( page.hasDescription() )
+ {
+ conversation.setDescription( page.getDescription() );
+ }
+ conversation.setTimeout( page.getTimeout() );
+ }
+
+ flushConversationMetadata();
+
+ }
+
+ public static FacesManager instance()
+ {
+ return (FacesManager) Manager.instance();
+ }
+
+}
Added: modules/trunk/faces/attic/FacesMessages.java
===================================================================
--- modules/trunk/faces/attic/FacesMessages.java (rev 0)
+++ modules/trunk/faces/attic/FacesMessages.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,356 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+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.contexts.Contexts;
+import org.jboss.seam.international.StatusMessage;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.util.Strings;
+
+/**
+ * A Seam component that propagates FacesMessages across redirects
+ * and interpolates EL expressions in the message string.
+ *
+ * @author Gavin King
+ * @author Pete Muir
+ */
+(a)Scope(ScopeType.CONVERSATION)
+(a)Name(StatusMessages.COMPONENT_NAME)
+@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
+@BypassInterceptors
+public class FacesMessages extends StatusMessages
+{
+
+ /**
+ * Called by Seam to transfer messages from FacesMessages to JSF
+ */
+ public void beforeRenderResponse()
+ {
+ for (StatusMessage statusMessage: getMessages())
+ {
+ FacesContext.getCurrentInstance().addMessage( null, toFacesMessage(statusMessage) );
+ }
+ for ( Map.Entry<String, List<StatusMessage>> entry: getKeyedMessages().entrySet() )
+ {
+ for ( StatusMessage statusMessage: entry.getValue() )
+ {
+ String clientId = getClientId(entry.getKey());
+ FacesContext.getCurrentInstance().addMessage( clientId, toFacesMessage(statusMessage) );
+ }
+ }
+ clear();
+ }
+
+ /**
+ * Called by Seam to transfer any messages added in the phase just processed
+ * to the FacesMessages component.
+ *
+ * A task runner is used to allow the messages access to outjected values.
+ */
+ public static void afterPhase()
+ {
+ runTasks();
+ }
+
+ /**
+ * Convert a StatusMessage to a FacesMessage
+ */
+ private static FacesMessage toFacesMessage(StatusMessage statusMessage)
+ {
+ if (!Strings.isEmpty(statusMessage.getSummary()))
+ {
+ return new FacesMessage(toSeverity(statusMessage.getSeverity()), statusMessage.getSummary(), statusMessage.getDetail() );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Convert a StatusMessage.Severity to a FacesMessage.Severity
+ */
+ private static javax.faces.application.FacesMessage.Severity toSeverity(org.jboss.seam.international.StatusMessage.Severity severity)
+ {
+ switch (severity)
+ {
+ case ERROR:
+ return FacesMessage.SEVERITY_ERROR;
+ case FATAL:
+ return FacesMessage.SEVERITY_FATAL;
+ case INFO:
+ return FacesMessage.SEVERITY_INFO;
+ case WARN:
+ return FacesMessage.SEVERITY_WARN;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Convert a FacesMessage.Severity to a StatusMessage.Severity
+ */
+ private static org.jboss.seam.international.StatusMessage.Severity toSeverity(javax.faces.application.FacesMessage.Severity severity)
+ {
+ if (FacesMessage.SEVERITY_ERROR.equals(severity))
+ {
+ return org.jboss.seam.international.StatusMessage.Severity.ERROR;
+ }
+ else if (FacesMessage.SEVERITY_FATAL.equals(severity))
+ {
+ return org.jboss.seam.international.StatusMessage.Severity.FATAL;
+ }
+ else if (FacesMessage.SEVERITY_INFO.equals(severity))
+ {
+ return org.jboss.seam.international.StatusMessage.Severity.INFO;
+ }
+ else if (FacesMessage.SEVERITY_WARN.equals(severity))
+ {
+ return org.jboss.seam.international.StatusMessage.Severity.WARN;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Calculate the JSF client ID from the provided widget ID
+ */
+ private String getClientId(String id)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return getClientId( facesContext.getViewRoot(), id, facesContext);
+ }
+
+ private static String getClientId(UIComponent component, String id, FacesContext facesContext)
+ {
+ String componentId = component.getId();
+ if (componentId!=null && componentId.equals(id))
+ {
+ return component.getClientId(facesContext);
+ }
+ else
+ {
+ Iterator iter = component.getFacetsAndChildren();
+ while ( iter.hasNext() )
+ {
+ UIComponent child = (UIComponent) iter.next();
+ String clientId = getClientId(child, id, facesContext);
+ if (clientId!=null) return clientId;
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Get all faces messages that have already been added
+ * to the context.
+ *
+ */
+ public List<FacesMessage> getCurrentMessages()
+ {
+ List<FacesMessage> result = new ArrayList<FacesMessage>();
+ Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages();
+ while ( iter.hasNext() )
+ {
+ result.add( iter.next() );
+ }
+ return result;
+ }
+
+ /**
+ * Get all faces global messages that have already been added
+ * to the context.
+ *
+ */
+ public List<FacesMessage> getCurrentGlobalMessages()
+ {
+ List<FacesMessage> result = new ArrayList<FacesMessage>();
+ Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(null);
+ while ( iter.hasNext() )
+ {
+ result.add( iter.next() );
+ }
+ return result;
+ }
+
+ /**
+ * Get all faces messages that have already been added
+ * to the control.
+ *
+ */
+ public List<FacesMessage> getCurrentMessagesForControl(String id)
+ {
+ String clientId = getClientId(id);
+ List<FacesMessage> result = new ArrayList<FacesMessage>();
+ Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(clientId);
+ while ( iter.hasNext() )
+ {
+ result.add( iter.next() );
+ }
+ return result;
+ }
+
+ /**
+ * Utility method to create a FacesMessage from a Severity, messageTemplate
+ * and params.
+ *
+ * This method interpolates the parameters provided
+ */
+ public static FacesMessage createFacesMessage(javax.faces.application.FacesMessage.Severity severity, String messageTemplate, Object... params)
+ {
+ return createFacesMessage(severity, null, messageTemplate, params);
+ }
+
+ /**
+ * Utility method to create a FacesMessage from a Severity, key,
+ * defaultMessageTemplate and params.
+ *
+ * This method interpolates the parameters provided
+ */
+ public static FacesMessage createFacesMessage(javax.faces.application.FacesMessage.Severity severity, String key, String defaultMessageTemplate, Object... params)
+ {
+ StatusMessage message = new StatusMessage(toSeverity(severity), key, null, defaultMessageTemplate, null);
+ message.interpolate(params);
+ return toFacesMessage(message);
+ }
+
+ /**
+ * Add a FacesMessage that will be used
+ * the next time a page is rendered.
+ *
+ * Deprecated, use a method in {@link StatusMessages} instead
+ */
+ @Deprecated
+ public void add(FacesMessage facesMessage)
+ {
+ if (facesMessage!=null)
+ {
+ add(toSeverity(facesMessage.getSeverity()), null, null, facesMessage.getSummary(), facesMessage.getDetail());
+ }
+ }
+
+ /**
+ * Create a new status message, with the messageTemplate is as the message.
+ *
+ * You can also specify the severity, and parameters to be interpolated
+ *
+ * Deprecated, use {@link #add(org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
+ * instead
+ */
+ @Deprecated
+ public void add(javax.faces.application.FacesMessage.Severity severity, String messageTemplate, Object... params)
+ {
+ add(toSeverity(severity), messageTemplate, params);
+ }
+
+
+ /**
+ * Create a new status message, with the messageTemplate is as the message.
+ *
+ * A severity of INFO will be used, and you can specify paramters to be
+ * interpolated
+ *
+ * Deprecated, use {@link #addToControl(String, org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
+ * instead
+ */
+ @Deprecated
+ public void addToControl(String id, javax.faces.application.FacesMessage.Severity severity, String messageTemplate, Object... params)
+ {
+ addToControl(id, toSeverity(severity), messageTemplate, params);
+ }
+
+ /**
+ * Add a status message, looking up the message in the resource bundle
+ * using the provided key.
+ *
+ * You can also specify the severity, and parameters to be interpolated
+ *
+ * Deprecated, use {@link #addFromResourceBundle(org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
+ * instead
+ */
+ @Deprecated
+ public void addFromResourceBundle(javax.faces.application.FacesMessage.Severity severity, String key, Object... params)
+ {
+ addFromResourceBundle(toSeverity(severity), key, params);
+ }
+
+ /**
+ * Add a status message, looking up the message in the resource bundle
+ * using the provided key.
+ *
+ * You can also specify the severity, and parameters to be interpolated
+ *
+ * Deprecated, use {@link #addFromResourceBundleOrDefault(javax.faces.application.FacesMessage.Severity, String, String, Object...)}
+ * instead
+ */
+ @Deprecated
+ public void addFromResourceBundleOrDefault(javax.faces.application.FacesMessage.Severity severity, String key, String defaultMessageTemplate, Object... params)
+ {
+ addFromResourceBundleOrDefault(toSeverity(severity), key, defaultMessageTemplate, params);
+ }
+
+ /**
+ * Create a new status message, looking up the message in the resource bundle
+ * using the provided key.
+ *
+ * The message will be added to the widget specified by the ID. The algorithm
+ * used determine which widget the id refers to is determined by the view
+ * layer implementation in use.
+ *
+ * You can also specify the severity, and parameters to be interpolated
+ *
+ * Deprecated, use {@link #addToControlFromResourceBundle(String, org.jboss.seam.international.StatusMessage.Severity, String, Object...)}
+ * instead
+ */
+ @Deprecated
+ public void addToControlFromResourceBundle(String id, javax.faces.application.FacesMessage.Severity severity, String key, Object... params)
+ {
+ addToControlFromResourceBundle(id, toSeverity(severity), key, params);
+ }
+
+ /**
+ * Add a status message, looking up the message in the resource bundle
+ * using the provided key. If the message is found, it is used, otherwise,
+ * the defaultMessageTemplate will be used.
+ *
+ * The message will be added to the widget specified by the ID. The algorithm
+ * used determine which widget the id refers to is determined by the view
+ * layer implementation in use.
+ *
+ * You can also specify the severity, and parameters to be interpolated
+ *
+ * Deprecated, use {@link #addToControlFromResourceBundleOrDefault(String, org.jboss.seam.international.StatusMessage.Severity, String, String, Object...)}
+ * instead
+ */
+ @Deprecated
+ public void addToControlFromResourceBundleOrDefault(String id, javax.faces.application.FacesMessage.Severity severity, String key, String defaultMessageTemplate, Object... params)
+ {
+ addToControlFromResourceBundleOrDefault(id, toSeverity(severity), key, defaultMessageTemplate, params);
+ }
+
+ public static FacesMessages instance()
+ {
+ if ( !Contexts.isConversationContextActive() )
+ {
+ throw new IllegalStateException("No active conversation context");
+ }
+ return (FacesMessages) Component.getInstance(StatusMessages.COMPONENT_NAME, ScopeType.CONVERSATION);
+ }
+}
Added: modules/trunk/faces/attic/FacesPage.java
===================================================================
--- modules/trunk/faces/attic/FacesPage.java (rev 0)
+++ modules/trunk/faces/attic/FacesPage.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,173 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.Serializable;
+
+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.contexts.Contexts;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.pageflow.Pageflow;
+import org.jboss.seam.web.Session;
+
+/**
+ * Book-keeping component that persists information
+ * about the conversation associated with the current
+ * page.
+ *
+ * @author Gavin King
+ *
+ */
+@Name("org.jboss.seam.faces.facesPage")
+@BypassInterceptors
+@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
+(a)Scope(ScopeType.PAGE)
+public class FacesPage implements Serializable
+{
+ private static final long serialVersionUID = 4807114041808347239L;
+ private String pageflowName;
+ private Integer pageflowCounter;
+ private String pageflowNodeName;
+
+ private String conversationId;
+ private boolean conversationIsLongRunning;
+
+ //private Map<String, Object> pageParameters;
+
+ public String getConversationId()
+ {
+ return conversationId;
+ }
+
+ public void discardTemporaryConversation()
+ {
+ conversationId = null;
+ conversationIsLongRunning = false;
+ }
+
+ public void discardNestedConversation(String outerConversationId)
+ {
+ conversationId = outerConversationId;
+ conversationIsLongRunning = true;
+ }
+
+ public void storeConversation(String conversationId)
+ {
+ this.conversationId = conversationId;
+ conversationIsLongRunning = true;
+ }
+
+ public void storePageflow()
+ {
+ if ( Init.instance().isJbpmInstalled() )
+ {
+ Pageflow pageflow = Pageflow.instance();
+ if ( pageflow.isInProcess() /*&& !pageflow.getProcessInstance().hasEnded()*/ && Manager.instance().isLongRunningConversation() )
+ {
+ pageflowName = pageflow.getSubProcessInstance().getProcessDefinition().getName();
+ pageflowNodeName = pageflow.getNode().getName();
+ pageflowCounter = pageflow.getPageflowCounter();
+ }
+ else
+ {
+ pageflowName = null;
+ pageflowNodeName = null;
+ pageflowCounter = null;
+ }
+ }
+ }
+
+ public static FacesPage instance()
+ {
+ if ( !Contexts.isPageContextActive() )
+ {
+ throw new IllegalStateException("No page context active");
+ }
+ return (FacesPage) Component.getInstance(FacesPage.class, ScopeType.PAGE);
+ }
+
+ public boolean isConversationLongRunning()
+ {
+ return conversationIsLongRunning;
+ }
+
+ public Integer getPageflowCounter()
+ {
+ return pageflowCounter;
+ }
+
+ public String getPageflowName()
+ {
+ return pageflowName;
+ }
+
+ public String getPageflowNodeName()
+ {
+ return pageflowNodeName;
+ }
+
+ public void storeConversation()
+ {
+ Manager manager = Manager.instance();
+
+ //we only need to execute this code when we are in the
+ //RENDER_RESPONSE phase, ie. not before redirects
+
+ Session session = Session.getInstance();
+ boolean sessionInvalid = session!=null && session.isInvalid();
+ if ( !sessionInvalid && manager.isLongRunningConversation() )
+ {
+ storeConversation( manager.getCurrentConversationId() );
+ }
+ else if ( !sessionInvalid && manager.isNestedConversation() )
+ {
+ discardNestedConversation( manager.getParentConversationId() );
+ }
+ else
+ {
+ discardTemporaryConversation();
+ }
+
+ /*if ( !sessionInvalid && Init.instance().isClientSideConversations() )
+ {
+ // if we are using client-side conversations, put the
+ // map containing the conversation context variables
+ // into the view root (or remove it for a temp
+ // conversation context)
+ Contexts.getConversationContext().flush();
+ }*/
+
+ }
+
+ /*public Map<String, Object> getPageParameters()
+ {
+ return pageParameters==null ? Collections.EMPTY_MAP : pageParameters;
+ }
+
+ public void setPageParameters(Map<String, Object> pageParameters)
+ {
+ this.pageParameters = pageParameters.isEmpty() ? null : pageParameters;
+ }
+
+ /**
+ * Used by test harness
+ *
+ * @param name the page parameter name
+ * @param value the value
+ */
+ /*public void setPageParameter(String name, Object value)
+ {
+ if (pageParameters==null)
+ {
+ pageParameters = new HashMap<String, Object>();
+ }
+ pageParameters.put(name, value);
+ }*/
+
+}
Added: modules/trunk/faces/attic/HttpError.java
===================================================================
--- modules/trunk/faces/attic/HttpError.java (rev 0)
+++ modules/trunk/faces/attic/HttpError.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,76 @@
+//$Id: HttpError.java 5350 2007-06-20 17:53:19Z gavin $
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletResponse;
+
+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.contexts.Contexts;
+
+/**
+ * Convenient HTTP errors
+ *
+ * @author Gavin King
+ */
+(a)Scope(ScopeType.APPLICATION)
+@BypassInterceptors
+@Name("org.jboss.seam.faces.httpError")
+@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
+public class HttpError
+{
+ /**
+ * Send a HTTP error as the response
+ */
+ public void send(int code)
+ {
+ try
+ {
+ getResponse().sendError(code);
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalStateException(ioe);
+ }
+ FacesContext.getCurrentInstance().responseComplete();
+ }
+
+ /**
+ * Send a HTTP error as the response
+ */
+ public void send(int code, String message)
+ {
+ try
+ {
+ getResponse().sendError(code, message);
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalStateException(ioe);
+ }
+ FacesContext.getCurrentInstance().responseComplete();
+ }
+
+ private static HttpServletResponse getResponse()
+ {
+ return (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
+ }
+
+ public static HttpError instance()
+ {
+ if ( !Contexts.isApplicationContextActive() )
+ {
+ throw new IllegalStateException("No active application scope");
+ }
+ return (HttpError) Component.getInstance(HttpError.class, ScopeType.APPLICATION);
+ }
+
+}
Added: modules/trunk/faces/attic/IsUserInRole.java
===================================================================
--- modules/trunk/faces/attic/IsUserInRole.java (rev 0)
+++ modules/trunk/faces/attic/IsUserInRole.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,37 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import javax.faces.context.FacesContext;
+
+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;
+
+/**
+ * Manager component for a map of roles assigned
+ * to the current user, as exposed via the JSF
+ * ExternalContext.
+ *
+ * @author Gavin King
+ */
+(a)Scope(ScopeType.APPLICATION)
+@BypassInterceptors
+@Name("org.jboss.seam.web.isUserInRole")
+@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
+public class IsUserInRole extends org.jboss.seam.web.IsUserInRole
+{
+ @Override
+ protected Boolean isUserInRole(String role)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if ( facesContext != null )
+ {
+ return facesContext.getExternalContext().isUserInRole(role);
+ }
+
+ return super.isUserInRole(role);
+ }
+}
Added: modules/trunk/faces/attic/Navigator.java
===================================================================
--- modules/trunk/faces/attic/Navigator.java (rev 0)
+++ modules/trunk/faces/attic/Navigator.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,109 @@
+package org.jboss.seam.faces;
+
+import java.util.Map;
+
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.navigation.Pages;
+import org.jboss.seam.util.Strings;
+
+public abstract class Navigator
+{
+ private static final LogProvider log = Logging.getLogProvider(Navigator.class);
+
+ /**
+ * Send an error.
+ */
+ protected void error(int code, String message)
+ {
+ if ( log.isDebugEnabled() ) log.debug("sending error: " + code);
+ org.jboss.seam.faces.HttpError httpError = org.jboss.seam.faces.HttpError.instance();
+ if (message==null)
+ {
+ httpError.send(code);
+ }
+ else
+ {
+ httpError.send(code, message);
+ }
+ }
+
+ protected void redirectExternal(String url) {
+ FacesManager.instance().redirectToExternalURL(url);
+ }
+
+ protected void redirect(String viewId, Map<String, Object> parameters)
+ {
+ redirect(viewId, parameters, true);
+ }
+
+ /**
+ * Redirect to the view id.
+ */
+ protected void redirect(String viewId, Map<String, Object> parameters, boolean includePageParams)
+ {
+ if ( Strings.isEmpty(viewId) )
+ {
+ viewId = Pages.getCurrentViewId();
+ }
+ if ( log.isDebugEnabled() ) log.debug("redirecting to: " + viewId);
+ FacesManager.instance().redirect(viewId, parameters, true, includePageParams);
+ }
+
+ /**
+ * Render the view id.
+ */
+ protected void render(String viewId)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if ( !Strings.isEmpty(viewId) )
+ {
+ UIViewRoot viewRoot = facesContext.getApplication().getViewHandler()
+ .createView(facesContext, viewId);
+ facesContext.setViewRoot(viewRoot);
+ }
+ else
+ {
+ viewId = Pages.getViewId(facesContext); //just for the log message
+ }
+ if ( log.isDebugEnabled() ) log.debug("rendering: " + viewId);
+ facesContext.renderResponse();
+ }
+
+ protected static String getDisplayMessage(Exception e, String message)
+ {
+ if ( Strings.isEmpty(message) && e.getMessage()!=null )
+ {
+ return e.getMessage();
+ }
+ else
+ {
+ return message;
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ protected static void addFacesMessage(String message, Severity severity, String control, Object... params)
+ {
+ if ( Contexts.isConversationContextActive() )
+ {
+ if ( !Strings.isEmpty(message) )
+ {
+ if ( Strings.isEmpty(control) )
+ {
+ FacesMessages.instance().add(severity, message, params);
+ }
+ else
+ {
+ FacesMessages.instance().addToControl(control, severity, message, params);
+ }
+ }
+ }
+ }
+
+}
Added: modules/trunk/faces/attic/Parameters.java
===================================================================
--- modules/trunk/faces/attic/Parameters.java (rev 0)
+++ modules/trunk/faces/attic/Parameters.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,67 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.util.Map;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+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;
+
+/**
+ * Access to request parameters in the JSF environment.
+ *
+ * @author Gavin King
+ *
+ */
+@Name("org.jboss.seam.web.parameters")
+@BypassInterceptors
+(a)Scope(ScopeType.STATELESS)
+@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
+public class Parameters extends org.jboss.seam.web.Parameters
+{
+
+ @Override
+ protected Object convertRequestParameter(String requestParameter, Class type)
+ {
+ if ( String.class.equals(type) ) return requestParameter;
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext==null)
+ {
+ throw new IllegalStateException("No FacesContext associated with current thread, cannot convert request parameter type");
+ }
+ else
+ {
+ Converter converter = facesContext.getApplication().createConverter(type);
+ if (converter==null)
+ {
+ throw new IllegalArgumentException("no converter for type: " + type);
+ }
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ return converter.getAsObject(
+ facesContext,
+ viewRoot==null ? new UIViewRoot() : viewRoot, //have to pass something here, or get a totally useless NPE from JSF
+ requestParameter );
+ }
+ }
+
+ @Override
+ public Map<String, String[]> getRequestParameters()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if ( facesContext != null )
+ {
+ return facesContext.getExternalContext().getRequestParameterValuesMap();
+ }
+
+ return super.getRequestParameters();
+ }
+
+}
Added: modules/trunk/faces/attic/Redirect.java
===================================================================
--- modules/trunk/faces/attic/Redirect.java (rev 0)
+++ modules/trunk/faces/attic/Redirect.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,204 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+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.PerNestedConversation;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.AbstractMutable;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.navigation.Pages;
+
+/**
+ * Convenient API for performing browser redirects with
+ * parameters.
+ *
+ * @author Gavin King
+ */
+@Name("org.jboss.seam.faces.redirect")
+@BypassInterceptors
+(a)Scope(ScopeType.CONVERSATION)
+@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
+@PerNestedConversation
+public class Redirect extends AbstractMutable implements Serializable
+{
+ private static final long serialVersionUID = 6947384474861235210L;
+ private String viewId;
+ private Map<String, Object> parameters = new HashMap<String, Object>();
+ private boolean conversationPropagationEnabled = true;
+ private boolean conversationBegun;
+
+ /**
+ * Get the JSF view id to redirect to
+ */
+ public String getViewId()
+ {
+ return viewId;
+ }
+
+ /**
+ * Set the JSF view id to redirect to
+ *
+ * @param viewId any JSF view id
+ */
+ public void setViewId(String viewId)
+ {
+ setDirty(this.viewId, viewId);
+ this.viewId = viewId;
+ }
+
+ /**
+ * Get all the request parameters that have been set
+ */
+ public Map<String, Object> getParameters()
+ {
+ return parameters;
+ }
+
+ /**
+ * Set a request parameter value (to set a multi-valued
+ * request parameter, pass an array or collection as
+ * the value)
+ */
+ public void setParameter(String name, Object value)
+ {
+ Object old = parameters.put(name, value);
+ setDirty(old, value);
+ }
+
+ /**
+ * Capture the view id and request parameters from the
+ * current request and squirrel them away so we can
+ * return here later in the conversation.
+ *
+ * @deprecated use captureCurrentView()
+ */
+ public void captureCurrentRequest()
+ {
+ parameters.clear();
+ FacesContext context = FacesContext.getCurrentInstance();
+ parameters.putAll( context.getExternalContext().getRequestParameterMap() );
+ viewId = Pages.getViewId(context);
+ setDirty();
+ }
+
+ /**
+ * Capture the view id, request parameters and page parameters (which take
+ * precedence) from the current request and squirrel them away so we can
+ * return here later in the conversation. If no conversation is active,
+ * begin a conversation. The conversation is terminated by {@link
+ * Redirect#returnToCapturedView()} if begun by this method.
+ *
+ * @see Redirect#returnToCapturedView()
+ */
+ public void captureCurrentView()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ // If this isn't a faces request then just return
+ if (context == null) return;
+
+ // first capture all request parameters
+ parameters.putAll( context.getExternalContext().getRequestParameterMap() );
+ // then preserve page parameters, overwriting request parameters with same names
+ parameters.putAll( Pages.instance().getStringValuesFromPageContext(context) );
+
+ // special case only needed for actionMethod if decide not to capture all request parameters
+ //if (context.getExternalContext().getRequestParameterMap().containsKey("actionMethod"))
+ //{
+ // parameters.put("actionMethod", context.getExternalContext().getRequestParameterMap().get("actionMethod"));
+ //}
+
+ viewId = Pages.getViewId(context);
+ conversationBegun = Conversation.instance().begin(true, false);
+ setDirty();
+ //if the request ends with an exception,
+ //the conversation context never gets
+ //flushed....
+ Contexts.getConversationContext().flush();
+ }
+
+ /**
+ * Should the conversation be propagated across the redirect?
+ * @return true by default
+ */
+ public boolean isConversationPropagationEnabled()
+ {
+ return conversationPropagationEnabled;
+ }
+
+ /**
+ * Note that conversations are propagated by default
+ */
+ public void setConversationPropagationEnabled(boolean conversationPropagationEnabled)
+ {
+ this.conversationPropagationEnabled = conversationPropagationEnabled;
+ }
+
+ /**
+ * Perform the redirect
+ */
+ public void execute()
+ {
+ FacesManager.instance().redirect(viewId, parameters, conversationPropagationEnabled, true);
+ }
+
+ /**
+ * Redirect to the captured view, and end any conversation
+ * that began in captureCurrentView().
+ *
+ *@see Redirect#captureCurrentView()
+ */
+ public boolean returnToCapturedView()
+ {
+ if (viewId!=null)
+ {
+ if (conversationBegun)
+ {
+ Conversation.instance().end();
+ }
+ execute();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ //TODO: replacement for Conversation.endAndRedirect()
+ /*public boolean returnToParentView()
+ {
+ Manager manager = Manager.instance();
+ String viewId = manager.getParentConversationViewId();
+ if (viewId==null)
+ {
+ return false;
+ }
+ else
+ {
+ manager.redirect(viewId);
+ return true;
+ }
+ }*/
+
+ public static Redirect instance()
+ {
+ if ( !Contexts.isConversationContextActive() )
+ {
+ throw new IllegalStateException("No active conversation context");
+ }
+ return (Redirect) Component.getInstance(Redirect.class, ScopeType.CONVERSATION);
+ }
+}
Added: modules/trunk/faces/attic/RedirectException.java
===================================================================
--- modules/trunk/faces/attic/RedirectException.java (rev 0)
+++ modules/trunk/faces/attic/RedirectException.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,17 @@
+package org.jboss.seam.faces;
+
+import java.io.IOException;
+
+public class RedirectException extends RuntimeException
+{
+
+ public RedirectException(IOException ioe)
+ {
+ super(ioe);
+ }
+
+ public RedirectException(String message)
+ {
+ super(message);
+ }
+}
Added: modules/trunk/faces/attic/Renderer.java
===================================================================
--- modules/trunk/faces/attic/Renderer.java (rev 0)
+++ modules/trunk/faces/attic/Renderer.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,23 @@
+package org.jboss.seam.faces;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+
+/**
+ * A component for direct rendering of
+ * templates. Especially useful with
+ * Seam Mail.
+ *
+ */
+@Name("org.jboss.seam.faces.renderer")
+@Install(false)
+public abstract class Renderer
+{
+ public abstract String render(String viewId);
+
+ public static Renderer instance()
+ {
+ return (Renderer) Component.getInstance(Renderer.class);
+ }
+}
Added: modules/trunk/faces/attic/ResourceLoader.java
===================================================================
--- modules/trunk/faces/attic/ResourceLoader.java (rev 0)
+++ modules/trunk/faces/attic/ResourceLoader.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,56 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.InputStream;
+import java.net.URL;
+
+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.util.FacesResources;
+
+/**
+ * Access to application resources in tye JSF environment.
+ *
+ * @author Gavin King
+ *
+ */
+(a)Scope(ScopeType.STATELESS)
+@BypassInterceptors
+@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
+@Name("org.jboss.seam.core.resourceLoader")
+public class ResourceLoader extends org.jboss.seam.core.ResourceLoader
+{
+
+ @Override
+ public InputStream getResourceAsStream(String resource)
+ {
+ javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
+ if (context!=null)
+ {
+ return FacesResources.getResourceAsStream( resource, context.getExternalContext() );
+ }
+ else
+ {
+ return super.getResourceAsStream(resource);
+ }
+ }
+
+ @Override
+ public URL getResource(String resource)
+ {
+ javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
+ if (context!=null)
+ {
+ return FacesResources.getResource( resource, context.getExternalContext() );
+ }
+ else
+ {
+ return super.getResource(resource);
+ }
+ }
+
+}
Added: modules/trunk/faces/attic/Selector.java
===================================================================
--- modules/trunk/faces/attic/Selector.java (rev 0)
+++ modules/trunk/faces/attic/Selector.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,122 @@
+package org.jboss.seam.faces;
+
+import java.io.Serializable;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.seam.core.AbstractMutable;
+
+/**
+ * Support for selector objects which remember their selection as a cookie
+ *
+ * @author Gavin King
+ */
+public abstract class Selector extends AbstractMutable implements Serializable
+{
+ public static final int DEFAULT_MAX_AGE = 31536000; // 1 year in seconds
+ private boolean cookieEnabled;
+ private int cookieMaxAge = DEFAULT_MAX_AGE;
+ private String cookiePath= "/";
+
+ /**
+ * Is the cookie enabled?
+ * @return false by default
+ */
+ public boolean isCookieEnabled()
+ {
+ return cookieEnabled;
+ }
+ public void setCookieEnabled(boolean cookieEnabled)
+ {
+ setDirty(this.cookieEnabled, cookieEnabled);
+ this.cookieEnabled = cookieEnabled;
+ }
+ /**
+ * The max age of the cookie
+ * @return 1 year by default
+ */
+ public int getCookieMaxAge()
+ {
+ return cookieMaxAge;
+ }
+ public void setCookieMaxAge(int cookieMaxAge)
+ {
+ this.cookieMaxAge = cookieMaxAge;
+ }
+
+ public String getCookiePath()
+ {
+ return cookiePath;
+ }
+
+ public void setCookiePath(String cookiePath)
+ {
+ this.cookiePath = cookiePath;
+ }
+
+ /**
+ * Override to define the cookie name
+ */
+ protected abstract String getCookieName();
+
+ /**
+ * Get the value of the cookie
+ */
+ protected String getCookieValueIfEnabled()
+ {
+ return isCookieEnabled() ?
+ getCookieValue() : null;
+ }
+
+ protected Cookie getCookie()
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ if (ctx != null)
+ {
+ return (Cookie) ctx.getExternalContext().getRequestCookieMap()
+ .get( getCookieName() );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected String getCookieValue()
+ {
+ Cookie cookie = getCookie();
+ return cookie==null ? null : cookie.getValue();
+ }
+
+ protected void clearCookieValue()
+ {
+ Cookie cookie = getCookie();
+ if ( cookie!=null )
+ {
+ HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
+ cookie.setValue(null);
+ cookie.setPath(cookiePath);
+ cookie.setMaxAge(0);
+ response.addCookie(cookie);
+ }
+ }
+
+ /**
+ * Set the cookie
+ */
+ protected void setCookieValueIfEnabled(String value)
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+
+ if ( isCookieEnabled() && ctx != null)
+ {
+ HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
+ Cookie cookie = new Cookie( getCookieName(), value );
+ cookie.setMaxAge( getCookieMaxAge() );
+ cookie.setPath(cookiePath);
+ response.addCookie(cookie);
+ }
+ }
+}
Added: modules/trunk/faces/attic/Switcher.java
===================================================================
--- modules/trunk/faces/attic/Switcher.java (rev 0)
+++ modules/trunk/faces/attic/Switcher.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,125 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.faces.model.SelectItem;
+
+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.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.core.ConversationEntries;
+import org.jboss.seam.core.ConversationEntry;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.web.Session;
+
+/**
+ * Support for the conversation switcher drop-down menu.
+ *
+ * @author Gavin King
+ */
+(a)Scope(ScopeType.PAGE)
+@Name("org.jboss.seam.faces.switcher")
+@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
+@BypassInterceptors
+public class Switcher implements Serializable
+{
+
+ private static final long serialVersionUID = -6403911073853051938L;
+ private List<SelectItem> selectItems;
+ private String conversationIdOrOutcome;
+ private String resultingConversationIdOrOutcome;
+
+ @Create
+ public void createSelectItems()
+ {
+ ConversationEntries conversationEntries = ConversationEntries.getInstance();
+ if (conversationEntries==null)
+ {
+ selectItems = Collections.EMPTY_LIST;
+ }
+ else
+ {
+ Set<ConversationEntry> orderedEntries = new TreeSet<ConversationEntry>();
+ orderedEntries.addAll( conversationEntries.getConversationEntries() );
+ selectItems = new ArrayList<SelectItem>( conversationEntries.size() );
+ for ( ConversationEntry entry: orderedEntries )
+ {
+ if ( entry.isDisplayable() && !Session.instance().isInvalid() )
+ {
+ selectItems.add( new SelectItem( entry.getId(), entry.getDescription() ) );
+ }
+ }
+ }
+ }
+
+ public List<SelectItem> getSelectItems()
+ {
+ return selectItems;
+ }
+
+ private String getLongRunningConversationId()
+ {
+ Manager manager = Manager.instance();
+ if ( manager.isLongRunningConversation() )
+ {
+ return manager.getCurrentConversationId();
+ }
+ else if ( manager.isNestedConversation() )
+ {
+ return manager.getParentConversationId();
+ }
+ else
+ {
+ //TODO: is there any way to set it to the current outcome, instead of null?
+ return null;
+ }
+ }
+
+ public String getConversationIdOrOutcome()
+ {
+ return resultingConversationIdOrOutcome==null ?
+ getLongRunningConversationId() :
+ resultingConversationIdOrOutcome;
+ }
+
+ public void setConversationIdOrOutcome(String selectedId)
+ {
+ this.conversationIdOrOutcome = selectedId;
+ }
+
+ public String select()
+ {
+
+ boolean isOutcome = conversationIdOrOutcome==null ||
+ (!Character.isDigit(conversationIdOrOutcome.charAt(0)) && conversationIdOrOutcome.indexOf(':') < 0);
+
+ String actualOutcome;
+ if (isOutcome)
+ {
+ resultingConversationIdOrOutcome = conversationIdOrOutcome;
+ actualOutcome = conversationIdOrOutcome;
+ }
+ else
+ {
+ ConversationEntry ce = ConversationEntries.instance().getConversationEntry(conversationIdOrOutcome);
+ if (ce!=null)
+ {
+ resultingConversationIdOrOutcome = ce.getId();
+ ce.redirect();
+ }
+ actualOutcome = null;
+ }
+ return actualOutcome;
+ }
+
+}
Added: modules/trunk/faces/attic/UiComponent.java
===================================================================
--- modules/trunk/faces/attic/UiComponent.java (rev 0)
+++ modules/trunk/faces/attic/UiComponent.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,81 @@
+package org.jboss.seam.faces;
+
+import static org.jboss.seam.ScopeType.STATELESS;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.util.AbstractMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+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;
+
+/**
+ * Access to UIComponents in the current view, by id.
+ *
+ * @author Gavin King
+ *
+ */
+@Name("org.jboss.seam.faces.uiComponent")
+@BypassInterceptors
+@Scope(STATELESS)
+@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
+public class UiComponent
+{
+
+ @Unwrap
+ public Map<String, UIComponent> getViewComponents()
+ {
+ return new AbstractMap<String, UIComponent>()
+ {
+
+ @Override
+ public boolean containsKey(Object key) {
+ return get(key) != null;
+ }
+
+
+ @Override
+ public Set<Map.Entry<String, UIComponent>> entrySet()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public UIComponent get(Object key)
+ {
+ if ( !(key instanceof String) ) return null;
+ try
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ if (context == null) {
+ return null;
+ }
+
+ UIViewRoot viewRoot = context.getViewRoot();
+
+ if (viewRoot == null)
+ {
+ return null;
+ }
+
+ return viewRoot.findComponent( (String) key );
+ }
+ catch (IllegalArgumentException iae)
+ {
+ return null;
+ }
+ }
+
+ };
+ }
+
+}
Added: modules/trunk/faces/attic/UserPrincipal.java
===================================================================
--- modules/trunk/faces/attic/UserPrincipal.java (rev 0)
+++ modules/trunk/faces/attic/UserPrincipal.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,30 @@
+package org.jboss.seam.faces;
+
+import java.security.Principal;
+
+import javax.annotation.Named;
+import javax.context.ApplicationScoped;
+import javax.faces.context.FacesContext;
+
+/**
+ * Manager component for the current user Principal
+ * exposed via the JSF ExternalContext.
+ *
+ * @author Gavin King
+ */
+@Named
+@ApplicationScoped
+public class UserPrincipal extends org.jboss.seam.web.UserPrincipal
+{
+ @Unwrap @Override
+ public Principal getUserPrincipal()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if ( facesContext != null )
+ {
+ return facesContext.getExternalContext().getUserPrincipal();
+ }
+
+ return super.getUserPrincipal();
+ }
+}
Added: modules/trunk/faces/attic/Validation.java
===================================================================
--- modules/trunk/faces/attic/Validation.java (rev 0)
+++ modules/trunk/faces/attic/Validation.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,52 @@
+package org.jboss.seam.faces;
+
+import javax.annotation.Named;
+import javax.faces.context.FacesContext;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+import org.jboss.seam.faces.events.ValidationFailedEvent;
+
+/**
+ * Allows the application to determine whether the JSF validation
+ * phase completed successfully, or if a validation failure
+ * occurred. This functionality is actually provided by JSF 2 now.
+ * What this class does is raise a {@link ValidationFailedEvent}
+ * so that observers can react accordingly.
+ *
+ * @author Gavin king
+ */
+@Named
+public class Validation
+{
+ private boolean succeeded;
+ private boolean failed;
+
+ @Current Manager manager;
+
+ public void afterProcessValidations(FacesContext facesContext)
+ {
+ failed = facesContext.isValidationFailed();
+ if (failed)
+ {
+ manager.fireEvent(new ValidationFailedEvent());
+ }
+ succeeded = !failed;
+ }
+
+ public boolean isSucceeded()
+ {
+ return succeeded;
+ }
+
+ public boolean isFailed()
+ {
+ return failed;
+ }
+
+ public void fail()
+ {
+ failed = true;
+ succeeded = false;
+ }
+}
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Faces.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Faces.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Faces.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -10,8 +10,9 @@
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.inject.DeploymentType;
+import javax.enterprise.inject.deployment.DeploymentType;
+
/**
* A binding type used on a JSF-specific implementation
* that specializes Seam's standard implementation.
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesContextProducer.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,7 +1,7 @@
//$Id: FacesContext.java 5350 2007-06-20 17:53:19Z gavin $
package org.jboss.seam.faces;
-import javax.inject.Produces;
+import javax.enterprise.inject.Produces;
import javax.faces.context.FacesContext;
/**
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesExpressions.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,10 +1,11 @@
//$Id: FacesExpressions.java 9684 2008-12-01 21:41:20Z dan.j.allen $
package org.jboss.seam.faces;
-import javax.context.ApplicationScoped;
import javax.el.ELContext;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.deployment.Specializes;
import javax.faces.context.FacesContext;
-import javax.inject.Specializes;
+
import org.jboss.seam.el.Expressions;
/**
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesResourceLoader.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -2,9 +2,10 @@
import java.io.InputStream;
import java.net.URL;
+
import javax.faces.context.FacesContext;
-import javax.inject.Current;
import javax.servlet.ServletContext;
+
import org.jboss.seam.international.ResourceLoader;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/FacesStatusMessages.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,13 +4,13 @@
import java.util.List;
import java.util.Map;
-import javax.context.ConversationScoped;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.deployment.Specializes;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.inject.Initializer;
-import javax.inject.Specializes;
import org.jboss.seam.international.Interpolator;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.international.StatusMessages;
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/Validation.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,9 +1,9 @@
package org.jboss.seam.faces;
-import javax.annotation.Named;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Named;
+import javax.enterprise.inject.spi.BeanManager;
import javax.faces.context.FacesContext;
-import javax.inject.Current;
-import javax.inject.manager.Manager;
import org.jboss.seam.faces.events.ValidationFailedEvent;
@@ -22,7 +22,7 @@
private boolean succeeded;
private boolean failed;
- @Current Manager manager;
+ @Current BeanManager manager;
public void afterProcessValidations(FacesContext facesContext)
{
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/annotations/DataModel.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -5,25 +5,22 @@
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import javax.context.ScopeType;
-
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import org.jboss.seam.faces.annotations.DataBinderClass;
import org.jboss.seam.faces.databinding.DataModelBinder;
/**
* Outjects a collection to the same scope as the owning component
* (or to the EVENT scope in the case of a stateless component),
* after wrapping as a JSF DataModel (a List as a ListDataModel, a
- * Map as a MapDataModel, a Set as a SetDataModel, an array as an
+ * Map as a MapDataModel, a Set as a SetDataModel, an array as an
* ArrayDataModel). Note that the List, Map, Set or array
* will be re-wrapped and re-outjected each time the current
* component value is different to the value held by the
- * context variable as determined by calling equals() on the
+ * context variable as determined by calling equals() on the
* underlying collection.
*
* @author Gavin King
@@ -40,16 +37,16 @@
public @interface DataModel
{
/**
- * The context variable name. Defaults to the name of
+ * The context variable name. Defaults to the name of
* the annotated field or getter method.
*/
String value() default "";
/**
- * Specifies the scope to outject the DataModel to.
- * If no scope is explicitly specified, the scope of
- * the component with the @DataModel attribute is used.
- * But if the component scope is STATELESS, the EVENT
+ * Specifies the scope to outject the DataModel to.
+ * If no scope is explicitly specified, the scope of
+ * the component with the @DataModel attribute is used.
+ * But if the component scope is STATELESS, the EVENT
* scope is used.
*
*/
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/LocaleConfig.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -5,11 +5,11 @@
import java.util.Set;
import java.util.StringTokenizer;
-import javax.context.ApplicationScoped;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Initializer;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
-import javax.inject.Initializer;
/**
* FIXME update docs
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/databinding/DataModelBinder.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,10 +3,10 @@
import java.lang.annotation.Annotation;
import java.util.Map;
-import javax.inject.Current;
+import javax.enterprise.inject.Current;
+import org.jboss.seam.faces.DataModels;
import org.jboss.seam.faces.annotations.DataModel;
-import org.jboss.seam.faces.DataModels;
/**
* Exposes a List, array, Map or Set to the UI as a JSF DataModel
@@ -39,11 +39,11 @@
public Object getSelection(DataModel out, javax.faces.model.DataModel wrapper)
{
- if ( wrapper.getRowCount()==0 || wrapper.getRowIndex()<0 ||
+ if ( wrapper.getRowCount()==0 || wrapper.getRowIndex()<0 ||
wrapper.getRowIndex()>=wrapper.getRowCount())
{
return null;
- }
+ }
else
{
Object rowData = wrapper.getRowData();
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/AfterPhase.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/AfterPhase.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/AfterPhase.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -9,7 +9,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.inject.BindingType;
+import javax.enterprise.inject.BindingType;
/**
* Binding type that identifies a PhaseEvent which is raised
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/BeforePhase.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/BeforePhase.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/BeforePhase.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -9,7 +9,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.inject.BindingType;
+import javax.enterprise.inject.BindingType;
/**
* Binding type that identifies a PhaseEvent which is
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ManagedSeamPhaseListener.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ManagedSeamPhaseListener.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ManagedSeamPhaseListener.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,11 +1,11 @@
package org.jboss.seam.faces.lifecycle;
-import javax.context.ApplicationScoped;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.BeanManager;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
-import javax.inject.AnnotationLiteral;
-import javax.inject.Initializer;
-import javax.inject.manager.Manager;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
@@ -22,13 +22,13 @@
@ApplicationScoped
class ManagedSeamPhaseListener
{
- private Manager manager;
+ private BeanManager manager;
private UserTransaction transaction;
public ManagedSeamPhaseListener() {}
- public @Initializer ManagedSeamPhaseListener(Manager manager, UserTransaction transaction)
+ public @Initializer ManagedSeamPhaseListener(BeanManager manager, UserTransaction transaction)
{
this.manager = manager;
this.transaction = transaction;
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/Transaction.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/Transaction.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/Transaction.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,7 +1,7 @@
package org.jboss.seam.faces.lifecycle;
-import javax.context.RequestScoped;
-import javax.inject.Produces;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,10 +1,10 @@
package org.jboss.seam.faces.lifecycle;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.BeanManager;
import javax.faces.component.UIViewRoot;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import javax.inject.UnsatisfiedDependencyException;
-import javax.inject.manager.Manager;
import org.jboss.seam.bridge.ManagerBridge;
import org.jboss.seam.international.StatusMessages;
@@ -39,14 +39,14 @@
{
try
{
- Manager manager = ManagerBridge.getProvider().getCurrentManager();
+ BeanManager manager = ManagerBridge.getProvider().getCurrentManager();
// tests
if (manager != null)
{
manager.getInstanceByType(StatusMessages.class).onBeforeRender();
}
}
- catch (UnsatisfiedDependencyException e)
+ catch (UnsatisfiedResolutionException e)
{
log.warn("Could not locate the StatusMessages bean. Status messages will not be transfered to the FacesContext.");
}
Added: modules/trunk/international/attic/LocaleSelector.java
===================================================================
--- modules/trunk/international/attic/LocaleSelector.java (rev 0)
+++ modules/trunk/international/attic/LocaleSelector.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,211 @@
+package org.jboss.seam.international;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.model.SelectItem;
+import javax.inject.Current;
+import javax.inject.Initializer;
+import javax.inject.Produces;
+import javax.inject.manager.Manager;
+import javax.servlet.ServletRequest;
+
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.faces.Selector;
+import org.jboss.seam.international.events.LocaleSelectedEvent;
+import org.jboss.seam.international.util.Strings;
+import org.jboss.seam.web.ServletContexts;
+
+/**
+ * Selects the current user's locale
+ *
+ * @author Gavin King
+ */
+@Named
+@SessionScoped
+public class LocaleSelector extends Selector
+{
+ private static final long serialVersionUID = -6087667065688208261L;
+
+ @Current Manager manager;
+
+ private String language;
+ private String country;
+ private String variant;
+
+ @Initializer
+ public void initLocale()
+ {
+ String localeString = getCookieValueIfEnabled();
+ if (localeString!=null) setLocaleString(localeString);
+ }
+
+ @Override
+ protected String getCookieName()
+ {
+ return "org.jboss.seam.core.Locale";
+ }
+
+ /**
+ * Force the resource bundle to reload, using the current locale,
+ * and raise the org.jboss.seam.localeSelected event.
+ */
+ public void select()
+ {
+ FacesContext.getCurrentInstance().getViewRoot().setLocale( getLocale() );
+ //Contexts.removeFromAllContexts("org.jboss.seam.core.resourceBundle");
+ Contexts.removeFromAllContexts("org.jboss.seam.international.messages");
+
+ setCookieValueIfEnabled( getLocaleString() );
+
+ manager.fireEvent(new LocaleSelectedEvent(getLocaleString()));
+ }
+
+ public void select(ValueChangeEvent event)
+ {
+ setLocaleString( (String) event.getNewValue() );
+ select();
+ }
+
+ /**
+ * Set the language and force resource bundle reload, useful for quick action links:
+ * <tt><h:commandLink value="DE" action="#{localeSelector.selectLanguage('de')}"/>"/></tt>
+ */
+ public void selectLanguage(String language) {
+ setLanguage(language);
+ select();
+ }
+
+ public Locale calculateLocale(Locale jsfLocale)
+ {
+ if ( !Strings.isEmpty(variant) )
+ {
+ return new java.util.Locale(language, country, variant);
+ }
+ else if ( !Strings.isEmpty(country) )
+ {
+ return new java.util.Locale(language, country);
+ }
+ else if ( !Strings.isEmpty(language) )
+ {
+ return new java.util.Locale(language);
+ }
+ else
+ {
+ return jsfLocale;
+ }
+ }
+
+ public void setLocale(Locale locale)
+ {
+ language = Strings.nullIfEmpty( locale.getLanguage() );
+ country = Strings.nullIfEmpty( locale.getCountry() );
+ variant = Strings.nullIfEmpty( locale.getVariant() );
+ }
+
+ public String getLocaleString()
+ {
+ return getLocale().toString();
+ }
+
+ public void setLocaleString(String localeString)
+ {
+ StringTokenizer tokens = new StringTokenizer(localeString, "-_");
+ language = tokens.hasMoreTokens() ? tokens.nextToken() : null;
+ country = tokens.hasMoreTokens() ? tokens.nextToken() : null;
+ variant = tokens.hasMoreTokens() ? tokens.nextToken() : null;
+ }
+
+ public List<SelectItem> getSupportedLocales()
+ {
+ List<SelectItem> selectItems = new ArrayList<SelectItem>();
+ Iterator<Locale> locales = FacesContext.getCurrentInstance().getApplication().getSupportedLocales();
+ while ( locales.hasNext() )
+ {
+ Locale locale = locales.next();
+ if ( !Strings.isEmpty( locale.getLanguage() ) )
+ {
+ selectItems.add( new SelectItem( locale.toString(), locale.getDisplayName(locale) ) );
+ }
+ }
+ return selectItems;
+ }
+
+ /**
+ * Get the selected locale
+ */
+ @Produces public Locale getLocale()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext!=null)
+ {
+ //Note: this does a double dispatch back to LocaleSelector.calculateLocale()
+ return facesContext.getApplication().getViewHandler().calculateLocale(facesContext);
+ }
+
+ ServletContexts servletContexts = ServletContexts.getInstance();
+ if (servletContexts!=null)
+ {
+ ServletRequest request = servletContexts.getRequest();
+ if (request!=null)
+ {
+ return calculateLocale( request.getLocale() );
+ }
+ }
+
+ return calculateLocale( Locale.getDefault() );
+ }
+
+ public static LocaleSelector instance()
+ {
+ if ( !Contexts.isSessionContextActive() )
+ {
+ throw new IllegalStateException("No active session context");
+ }
+ return (LocaleSelector) Component.getInstance(LocaleSelector.class, ScopeType.SESSION);
+ }
+
+ public String getCountry()
+ {
+ if (country==null) return getLocale().getCountry();
+ return country;
+ }
+
+ public void setCountry(String country)
+ {
+ setDirty(this.country, country);
+ this.country = country;
+ }
+
+ public String getLanguage()
+ {
+ if (language==null) return getLocale().getLanguage();
+ return language;
+ }
+
+ public void setLanguage(String language)
+ {
+ setDirty(this.language, language);
+ this.language = language;
+ }
+
+ public String getVariant()
+ {
+ if (variant==null) return getLocale().getVariant();
+ return variant;
+ }
+
+ public void setVariant(String variant)
+ {
+ setDirty(this.variant, variant);
+ this.variant = variant;
+ }
+
+}
Added: modules/trunk/international/attic/ResourceBundleProducer.java
===================================================================
--- modules/trunk/international/attic/ResourceBundleProducer.java (rev 0)
+++ modules/trunk/international/attic/ResourceBundleProducer.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,153 @@
+package org.jboss.seam.international;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * The Seam resource bundle which searches for resources in delegate resource
+ * bundles specified in pages.xml, and a configurable list of delegate resource
+ * bundles specified in components.xml.
+ *
+ * @see ResourceLoader
+ * @author Gavin King
+ */
+public class ResourceBundleProducer extends java.util.ResourceBundle
+{
+ private Map<Locale, List<ResourceBundle>> bundleCache = new ConcurrentHashMap<Locale, List<ResourceBundle>>();
+
+ /**
+ * Get an instance for the current Seam Locale
+ *
+ * @see Locale
+ *
+ * @return a SeamResourceBundle
+ */
+ public static java.util.ResourceBundle getBundle()
+ {
+ return getBundleNamed(ResourceBundleProducer.class.getName());
+ }
+
+
+ public static java.util.ResourceBundle getBundleNamed(String bundleName)
+ {
+ return java.util.ResourceBundle.getBundle(bundleName,
+ org.jboss.seam.core.Locale.instance());
+ }
+
+ @Override
+ public Enumeration<String> getKeys()
+ {
+ List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
+ List<ResourceBundle> bundles = getBundlesForCurrentLocale();
+ Enumeration<String>[] enumerations = new Enumeration[bundles.size() + pageBundles.size()];
+
+ int i = 0;
+ for (java.util.ResourceBundle bundle: pageBundles) {
+ enumerations[i++] = bundle.getKeys();
+ }
+
+ for (ResourceBundle bundle: bundles) {
+ enumerations[i++] = bundle.getKeys();
+ }
+
+ return new EnumerationEnumeration<String>(enumerations);
+ }
+
+ @Override
+ public Locale getLocale()
+ {
+ return org.jboss.seam.core.Locale.instance();
+ }
+
+ @Override
+ protected Object handleGetObject(String key)
+ {
+// List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
+// for (java.util.ResourceBundle pageBundle : pageBundles)
+// {
+// try
+// {
+// return interpolate(pageBundle.getObject(key));
+// }
+// catch (MissingResourceException mre) {}
+// }
+
+ for (java.util.ResourceBundle littleBundle : getBundlesForCurrentLocale())
+ {
+ try
+ {
+ return interpolate( littleBundle.getObject(key) );
+ }
+ catch (MissingResourceException mre) {}
+ }
+
+ return null; // superclass is responsible for throwing MRE
+ }
+
+ private List<java.util.ResourceBundle> getBundlesForCurrentLocale()
+ {
+ Locale instance = org.jboss.seam.core.Locale.instance();
+ List<ResourceBundle> bundles = bundleCache.get(instance);
+ if ( bundles==null )
+ {
+ bundles = loadBundlesForCurrentLocale();
+ bundleCache.put(instance, bundles);
+ }
+ return bundles;
+
+ }
+
+ private List<ResourceBundle> loadBundlesForCurrentLocale()
+ {
+ List<ResourceBundle> bundles = new ArrayList<ResourceBundle>();
+ ResourceLoader resourceLoader = ResourceLoader.instance();
+ for (String bundleName : resourceLoader.getBundleNames())
+ {
+ ResourceBundle bundle = resourceLoader.loadBundle(bundleName);
+ if (bundle != null) bundles.add(bundle);
+ }
+ ResourceBundle bundle = resourceLoader.loadBundle("ValidationMessages");
+ if (bundle != null)
+ {
+ bundles.add(bundle);
+ }
+ bundle = resourceLoader.loadBundle("org/hibernate/validation/ValidationMessages");
+ if (bundle != null) bundles.add(bundle);
+ bundle = resourceLoader.loadBundle("javax.faces.Messages");
+ if (bundle != null) bundles.add(bundle);
+ return Collections.unmodifiableList(bundles);
+ }
+
+ private Object interpolate(Object message)
+ {
+ return message!=null && message instanceof String ?
+ Interpolator.instance().interpolate( (String) message ) :
+ message;
+ }
+
+ /*
+ private List<java.util.ResourceBundle> getPageResourceBundles()
+ {
+ // TODO: oops! A hard dependency to JSF!
+ String viewId = Pages.getCurrentViewId();
+ if (viewId != null)
+ {
+ // we can't cache these bundles, since the viewId
+ // may change in the middle of a request
+ return Pages.instance().getResourceBundles(viewId);
+ }
+ else
+ {
+ return Collections.EMPTY_LIST;
+ }
+ }*/
+
+
+}
Added: modules/trunk/international/attic/SeamResourceBundle.java
===================================================================
--- modules/trunk/international/attic/SeamResourceBundle.java (rev 0)
+++ modules/trunk/international/attic/SeamResourceBundle.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,156 @@
+package org.jboss.seam.international;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.inject.Current;
+
+/**
+ * The Seam resource bundle which searches for resources in delegate resource
+ * bundles specified in pages.xml, and a configurable list of delegate resource
+ * bundles specified in components.xml.
+ *
+ * @see ResourceLoader
+ * @author Gavin King
+ *
+ */
+public class SeamResourceBundle extends java.util.ResourceBundle
+{
+ private Map<Locale, List<ResourceBundle>> bundleCache = new ConcurrentHashMap<Locale, List<ResourceBundle>>();
+
+ @Current Locale locale;
+ @Current Interpolator interpolator;
+ @Current ResourceLoader resourceLoader;
+
+ /**
+ * Get an instance for the current Seam Locale
+ *
+ * @see Locale
+ *
+ * @return a SeamResourceBundle
+ */
+ public java.util.ResourceBundle getBundle()
+ {
+ return java.util.ResourceBundle.getBundle(SeamResourceBundle.class.getName(), locale);
+ }
+
+
+ public java.util.ResourceBundle getBundleNamed(String bundleName)
+ {
+ return java.util.ResourceBundle.getBundle(bundleName, locale);
+ }
+
+
+ private List<java.util.ResourceBundle> getBundlesForCurrentLocale()
+ {
+ List<ResourceBundle> bundles = bundleCache.get(locale);
+ if ( bundles==null )
+ {
+ bundles = loadBundlesForCurrentLocale();
+ bundleCache.put(locale, bundles);
+ }
+ return bundles;
+
+ }
+
+ private List<ResourceBundle> loadBundlesForCurrentLocale()
+ {
+ List<ResourceBundle> bundles = new ArrayList<ResourceBundle>();
+ for (String bundleName : resourceLoader.getBundleNames())
+ {
+ ResourceBundle bundle = resourceLoader.loadBundle(bundleName);
+ if (bundle != null) bundles.add(bundle);
+ }
+ ResourceBundle bundle = resourceLoader.loadBundle("ValidatorMessages");
+ if (bundle != null)
+ {
+ bundles.add(bundle);
+ }
+ bundle = resourceLoader.loadBundle("org/hibernate/validator/resources/DefaultValidatorMessages");
+ if (bundle != null) bundles.add(bundle);
+ bundle = resourceLoader.loadBundle("javax.faces.Messages");
+ if (bundle != null) bundles.add(bundle);
+ return Collections.unmodifiableList(bundles);
+ }
+
+ @Override
+ public Enumeration<String> getKeys()
+ {
+ List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
+ List<ResourceBundle> bundles = getBundlesForCurrentLocale();
+ Enumeration<String>[] enumerations = new Enumeration[bundles.size() + pageBundles.size()];
+
+ int i = 0;
+ for (java.util.ResourceBundle bundle: pageBundles) {
+ enumerations[i++] = bundle.getKeys();
+ }
+
+ for (ResourceBundle bundle: bundles) {
+ enumerations[i++] = bundle.getKeys();
+ }
+
+ return new EnumerationEnumeration<String>(enumerations);
+ }
+
+ @Override
+ protected Object handleGetObject(String key)
+ {
+ List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
+ for (java.util.ResourceBundle pageBundle : pageBundles)
+ {
+ try
+ {
+ return interpolate(pageBundle.getObject(key));
+ }
+ catch (MissingResourceException mre) {}
+ }
+
+ for (java.util.ResourceBundle littleBundle : getBundlesForCurrentLocale())
+ {
+ try
+ {
+ return interpolate( littleBundle.getObject(key) );
+ }
+ catch (MissingResourceException mre) {}
+ }
+
+ return null; // superclass is responsible for throwing MRE
+ }
+
+ private Object interpolate(Object message)
+ {
+ return message!=null && message instanceof String ?
+ interpolator.interpolate( (String) message ) :
+ message;
+ }
+
+ private List<java.util.ResourceBundle> getPageResourceBundles()
+ {
+ // TODO: oops! A hard dependency to JSF!
+ String viewId = Pages.getCurrentViewId();
+ if (viewId != null)
+ {
+ // we can't cache these bundles, since the viewId
+ // may change in the middle of a request
+ return Pages.instance().getResourceBundles(viewId);
+ }
+ else
+ {
+ return Collections.EMPTY_LIST;
+ }
+ }
+
+ @Override
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+}
\ No newline at end of file
Added: modules/trunk/international/attic/TimeZoneSelector.java
===================================================================
--- modules/trunk/international/attic/TimeZoneSelector.java (rev 0)
+++ modules/trunk/international/attic/TimeZoneSelector.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -0,0 +1,93 @@
+package org.jboss.seam.international;
+
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.faces.event.ValueChangeEvent;
+import javax.inject.Initializer;
+import javax.inject.Produces;
+
+import org.jboss.seam.faces.Selector;
+
+/**
+ * Selects the current user's time zone, defaulting
+ * to the server time zone.
+ *
+ * @author Gavin King
+ */
+@SessionScoped
+public class TimeZoneSelector extends Selector
+{
+ private static final long serialVersionUID = -5013819375360015369L;
+
+ private String id;
+
+ @Initializer
+ public void initTimeZone()
+ {
+ String timeZoneId = getCookieValueIfEnabled();
+ if (timeZoneId!=null) setTimeZoneId(timeZoneId);
+ }
+
+ @Override
+ protected String getCookieName()
+ {
+ return "org.jboss.seam.core.TimeZone";
+ }
+
+ /**
+ * Force the resource bundle to reload, using the current locale,
+ * and raise the org.jboss.seam.timeZoneSelected event
+ */
+ public void select()
+ {
+ setCookieValueIfEnabled( getTimeZoneId() );
+
+ if ( Events.exists() )
+ {
+ Events.instance().raiseEvent( "org.jboss.seam.timeZoneSelected", getTimeZoneId() );
+ }
+ }
+
+ public void select(ValueChangeEvent event)
+ {
+ selectTimeZone( (String) event.getNewValue() );
+ }
+
+ public void selectTimeZone(String timeZoneId)
+ {
+ setTimeZoneId(timeZoneId);
+ select();
+ }
+
+ public void setTimeZone(java.util.TimeZone timeZone)
+ {
+ setTimeZoneId( timeZone.getID() );
+ }
+
+ public void setTimeZoneId(String id)
+ {
+ setDirty(this.id, id);
+ this.id = id;
+ }
+
+ public String getTimeZoneId()
+ {
+ return id;
+ }
+
+ /**
+ * Get the selected timezone
+ */
+ @Produces @Named public java.util.TimeZone getTimeZone()
+ {
+ if (id==null)
+ {
+ return java.util.TimeZone.getDefault();
+ }
+ else
+ {
+ return java.util.TimeZone.getTimeZone( getTimeZoneId() );
+ }
+ }
+
+}
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/Interpolator.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,12 +1,13 @@
package org.jboss.seam.international;
import java.io.Serializable;
-import org.jboss.seam.el.*;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.StringTokenizer;
-import javax.inject.Current;
+import javax.enterprise.inject.Current;
+
+import org.jboss.seam.el.Expressions;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/LocaleProducer.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,11 +1,11 @@
package org.jboss.seam.international;
-import javax.annotation.Named;
-import javax.inject.Produces;
+import javax.enterprise.inject.Named;
+import javax.enterprise.inject.Produces;
/**
* Producer component for the current locale. This base
- * implementation simply returns the server default
+ * implementation simply returns the server default
* locale.
*
* @author Gavin King
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/Messages.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -11,11 +11,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.inject.BindingType;
+import javax.enterprise.inject.BindingType;
/**
* Binding type for messages
- *
+ *
* @author Shane Bryzak
*/
@Target( { TYPE, METHOD, PARAMETER, FIELD })
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/MessagesProducer.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -10,10 +10,9 @@
import java.util.ResourceBundle;
import java.util.Set;
-import javax.annotation.Named;
-import javax.context.RequestScoped;
-import javax.inject.Current;
-import javax.inject.Produces;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Named;
+import javax.enterprise.inject.Produces;
/**
* Factory for a Map that contains interpolated messages defined in the
@@ -30,9 +29,9 @@
//@Current
ResourceBundle bundle;
- protected Map createMap()
- {
- // AbstractMap uses the implementation of entrySet to perform all its
+ protected Map createMap()
+ {
+ // AbstractMap uses the implementation of entrySet to perform all its
// operations - for a resource bundle this is very inefficient for keys
return new AbstractMap<String, String>()
{
@@ -41,7 +40,7 @@
private java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("messages");
@Override
- public String get(Object key)
+ public String get(Object key)
{
if (key instanceof String)
{
@@ -67,15 +66,15 @@
}
@Override
- public Set<Map.Entry<String, String>> entrySet()
+ public Set<Map.Entry<String, String>> entrySet()
{
- Enumeration<String> keys = bundle.getKeys();
+ Enumeration<String> keys = bundle.getKeys();
Map<String, String> map = new HashMap<String, String>();
while ( keys.hasMoreElements() )
{
String key = keys.nextElement();
map.put( key, get(key) );
- }
+ }
return Collections.unmodifiableSet(map.entrySet());
}
@@ -88,7 +87,7 @@
@Override
public Set<String> keySet()
{
- Enumeration<String> keys = bundle.getKeys();
+ Enumeration<String> keys = bundle.getKeys();
return new HashSet<String>(Collections.list(keys));
}
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceBundle.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,14 +1,18 @@
package org.jboss.seam.international;
-import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.inject.BindingType;
+import javax.enterprise.inject.BindingType;
+
/**
* The binding type for the Seam resource bundle.
*
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/ResourceLoader.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -5,8 +5,9 @@
import java.net.URL;
import java.util.Locale;
import java.util.MissingResourceException;
-import javax.inject.Current;
-import javax.inject.manager.Manager;
+
+import javax.enterprise.inject.spi.BeanManager;
+
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -22,19 +23,19 @@
private String[] bundleNames = { "messages" };
//@Current
- Manager manager;
+ BeanManager manager;
/**
* The configurable list of delegate resource bundle names
*
* @return an array of resource bundle names
*/
- public String[] getBundleNames()
+ public String[] getBundleNames()
{
return bundleNames;
}
- public void setBundleNames(String[] bundleNames)
+ public void setBundleNames(String[] bundleNames)
{
this.bundleNames = bundleNames;
}
@@ -54,7 +55,7 @@
return getResourceAsStream(resource, relativePath);
}
- public URL getResource(String resource)
+ public URL getResource(String resource)
{
String relativePath = resource;
if (resource.startsWith("/"))
@@ -76,14 +77,14 @@
* @param bundleName the name of the resource bundle
* @return an instance of java.util.ResourceBundle
*/
- public java.util.ResourceBundle loadBundle(String bundleName)
+ public java.util.ResourceBundle loadBundle(String bundleName)
{
try
{
- java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(
- bundleName,
+ java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(
+ bundleName,
manager.getInstanceByType(Locale.class),
- Thread.currentThread().getContextClassLoader()
+ Thread.currentThread().getContextClassLoader()
);
log.debug("loaded resource bundle: " + bundleName);
return bundle;
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/StatusMessages.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,4 +1,4 @@
-/*
+/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
@@ -32,10 +32,11 @@
import java.util.List;
import java.util.Map;
-import javax.annotation.Named;
-import javax.context.ConversationScoped;
-import javax.inject.Initializer;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Named;
import javax.validation.ConstraintViolation;
+
import org.jboss.seam.international.StatusMessage.Severity;
/**
@@ -152,7 +153,7 @@
/**
* Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
+ * using the provided key. If the message is found, it is used, otherwise,
* the defaultMessageTemplate will be used.
*
* You can also specify the severity, and parameters to be interpolated
@@ -169,11 +170,11 @@
/**
* Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
- * the defaultMessageTemplate will be used.
+ * using the provided key. If the message is found, it is used, otherwise,
+ * the defaultMessageTemplate will be used.
*
* The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
+ * used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
* You can also specify the severity, and parameters to be interpolated
@@ -224,7 +225,7 @@
* Create a new status message, with the messageTemplate is as the message.
*
* The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
+ * used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
* A severity of WARN will be used, and you can specify parameters to be
@@ -240,7 +241,7 @@
* Create a new status message, with the messageTemplate is as the message.
*
* The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
+ * used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
* You can also specify the severity, and parameters to be interpolated
@@ -253,10 +254,10 @@
/**
* Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
+ * using the provided key. If the message is found, it is used, otherwise,
* the defaultMessageTemplate will be used.
*
- * A severity of INFO will be used, and you can specify parameters to be
+ * A severity of INFO will be used, and you can specify parameters to be
* interpolated
*/
public void addFromResourceBundle(String key, Object... params)
@@ -278,10 +279,10 @@
/**
* Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
+ * using the provided key. If the message is found, it is used, otherwise,
* the defaultMessageTemplate will be used.
*
- * A severity of INFO will be used, and you can specify parameters to be
+ * A severity of INFO will be used, and you can specify parameters to be
* interpolated
*
*/
@@ -292,7 +293,7 @@
/**
* Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
+ * using the provided key. If the message is found, it is used, otherwise,
* the defaultMessageTemplate will be used.
*
* You can also specify the severity, and parameters to be interpolated
@@ -308,7 +309,7 @@
* using the provided key.
*
* The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
+ * used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
* A severity of WARN will be used, and you can specify parameters to be
@@ -325,7 +326,7 @@
* using the provided key.
*
* The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
+ * used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
* You can also specify the severity, and parameters to be interpolated
@@ -338,11 +339,11 @@
/**
* Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
+ * using the provided key. If the message is found, it is used, otherwise,
* the defaultMessageTemplate will be used.
*
* The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
+ * used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
* A severity of WARN will be used, and you can specify parameters to be
@@ -356,11 +357,11 @@
/**
* Add a status message, looking up the message in the resource bundle
- * using the provided key. If the message is found, it is used, otherwise,
+ * using the provided key. If the message is found, it is used, otherwise,
* the defaultMessageTemplate will be used.
*
* The message will be added to the widget specified by the ID. The algorithm
- * used determine which widget the id refers to is determined by the view
+ * used determine which widget the id refers to is determined by the view
* layer implementation in use.
*
* You can also specify the severity, and parameters to be interpolated
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZones.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZones.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZones.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -11,7 +11,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.inject.BindingType;
+import javax.enterprise.inject.BindingType;
/**
* Binding type for timezones
Modified: modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java
===================================================================
--- modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/international/src/main/java/org/jboss/seam/international/TimeZonesProducer.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -6,9 +6,9 @@
import java.util.List;
import java.util.TimeZone;
-import javax.context.ApplicationScoped;
-import javax.inject.Initializer;
-import javax.inject.Produces;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Produces;
/**
* <p>Seam component that provides a list of time zones, limited to time zones
Modified: modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java
===================================================================
--- modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,6 +1,6 @@
package org.jboss.seam.bridge.jndi;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.spi.BeanManager;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -23,14 +23,14 @@
private LogProvider log = Logging.getLogProvider(JndiManagerProvider.class);
- private Manager manager;
+ private BeanManager manager;
public JndiManagerProvider()
{
lookupManager();
}
- public Manager getCurrentManager()
+ public BeanManager getCurrentManager()
{
return manager;
}
@@ -42,11 +42,11 @@
InitialContext initialContext = new InitialContext();
try
{
- manager = (Manager) initialContext.lookup(JCDI_MANAGER_JNDI_NAME);
+ manager = (BeanManager) initialContext.lookup(JCDI_MANAGER_JNDI_NAME);
}
catch (NamingException e)
{
- manager = (Manager) initialContext.lookup(JCDI_MANAGER_ALT_JNDI_NAME);
+ manager = (BeanManager) initialContext.lookup(JCDI_MANAGER_ALT_JNDI_NAME);
}
}
catch (NamingException e)
Modified: modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java
===================================================================
--- modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,11 +1,9 @@
package org.jboss.seam.bridge.openwebbeans;
-import javax.el.ELResolver;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.spi.BeanManager;
import org.apache.webbeans.container.activity.ActivityManager;
import org.jboss.seam.bridge.spi.ManagerProvider;
-import org.jboss.webbeans.el.WebBeansELResolver;
/**
* An implementation of Seam's Manager SPI interface for integrating Seam with
@@ -15,8 +13,9 @@
*/
public class OpenWebBeansManagerProvider implements ManagerProvider
{
- public Manager getCurrentManager()
+ public BeanManager getCurrentManager()
{
- return ActivityManager.getInstance().getCurrentActivity();
+ // FIXME: waiting on upgrade
+ return (BeanManager) ActivityManager.getInstance().getCurrentActivity();
}
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -2,10 +2,10 @@
import java.io.Serializable;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.inject.Current;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Named;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.security.events.CredentialsInitializedEvent;
import org.jboss.seam.security.events.CredentialsUpdatedEvent;
@@ -23,7 +23,7 @@
private static final LogProvider log = Logging.getLogProvider(Credentials.class);
- @Current Manager manager;
+ @Current BeanManager manager;
private String username;
private String password;
@@ -59,7 +59,7 @@
{
this.username = username;
invalid = false;
- manager.fireEvent(new CredentialsUpdatedEvent());
+ manager.fireEvent(new CredentialsUpdatedEvent());
}
}
@@ -75,12 +75,12 @@
this.password = password;
invalid = false;
manager.fireEvent(new CredentialsUpdatedEvent());
- }
+ }
}
public boolean isSet()
{
- return getUsername() != null && password != null;
+ return getUsername() != null && password != null;
}
public boolean isInvalid()
@@ -103,5 +103,5 @@
public String toString()
{
return "Credentials[" + username + "]";
- }
+ }
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,16 +1,7 @@
package org.jboss.seam.security;
-import java.lang.reflect.Method;
+import javax.enterprise.context.ApplicationScoped;
-import javax.context.ApplicationScoped;
-import javax.inject.Current;
-import javax.inject.manager.Manager;
-import javax.persistence.EntityManager;
-
-import org.jboss.seam.security.annotations.Restrict;
-//import org.jboss.seam.persistence.PersistenceProvider;
-import org.jboss.seam.security.util.Strings;
-
/**
* Entity permission checks
*
@@ -37,10 +28,10 @@
public void setEntityManagerName(String name)
{
this.entityManagerName = name;
- }
+ }
public void checkEntityPermission(Object entity, EntityAction action)
- {
+ {
if (!Identity.isSecurityEnabled()) return;
Identity identity = manager.getInstanceByType(Identity.class);
@@ -51,7 +42,7 @@
Class beanClass = provider.getBeanClass(entity);
if (beanClass != null)
- {
+ {
Method m = null;
switch (action)
{
@@ -92,5 +83,5 @@
}
}
}
- */
+ */
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -10,13 +10,13 @@
import java.util.List;
import java.util.Set;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
import javax.el.ValueExpression;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Named;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
@@ -46,14 +46,14 @@
import org.jboss.webbeans.log.Logging;
/**
- * API for authorization and authentication via Seam security.
+ * API for authorization and authentication via Seam security.
*
* @author Shane Bryzak
*/
@Named
@SessionScoped
public class Identity implements Serializable
-{
+{
private static final long serialVersionUID = 3751659008033189259L;
protected static boolean securityEnabled = true;
@@ -62,17 +62,17 @@
private static final LogProvider log = Logging.getLogProvider(Identity.class);
- @Current private Manager manager;
+ @Current private BeanManager manager;
@Current private Credentials credentials;
@Current private PermissionMapper permissionMapper;
@Current private Expressions expressions;
- private Principal principal;
+ private Principal principal;
private Subject subject;
- private String jaasConfigName = null;
- private List<String> preAuthenticationRoles = new ArrayList<String>();
+ private String jaasConfigName = null;
+ private List<String> preAuthenticationRoles = new ArrayList<String>();
- private transient ThreadLocal<Boolean> systemOp;
+ private transient ThreadLocal<Boolean> systemOp;
/**
* Flag that indicates we are in the process of authenticating
@@ -81,7 +81,7 @@
@Initializer
public void create()
- {
+ {
subject = new Subject();
}
@@ -101,7 +101,7 @@
* @return true if the user is logged in
*/
public boolean isLoggedIn()
- {
+ {
// If there is a principal set, then the user is logged in.
return getPrincipal() != null;
}
@@ -123,7 +123,7 @@
quietLogin();
}
- return isLoggedIn();
+ return isLoggedIn();
}
public Principal getPrincipal()
@@ -140,7 +140,7 @@
* Performs an authorization check, based on the specified security expression.
*
* @param expr The security expression to evaluate
- * @throws NotLoggedInException Thrown if the authorization check fails and
+ * @throws NotLoggedInException Thrown if the authorization check fails and
* the user is not authenticated
* @throws AuthorizationException Thrown if the authorization check fails and
* the user is authenticated
@@ -156,7 +156,7 @@
if (!expressions.getValue(expression, Boolean.class))
{
if (!isLoggedIn())
- {
+ {
manager.fireEvent(new NotLoggedInEvent());
log.debug(String.format(
@@ -176,13 +176,13 @@
* Performs an authorization check, based on the specified security expression string.
*
* @param expr The security expression string to evaluate
- * @throws NotLoggedInException Thrown if the authorization check fails and
+ * @throws NotLoggedInException Thrown if the authorization check fails and
* the user is not authenticated
* @throws AuthorizationException Thrown if the authorization check fails and
* the user is authenticated
*/
public void checkRestriction(String expr)
- {
+ {
if (!securityEnabled)
{
return;
@@ -192,7 +192,7 @@
}
/**
- * Attempts to authenticate the user. This method is distinct to the
+ * Attempts to authenticate the user. This method is distinct to the
* authenticate() method in that it raises events in response to whether
* authentication is successful or not. The following events may be raised
* by calling login():
@@ -206,21 +206,21 @@
public String login()
{
try
- {
+ {
if (isLoggedIn())
{
// If authentication has already occurred during this request via a silent login,
// and login() is explicitly called then we still want to raise the LOGIN_SUCCESSFUL event,
- // and then return.
- RequestSecurityState state = manager.getInstanceByType(RequestSecurityState.class);
+ // and then return.
+ RequestSecurityState state = manager.getInstanceByType(RequestSecurityState.class);
if (state.isSilentLogin())
{
- manager.fireEvent(new LoggedInEvent(principal));
- return "loggedIn";
- }
+ manager.fireEvent(new LoggedInEvent(principal));
+ return "loggedIn";
+ }
manager.fireEvent(new AlreadyLoggedInEvent());
- return "loggedIn";
+ return "loggedIn";
}
authenticate();
@@ -250,28 +250,28 @@
manager.fireEvent(new LoginFailedEvent(ex));
}
- return null;
+ return null;
}
/**
* Attempts a quiet login, suppressing any login exceptions and not creating
- * any faces messages. This method is intended to be used primarily as an
+ * any faces messages. This method is intended to be used primarily as an
* internal API call, however has been made public for convenience.
*/
public void quietLogin()
{
try
{
- manager.fireEvent(new QuietLoginEvent());
+ manager.fireEvent(new QuietLoginEvent());
// Ensure that we haven't been authenticated as a result of the EVENT_QUIET_LOGIN event
if (!isLoggedIn())
{
- if (credentials.isSet())
+ if (credentials.isSet())
{
authenticate();
- RequestSecurityState state = manager.getInstanceByType(RequestSecurityState.class);
+ RequestSecurityState state = manager.getInstanceByType(RequestSecurityState.class);
if (isLoggedIn())
{
state.setSilentLogin(true);
@@ -279,8 +279,8 @@
}
}
}
- catch (LoginException ex)
- {
+ catch (LoginException ex)
+ {
credentials.invalidate();
}
}
@@ -289,7 +289,7 @@
*
* @throws LoginException
*/
- public synchronized void authenticate()
+ public synchronized void authenticate()
throws LoginException
{
// If we're already authenticated, then don't authenticate again
@@ -298,11 +298,11 @@
principal = null;
subject = new Subject();
authenticate( getLoginContext() );
- }
+ }
}
- protected void authenticate(LoginContext loginContext)
+ protected void authenticate(LoginContext loginContext)
throws LoginException
{
try
@@ -315,21 +315,21 @@
finally
{
// Set password to null whether authentication is successful or not
- credentials.setPassword(null);
+ credentials.setPassword(null);
authenticating = false;
}
}
/**
- * Clears any roles added by calling addRole() while not authenticated.
- * This method may be overridden by a subclass if different
+ * Clears any roles added by calling addRole() while not authenticated.
+ * This method may be overridden by a subclass if different
* pre-authentication logic should occur.
*/
protected void preAuthenticate()
- {
- preAuthenticationRoles.clear();
+ {
+ preAuthenticationRoles.clear();
manager.fireEvent(new PreAuthenticateEvent());
- }
+ }
/**
* Extracts the principal from the subject, and populates the roles of the
@@ -340,16 +340,16 @@
{
// Populate the working memory with the user's principals
for ( Principal p : getSubject().getPrincipals() )
- {
+ {
if ( !(p instanceof Group))
{
- if (principal == null)
+ if (principal == null)
{
principal = p;
break;
- }
- }
- }
+ }
+ }
+ }
if (!preAuthenticationRoles.isEmpty() && isLoggedIn())
{
@@ -362,14 +362,14 @@
credentials.setPassword(null);
- manager.fireEvent(new PostAuthenticateEvent());
+ manager.fireEvent(new PostAuthenticateEvent());
}
/**
* Resets all security state and credentials
*/
public void unAuthenticate()
- {
+ {
principal = null;
subject = new Subject();
@@ -380,21 +380,21 @@
{
if (getJaasConfigName() != null)
{
- return new LoginContext(getJaasConfigName(), getSubject(),
+ return new LoginContext(getJaasConfigName(), getSubject(),
createCallbackHandler());
}
- Bean<Configuration> configBean = manager.resolveByType(Configuration.class).iterator().next();
+ Bean<Configuration> configBean = manager.getBeans(Configuration.class).iterator().next();
Configuration config = manager.getInstance(configBean);
- return new LoginContext(JaasConfiguration.DEFAULT_JAAS_CONFIG_NAME, getSubject(),
+ return new LoginContext(JaasConfiguration.DEFAULT_JAAS_CONFIG_NAME, getSubject(),
createCallbackHandler(), config);
}
/**
* Creates a callback handler that can handle a standard username/password
- * callback, using the credentials username and password properties
+ * callback, using the credentials username and password properties
*/
public CallbackHandler createCallbackHandler()
{
@@ -402,7 +402,7 @@
final Authenticator authenticator;
final IdentityManager identityManager = manager.getInstanceByType(IdentityManager.class);
- Set<Bean<Authenticator>> authenticators = manager.resolveByType(Authenticator.class);
+ Set<Bean<Authenticator>> authenticators = manager.getBeans(Authenticator.class);
if (authenticators.size() == 1)
{
Bean<Authenticator> authenticatorBean = authenticators.iterator().next();
@@ -412,16 +412,16 @@
{
throw new IllegalStateException("More than one Authenticator bean found - please ensure " +
"only one Authenticator implementation is provided");
- }
+ }
else
{
authenticator = null;
}
- return new CallbackHandler()
+ return new CallbackHandler()
{
- public void handle(Callback[] callbacks)
- throws IOException, UnsupportedCallbackException
+ public void handle(Callback[] callbacks)
+ throws IOException, UnsupportedCallbackException
{
for (int i=0; i < callbacks.length; i++)
{
@@ -431,13 +431,13 @@
}
else if (callbacks[i] instanceof PasswordCallback)
{
- ( (PasswordCallback) callbacks[i] ).setPassword( credentials.getPassword() != null ?
+ ( (PasswordCallback) callbacks[i] ).setPassword( credentials.getPassword() != null ?
credentials.getPassword().toCharArray() : null );
}
else if (callbacks[i] instanceof IdentityCallback)
{
((IdentityCallback ) callbacks[i]).setIdentity(identity);
- }
+ }
else if (callbacks[i] instanceof AuthenticatorCallback)
{
((AuthenticatorCallback) callbacks[i]).setAuthenticator(authenticator);
@@ -453,7 +453,7 @@
}
}
};
- }
+ }
public void logout()
{
@@ -482,7 +482,7 @@
tryLogin();
- for ( Group sg : getSubject().getPrincipals(Group.class) )
+ for ( Group sg : getSubject().getPrincipals(Group.class) )
{
if ( ROLES_GROUP.equals( sg.getName() ) )
{
@@ -511,7 +511,7 @@
}
else
{
- for ( Group sg : getSubject().getPrincipals(Group.class) )
+ for ( Group sg : getSubject().getPrincipals(Group.class) )
{
if ( ROLES_GROUP.equals( sg.getName() ) )
{
@@ -532,8 +532,8 @@
* @param role The name of the role to remove
*/
public void removeRole(String role)
- {
- for ( Group sg : getSubject().getPrincipals(Group.class) )
+ {
+ for ( Group sg : getSubject().getPrincipals(Group.class) )
{
if ( ROLES_GROUP.equals( sg.getName() ) )
{
@@ -549,8 +549,8 @@
}
}
- }
- }
+ }
+ }
/**
* Checks that the current authenticated user is a member of
@@ -566,7 +566,7 @@
if ( !hasRole(role) )
{
if ( !isLoggedIn() )
- {
+ {
manager.fireEvent(new NotLoggedInEvent());
throw new NotLoggedInException();
}
@@ -590,7 +590,7 @@
if ( !isLoggedIn() )
{
manager.fireEvent(new NotLoggedInEvent());
- throw new NotLoggedInException();
+ throw new NotLoggedInException();
}
else
{
@@ -603,13 +603,13 @@
public void filterByPermission(Collection<?> collection, String action)
{
- permissionMapper.filterByPermission(collection, action);
+ permissionMapper.filterByPermission(collection, action);
}
public boolean hasPermission(Object target, String action)
{
if (!securityEnabled) return true;
- if (systemOp != null && Boolean.TRUE.equals(systemOp.get())) return true;
+ if (systemOp != null && Boolean.TRUE.equals(systemOp.get())) return true;
if (permissionMapper == null) return false;
if (target == null) return false;
@@ -623,10 +623,10 @@
* @param expr String The expression to evaluate
* @return boolean The result of the expression evaluation
*/
- protected boolean evaluateExpression(String expr)
- {
+ protected boolean evaluateExpression(String expr)
+ {
return expressions.createValueExpression(expr, Boolean.class).getValue();
- }
+ }
public String getJaasConfigName()
{
@@ -663,5 +663,5 @@
principal = savedPrincipal;
subject = savedSubject;
}
- }
+ }
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -2,8 +2,8 @@
import java.util.HashMap;
-import javax.context.ApplicationScoped;
-import javax.inject.Produces;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.Configuration;
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
@@ -18,7 +18,7 @@
*/
public class JaasConfiguration
{
- static final String DEFAULT_JAAS_CONFIG_NAME = "default";
+ static final String DEFAULT_JAAS_CONFIG_NAME = "default";
protected Configuration createConfiguration()
{
@@ -39,10 +39,10 @@
protected AppConfigurationEntry createAppConfigurationEntry()
{
- return new AppConfigurationEntry(
- SeamLoginModule.class.getName(),
- LoginModuleControlFlag.REQUIRED,
- new HashMap<String,String>()
+ return new AppConfigurationEntry(
+ SeamLoginModule.class.getName(),
+ LoginModuleControlFlag.REQUIRED,
+ new HashMap<String,String>()
);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -2,10 +2,10 @@
import java.io.Serializable;
-import javax.context.ApplicationScoped;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
@@ -25,30 +25,30 @@
{
private static final long serialVersionUID = -1984227349549914828L;
- private Class<?> tokenEntityClass;
+ private Class<?> tokenEntityClass;
private AnnotatedBeanProperty<TokenUsername> tokenUsernameProperty;
private AnnotatedBeanProperty<TokenValue> tokenValueProperty;
- @Current Manager manager;
+ @Current BeanManager manager;
@Initializer
public void create()
- {
+ {
tokenUsernameProperty = new AnnotatedBeanProperty<TokenUsername>(tokenEntityClass, TokenUsername.class);
tokenValueProperty = new AnnotatedBeanProperty<TokenValue>(tokenEntityClass, TokenValue.class);
- if (!tokenUsernameProperty.isSet())
+ if (!tokenUsernameProperty.isSet())
{
- throw new IllegalStateException("Invalid tokenClass " + tokenEntityClass.getName() +
+ throw new IllegalStateException("Invalid tokenClass " + tokenEntityClass.getName() +
" - required annotation @TokenUsername not found on any Field or Method.");
}
- if (!tokenValueProperty.isSet())
+ if (!tokenValueProperty.isSet())
{
- throw new IllegalStateException("Invalid tokenClass " + tokenEntityClass.getName() +
+ throw new IllegalStateException("Invalid tokenClass " + tokenEntityClass.getName() +
" - required annotation @TokenValue not found on any Field or Method.");
- }
+ }
}
public void createToken(String username, String value)
@@ -56,7 +56,7 @@
if (tokenEntityClass == null)
{
throw new IllegalStateException("Could not create token, tokenEntityClass not set");
- }
+ }
try
{
@@ -77,7 +77,7 @@
{
throw new IdentityManagementException("Could not create account", ex);
}
- }
+ }
}
public boolean validateToken(String username, String value)
@@ -104,10 +104,10 @@
for (Object token : query.getResultList())
{
lookupEntityManager().remove(token);
- }
+ }
}
- public Object lookupToken(String username, String value)
+ public Object lookupToken(String username, String value)
{
try
{
@@ -122,9 +122,9 @@
}
catch (NoResultException ex)
{
- return null;
- }
- }
+ return null;
+ }
+ }
public Class<?> getTokenEntityClass()
{
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -6,13 +6,13 @@
import java.util.List;
import java.util.Random;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Named;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
import javax.event.Observes;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Manager;
import org.jboss.seam.security.events.CredentialsInitializedEvent;
import org.jboss.seam.security.events.LoggedOutEvent;
@@ -49,7 +49,7 @@
{
try
{
- String decoded = new String(Base64.decode(cookieValue));
+ String decoded = new String(Base64.decode(cookieValue));
username = decoded.substring(0, decoded.indexOf(':'));
value = decoded.substring(decoded.indexOf(':') + 1);
}
@@ -71,12 +71,12 @@
}
}
- private ManagedCookie usernameSelector;
- private ManagedCookie tokenSelector;
+ private ManagedCookie usernameSelector;
+ private ManagedCookie tokenSelector;
private TokenStore tokenStore;
- @Current Manager manager;
+ @Current BeanManager manager;
private boolean enabled;
@@ -124,7 +124,7 @@
{
tokenSelector.setCookieEnabled(enabled);
}
- }
+ }
}
public int getCookieMaxAge() {
@@ -148,25 +148,25 @@
@Initializer
public void create()
{
- Bean<ManagedCookie> selectorBean = manager.resolveByType(ManagedCookie.class).iterator().next();
+ Bean<ManagedCookie> selectorBean = manager.getBeans(ManagedCookie.class).iterator().next();
if (mode.equals(Mode.usernameOnly))
- {
+ {
usernameSelector = manager.getInstance(selectorBean);
- usernameSelector.setCookieName("org.jboss.seam.security.username");
+ usernameSelector.setCookieName("org.jboss.seam.security.username");
usernameSelector.setCookieEnabled(enabled);
}
else if (mode.equals(Mode.autoLogin))
{
tokenSelector = manager.getInstance(selectorBean);
- tokenSelector.setCookieName("org.jboss.seam.security.authtoken");
+ tokenSelector.setCookieName("org.jboss.seam.security.authtoken");
tokenSelector.setCookieEnabled(enabled);
// Default to JpaTokenStore
if (tokenStore == null)
{
tokenStore = manager.getInstanceByType(JpaTokenStore.class);
- }
+ }
}
}
@@ -185,17 +185,17 @@
sb.append(username);
sb.append(":");
sb.append(value);
- return Base64.encodeBytes(sb.toString().getBytes());
+ return Base64.encodeBytes(sb.toString().getBytes());
}
public void initCredentials(@Observes CredentialsInitializedEvent event)
- {
- // FIXME use the context path as the cookie path
+ {
+ // FIXME use the context path as the cookie path
// String cookiePath = getCookiePath();
String cookiePath = "/";
if (mode.equals(Mode.usernameOnly))
- {
+ {
if (cookiePath != null)
{
usernameSelector.setCookiePath(cookiePath);
@@ -225,7 +225,7 @@
if (tokenStore.validateToken(decoded.getUsername(), decoded.getValue()))
{
event.getCredentials().setUsername(decoded.getUsername());
- event.getCredentials().setPassword(decoded.getValue());
+ event.getCredentials().setPassword(decoded.getValue());
}
else
{
@@ -237,28 +237,28 @@
}
/**
- * I hate these hacks...
+ * I hate these hacks...
*/
- private class BoolWrapper
+ private class BoolWrapper
{
boolean value;
}
public void quietLogin(@Observes QuietLoginEvent event)
- {
+ {
if (mode.equals(Mode.autoLogin) && isEnabled())
{
- final String username = credentials.getUsername();
+ final String username = credentials.getUsername();
final BoolWrapper userEnabled = new BoolWrapper();
final List<String> roles = new ArrayList<String>();
// Double check our credentials again
if (tokenStore.validateToken(username, credentials.getPassword()))
- {
+ {
identity.runAs(new RunAsOperation(true) {
@Override
public void execute()
- {
+ {
if (identityManager.isUserEnabled(username))
{
userEnabled.value = true;
@@ -288,7 +288,7 @@
autoLoggedIn = true;
}
- }
+ }
}
}
@@ -303,7 +303,7 @@
public void postAuthenticate(@Observes PostAuthenticateEvent event)
{
if (mode.equals(Mode.usernameOnly))
- {
+ {
if ( !enabled )
{
usernameSelector.clearCookieValue();
@@ -315,7 +315,7 @@
}
}
else if (mode.equals(Mode.autoLogin))
- {
+ {
DecodedToken decoded = new DecodedToken(tokenSelector.getCookieValue());
// Invalidate the current token (if it exists) whether enabled or not
@@ -324,9 +324,9 @@
tokenStore.invalidateToken(decoded.getUsername(), decoded.getValue());
}
- if ( !enabled )
+ if ( !enabled )
{
- tokenSelector.clearCookieValue();
+ tokenSelector.clearCookieValue();
}
else
{
@@ -334,15 +334,15 @@
tokenStore.createToken(identity.getPrincipal().getName(), value);
tokenSelector.setCookieEnabled(enabled);
tokenSelector.setCookieMaxAge(cookieMaxAge);
- tokenSelector.setCookieValueIfEnabled(encodeToken(identity.getPrincipal().getName(), value));
+ tokenSelector.setCookieValueIfEnabled(encodeToken(identity.getPrincipal().getName(), value));
}
}
- }
+ }
/**
* A flag that an application can use to protect sensitive operations if the user has been
- * auto-authenticated.
- */
+ * auto-authenticated.
+ */
public boolean isAutoLoggedIn()
{
return autoLoggedIn;
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/RequestSecurityState.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/RequestSecurityState.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/RequestSecurityState.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,6 +1,6 @@
package org.jboss.seam.security;
-import javax.context.RequestScoped;
+import javax.enterprise.context.RequestScoped;
/**
* Contains the authentication state of the current request
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,15 +1,8 @@
package org.jboss.seam.security;
-import javax.context.ApplicationScoped;
+import javax.enterprise.context.ApplicationScoped;
import javax.event.Observes;
-import javax.inject.Current;
-import org.jboss.seam.international.StatusMessages;
-import org.jboss.seam.international.StatusMessage.Severity;
-import org.jboss.seam.security.events.AlreadyLoggedInEvent;
-import org.jboss.seam.security.events.LoggedInEvent;
-import org.jboss.seam.security.events.LoginFailedEvent;
-import org.jboss.seam.security.events.NotLoggedInEvent;
import org.jboss.seam.security.events.PostAuthenticateEvent;
/**
@@ -19,10 +12,10 @@
* @author Shane Bryzak
*/
@ApplicationScoped
-public class SecurityEventMessages
-{
+public class SecurityEventMessages
+{
public void postAuthenticate(@Observes PostAuthenticateEvent event)
- {
+ {
//org.jboss.security.saml.SSOManager.processManualLoginNotification(
//ServletContexts.instance().getRequest(), identity.getPrincipal().getName());
}
@@ -34,9 +27,9 @@
public void addLoginFailedMessage(@Observes LoginFailedEvent event)
{
statusMessages.addFromResourceBundleOrDefault(
- getLoginFailedMessageSeverity(),
- getLoginFailedMessageKey(),
- getLoginFailedMessage(),
+ getLoginFailedMessageSeverity(),
+ getLoginFailedMessageKey(),
+ getLoginFailedMessage(),
event.getLoginException());
}
@@ -58,18 +51,18 @@
public void addLoginSuccessfulMessage(@Observes LoggedInEvent event)
{
statusMessages.addFromResourceBundleOrDefault(
- getLoginSuccessfulMessageSeverity(),
- getLoginSuccessfulMessageKey(),
- getLoginSuccessfulMessage(),
+ getLoginSuccessfulMessageSeverity(),
+ getLoginSuccessfulMessageKey(),
+ getLoginSuccessfulMessage(),
credentials.getUsername());
}
public void addNotLoggedInMessage(@Observes NotLoggedInEvent event)
- {
- statusMessages.addFromResourceBundleOrDefault( Severity.WARN,
- "org.jboss.seam.NotLoggedIn",
- "Please log in first"
- );
+ {
+ statusMessages.addFromResourceBundleOrDefault( Severity.WARN,
+ "org.jboss.seam.NotLoggedIn",
+ "Please log in first"
+ );
}
public Severity getLoginSuccessfulMessageSeverity()
@@ -85,7 +78,7 @@
public String getLoginSuccessfulMessageKey()
{
return "org.jboss.seam.loginSuccessful";
- }
+ }
public void addAlreadyLoggedInMessage(@Observes AlreadyLoggedInEvent event)
{
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -8,9 +8,9 @@
import java.util.Map;
import java.util.Set;
-import javax.inject.Current;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
@@ -25,7 +25,7 @@
*
* @author Shane Bryzak
*/
-@Secure @Interceptor
+@Secure @Interceptor
public class SecurityInterceptor implements Serializable
{
private static final long serialVersionUID = -6567750187000766925L;
@@ -36,7 +36,7 @@
*/
private transient volatile Map<Method,Restriction> restrictions = new HashMap<Method,Restriction>();
- @Current Manager manager;
+ @Current BeanManager manager;
private class Restriction
{
@@ -107,7 +107,7 @@
}
public void check(Identity identity, Object[] parameters)
- {
+ {
if (Identity.isSecurityEnabled())
{
if (expression != null)
@@ -128,7 +128,7 @@
for (Integer idx : paramRestrictions.keySet())
{
Set<String> actions = paramRestrictions.get(idx);
- for (String action : actions)
+ for (String action : actions)
{
identity.checkPermission(parameters[idx], action);
}
@@ -158,16 +158,16 @@
if (!"hashCode".equals(interfaceMethod.getName()))
{
- Restriction restriction = getRestriction(interfaceMethod);
+ Restriction restriction = getRestriction(interfaceMethod);
if ( restriction != null )
- {
+ {
Identity identity = manager.getInstanceByType(Identity.class);
restriction.check(identity, invocation.getParameters());
}
}
return invocation.proceed();
- }
+ }
private Restriction getRestriction(Method interfaceMethod) throws Exception
{
@@ -186,11 +186,11 @@
{
// FIXME this logic should be abstracted rather than sitting in the middle of this interceptor
if (!restrictions.containsKey(interfaceMethod))
- {
+ {
Restriction restriction = null;
- /*Method method = getComponent().getBeanClass().getMethod(
- interfaceMethod.getName(), interfaceMethod.getParameterTypes() );*/
+ /*Method method = getComponent().getBeanClass().getMethod(
+ interfaceMethod.getName(), interfaceMethod.getParameterTypes() );*/
Restrict restrict = null;
@@ -200,7 +200,7 @@
}
else if ( interfaceMethod.getDeclaringClass().isAnnotationPresent(Restrict.class) )
{
- restrict = interfaceMethod.getDeclaringClass().getAnnotation(Restrict.class);
+ restrict = interfaceMethod.getDeclaringClass().getAnnotation(Restrict.class);
}
if (restrict != null)
@@ -209,7 +209,7 @@
if ( Strings.isEmpty(restrict.value()) )
{
- Bean<?> bean = manager.resolveByType(interfaceMethod.getDeclaringClass()).iterator().next();
+ Bean<?> bean = manager.getBeans(interfaceMethod.getDeclaringClass()).iterator().next();
restriction.setPermissionTarget(bean.getName());
restriction.setPermissionAction(interfaceMethod.getName());
}
@@ -243,13 +243,13 @@
}
if (valueMethod != null)
- {
+ {
if (restriction == null) restriction = new Restriction();
Object target = valueMethod.invoke(annotation);
if (!target.equals(void.class))
{
if (restriction == null) restriction = new Restriction();
- restriction.addMethodRestriction(target,
+ restriction.addMethodRestriction(target,
getPermissionAction(permissionCheck, annotation));
}
}
@@ -259,30 +259,30 @@
if (restriction == null) restriction = new Restriction();
restriction.addRoleRestriction(annotation.annotationType().getSimpleName().toLowerCase());
}
- }
+ }
for (int i = 0; i < interfaceMethod.getParameterAnnotations().length; i++)
{
- Annotation[] annotations = interfaceMethod.getParameterAnnotations()[i];
+ Annotation[] annotations = interfaceMethod.getParameterAnnotations()[i];
for (Annotation annotation : annotations)
{
if (annotation.annotationType().isAnnotationPresent(PermissionCheck.class))
- {
+ {
PermissionCheck permissionCheck = annotation.annotationType().getAnnotation(
PermissionCheck.class);
if (restriction == null) restriction = new Restriction();
- restriction.addParameterRestriction(i,
- getPermissionAction(permissionCheck, annotation));
+ restriction.addParameterRestriction(i,
+ getPermissionAction(permissionCheck, annotation));
}
}
- }
+ }
restrictions.put(interfaceMethod, restriction);
return restriction;
}
}
}
- return restrictions.get(interfaceMethod);
+ return restrictions.get(interfaceMethod);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -6,17 +6,17 @@
import java.util.Comparator;
import java.util.List;
-import javax.annotation.Named;
-import javax.context.RequestScoped;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.Named;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.util.Strings;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
-import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.util.Strings;
/**
* Identity Management API, deals with user name/password-based identity management.
@@ -37,12 +37,12 @@
public static final String PERMISSION_UPDATE = "update";
public static final String PERMISSION_DELETE = "delete";
- private static final LogProvider log = Logging.getLogProvider(IdentityManager.class);
+ private static final LogProvider log = Logging.getLogProvider(IdentityManager.class);
private IdentityStore identityStore;
private IdentityStore roleIdentityStore;
- @Current Manager manager;
+ @Current BeanManager manager;
@Current Identity identity;
@Initializer
@@ -52,25 +52,25 @@
}
protected void initIdentityStore()
- {
+ {
// Default to JpaIdentityStore
if (identityStore == null)
- {
- Bean<JpaIdentityStore> jpaIdentityStoreBean = manager.resolveByType(JpaIdentityStore.class).iterator().next();
- identityStore = (IdentityStore) manager.getInstance(jpaIdentityStoreBean);
+ {
+ Bean<JpaIdentityStore> jpaIdentityStoreBean = manager.getBeans(JpaIdentityStore.class).iterator().next();
+ identityStore = manager.getInstance(jpaIdentityStoreBean);
}
if (roleIdentityStore == null && identityStore != null)
{
roleIdentityStore = identityStore;
- }
+ }
if (identityStore == null || roleIdentityStore == null)
{
log.warn("no identity store available - please configure an identityStore if identity " +
"management is required.");
}
- }
+ }
public boolean createUser(String name, String password)
{
@@ -80,8 +80,8 @@
public boolean createUser(String name, String password, String firstname, String lastname)
{
identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE);
- return identityStore.createUser(name, password, firstname, lastname);
- }
+ return identityStore.createUser(name, password, firstname, lastname);
+ }
public boolean deleteUser(String name)
{
@@ -146,7 +146,7 @@
public boolean removeRoleFromGroup(String role, String group)
{
identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
- return roleIdentityStore.removeRoleFromGroup(role, group);
+ return roleIdentityStore.removeRoleFromGroup(role, group);
}
public boolean userExists(String name)
@@ -157,13 +157,13 @@
public boolean roleExists(String name)
{
- return roleIdentityStore.roleExists(name);
+ return roleIdentityStore.roleExists(name);
}
public List<String> listUsers()
{
identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
- List<String> users = identityStore.listUsers();
+ List<String> users = identityStore.listUsers();
Collections.sort(users, new Comparator<String>() {
public int compare(String value1, String value2) {
@@ -185,11 +185,11 @@
}
});
- return users;
+ return users;
}
public List<String> listRoles()
- {
+ {
identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
List<String> roles = roleIdentityStore.listRoles();
@@ -199,7 +199,7 @@
}
});
- return roles;
+ return roles;
}
public List<String> listGrantableRoles()
@@ -212,7 +212,7 @@
}
});
- return roles;
+ return roles;
}
/**
@@ -227,7 +227,7 @@
}
/**
- * Returns a list of roles that are either explicitly or indirectly granted to the specified user.
+ * Returns a list of roles that are either explicitly or indirectly granted to the specified user.
*
* @param name The user for which to return the list of roles
* @return List containing the names of the implied roles
@@ -239,7 +239,7 @@
public List<Principal> listMembers(String role)
{
- identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
return roleIdentityStore.listMembers(role);
}
@@ -250,7 +250,7 @@
public boolean authenticate(String username, String password)
{
- if (Strings.isEmpty(username)) return false;
+ if (Strings.isEmpty(username)) return false;
return identityStore.authenticate(username, password);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStoreEntityClasses.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStoreEntityClasses.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityStoreEntityClasses.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,6 +1,6 @@
package org.jboss.seam.security.management;
-import javax.context.ApplicationScoped;
+import javax.enterprise.context.ApplicationScoped;
/**
* FIXME - a hack until we get some proper bean configuration
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -11,10 +11,10 @@
import java.util.List;
import java.util.Set;
-import javax.context.RequestScoped;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
@@ -36,17 +36,17 @@
*/
@RequestScoped
public class JpaIdentityStore implements IdentityStore, Serializable
-{
+{
private static final long serialVersionUID = 1171875389743972646L;
- private static final LogProvider log = Logging.getLogProvider(JpaIdentityStore.class);
+ private static final LogProvider log = Logging.getLogProvider(JpaIdentityStore.class);
protected FeatureSet featureSet;
@PersistenceContext EntityManager entityManager;
JpaIdentityStoreConfig config;
- Manager manager;
+ BeanManager manager;
public Set<Feature> getFeatures()
{
@@ -61,11 +61,11 @@
public boolean supportsFeature(Feature feature)
{
return featureSet.supports(feature);
- }
+ }
@Initializer
- public void init(@Current JpaIdentityStoreConfig config, @Current Manager manager)
- {
+ public void init(@Current JpaIdentityStoreConfig config, @Current BeanManager manager)
+ {
this.config = config;
this.manager = manager;
@@ -73,14 +73,14 @@
{
featureSet = new FeatureSet();
featureSet.enableAll();
- }
+ }
if (config.getUserEntityClass() == null)
{
log.error("Error in JpaIdentityStore configuration - userClass must be configured.");
return;
- }
- }
+ }
+ }
public boolean createUser(String username, String password, String firstname, String lastname)
{
@@ -100,7 +100,7 @@
config.getUserPrincipalProperty().setValue(user, username);
- if (config.getUserFirstNameProperty().isSet()) config.getUserFirstNameProperty().setValue(user, firstname);
+ if (config.getUserFirstNameProperty().isSet()) config.getUserFirstNameProperty().setValue(user, firstname);
if (config.getUserLastNameProperty().isSet()) config.getUserLastNameProperty().setValue(user, lastname);
if (password == null)
@@ -108,7 +108,7 @@
if (config.getUserEnabledProperty().isSet()) config.getUserEnabledProperty().setValue(user, false);
}
else
- {
+ {
setUserPassword(user, password);
if (config.getUserEnabledProperty().isSet()) config.getUserEnabledProperty().setValue(user, true);
}
@@ -131,14 +131,14 @@
{
throw new IdentityManagementException("Could not create account", ex);
}
- }
+ }
}
protected void setUserPassword(Object user, String password)
{
if (config.getPasswordSaltProperty().isSet())
{
- byte[] salt = generateUserSalt(user);
+ byte[] salt = generateUserSalt(user);
config.getPasswordSaltProperty().setValue(user, BinTools.bin2hex(salt));
config.getUserPasswordProperty().setValue(user, generatePasswordHash(password, salt));
}
@@ -153,7 +153,7 @@
*/
@Deprecated
protected String getUserAccountSalt(Object user)
- {
+ {
// By default, we'll use the user's username as the password salt
return config.getUserPrincipalProperty().getValue(user).toString();
}
@@ -174,7 +174,7 @@
public boolean deleteUser(String name)
{
Object user = lookupUser(name);
- if (user == null)
+ if (user == null)
{
throw new NoSuchUserException("Could not delete, user '" + name + "' does not exist");
}
@@ -218,7 +218,7 @@
throw new NoSuchRoleException("Could not grant role, role '" + role + "' does not exist");
}
- Collection<?> userRoles = (Collection<?>) config.getUserRolesProperty().getValue(user);
+ Collection<?> userRoles = (Collection<?>) config.getUserRolesProperty().getValue(user);
if (userRoles == null)
{
Type propType = config.getUserRolesProperty().getPropertyType();
@@ -257,7 +257,7 @@
if (config.getXrefEntityClass() == null)
{
- // If this is a Many-To-Many relationship, simply add the role
+ // If this is a Many-To-Many relationship, simply add the role
((Collection<Object>) config.getUserRolesProperty().getValue(user)).add(roleToGrant);
}
else
@@ -265,7 +265,7 @@
// Otherwise we need to insert a cross-reference entity instance
try
{
- Object xref = config.getXrefEntityClass().newInstance();
+ Object xref = config.getXrefEntityClass().newInstance();
config.getXrefUserProperty().setValue(xref, user);
config.getXrefRoleProperty().setValue(xref, roleToGrant);
@@ -280,7 +280,7 @@
}
return true;
- }
+ }
public boolean revokeRole(String username, String role)
{
@@ -294,7 +294,7 @@
if (roleToRevoke == null)
{
throw new NoSuchRoleException("Could not revoke role, role '" + role + "' does not exist");
- }
+ }
boolean success = false;
@@ -322,7 +322,7 @@
@SuppressWarnings("unchecked")
public boolean addRoleToGroup(String role, String group)
{
- if (!config.getRoleGroupsProperty().isSet()) return false;
+ if (!config.getRoleGroupsProperty().isSet()) return false;
Object targetRole = lookupRole(role);
if (targetRole == null)
@@ -336,7 +336,7 @@
throw new NoSuchRoleException("Could not grant role, group '" + group + "' does not exist");
}
- Collection<?> roleGroups = (Collection<?>) config.getRoleGroupsProperty().getValue(targetRole);
+ Collection<?> roleGroups = (Collection<?>) config.getRoleGroupsProperty().getValue(targetRole);
if (roleGroups == null)
{
// This should either be a Set, or a List...
@@ -348,7 +348,7 @@
else
{
return false;
- }
+ }
if (Set.class.isAssignableFrom(rawType))
{
@@ -385,12 +385,12 @@
if (targetGroup == null)
{
throw new NoSuchRoleException("Could not remove role from group, no such group '" + group + "'");
- }
+ }
boolean success = ((Collection<?>) config.getRoleGroupsProperty().getValue(roleToRemove)).remove(targetGroup);
return success;
- }
+ }
public boolean createRole(String role)
{
@@ -406,7 +406,7 @@
throw new IdentityManagementException("Could not create role, already exists");
}
- Object instance = config.getRoleEntityClass().newInstance();
+ Object instance = config.getRoleEntityClass().newInstance();
config.getRoleNameProperty().setValue(instance, role);
entityManager.persist(instance);
@@ -422,16 +422,16 @@
{
throw new IdentityManagementException("Could not create role", ex);
}
- }
+ }
}
public boolean deleteRole(String role)
- {
+ {
Object roleToDelete = lookupRole(role);
if (roleToDelete == null)
{
throw new NoSuchRoleException("Could not delete role, role '" + role + "' does not exist");
- }
+ }
if (config.getXrefEntityClass() != null)
{
@@ -462,7 +462,7 @@
{
if (!config.getUserEnabledProperty().isSet())
{
- log.debug("Can not enable user, no @UserEnabled property configured in userClass " +
+ log.debug("Can not enable user, no @UserEnabled property configured in userClass " +
config.getUserEntityClass().getName());
return false;
}
@@ -479,7 +479,7 @@
return false;
}
- config.getUserEnabledProperty().setValue(user, true);
+ config.getUserEnabledProperty().setValue(user, true);
return true;
}
@@ -487,7 +487,7 @@
{
if (!config.getUserEnabledProperty().isSet())
{
- log.debug("Can not disable user, no @UserEnabled property configured in userClass " +
+ log.debug("Can not disable user, no @UserEnabled property configured in userClass " +
config.getUserEntityClass().getName());
return false;
}
@@ -502,9 +502,9 @@
if (((Boolean) config.getUserEnabledProperty().getValue(user)) == false)
{
return false;
- }
+ }
- config.getUserEnabledProperty().setValue(user, false);
+ config.getUserEnabledProperty().setValue(user, false);
return true;
}
@@ -534,7 +534,7 @@
public boolean isUserEnabled(String name)
{
Object user = lookupUser(name);
- return user != null && (!config.getUserEnabledProperty().isSet() ||
+ return user != null && (!config.getUserEnabledProperty().isSet() ||
(((Boolean) config.getUserEnabledProperty().getValue(user))) == true);
}
@@ -543,7 +543,7 @@
Object user = lookupUser(name);
if (user == null)
{
- throw new NoSuchUserException("No such user '" + name + "'");
+ throw new NoSuchUserException("No such user '" + name + "'");
}
List<String> roles = new ArrayList<String>();
@@ -566,7 +566,7 @@
}
}
- return roles;
+ return roles;
}
public List<String> getRoleGroups(String name)
@@ -591,15 +591,15 @@
}
}
- return groups;
+ return groups;
}
public List<String> getImpliedRoles(String name)
{
Object user = lookupUser(name);
- if (user == null)
+ if (user == null)
{
- throw new NoSuchUserException("No such user '" + name + "'");
+ throw new NoSuchUserException("No such user '" + name + "'");
}
Set<String> roles = new HashSet<String>();
@@ -618,7 +618,7 @@
private void addRoleAndMemberships(String role, Set<String> roles)
{
if (roles.add(role))
- {
+ {
Object instance = lookupRole(role);
if (config.getRoleGroupsProperty().isSet())
@@ -642,7 +642,7 @@
{
try
{
- return getPasswordHash().createPasswordKey(password.toCharArray(), salt,
+ return getPasswordHash().createPasswordKey(password.toCharArray(), salt,
config.getUserPasswordProperty().getAnnotation().iterations());
}
catch (GeneralSecurityException ex)
@@ -662,7 +662,7 @@
*/
@Deprecated
protected String generatePasswordHash(String password, String salt)
- {
+ {
String algorithm = config.getUserPasswordProperty().getAnnotation().hash();
if (algorithm == null || "".equals(algorithm))
@@ -679,7 +679,7 @@
else if ("none".equalsIgnoreCase(algorithm))
{
return password;
- }
+ }
else
{
if (salt == null || "".equals(salt))
@@ -695,8 +695,8 @@
public boolean authenticate(String username, String password)
{
- Object user = lookupUser(username);
- if (user == null || (config.getUserEnabledProperty().isSet() &&
+ Object user = lookupUser(username);
+ if (user == null || (config.getUserEnabledProperty().isSet() &&
((Boolean) config.getUserEnabledProperty().getValue(user) == false)))
{
return false;
@@ -709,7 +709,7 @@
String encodedSalt = (String) config.getPasswordSaltProperty().getValue(user);
if (encodedSalt == null)
{
- throw new IdentityManagementException("A @PasswordSalt property was found on entity " + user +
+ throw new IdentityManagementException("A @PasswordSalt property was found on entity " + user +
", but it contains no value");
}
@@ -717,26 +717,26 @@
}
else
{
- passwordHash = generatePasswordHash(password, getUserAccountSalt(user));
+ passwordHash = generatePasswordHash(password, getUserAccountSalt(user));
}
boolean success = passwordHash.equals(config.getUserPasswordProperty().getValue(user));
if (success)
- {
+ {
manager.fireEvent(new UserAuthenticatedEvent(user));
}
return success;
}
- public Object lookupUser(String username)
+ public Object lookupUser(String username)
{
try
{
Object user = entityManager.createQuery(
- "select u from " + config.getUserEntityClass().getName() + " u where " +
+ "select u from " + config.getUserEntityClass().getName() + " u where " +
config.getUserPrincipalProperty().getName() + " = :username")
.setParameter("username", username)
.getSingleResult();
@@ -745,8 +745,8 @@
}
catch (NoResultException ex)
{
- return null;
- }
+ return null;
+ }
}
public String getUserName(Object user)
@@ -760,12 +760,12 @@
}
public boolean isRoleConditional(String role)
- {
+ {
return config.getRoleConditionalProperty().isSet() ? (Boolean) config.getRoleConditionalProperty().getValue(
lookupRole(role)) : false;
}
- public Object lookupRole(String role)
+ public Object lookupRole(String role)
{
try
{
@@ -779,35 +779,35 @@
}
catch (NoResultException ex)
{
- return null;
+ return null;
}
- }
+ }
@SuppressWarnings("unchecked")
public List<String> listUsers()
{
- return (List<String>) entityManager.createQuery(
- "select u." + config.getUserPrincipalProperty().getName() + " from " +
+ return entityManager.createQuery(
+ "select u." + config.getUserPrincipalProperty().getName() + " from " +
config.getUserEntityClass().getName() + " u")
- .getResultList();
+ .getResultList();
}
@SuppressWarnings("unchecked")
public List<String> listUsers(String filter)
{
- return (List<String>) entityManager.createQuery(
- "select u." + config.getUserPrincipalProperty().getName() + " from " + config.getUserEntityClass().getName() +
+ return entityManager.createQuery(
+ "select u." + config.getUserPrincipalProperty().getName() + " from " + config.getUserEntityClass().getName() +
" u where lower(" + config.getUserPrincipalProperty().getName() + ") like :username")
- .setParameter("username", "%" + (filter != null ? filter.toLowerCase() : "") +
+ .setParameter("username", "%" + (filter != null ? filter.toLowerCase() : "") +
"%")
.getResultList();
}
@SuppressWarnings("unchecked")
public List<String> listRoles()
- {
- return (List<String>) entityManager.createQuery(
- "select r." + config.getRoleNameProperty().getName() + " from " +
+ {
+ return entityManager.createQuery(
+ "select r." + config.getRoleNameProperty().getName() + " from " +
config.getRoleEntityClass().getName() + " r").getResultList();
}
@@ -830,21 +830,21 @@
@SuppressWarnings("unchecked")
private List<String> listUserMembers(String role)
- {
+ {
Object roleEntity = lookupRole(role);
if (config.getXrefEntityClass() == null)
- {
- return (List<String>) entityManager.createQuery("select u." +
- config.getUserPrincipalProperty().getName() +
- " from " + config.getUserEntityClass().getName() + " u where :role member of u." +
+ {
+ return entityManager.createQuery("select u." +
+ config.getUserPrincipalProperty().getName() +
+ " from " + config.getUserEntityClass().getName() + " u where :role member of u." +
config.getUserRolesProperty().getName())
.setParameter("role", roleEntity)
.getResultList();
}
else
{
- List<?> xrefs = entityManager.createQuery("select x from " +
+ List<?> xrefs = entityManager.createQuery("select x from " +
config.getXrefEntityClass().getName() + " x where x." +
config.getXrefRoleProperty().getName() + " = :role")
.setParameter("role", roleEntity)
@@ -865,14 +865,14 @@
@SuppressWarnings("unchecked")
private List<String> listRoleMembers(String role)
- {
+ {
if (config.getRoleGroupsProperty().isSet())
{
- Object roleEntity = lookupRole(role);
+ Object roleEntity = lookupRole(role);
- return (List<String>) entityManager.createQuery("select r." +
+ return entityManager.createQuery("select r." +
config.getRoleNameProperty().getName() +
- " from " + config.getRoleEntityClass().getName() + " r where :role member of r." +
+ " from " + config.getRoleEntityClass().getName() + " r where :role member of r." +
config.getRoleGroupsProperty().getName())
.setParameter("role", roleEntity)
.getResultList();
@@ -899,7 +899,7 @@
roleQuery.append(" = false");
}
- return (List<String>) entityManager.createQuery(roleQuery.toString()).getResultList();
+ return entityManager.createQuery(roleQuery.toString()).getResultList();
}
protected PasswordHash getPasswordHash()
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStoreConfig.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStoreConfig.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStoreConfig.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,9 +4,9 @@
import java.lang.reflect.Type;
import java.util.Collection;
-import javax.context.ApplicationScoped;
-import javax.inject.Current;
-import javax.inject.Initializer;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
import org.jboss.seam.security.annotations.management.PasswordSalt;
import org.jboss.seam.security.annotations.management.RoleConditional;
@@ -23,14 +23,14 @@
/**
* The configuration for JpaIdentityStore
- *
+ *
* @author Shane Bryzak
*/
@ApplicationScoped
public class JpaIdentityStoreConfig
{
private Class<?> userEntityClass;
- private Class<?> roleEntityClass;
+ private Class<?> roleEntityClass;
private Class<?> xrefEntityClass;
private TypedBeanProperty xrefUserProperty;
private TypedBeanProperty xrefRoleProperty;
@@ -41,12 +41,12 @@
private AnnotatedBeanProperty<UserRoles> userRolesProperty;
private AnnotatedBeanProperty<UserEnabled> userEnabledProperty;
private AnnotatedBeanProperty<UserFirstName> userFirstNameProperty;
- private AnnotatedBeanProperty<UserLastName> userLastNameProperty;
+ private AnnotatedBeanProperty<UserLastName> userLastNameProperty;
private AnnotatedBeanProperty<RoleName> roleNameProperty;
private AnnotatedBeanProperty<RoleGroups> roleGroupsProperty;
private AnnotatedBeanProperty<RoleConditional> roleConditionalProperty;
- @Current IdentityStoreEntityClasses entityClasses;
+ @Current IdentityStoreEntityClasses entityClasses;
@Initializer
public void initProperties()
@@ -59,32 +59,32 @@
userFirstNameProperty = new AnnotatedBeanProperty<UserFirstName>(getUserEntityClass(), UserFirstName.class);
userLastNameProperty = new AnnotatedBeanProperty<UserLastName>(getUserEntityClass(), UserLastName.class);
- if (!userPrincipalProperty.isSet())
+ if (!userPrincipalProperty.isSet())
{
- throw new IdentityManagementException("Invalid userClass " + getUserEntityClass().getName() +
+ throw new IdentityManagementException("Invalid userClass " + getUserEntityClass().getName() +
" - required annotation @UserPrincipal not found on any Field or Method.");
}
if (!userRolesProperty.isSet())
{
- throw new IdentityManagementException("Invalid userClass " + getUserEntityClass().getName() +
- " - required annotation @UserRoles not found on any Field or Method.");
- }
+ throw new IdentityManagementException("Invalid userClass " + getUserEntityClass().getName() +
+ " - required annotation @UserRoles not found on any Field or Method.");
+ }
if (getRoleEntityClass() != null)
- {
+ {
roleNameProperty = new AnnotatedBeanProperty<RoleName>(getRoleEntityClass(), RoleName.class);
roleGroupsProperty = new AnnotatedBeanProperty<RoleGroups>(getRoleEntityClass(), RoleGroups.class);
roleConditionalProperty = new AnnotatedBeanProperty<RoleConditional>(getRoleEntityClass(), RoleConditional.class);
if (!roleNameProperty.isSet())
{
- throw new IdentityManagementException("Invalid roleClass " + getRoleEntityClass().getName() +
- " - required annotation @RoleName not found on any Field or Method.");
- }
+ throw new IdentityManagementException("Invalid roleClass " + getRoleEntityClass().getName() +
+ " - required annotation @RoleName not found on any Field or Method.");
+ }
Type type = userRolesProperty.getPropertyType();
- if (type instanceof ParameterizedType &&
+ if (type instanceof ParameterizedType &&
Collection.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType()))
{
Type genType = Object.class;
@@ -93,10 +93,10 @@
{
genType = t;
break;
- }
+ }
// If the @UserRoles property isn't a collection of <roleClass>, then assume the relationship
- // is going through a cross-reference table
+ // is going through a cross-reference table
if (!genType.equals(getRoleEntityClass()))
{
xrefEntityClass = (Class<?>) genType;
@@ -112,12 +112,12 @@
if (!xrefRoleProperty.isSet())
{
throw new IdentityManagementException("Error configuring JpaIdentityStore - it looks like " +
- "you're using a cross-reference table, however the role property cannot be determined.");
+ "you're using a cross-reference table, however the role property cannot be determined.");
}
}
}
}
- }
+ }
public Class<?> getUserEntityClass()
{
@@ -132,14 +132,14 @@
public void setUserEntityClass(Class<?> userEntityClass)
{
this.userEntityClass = userEntityClass;
- }
+ }
public Class<?> getRoleEntityClass()
{
if (roleEntityClass == null)
{
roleEntityClass = entityClasses.getRoleEntityClass();
- }
+ }
return roleEntityClass;
}
@@ -147,7 +147,7 @@
public void setRoleEntityClass(Class<?> roleEntityClass)
{
this.roleEntityClass = roleEntityClass;
- }
+ }
public Class<?> getXrefEntityClass()
{
@@ -161,7 +161,7 @@
public TypedBeanProperty getXrefRoleProperty()
{
- return xrefRoleProperty;
+ return xrefRoleProperty;
}
public AnnotatedBeanProperty<UserPrincipal> getUserPrincipalProperty()
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -8,8 +8,7 @@
import java.util.Properties;
import java.util.Set;
-import javax.annotation.Named;
-import javax.context.ApplicationScoped;
+import javax.enterprise.context.ApplicationScoped;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -40,7 +39,7 @@
private static final String LDAP_BOOLEAN_TRUE = "TRUE";
private static final String LDAP_BOOLEAN_FALSE = "FALSE";
- private static final LogProvider log = Logging.getLogProvider(LdapIdentityStore.class);
+ private static final LogProvider log = Logging.getLogProvider(LdapIdentityStore.class);
protected FeatureSet featureSet = new FeatureSet();
@@ -54,7 +53,7 @@
private String userDNSuffix = ",ou=Person,dc=acme,dc=com";
- private String roleContextDN = "ou=Role,dc=acme,dc=com";
+ private String roleContextDN = "ou=Role,dc=acme,dc=com";
private String roleDNPrefix = "cn=";
@@ -389,11 +388,11 @@
env.setProperty(Context.PROVIDER_URL, providerUrl);
env.setProperty(Context.SECURITY_PRINCIPAL, principal);
- env.setProperty(Context.SECURITY_CREDENTIALS, credentials);
+ env.setProperty(Context.SECURITY_CREDENTIALS, credentials);
InitialLdapContext ctx = new InitialLdapContext(env, null);
return ctx;
- }
+ }
protected String getUserDN(String username)
{
@@ -405,8 +404,8 @@
return String.format("%s%s%s", getRoleDNPrefix(), role, getRoleDNSuffix());
}
- public boolean authenticate(String username, String password)
- {
+ public boolean authenticate(String username, String password)
+ {
final String securityPrincipal = getUserDN(username);
InitialLdapContext ctx = null;
@@ -425,11 +424,11 @@
Object value = enabledAttrib.get(r);
if (LDAP_BOOLEAN_TRUE.equals(value)) return true;
}
- }
+ }
return false;
}
- return true;
+ return true;
}
catch (NamingException ex)
{
@@ -437,7 +436,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -445,19 +444,19 @@
}
catch (NamingException ex) {}
}
- }
+ }
}
- public boolean changePassword(String name, String password)
+ public boolean changePassword(String name, String password)
{
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
ctx = initialiseContext();
BasicAttribute passwordAttrib = new BasicAttribute(getUserPasswordAttribute(), password);
ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, passwordAttrib);
- ctx.modifyAttributes(getUserDN(name), new ModificationItem[] { mod });
+ ctx.modifyAttributes(getUserDN(name), new ModificationItem[] { mod });
return true;
}
@@ -467,7 +466,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -475,12 +474,12 @@
}
catch (NamingException ex) {}
}
- }
+ }
}
- public boolean createRole(String role)
+ public boolean createRole(String role)
{
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
ctx = initialiseContext();
@@ -496,7 +495,7 @@
roleAttribs.put(roleClass);
roleAttribs.put(new BasicAttribute(getRoleNameAttribute(), role));
- String roleDN = getRoleDN(role);
+ String roleDN = getRoleDN(role);
ctx.createSubcontext(roleDN, roleAttribs);
return true;
@@ -507,7 +506,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -515,12 +514,12 @@
}
catch (NamingException ex) {}
}
- }
+ }
}
public boolean createUser(String username, String password, String firstname, String lastname)
{
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
ctx = initialiseContext();
@@ -557,7 +556,7 @@
userAttribs.put(new BasicAttribute(getEnabledAttribute(), LDAP_BOOLEAN_TRUE));
}
- String userDN = String.format("%s=%s,%s", getUserNameAttribute(), username, getUserContextDN() );
+ String userDN = String.format("%s=%s,%s", getUserNameAttribute(), username, getUserContextDN() );
ctx.createSubcontext(userDN, userAttribs);
return true;
@@ -565,10 +564,10 @@
catch (NamingException ex)
{
throw new IdentityManagementException("Failed to create user", ex);
- }
+ }
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -576,24 +575,24 @@
}
catch (NamingException ex) {}
}
- }
+ }
}
- public boolean createUser(String username, String password)
+ public boolean createUser(String username, String password)
{
return createUser(username, password, null, null);
}
- public boolean deleteRole(String role)
+ public boolean deleteRole(String role)
{
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
ctx = initialiseContext();
// Delete the role entry itself
- String roleDN = String.format("%s=%s,%s", getRoleNameAttribute(), role, getRoleContextDN() );
- ctx.destroySubcontext(roleDN);
+ String roleDN = String.format("%s=%s,%s", getRoleNameAttribute(), role, getRoleContextDN() );
+ ctx.destroySubcontext(roleDN);
// Then delete all user attributes that point to this role
int searchScope = SearchControls.SUBTREE_SCOPE;
@@ -632,11 +631,11 @@
SearchResult sr = (SearchResult) answer.next();
Attributes attrs = sr.getAttributes();
Attribute user = attrs.get( getUserRoleAttribute() );
- user.remove(roleDN);
+ user.remove(roleDN);
ctx.modifyAttributes(sr.getNameInNamespace(), new ModificationItem[] {
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, user)});
}
- answer.close();
+ answer.close();
return true;
}
@@ -646,7 +645,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -654,15 +653,15 @@
}
catch (NamingException ex) {}
}
- }
+ }
}
- public boolean roleExists(String role)
- {
- InitialLdapContext ctx = null;
+ public boolean roleExists(String role)
+ {
+ InitialLdapContext ctx = null;
try
{
- ctx = initialiseContext();
+ ctx = initialiseContext();
int searchScope = SearchControls.SUBTREE_SCOPE;
int searchTimeLimit = 10000;
@@ -688,7 +687,7 @@
{
Object value = user.get(i);
if (role.equals(value)) return true;
- }
+ }
}
answer.close();
@@ -700,7 +699,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -709,17 +708,17 @@
catch (NamingException ex) {}
}
}
- }
+ }
- public boolean deleteUser(String name)
+ public boolean deleteUser(String name)
{
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
ctx = initialiseContext();
- String userDN = getUserDN(name);
- ctx.destroySubcontext(userDN);
+ String userDN = getUserDN(name);
+ ctx.destroySubcontext(userDN);
return true;
}
catch (NamingException ex)
@@ -728,7 +727,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -736,19 +735,19 @@
}
catch (NamingException ex) {}
}
- }
+ }
}
- public boolean isUserEnabled(String name)
+ public boolean isUserEnabled(String name)
{
- if (getEnabledAttribute() == null) return true;
+ if (getEnabledAttribute() == null) return true;
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
ctx = initialiseContext();
- String userDN = getUserDN(name);
+ String userDN = getUserDN(name);
Attributes attribs = ctx.getAttributes(userDN, new String[] { getEnabledAttribute() });
Attribute enabledAttrib = attribs.get( getEnabledAttribute() );
if (enabledAttrib != null)
@@ -758,7 +757,7 @@
Object value = enabledAttrib.get(r);
if (LDAP_BOOLEAN_TRUE.equals(value)) return true;
}
- }
+ }
return false;
}
@@ -768,7 +767,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -776,10 +775,10 @@
}
catch (NamingException ex) {}
}
- }
- }
+ }
+ }
- public boolean disableUser(String name)
+ public boolean disableUser(String name)
{
if (getEnabledAttribute() == null) return false;
@@ -788,7 +787,7 @@
{
ctx = initialiseContext();
- String userDN = getUserDN(name);
+ String userDN = getUserDN(name);
BasicAttribute enabledAttrib = new BasicAttribute(getEnabledAttribute(), LDAP_BOOLEAN_FALSE);
ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, enabledAttrib);
@@ -798,10 +797,10 @@
catch (NamingException ex)
{
throw new IdentityManagementException("Failed to disable user", ex);
- }
+ }
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -812,7 +811,7 @@
}
}
- public boolean enableUser(String name)
+ public boolean enableUser(String name)
{
if (getEnabledAttribute() == null) return false;
@@ -821,7 +820,7 @@
{
ctx = initialiseContext();
- String userDN = getUserDN(name);
+ String userDN = getUserDN(name);
BasicAttribute enabledAttrib = new BasicAttribute(getEnabledAttribute(), LDAP_BOOLEAN_TRUE);
ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, enabledAttrib);
@@ -831,10 +830,10 @@
catch (NamingException ex)
{
throw new IdentityManagementException("Failed to disable user", ex);
- }
+ }
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -845,16 +844,16 @@
}
}
- public List<String> getGrantedRoles(String name)
+ public List<String> getGrantedRoles(String name)
{
Set<String> userRoles = new HashSet<String>();
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
ctx = initialiseContext();
- String userFilter = "(" + getUserNameAttribute() + "={0})";
+ String userFilter = "(" + getUserNameAttribute() + "={0})";
String[] roleAttr = { getUserRoleAttribute() };
SearchControls controls = new SearchControls();
@@ -906,9 +905,9 @@
}
}
}
- answer.close();
+ answer.close();
- return new ArrayList<String>(userRoles);
+ return new ArrayList<String>(userRoles);
}
catch (NamingException ex)
{
@@ -916,7 +915,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -927,13 +926,13 @@
}
}
- public List<String> getImpliedRoles(String name)
+ public List<String> getImpliedRoles(String name)
{
return getGrantedRoles(name);
}
- public boolean grantRole(String name, String role)
- {
+ public boolean grantRole(String name, String role)
+ {
InitialLdapContext ctx = null;
try
{
@@ -941,7 +940,7 @@
String userDN = getUserDN(name);
- BasicAttribute roleAttrib = new BasicAttribute(getUserRoleAttribute(),
+ BasicAttribute roleAttrib = new BasicAttribute(getUserRoleAttribute(),
getRoleAttributeIsDN() ? getRoleDN(role) : role);
ModificationItem mod = new ModificationItem(DirContext.ADD_ATTRIBUTE, roleAttrib);
@@ -951,10 +950,10 @@
catch (NamingException ex)
{
throw new IdentityManagementException("Failed to grant role", ex);
- }
+ }
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -965,29 +964,29 @@
}
}
- public boolean revokeRole(String name, String role)
- {
- InitialLdapContext ctx = null;
+ public boolean revokeRole(String name, String role)
+ {
+ InitialLdapContext ctx = null;
try
{
- ctx = initialiseContext();
+ ctx = initialiseContext();
String userDN = getUserDN(name);
Attributes roleAttribs = ctx.getAttributes(userDN, new String[] { getUserRoleAttribute() });
Attribute roleAttrib = roleAttribs.get( getUserRoleAttribute() );
if (roleAttrib != null)
- {
- boolean modified = false;
+ {
+ boolean modified = false;
for (int i = roleAttrib.size() - 1; i >= 0; i--)
- {
+ {
if (getRoleAttributeIsDN())
{
- Attributes attribs = ctx.getAttributes((String) roleAttrib.get(i),
+ Attributes attribs = ctx.getAttributes((String) roleAttrib.get(i),
new String[] { getRoleNameAttribute() });
Attribute roleNameAttrib = attribs.get( getRoleNameAttribute() );
for (int j = 0; j < roleNameAttrib.size(); j++)
{
- if (role.equals(roleNameAttrib.get(j)))
+ if (role.equals(roleNameAttrib.get(j)))
{
modified = true;
roleAttrib.remove(i);
@@ -1005,16 +1004,16 @@
{
ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, roleAttrib);
ctx.modifyAttributes(userDN, new ModificationItem[] { mod });
- }
+ }
}
}
catch (NamingException ex)
{
throw new IdentityManagementException("Failed to grant role", ex);
- }
+ }
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -1022,19 +1021,19 @@
}
catch (NamingException ex) {}
}
- }
+ }
return false;
- }
+ }
- public List<String> listRoles()
+ public List<String> listRoles()
{
List<String> roles = new ArrayList<String>();
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
- ctx = initialiseContext();
+ ctx = initialiseContext();
String[] roleAttr = { getRoleNameAttribute() };
@@ -1054,9 +1053,9 @@
roleFilter.append(i);
roleFilter.append("})");
filterArgs[i] = getRoleObjectClasses()[i];
- }
+ }
- NamingEnumeration<?> answer = ctx.search( getRoleContextDN(), roleFilter.toString(),
+ NamingEnumeration<?> answer = ctx.search( getRoleContextDN(), roleFilter.toString(),
filterArgs, controls);
while (answer.hasMore())
{
@@ -1068,10 +1067,10 @@
{
Object value = user.get(i);
roles.add(value.toString());
- }
+ }
}
answer.close();
- return roles;
+ return roles;
}
catch (NamingException ex)
{
@@ -1079,7 +1078,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -1094,21 +1093,21 @@
public List<String> listGrantableRoles()
{
return listRoles();
- }
+ }
- public List<String> listUsers()
+ public List<String> listUsers()
{
return listUsers(null);
}
- public List<String> listUsers(String filter)
+ public List<String> listUsers(String filter)
{
List<String> users = new ArrayList<String>();
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
- ctx = initialiseContext();
+ ctx = initialiseContext();
String[] userAttr = {getUserNameAttribute()};
@@ -1128,7 +1127,7 @@
userFilter.append(i);
userFilter.append("})");
filterArgs[i] = getUserObjectClasses()[i];
- }
+ }
userFilter.append(")");
@@ -1151,13 +1150,13 @@
}
}
else
- {
+ {
users.add(value.toString());
}
- }
+ }
}
answer.close();
- return users;
+ return users;
}
catch (NamingException ex)
{
@@ -1165,7 +1164,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
@@ -1176,12 +1175,12 @@
}
}
- public boolean userExists(String name)
+ public boolean userExists(String name)
{
- InitialLdapContext ctx = null;
+ InitialLdapContext ctx = null;
try
{
- ctx = initialiseContext();
+ ctx = initialiseContext();
String[] userAttr = {getUserNameAttribute()};
@@ -1201,7 +1200,7 @@
userFilter.append(i);
userFilter.append("})");
filterArgs[i] = getUserObjectClasses()[i];
- }
+ }
NamingEnumeration<?> answer = ctx.search(getUserContextDN(), userFilter.toString(), filterArgs, controls);
while (answer.hasMore())
@@ -1218,10 +1217,10 @@
answer.close();
return true;
}
- }
+ }
}
answer.close();
- return false;
+ return false;
}
catch (NamingException ex)
{
@@ -1229,7 +1228,7 @@
}
finally
{
- if (ctx != null)
+ if (ctx != null)
{
try
{
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/PasswordHash.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,11 +4,11 @@
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 javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Named;
import org.jboss.seam.security.crypto.BinTools;
import org.jboss.seam.security.crypto.PBKDF2;
@@ -18,7 +18,7 @@
/**
* Password hashing utility functions
- *
+ *
* @author Shane Bryzak
*/
@Named
@@ -38,7 +38,7 @@
/*
* default password salt length, in bytes
*/
- private int saltLength = 8;
+ private int saltLength = 8;
@Deprecated
public String generateHash(String password)
@@ -64,7 +64,7 @@
@Deprecated
public String generateSaltedHash(String password, String saltPhrase, String algorithm)
{
- try {
+ try {
MessageDigest md = MessageDigest.getInstance(algorithm);
if (saltPhrase != null)
@@ -83,24 +83,24 @@
byte[] raw = md.digest();
return Base64.encodeBytes(raw);
- }
+ }
catch (Exception e) {
- throw new RuntimeException(e);
- }
+ throw new RuntimeException(e);
+ }
}
public byte[] generateRandomSalt()
- {
+ {
byte[] salt = new byte[saltLength];
new SecureRandom().nextBytes(salt);
- return salt;
+ return salt;
}
/**
*
*/
- public String createPasswordKey(char[] password, byte[] salt, int iterations)
- throws GeneralSecurityException
+ public String createPasswordKey(char[] password, byte[] salt, int iterations)
+ throws GeneralSecurityException
{
if (hashAlgorithm != null)
{
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,10 +4,10 @@
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.Named;
-import javax.context.Conversation;
-import javax.context.ConversationScoped;
-import javax.inject.Current;
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Named;
import org.jboss.seam.security.management.IdentityManager;
@@ -57,7 +57,7 @@
}
private String saveNewRole()
- {
+ {
boolean success = identityManager.createRole(role);
if (success)
@@ -70,7 +70,7 @@
conversation.end();
}
- return "success";
+ return "success";
}
private String saveExistingRole()
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,14 +1,10 @@
package org.jboss.seam.security.management.action;
import java.io.Serializable;
-import java.util.List;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.inject.Current;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Named;
-import org.jboss.seam.security.management.IdentityManager;
-
@Named
@SessionScoped
public class RoleSearch implements Serializable
@@ -26,7 +22,7 @@
public void loadRoles()
{
- roles = identityManager.listRoles();
+ roles = identityManager.listRoles();
}
public String getRoleGroups(String role)
@@ -39,10 +35,10 @@
for (String r : roles)
{
- sb.append((sb.length() > 0 ? ", " : "") + r);
+ sb.append((sb.length() > 0 ? ", " : "") + r);
}
- return sb.toString();
+ return sb.toString();
}
public String getSelectedRole()
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,12 +4,11 @@
import java.util.ArrayList;
import java.util.List;
-import javax.annotation.Named;
-import javax.context.Conversation;
-import javax.context.ConversationScoped;
-import javax.inject.Current;
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Named;
-//import org.jboss.seam.international.StatusMessages;
import org.jboss.seam.security.management.IdentityManager;
/**
@@ -29,7 +28,7 @@
private List<String> roles;
private boolean enabled;
- private boolean newUserFlag;
+ private boolean newUserFlag;
@Current IdentityManager identityManager;
@Current Conversation conversation;
@@ -63,7 +62,7 @@
}
private String saveNewUser()
- {
+ {
if (password == null || !password.equals(confirm))
{
// TODO - add control message
@@ -82,7 +81,7 @@
if (!enabled)
{
- identityManager.disableUser(username);
+ identityManager.disableUser(username);
}
conversation.end();
@@ -90,7 +89,7 @@
return "success";
}
- return "failure";
+ return "failure";
}
private String saveExistingUser()
@@ -122,7 +121,7 @@
for (String role : roles)
{
- if (grantedRoles == null || !grantedRoles.contains(role))
+ if (grantedRoles == null || !grantedRoles.contains(role))
{
identityManager.grantRole(username, role);
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,16 +1,10 @@
package org.jboss.seam.security.management.action;
import java.io.Serializable;
-import java.util.List;
-import javax.annotation.Named;
-import javax.context.SessionScoped;
-import javax.inject.Current;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Named;
-//import org.jboss.seam.faces.annotations.DataModel;
-//import org.jboss.seam.faces.annotations.DataModelSelection;
-import org.jboss.seam.security.management.IdentityManager;
-
@Named
@SessionScoped
public class UserSearch implements Serializable
@@ -28,7 +22,7 @@
public void loadUsers()
{
- users = identityManager.listUsers();
+ users = identityManager.listUsers();
}
public String getUserRoles(String username)
@@ -41,10 +35,10 @@
for (String role : roles)
{
- sb.append((sb.length() > 0 ? ", " : "") + role);
+ sb.append((sb.length() > 0 ? ", " : "") + role);
}
- return sb.toString();
+ return sb.toString();
}
public String getSelectedUser()
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ClassIdentifierStrategy.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,7 +3,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import javax.context.Dependent;
+import javax.enterprise.context.Dependent;
import org.jboss.seam.security.annotations.permission.Identifier;
@@ -15,7 +15,7 @@
@Dependent
public class ClassIdentifierStrategy implements IdentifierStrategy
{
- private Map<Class,String> identifierNames = new ConcurrentHashMap<Class,String>();
+ private Map<Class,String> identifierNames = new ConcurrentHashMap<Class,String>();
public boolean canIdentify(Class targetClass)
{
@@ -35,7 +35,7 @@
private String getIdentifierName(Class cls)
{
if (!identifierNames.containsKey(cls))
- {
+ {
String name = null;
if (cls.isAnnotationPresent(Identifier.class))
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,16 +3,13 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import javax.context.Dependent;
-import javax.inject.Current;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
-import org.jboss.seam.security.annotations.permission.Identifier;
import org.jboss.seam.el.Expressions;
-import org.jboss.seam.el.Expressions.ValueExpression;
-//import org.jboss.seam.persistence.PersistenceProvider;
+import org.jboss.seam.security.annotations.permission.Identifier;
import org.jboss.seam.security.util.Strings;
/**
@@ -21,12 +18,12 @@
* @author Shane Bryzak
*/
public class EntityIdentifierStrategy implements IdentifierStrategy
-{
+{
private Map<Class,String> identifierNames = new ConcurrentHashMap<Class,String>();
//@Current PersistenceProvider persistenceProvider;
@Current Expressions expressions;
- @Current Manager manager;
+ @Current BeanManager manager;
public boolean canIdentify(Class targetClass)
{
@@ -36,7 +33,7 @@
public String getIdentifier(Object target)
{
/**
- return String.format("%s:%s", getIdentifierName(target.getClass()),
+ return String.format("%s:%s", getIdentifierName(target.getClass()),
persistenceProvider.getId(target, lookupEntityManager()).toString());
*/
@@ -46,7 +43,7 @@
private String getIdentifierName(Class cls)
{
if (!identifierNames.containsKey(cls))
- {
+ {
String name = null;
if (cls.isAnnotationPresent(Identifier.class))
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/IdentifierPolicy.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -5,16 +5,16 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import javax.context.ApplicationScoped;
-import javax.inject.Initializer;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.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
- * ability to generate identifiers for specific classes of objects.
- *
+ * ability to generate identifiers for specific classes of objects.
+ *
* @author Shane Bryzak
*/
@ApplicationScoped
@@ -47,7 +47,7 @@
{
if (target.getClass().isAnnotationPresent(Identifier.class))
{
- Class<? extends IdentifierStrategy> strategyClass =
+ Class<? extends IdentifierStrategy> strategyClass =
target.getClass().getAnnotation(Identifier.class).value();
if (strategyClass != IdentifierStrategy.class)
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -9,27 +9,27 @@
import java.util.Map;
import java.util.Set;
-import javax.context.ApplicationScoped;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.EntityManager;
import javax.persistence.Query;
+import org.jboss.seam.security.Role;
+import org.jboss.seam.security.SimplePrincipal;
import org.jboss.seam.security.annotations.permission.PermissionAction;
import org.jboss.seam.security.annotations.permission.PermissionDiscriminator;
import org.jboss.seam.security.annotations.permission.PermissionRole;
import org.jboss.seam.security.annotations.permission.PermissionTarget;
import org.jboss.seam.security.annotations.permission.PermissionUser;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.seam.security.Role;
-import org.jboss.seam.security.SimplePrincipal;
import org.jboss.seam.security.management.IdentityManager;
import org.jboss.seam.security.management.JpaIdentityStore;
import org.jboss.seam.security.management.JpaIdentityStoreConfig;
import org.jboss.seam.security.permission.PermissionMetadata.ActionSet;
import org.jboss.seam.security.util.AnnotatedBeanProperty;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
/**
* A permission store implementation that uses JPA as its persistence mechanism.
@@ -52,7 +52,7 @@
private AnnotatedBeanProperty<PermissionRole> roleProperty;
private AnnotatedBeanProperty<PermissionTarget> targetProperty;
- private AnnotatedBeanProperty<PermissionAction> actionProperty;
+ private AnnotatedBeanProperty<PermissionAction> actionProperty;
private AnnotatedBeanProperty<PermissionDiscriminator> discriminatorProperty;
private AnnotatedBeanProperty<PermissionTarget> roleTargetProperty;
@@ -63,7 +63,7 @@
private PermissionMetadata metadata;
@Current IdentifierPolicy identifierPolicy;
- @Current Manager manager;
+ @Current BeanManager manager;
@Current IdentityManager identityManager;
@Initializer
@@ -71,15 +71,15 @@
{
metadata = new PermissionMetadata();
- // TODO see if we can scan for this automatically
+ // TODO see if we can scan for this automatically
if (userPermissionClass == null)
{
log.debug("No permissionClass set, JpaPermissionStore will be unavailable.");
return;
- }
+ }
initProperties();
- }
+ }
protected void initProperties()
{
@@ -92,9 +92,9 @@
roleProperty = new AnnotatedBeanProperty<PermissionRole>(rolePermissionClass, PermissionRole.class);
if (roleProperty.isSet())
{
- roleTargetProperty = new AnnotatedBeanProperty<PermissionTarget>(rolePermissionClass,
+ roleTargetProperty = new AnnotatedBeanProperty<PermissionTarget>(rolePermissionClass,
PermissionTarget.class);
- roleActionProperty = new AnnotatedBeanProperty<PermissionAction>(rolePermissionClass,
+ roleActionProperty = new AnnotatedBeanProperty<PermissionAction>(rolePermissionClass,
PermissionAction.class);
}
}
@@ -103,14 +103,14 @@
roleProperty = new AnnotatedBeanProperty<PermissionRole>(userPermissionClass, PermissionRole.class);
if (roleProperty.isSet())
{
- discriminatorProperty = new AnnotatedBeanProperty<PermissionDiscriminator>(userPermissionClass,
+ discriminatorProperty = new AnnotatedBeanProperty<PermissionDiscriminator>(userPermissionClass,
PermissionDiscriminator.class);
}
}
- if (!userProperty.isSet())
+ if (!userProperty.isSet())
{
- throw new RuntimeException("Invalid userPermissionClass " + userPermissionClass.getName() +
+ throw new RuntimeException("Invalid userPermissionClass " + userPermissionClass.getName() +
" - required annotation @PermissionUser not found on any Field or Method.");
}
@@ -140,10 +140,10 @@
" - no rolePermissionClass set and @PermissionDiscriminator annotation not found on " +
"any Field or Method");
}
- }
+ }
/**
- * Creates a Query that returns a list of permission records for the specified parameters.
+ * Creates a Query that returns a list of permission records for the specified parameters.
*
* @param target The target of the permission, may be null
* @param targets A set of permission targets, may be null
@@ -166,10 +166,10 @@
queryKey |= (discrimination.equals(Discrimination.either) ? 32 : 0);
boolean isRole = discrimination.equals(Discrimination.role);
- boolean useRoleTable = isRole && rolePermissionClass != null;
+ boolean useRoleTable = isRole && rolePermissionClass != null;
if (!queryCache.containsKey(queryKey))
- {
+ {
boolean conditionsAdded = false;
StringBuilder q = new StringBuilder();
@@ -230,7 +230,7 @@
if (recipient != null) query.setParameter("recipient", resolvePrincipalEntity(recipient));
- if (!discrimination.equals(Discrimination.either) && discriminatorProperty != null)
+ if (!discrimination.equals(Discrimination.either) && discriminatorProperty != null)
{
query.setParameter("discriminator", getDiscriminatorValue(
discrimination.equals(Discrimination.role)));
@@ -241,7 +241,7 @@
public boolean grantPermission(Permission permission)
{
- return updatePermissionActions(permission.getTarget(), permission.getRecipient(),
+ return updatePermissionActions(permission.getTarget(), permission.getRecipient(),
new String[] {permission.getAction()}, true);
}
@@ -249,10 +249,10 @@
{
return updatePermissionActions(permission.getTarget(), permission.getRecipient(),
new String[] { permission.getAction() }, false);
- }
+ }
/**
- * This is where the bulk of the actual work happens.
+ * This is where the bulk of the actual work happens.
*
* @param target The target object to update permissions for
* @param recipient The recipient to update permissions for
@@ -293,7 +293,7 @@
Object instance = permissions.get(0);
- ActionSet actionSet = metadata.createActionSet(target.getClass(),
+ ActionSet actionSet = metadata.createActionSet(target.getClass(),
roleActionProperty.getValue(instance).toString());
for (String action : actions)
@@ -319,7 +319,7 @@
{
lookupEntityManager().remove(p);
}
- }
+ }
}
if (!actionSet.isEmpty())
@@ -338,7 +338,7 @@
if (!discriminatorProperty.isSet())
{
- throw new RuntimeException("Could not grant permission, rolePermissionClass not set");
+ throw new RuntimeException("Could not grant permission, rolePermissionClass not set");
}
}
@@ -347,7 +347,7 @@
throw new RuntimeException("Could not grant permission, userPermissionClass not set");
}
- List permissions = createPermissionQuery(target, null, recipient, recipientIsRole ?
+ List permissions = createPermissionQuery(target, null, recipient, recipientIsRole ?
Discrimination.role : Discrimination.user).getResultList();
if (permissions.isEmpty())
@@ -386,7 +386,7 @@
Object instance = permissions.get(0);
- ActionSet actionSet = metadata.createActionSet(target.getClass(),
+ ActionSet actionSet = metadata.createActionSet(target.getClass(),
actionProperty.getValue(instance).toString());
for (String action : actions)
@@ -411,7 +411,7 @@
{
lookupEntityManager().remove(p);
}
- }
+ }
}
if (!actionSet.isEmpty())
@@ -425,12 +425,12 @@
lookupEntityManager().remove(instance);
}
- return true;
+ return true;
}
catch (Exception ex)
{
throw new RuntimeException("Could not grant permission", ex);
- }
+ }
}
public boolean grantPermissions(List<Permission> permissions)
@@ -473,13 +473,13 @@
}
return true;
- }
+ }
/**
* Groups a list of arbitrary permissions into a more easily-consumed structure
*
* @param permissions The list of permissions to group
- * @return
+ * @return
*/
private Map<Object,Map<Principal,List<Permission>>> groupPermissions(List<Permission> permissions)
{
@@ -512,13 +512,13 @@
private String getDiscriminatorValue(boolean isRole)
{
PermissionDiscriminator discriminator = discriminatorProperty.getAnnotation();
- return isRole ? discriminator.roleValue() : discriminator.userValue();
+ return isRole ? discriminator.roleValue() : discriminator.userValue();
}
/**
* If the user or role properties in the entity class refer to other entities, then this method
* uses the JpaIdentityStore (if available) to lookup that user or role entity. Otherwise it
- * simply returns the name of the recipient.
+ * simply returns the name of the recipient.
*
* @param recipient
* @return The entity or name representing the permission recipient
@@ -532,7 +532,7 @@
if (identityStore != null)
{
- if (recipientIsRole && roleProperty.isSet() &&
+ if (recipientIsRole && roleProperty.isSet() &&
roleProperty.getPropertyType().equals(config.getRoleEntityClass()))
{
return identityStore.lookupRole(recipient.getName());
@@ -541,7 +541,7 @@
{
return identityStore.lookupUser(recipient.getName());
}
- }
+ }
return recipient.getName();
}
@@ -554,10 +554,10 @@
JpaIdentityStoreConfig config = manager.getInstanceByType(JpaIdentityStoreConfig.class);
if (principal instanceof String)
- {
- return isUser ? new SimplePrincipal((String) principal) : new Role((String) principal,
+ {
+ return isUser ? new SimplePrincipal((String) principal) : new Role((String) principal,
identityStore == null ? false : identityStore.isRoleConditional((String) principal));
- }
+ }
if (identityStore != null)
{
@@ -573,7 +573,7 @@
}
}
- throw new IllegalArgumentException("Cannot resolve principal name for principal " + principal);
+ throw new IllegalArgumentException("Cannot resolve principal name for principal " + principal);
}
/**
@@ -588,7 +588,7 @@
/**
* Returns a list of all user and role permissions for a specific permission target and action.
*/
- public List<Permission> listPermissions(Object target, String action)
+ public List<Permission> listPermissions(Object target, String action)
{
return listPermissions(target, null, action);
}
@@ -632,25 +632,25 @@
ActionSet actionSet = null;
if (targets != null)
- {
+ {
target = identifierCache.get(targetProperty.getValue(permission));
if (target != null)
{
- actionSet = metadata.createActionSet(target.getClass(),
+ actionSet = metadata.createActionSet(target.getClass(),
actionProperty.getValue(permission).toString());
}
}
else
{
actionSet = metadata.createActionSet(target.getClass(),
- actionProperty.getValue(permission).toString());
+ actionProperty.getValue(permission).toString());
}
if (target != null && (action == null || (actionSet != null && actionSet.contains(action))))
- {
+ {
boolean isUser = true;
- if (useDiscriminator &&
+ if (useDiscriminator &&
discriminatorProperty.getAnnotation().roleValue().equals(
discriminatorProperty.getValue(permission)))
{
@@ -664,7 +664,7 @@
permissions.add(new Permission(target, action, principal));
}
else
- {
+ {
for (String a : actionSet.members())
{
permissions.add(new Permission(target, a, principal));
@@ -678,30 +678,30 @@
{
permissionQuery = targets != null ?
createPermissionQuery(null, targets, null, Discrimination.role) :
- createPermissionQuery(target, null, null, Discrimination.role);
+ createPermissionQuery(target, null, null, Discrimination.role);
List<?> rolePermissions = permissionQuery.getResultList();
for (Object permission : rolePermissions)
- {
+ {
ActionSet actionSet = null;
if (targets != null)
- {
+ {
target = identifierCache.get(roleTargetProperty.getValue(permission));
if (target != null)
{
- actionSet = metadata.createActionSet(target.getClass(),
+ actionSet = metadata.createActionSet(target.getClass(),
roleActionProperty.getValue(permission).toString());
}
}
else
{
actionSet = metadata.createActionSet(target.getClass(),
- roleActionProperty.getValue(permission).toString());
- }
+ roleActionProperty.getValue(permission).toString());
+ }
if (target != null && (action == null || (actionSet != null && actionSet.contains(action))))
- {
+ {
Principal principal = lookupPrincipal(principalCache, permission, false);
if (action != null)
@@ -709,12 +709,12 @@
permissions.add(new Permission(target, action, principal));
}
else
- {
+ {
for (String a : actionSet.members())
{
permissions.add(new Permission(target, a, principal));
}
- }
+ }
}
}
}
@@ -736,12 +736,12 @@
else
{
principal = cache.get(key);
- }
+ }
return principal;
}
- public List<Permission> listPermissions(Object target)
+ public List<Permission> listPermissions(Object target)
{
return listPermissions(target, null);
}
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionManager.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,8 +3,8 @@
import java.io.Serializable;
import java.util.List;
-import javax.annotation.Named;
-import javax.inject.Current;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Named;
import org.jboss.seam.security.Identity;
import org.jboss.webbeans.log.LogProvider;
@@ -23,7 +23,7 @@
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";
+ public static final String PERMISSION_REVOKE = "seam.revoke-permission";
private static final LogProvider log = Logging.getLogProvider(PermissionManager.class);
@@ -42,7 +42,7 @@
public List<Permission> listPermissions(Object target, String action)
{
- if (target == null) return null;
+ if (target == null) return null;
identity.checkPermission(target, PERMISSION_READ);
return permissionStore.listPermissions(target, action);
}
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -7,10 +7,10 @@
import java.util.Map;
import java.util.Set;
-import javax.context.ApplicationScoped;
-import javax.inject.Current;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.security.events.DefaultResolverChainCreatedEvent;
@@ -30,7 +30,7 @@
private static final String DEFAULT_RESOLVER_CHAIN = "org.jboss.seam.security.defaultResolverChain";
- @Current Manager manager;
+ @Current BeanManager manager;
private ResolverChain getResolverChain(Object target, String action)
{
@@ -53,15 +53,15 @@
{
return (ResolverChain) manager.getInstanceByName(chains.get(action));
}
- }
+ }
if (defaultResolverChain != null && !"".equals(defaultResolverChain))
{
- return (ResolverChain) manager.getInstanceByName(defaultResolverChain);
+ return (ResolverChain) manager.getInstanceByName(defaultResolverChain);
}
return createDefaultResolverChain();
- }
+ }
public boolean resolvePermission(Object target, String action)
{
@@ -75,7 +75,7 @@
}
return false;
- }
+ }
public void filterByPermission(Collection collection, String action)
{
@@ -94,7 +94,7 @@
if (homogenous)
{
- Set<Object> denied = new HashSet<Object>(collection);
+ Set<Object> denied = new HashSet<Object>(collection);
ResolverChain chain = getResolverChain(targetClass, action);
for (PermissionResolver resolver : chain.getResolvers())
{
@@ -104,7 +104,7 @@
for (Object target : denied)
{
collection.remove(target);
- }
+ }
}
else
{
@@ -149,10 +149,10 @@
{
chain = new ResolverChain();
- Set<Bean<PermissionResolver>> resolvers = manager.resolveByType(PermissionResolver.class);
+ Set<Bean<PermissionResolver>> resolvers = manager.getBeans(PermissionResolver.class);
for (Bean<PermissionResolver> resolverBean : resolvers)
{
- chain.getResolvers().add((PermissionResolver) manager.getInstance(resolverBean));
+ chain.getResolvers().add(manager.getInstance(resolverBean));
}
// TODO fix
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -5,31 +5,31 @@
import java.util.List;
import java.util.Set;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.BeanManager;
-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;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
/**
- * Resolves dynamically-assigned permissions, mapped to a user or a role, and kept in persistent
+ * Resolves dynamically-assigned permissions, mapped to a user or a role, and kept in persistent
* storage, such as a relational database.
*
* @author Shane Bryzak
*/
public class PersistentPermissionResolver implements PermissionResolver, Serializable
-{
+{
private static final long serialVersionUID = -603389172032219059L;
private PermissionStore permissionStore;
private static final LogProvider log = Logging.getLogProvider(PersistentPermissionResolver.class);
- @Current Manager manager;
+ @Current BeanManager manager;
@Current Identity identity;
@Current RuleBasedPermissionResolver ruleBasedPermissionResolver;
@@ -37,15 +37,15 @@
public void initPermissionStore()
{
if (permissionStore == null)
- {
+ {
permissionStore = manager.getInstanceByType(JpaPermissionStore.class);
- }
+ }
if (permissionStore == null)
{
log.warn("no permission store available - please install a PermissionStore if persistent permissions are required.");
}
- }
+ }
public PermissionStore getPermissionStore()
{
@@ -58,10 +58,10 @@
}
public boolean hasPermission(Object target, String action)
- {
+ {
if (permissionStore == null) return false;
- if (!identity.isLoggedIn()) return false;
+ if (!identity.isLoggedIn()) return false;
List<Permission> permissions = permissionStore.listPermissions(target, action);
@@ -81,14 +81,14 @@
if (role.isConditional())
{
- if (ruleBasedPermissionResolver.checkConditionalRole(role.getName(), target, action)) return true;
+ if (ruleBasedPermissionResolver.checkConditionalRole(role.getName(), target, action)) return true;
}
else if (identity.hasRole(role.getName()))
{
return true;
}
}
- }
+ }
return false;
}
@@ -136,7 +136,7 @@
iter.remove();
break;
}
- }
+ }
}
}
}
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/ResolverChain.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -4,11 +4,11 @@
import java.util.ArrayList;
import java.util.List;
-import javax.context.SessionScoped;
+import javax.enterprise.context.SessionScoped;
/**
- * A chain of permission resolvers. Specific permission checks are generally mapped to a
- * particular ResolverChain for resolution.
+ * A chain of permission resolvers. Specific permission checks are generally mapped to a
+ * particular ResolverChain for resolution.
*
* @author Shane Bryzak
*/
@@ -27,5 +27,5 @@
public void setResolvers(List<PermissionResolver> resolvers)
{
this.resolvers = resolvers;
- }
+ }
}
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-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -9,43 +9,41 @@
import java.util.List;
import java.util.Set;
-import javax.context.SessionScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.BeanManager;
import javax.event.Observes;
-import javax.inject.Current;
-import javax.inject.Initializer;
-import javax.inject.manager.Initialized;
-import javax.inject.manager.Manager;
import org.drools.FactHandle;
import org.drools.RuleBase;
import org.drools.StatefulSession;
import org.drools.base.ClassObjectFilter;
import org.jboss.seam.drools.SeamGlobalResolver;
-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;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
/**
* A permission resolver that uses a Drools rule base to perform permission checks
- *
+ *
* @author Shane Bryzak
*/
@SessionScoped
public class RuleBasedPermissionResolver implements PermissionResolver, Serializable
-{
+{
private static final long serialVersionUID = -7572627522601793024L;
private static final LogProvider log = Logging.getLogProvider(RuleBasedPermissionResolver.class);
private StatefulSession securityContext;
- private RuleBase securityRules;
+ private RuleBase securityRules;
- @Current Manager manager;
+ @Current BeanManager manager;
@Current Identity identity;
@Initializer
@@ -56,7 +54,7 @@
}
protected void initSecurityContext()
- {
+ {
if (getSecurityRules() != null)
{
setSecurityContext(getSecurityRules().newStatefulSession(false));
@@ -72,12 +70,12 @@
* @return boolean True if the user has the specified permission
*/
public boolean hasPermission(Object target, String action)
- {
+ {
StatefulSession securityContext = getSecurityContext();
- if (securityContext == null) return false;
+ if (securityContext == null) return false;
- List<FactHandle> handles = new ArrayList<FactHandle>();
+ List<FactHandle> handles = new ArrayList<FactHandle>();
PermissionCheck check;
@@ -94,7 +92,7 @@
target = componentName != null ? componentName : ((Class) target).getName();
}
- check = new PermissionCheck(target, action);
+ check = new PermissionCheck(target, action);
try
{
@@ -127,7 +125,7 @@
}
public boolean checkConditionalRole(String roleName, Object target, String action)
- {
+ {
StatefulSession securityContext = getSecurityContext();
if (securityContext == null) return false;
@@ -165,7 +163,7 @@
{
handles.add (securityContext.insert(value));
}
- }
+ }
}
synchronizeContext();
@@ -187,12 +185,12 @@
return roleCheck.isGranted();
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public void unAuthenticate(@Observes LoggedOutEvent event)
{
if (getSecurityContext() != null)
{
- getSecurityContext().dispose();
+ getSecurityContext().dispose();
setSecurityContext(null);
}
initSecurityContext();
@@ -202,12 +200,12 @@
* Synchronises the state of the security context with that of the subject
*/
private void synchronizeContext()
- {
+ {
if (getSecurityContext() != null)
{
getSecurityContext().insert(identity.getPrincipal());
- for ( Group sg : identity.getSubject().getPrincipals(Group.class) )
+ for ( Group sg : identity.getSubject().getPrincipals(Group.class) )
{
if ( Identity.ROLES_GROUP.equals( sg.getName() ) )
{
@@ -217,8 +215,8 @@
Principal role = (Principal) e.nextElement();
boolean found = false;
- Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
- while (iter.hasNext())
+ Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
+ while (iter.hasNext())
{
Role r = iter.next();
if (r.getName().equals(role.getName()))
@@ -235,10 +233,10 @@
}
}
- }
+ }
- Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
- while (iter.hasNext())
+ Iterator<Role> iter = getSecurityContext().iterateObjects(new ClassObjectFilter(Role.class));
+ while (iter.hasNext())
{
Role r = iter.next();
if (!identity.hasRole(r.getName()))
@@ -270,7 +268,7 @@
public void setSecurityRules(RuleBase securityRules)
{
this.securityRules = securityRules;
- }
+ }
/**
* Post-authentication event observer
@@ -278,7 +276,7 @@
public void setUserAccountInSecurityContext(@Observes PostAuthenticateEvent event)
{
if (getSecurityContext() != null)
- {
+ {
getSecurityContext().insert(identity.getPrincipal());
// If we were authenticated with the JpaIdentityStore, then insert the authenticated
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -7,13 +7,11 @@
import java.util.List;
import java.util.Map;
-import javax.annotation.Named;
-import javax.context.Conversation;
-import javax.context.ConversationScoped;
-import javax.inject.Current;
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Named;
-//import org.jboss.seam.faces.annotations.DataModel;
-//import org.jboss.seam.faces.annotations.DataModelSelection;
import org.jboss.seam.security.management.IdentityManager;
import org.jboss.seam.security.permission.Permission;
import org.jboss.seam.security.permission.PermissionManager;
@@ -44,12 +42,12 @@
public void search(Object target)
{
conversation.begin();
- this.target = target;
+ this.target = target;
}
public void refresh()
{
- List<Permission> permissions = permissionManager.listPermissions(target);
+ List<Permission> permissions = permissionManager.listPermissions(target);
groupedPermissions.clear();
for (Permission permission : permissions)
@@ -66,7 +64,7 @@
recipientPermissions = groupedPermissions.get(permission.getRecipient());
}
- recipientPermissions.add(permission);
+ recipientPermissions.add(permission);
}
recipients = new ArrayList<Principal>(groupedPermissions.keySet());
@@ -104,5 +102,5 @@
public List<Permission> getSelectedPermissions()
{
return groupedPermissions.get(selectedRecipient);
- }
+ }
}
Modified: modules/trunk/web/src/main/java/org/jboss/seam/web/HttpSessionManager.java
===================================================================
--- modules/trunk/web/src/main/java/org/jboss/seam/web/HttpSessionManager.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/web/src/main/java/org/jboss/seam/web/HttpSessionManager.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,8 +3,8 @@
import java.util.Enumeration;
import javax.annotation.PreDestroy;
-import javax.context.RequestScoped;
-import javax.inject.Produces;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;
Modified: modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java
===================================================================
--- modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -1,6 +1,6 @@
package org.jboss.seam.bridge.webbeans;
-import javax.inject.manager.Manager;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.webbeans.CurrentManager;
@@ -13,7 +13,7 @@
*/
public class WebBeansManagerProvider implements ManagerProvider
{
- public Manager getCurrentManager()
+ public BeanManager getCurrentManager()
{
return CurrentManager.rootManager().getCurrent();
}
Modified: modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java
===================================================================
--- modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java 2009-05-26 16:08:23 UTC (rev 10992)
+++ modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java 2009-05-26 16:23:09 UTC (rev 10993)
@@ -3,8 +3,8 @@
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
-import javax.context.RequestScoped;
-import javax.inject.manager.Manager;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.bridge.ManagerBridge;
import org.jboss.seam.bridge.spi.ManagerProvider;
@@ -37,7 +37,7 @@
ManagerProvider provider = ManagerBridge.getProvider();
assertTrue(provider instanceof WebBeansManagerProvider);
assertSame(provider.getCurrentManager(), getCurrentManager());
- Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
+ BeanManager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
assertSame(provider.getCurrentManager(), currentManager);
}
15 years, 6 months
Seam SVN: r10992 - branches/community/Seam_2_1/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: nico.ben
Date: 2009-05-26 12:08:23 -0400 (Tue, 26 May 2009)
New Revision: 10992
Modified:
branches/community/Seam_2_1/doc/Seam_Reference_Guide/en-US/I18n.xml
Log:
Eliminated <anchor>
Modified: branches/community/Seam_2_1/doc/Seam_Reference_Guide/en-US/I18n.xml
===================================================================
--- branches/community/Seam_2_1/doc/Seam_Reference_Guide/en-US/I18n.xml 2009-05-26 15:38:57 UTC (rev 10991)
+++ branches/community/Seam_2_1/doc/Seam_Reference_Guide/en-US/I18n.xml 2009-05-26 16:08:23 UTC (rev 10992)
@@ -72,7 +72,7 @@
<para>
You can write your translation of labels
- (<xlink linkend="labels">Labels</xlink>) to your messages resource
+ (<xref linkend="labels"/>) to your messages resource
bundle in the native encoding and then convert the content of the
file into the escaped format through the tool <literal>native2ascii</literal>
provided in the JDK. This tool will convert a file written in your
@@ -124,8 +124,8 @@
</section>
</section>
- <section>
- <title>Locales<anchor id="locales" /></title>
+ <section id="locales">
+ <title>Locales</title>
<para>Each user login session has an associated instance of
<literal>java.util.Locale</literal> (available to the application as a
@@ -206,8 +206,8 @@
the language-specific labels.</para>
</section>
- <section>
- <title>Labels<anchor id="labels" /></title>
+ <section id="labels" />
+ <title>Labels</title>
<para>JSF supports internationalization of user interface labels and
descriptive text via the use of <literal><f:loadBundle /></literal>.
@@ -316,7 +316,6 @@
<literal>G'day, Gavin</literal>, depending upon the user's
locale.</para>
</section>
- </section>
<section>
<title>Timezones</title>
15 years, 6 months
Seam SVN: r10991 - in modules/trunk/faces: src/main/java/org/jboss/seam/faces and 4 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 11:38:57 -0400 (Tue, 26 May 2009)
New Revision: 10991
Added:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIViewAction.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/
modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/ActionSourceHandler.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/DeferredValueExpressionHandler.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ViewActionExecutor.java
modules/trunk/faces/src/main/resources/META-INF/seam-faces.taglib.xml
Modified:
modules/trunk/faces/pom.xml
modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
Log:
add UIViewAction (page actions) component
add UIRestriceView (page security restrictions) component
add facelets helper classes
Modified: modules/trunk/faces/pom.xml
===================================================================
--- modules/trunk/faces/pom.xml 2009-05-26 15:37:39 UTC (rev 10990)
+++ modules/trunk/faces/pom.xml 2009-05-26 15:38:57 UTC (rev 10991)
@@ -59,6 +59,13 @@
<groupId>${seam.groupId}</groupId>
<artifactId>seam-international</artifactId>
</dependency>
+
+ <!-- QUESTION do we want this dependency? -->
+ <dependency>
+ <groupId>${seam.groupId}</groupId>
+ <artifactId>seam-security</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>${seam.groupId}</groupId>
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIRestrictView.java 2009-05-26 15:38:57 UTC (rev 10991)
@@ -0,0 +1,65 @@
+package org.jboss.seam.faces.component;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Dan Allen
+ */
+public class UIRestrictView extends UIComponentBase
+{
+
+ // ------------------------------------------------------ Manifest Constants
+
+ /**
+ * <p>
+ * The standard component type for this component.
+ * </p>
+ */
+ public static final String COMPONENT_TYPE = "org.jboss.seam.faces.RestrictView";
+
+ /**
+ * <p>
+ * The standard component type for this component.
+ * </p>
+ */
+ public static final String COMPONENT_FAMILY = "org.jboss.seam.faces.RestrictView";
+
+ /**
+ * Properties that are tracked by state saving.
+ */
+ enum PropertyKeys {
+ require
+ }
+
+ // ------------------------------------------------------------ Constructors
+
+ /**
+ * <p>
+ * Create a new {@link UIRestrictView} instance with default property values.
+ * </p>
+ */
+ public UIRestrictView()
+ {
+ super();
+ setRendererType(null);
+ }
+
+ // -------------------------------------------------------------- Properties
+
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public ValueExpression getRequire()
+ {
+ return (ValueExpression) getStateHelper().get(PropertyKeys.require);
+ }
+
+ public void setRequire(ValueExpression require)
+ {
+ getStateHelper().put(PropertyKeys.require, require);
+ }
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIViewAction.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIViewAction.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/component/UIViewAction.java 2009-05-26 15:38:57 UTC (rev 10991)
@@ -0,0 +1,77 @@
+package org.jboss.seam.faces.component;
+
+import javax.el.MethodExpression;
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Dan Allen
+ */
+public class UIViewAction extends UIComponentBase
+{
+
+ // ------------------------------------------------------ Manifest Constants
+
+ /**
+ * <p>
+ * The standard component type for this component.
+ * </p>
+ */
+ public static final String COMPONENT_TYPE = "org.jboss.seam.faces.ViewAction";
+
+ /**
+ * <p>
+ * The standard component type for this component.
+ * </p>
+ */
+ public static final String COMPONENT_FAMILY = "org.jboss.seam.faces.ViewAction";
+
+ /**
+ * Properties that are tracked by state saving.
+ */
+ enum PropertyKeys {
+ onPostback,
+ execute
+ }
+
+ // ------------------------------------------------------------ Constructors
+
+ /**
+ * <p>
+ * Create a new {@link UIViewAction} instance with default property values.
+ * </p>
+ */
+ public UIViewAction()
+ {
+ super();
+ setRendererType(null);
+ }
+
+ // -------------------------------------------------------------- Properties
+
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public MethodExpression getExecute()
+ {
+ return (MethodExpression) getStateHelper().get(PropertyKeys.execute);
+ }
+
+ public void setExecute(MethodExpression execute)
+ {
+ getStateHelper().put(PropertyKeys.execute, execute);
+ }
+
+ public boolean isOnPostback()
+ {
+ return (Boolean) getStateHelper().eval(PropertyKeys.onPostback, false);
+ }
+
+ public void setOnPostback(boolean onPostback)
+ {
+ getStateHelper().put(PropertyKeys.onPostback, onPostback);
+ }
+
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/ActionSourceHandler.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/ActionSourceHandler.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/ActionSourceHandler.java 2009-05-26 15:38:57 UTC (rev 10991)
@@ -0,0 +1,91 @@
+package org.jboss.seam.faces.facelets;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.el.MethodExpression;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+
+/**
+ * An adaptor class for Facelets that allows the method expression attribute to
+ * be accepted rather than interpreted as a value expression. This class should
+ * be supplemented to support all such tags that require a method expression.
+ *
+ * @author Dan Allen
+ */
+public class ActionSourceHandler extends ComponentHandler
+{
+ public static final String EXECUTE_ATTRIBUTE_NAME = "execute";
+
+ public ActionSourceHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ return super.createMetaRuleset(type).addRule(new ExecuteRule());
+ }
+
+ private class ExecuteRule extends MetaRule
+ {
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+ {
+ if (EXECUTE_ATTRIBUTE_NAME.equals(name) && MethodExpression.class.equals(meta.getPropertyType(name)))
+ {
+ return new MethodExpressionMetadata(meta.getWriteMethod(name), attribute, Object.class, new Class[0]);
+ }
+
+ return null;
+ }
+ }
+
+ private static class MethodExpressionMetadata extends Metadata
+ {
+ private final Method method;
+
+ private final TagAttribute attribute;
+
+ private Class returnType;
+
+ private Class[] argumentTypes;
+
+ public MethodExpressionMetadata(Method method, TagAttribute attribute, Class returnType, Class[] argumentTypes)
+ {
+ this.method = method;
+ this.attribute = attribute;
+ this.returnType = returnType;
+ this.argumentTypes = argumentTypes;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ MethodExpression expr = attribute.getMethodExpression(ctx, returnType, argumentTypes);
+
+ try
+ {
+ // this invocation is to assign the method expression to the property of the component
+ method.invoke(instance, expr);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TagAttributeException(attribute, e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TagAttributeException(attribute, e);
+ }
+ }
+ }
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/DeferredValueExpressionHandler.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/DeferredValueExpressionHandler.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/facelets/DeferredValueExpressionHandler.java 2009-05-26 15:38:57 UTC (rev 10991)
@@ -0,0 +1,81 @@
+package org.jboss.seam.faces.facelets;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.el.ValueExpression;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+
+public class DeferredValueExpressionHandler extends ComponentHandler
+{
+ public static final String REQUIRE_ATTRIBUTE_NAME = "require";
+
+ public DeferredValueExpressionHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ return super.createMetaRuleset(type).addRule(new RequiredRule());
+ }
+
+ private class RequiredRule extends MetaRule
+ {
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+ {
+ if (REQUIRE_ATTRIBUTE_NAME.equals(name) && ValueExpression.class.equals(meta.getPropertyType(name)))
+ {
+ return new ValueExpressionMetadata(meta.getWriteMethod(name), attribute, Boolean.class);
+ }
+
+ return null;
+ }
+ }
+
+ private static class ValueExpressionMetadata extends Metadata
+ {
+ private final Method method;
+
+ private final TagAttribute attribute;
+
+ private Class returnType;
+
+ public ValueExpressionMetadata(Method method, TagAttribute attribute, Class returnType)
+ {
+ this.method = method;
+ this.attribute = attribute;
+ this.returnType = returnType;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ ValueExpression expr = attribute.getValueExpression(ctx, returnType);
+
+ try
+ {
+ // this invocation is to assign the value expression to the property of the component
+ method.invoke(instance, expr);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TagAttributeException(attribute, e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TagAttributeException(attribute, e);
+ }
+ }
+ }
+}
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ViewActionExecutor.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ViewActionExecutor.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/ViewActionExecutor.java 2009-05-26 15:38:57 UTC (rev 10991)
@@ -0,0 +1,228 @@
+package org.jboss.seam.faces.lifecycle;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.faces.FacesException;
+import javax.faces.application.NavigationHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+
+import org.jboss.seam.bridge.ManagerBridge;
+import org.jboss.seam.faces.component.UIRestrictView;
+import org.jboss.seam.faces.component.UIViewAction;
+import org.jboss.seam.security.Identity;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
+
+//@ListenerFor(systemEventClass = PreRenderViewEvent.class, sourceClass = UIViewRoot.class)
+public class ViewActionExecutor implements SystemEventListener
+{
+ private static final Log log = Logging.getLog(ViewActionExecutor.class);
+
+ public boolean isListenerForSource(Object source)
+ {
+ return source instanceof UIViewRoot;
+ }
+
+ public void processEvent(SystemEvent event) throws AbortProcessingException
+ {
+ processViewActions();
+ }
+
+ protected void processViewActions()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIViewRoot initialViewRoot = context.getViewRoot();
+
+ // TEMPORARY needs to be organized better
+
+ // collect first so as not to introduce a hard dependency on Identity if tag is not in use
+ Collection<UIRestrictView> restrictions = collectionViewRestrictions(initialViewRoot);
+ if (!restrictions.isEmpty())
+ {
+ if (Identity.isSecurityEnabled())
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Processing view restrictions before render view");
+ }
+
+ Identity identity = ManagerBridge.getProvider().getCurrentManager().getInstanceByType(Identity.class);
+ try
+ {
+ for (UIRestrictView restriction : restrictions)
+ {
+ if (restriction.getRequire() != null)
+ {
+ identity.checkRestriction(restriction.getRequire());
+ }
+ else
+ {
+ identity.checkPermission(initialViewRoot.getViewId(), "render");
+ }
+ }
+ }
+ // FIXME damn this is ugly, but JCDI is wrapping exceptions
+ catch (Exception e)
+ {
+ Throwable cause = e;
+ if (e instanceof InvocationTargetException)
+ {
+ cause = e.getCause();
+ }
+
+ context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, new ExceptionQueuedEventContext(context, cause));
+ // FIXME this is lame; there should be some other way to stop view rendering
+ context.getViewRoot().setRendered(false);
+ throw new AbortProcessingException("View restriction criteria was not met.");
+ //return;
+ }
+ }
+ }
+ // END TEMPORARY
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("Processing view actions before render view");
+ }
+
+ NavigationHandler navHandler = context.getApplication().getNavigationHandler();
+ boolean postback = context.isPostback();
+
+ if (!postback && context.isValidationFailed())
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Validation flagged as failed. Calling navigation handler without executing view actions.");
+ }
+ navHandler.handleNavigation(context, null, null);
+ return;
+ }
+
+ Collection<UIViewAction> actions = collectViewActions(initialViewRoot, postback);
+ for (UIViewAction action : actions)
+ {
+ String outcome = null;
+ String fromAction = null;
+
+ MethodExpression execute = action.getExecute();
+ // QUESTION shouldn't this be an illegal state otherwise??
+ if (execute != null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Executing view action expression {0}", execute.getExpressionString());
+ }
+ try
+ {
+ Object returnVal = execute.invoke(context.getELContext(), null);
+ outcome = (returnVal != null ? returnVal.toString() : null);
+ fromAction = execute.getExpressionString();
+ }
+ catch (ELException e)
+ {
+ if (log.isErrorEnabled())
+ {
+ log.error(e.getMessage(), e);
+ }
+ throw new FacesException(execute.getExpressionString() + ": " + e.getMessage(), e);
+ }
+ }
+
+ navHandler.handleNavigation(context, fromAction, outcome);
+
+ // QUESTION In either of these two cases, should an AbortProcessingEvent exception be thrown?
+ if (context.getResponseComplete())
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Response marked as complete during view action processing. Short-circuiting remaining actions.");
+ }
+ // FIXME this is lame; there should be some other way to stop view rendering
+ context.getViewRoot().setRendered(false);
+ break;
+ }
+ else if (!initialViewRoot.getViewId().equals(context.getViewRoot().getViewId()))
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Detected change in view ID during view action processing. Short-circuiting remaining actions.");
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * Pick out the UIRestrictView components from the metadata facet's children. If no
+ * matches are found, an unmodifiable empty list is returned.
+ */
+ protected Collection<UIRestrictView> collectionViewRestrictions(UIViewRoot viewRoot)
+ {
+ return collectMetadataComponents(viewRoot, new UIComponentFilter<UIRestrictView>() {
+
+ @Override
+ public boolean accept(UIComponent candidate)
+ {
+ return candidate instanceof UIRestrictView;
+ }
+
+ });
+ }
+
+ /**
+ * Pick out the UIViewAction components from the metadata facet's children. If this is a postback,
+ * only select UIViewAction components that are to be executed on a postback. If no matches
+ * are found, an unmodifiable empty list is returned.
+ */
+ protected Collection<UIViewAction> collectViewActions(UIViewRoot viewRoot, final boolean postback)
+ {
+ return collectMetadataComponents(viewRoot, new UIComponentFilter<UIViewAction>() {
+
+ @Override
+ public boolean accept(UIComponent candidate)
+ {
+ return candidate instanceof UIViewAction && (!postback || ((UIViewAction) candidate).isOnPostback());
+ }
+
+ });
+ }
+
+ protected <C extends UIComponent> Collection<C> collectMetadataComponents(UIViewRoot viewRoot, UIComponentFilter<C> componentFilter)
+ {
+ UIComponent metadataFacet = viewRoot.getFacet(UIViewRoot.METADATA_FACET_NAME);
+
+ if (metadataFacet == null)
+ {
+ return Collections.<C>emptyList();
+ }
+
+ Collection<C> matches = new ArrayList<C>();
+ for (UIComponent candidate : metadataFacet.getChildren())
+ {
+ if (componentFilter.accept(candidate))
+ {
+ matches.add((C) candidate);
+ }
+ }
+
+ return matches;
+ }
+
+ protected abstract class UIComponentFilter<C extends UIComponent>
+ {
+ public abstract boolean accept(UIComponent candidate);
+ }
+
+}
Modified: modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
===================================================================
--- modules/trunk/faces/src/main/resources/META-INF/faces-config.xml 2009-05-26 15:37:39 UTC (rev 10990)
+++ modules/trunk/faces/src/main/resources/META-INF/faces-config.xml 2009-05-26 15:38:57 UTC (rev 10991)
@@ -5,8 +5,12 @@
version="2.0"
id="seam3">
+ <name>seam3</name>
+
<ordering>
- <after>webbeans</after>
+ <after>
+ <name>webbeans</name>
+ </after>
</ordering>
<factory>
@@ -18,8 +22,12 @@
<el-resolver>org.jboss.seam.el.SeamELResolver</el-resolver>
<el-resolver>org.jboss.seam.faces.el.SeamFacesELResolver</el-resolver>
<system-event-listener>
+ <system-event-listener-class>org.jboss.seam.faces.lifecycle.ViewActionExecutor</system-event-listener-class>
<system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
+ </system-event-listener>
+ <system-event-listener>
<system-event-listener-class>org.jboss.seam.faces.lifecycle.TransferStatusMessagesListener</system-event-listener-class>
+ <system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
</system-event-listener>
</application>
@@ -28,5 +36,15 @@
<phase-listener>org.jboss.seam.faces.lifecycle.SeamPhaseListener</phase-listener>
-->
</lifecycle>
+
+ <component>
+ <component-type>org.jboss.seam.faces.RestrictView</component-type>
+ <component-class>org.jboss.seam.faces.component.UIRestrictView</component-class>
+ </component>
+
+ <component>
+ <component-type>org.jboss.seam.faces.ViewAction</component-type>
+ <component-class>org.jboss.seam.faces.component.UIViewAction</component-class>
+ </component>
</faces-config>
Added: modules/trunk/faces/src/main/resources/META-INF/seam-faces.taglib.xml
===================================================================
--- modules/trunk/faces/src/main/resources/META-INF/seam-faces.taglib.xml (rev 0)
+++ modules/trunk/faces/src/main/resources/META-INF/seam-faces.taglib.xml 2009-05-26 15:38:57 UTC (rev 10991)
@@ -0,0 +1,23 @@
+<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibary_2_0.xsd"
+ version="2.0">
+ <namespace>http://jboss.com/products/seam/faces</namespace>
+
+ <tag>
+ <tag-name>restrictView</tag-name>
+ <component>
+ <component-type>org.jboss.seam.faces.RestrictView</component-type>
+ <handler-class>org.jboss.seam.faces.component.DeferredValueExpressionHandler</handler-class>
+ </component>
+ </tag>
+
+ <tag>
+ <tag-name>viewAction</tag-name>
+ <component>
+ <component-type>org.jboss.seam.faces.ViewAction</component-type>
+ <handler-class>org.jboss.seam.faces.component.ActionSourceHandler</handler-class>
+ </component>
+ </tag>
+
+</facelet-taglib>
\ No newline at end of file
15 years, 6 months
Seam SVN: r10990 - modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 11:37:39 -0400 (Tue, 26 May 2009)
New Revision: 10990
Modified:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
Log:
use correct bridge call
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-05-26 15:31:37 UTC (rev 10989)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-05-26 15:37:39 UTC (rev 10990)
@@ -1,5 +1,6 @@
package org.jboss.seam.faces.lifecycle;
+import javax.faces.component.UIViewRoot;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
import javax.inject.UnsatisfiedDependencyException;
@@ -15,28 +16,30 @@
* a redirect navigation event (via SeamViewHandler) and transposes Seam
* StatusMessage objects into FacesMessage objects and transfers them to the FacesContext.
*
+ * FIXME this is going to be a problem if a view action causes a navigation event followed by a redirect event
+ *
* @author Dan Allen
*/
//@ListenerFor(systemEventClass = PreRenderViewEvent.class, sourceClass = UIViewRoot.class)
public class TransferStatusMessagesListener implements SystemEventListener
{
private static final LogProvider log = Logging.getLogProvider(TransferStatusMessagesListener.class);
+
+ public boolean isListenerForSource(Object source)
+ {
+ return source instanceof UIViewRoot;
+ }
public void processEvent(SystemEvent preRenderViewEvent)
{
execute();
}
- public boolean isListenerForSource(Object source)
- {
- return true;
- }
-
public void execute()
{
try
{
- Manager manager = ManagerBridge.getProvider().getRootManager();
+ Manager manager = ManagerBridge.getProvider().getCurrentManager();
// tests
if (manager != null)
{
15 years, 6 months
Seam SVN: r10989 - in modules/trunk: bridge-api/src/main/java/org/jboss/seam/bridge and 19 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 11:31:37 -0400 (Tue, 26 May 2009)
New Revision: 10989
Added:
modules/trunk/jndi-bridge/
modules/trunk/jndi-bridge/pom.xml
modules/trunk/jndi-bridge/src/
modules/trunk/jndi-bridge/src/main/
modules/trunk/jndi-bridge/src/main/java/
modules/trunk/jndi-bridge/src/main/java/org/
modules/trunk/jndi-bridge/src/main/java/org/jboss/
modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/
modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/
modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/
modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java
modules/trunk/jndi-bridge/src/main/resources/
modules/trunk/jndi-bridge/src/main/resources/META-INF/
modules/trunk/jndi-bridge/src/main/resources/META-INF/services/
modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider
Modified:
modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java
modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java
modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java
modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java
modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java
modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java
modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java
Log:
upgrade bridge so that the provider only has one method, getCurrentManager()
introduce JNDI bridge impl
Modified: modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java
===================================================================
--- modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/ManagerBridge.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -114,7 +114,7 @@
managerImplClass = manager.getClass();
for (ManagerProvider candidate : resolver.getManagerProviders())
{
- if (manager.equals(candidate.getRootManager()))
+ if (manager.equals(candidate.getCurrentManager()))
{
provider = candidate;
if (log.isDebugEnabled())
Modified: modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java
===================================================================
--- modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/main/java/org/jboss/seam/bridge/spi/ManagerProvider.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,19 +1,14 @@
package org.jboss.seam.bridge.spi;
-import javax.el.ELResolver;
import javax.inject.manager.Manager;
/**
- * A contract between the provider engine and the JCDI bootstrap
- * mechanism to return the current (root) Manager instance.
+ * A contract between the provider engine and the JCDI bootstrap mechanism to
+ * return the current Manager instance.
*
* @author Dan Allen
*/
public interface ManagerProvider
{
- Manager getRootManager();
-
Manager getCurrentManager();
-
- ELResolver getELResolver();
}
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeOverrideTest.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -2,7 +2,6 @@
import static org.testng.Assert.assertSame;
-import javax.el.ELResolver;
import javax.inject.manager.Manager;
import org.jboss.seam.bridge.spi.ManagerProvider;
@@ -16,7 +15,7 @@
* @author Dan Allen
*/
public class ManagerBridgeOverrideTest
-{
+{
@Test
public void testProviderOverride()
{
@@ -34,20 +33,9 @@
class MockManagerProvider implements ManagerProvider
{
- public Manager getRootManager()
- {
- return null;
- }
-
public Manager getCurrentManager()
{
return null;
}
-
- public ELResolver getELResolver()
- {
- return null;
- }
-
}
}
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeServiceLoaderTest.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -44,7 +44,6 @@
{
ManagerProvider provider = ManagerBridge.getProvider();
assertTrue(provider instanceof ManagerProviderStub);
- assertSame(provider.getRootManager(), getCurrentManager());
assertSame(provider.getCurrentManager(), getCurrentManager());
Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
assertSame(provider.getCurrentManager(), currentManager);
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/ManagerBridgeTest.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -48,7 +48,6 @@
bridge.onManagerDeployed(getCurrentManager());
ManagerProvider provider = ManagerBridge.getProvider();
assertTrue(provider instanceof ManagerProviderStub);
- assertSame(provider.getRootManager(), getCurrentManager());
assertSame(provider.getCurrentManager(), getCurrentManager());
Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
assertSame(provider.getCurrentManager(), currentManager);
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/IncorrectManagerProviderStub.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,20 +1,16 @@
-/**
- *
- */
package org.jboss.seam.bridge.stubs;
import javax.inject.manager.Manager;
+import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
-public class IncorrectManagerProviderStub extends ManagerProviderStub
+public class IncorrectManagerProviderStub implements ManagerProvider
{
- public Manager getRootManager()
- {
- return ManagerImpl.newChildManager(CurrentManager.rootManager());
- }
-
+ /**
+ * Just return something bogus.
+ */
public Manager getCurrentManager()
{
return ManagerImpl.newChildManager(CurrentManager.rootManager());
Modified: modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java
===================================================================
--- modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/bridge-api/src/test/java/org/jboss/seam/bridge/stubs/ManagerProviderStub.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,29 +1,14 @@
-/**
- *
- */
package org.jboss.seam.bridge.stubs;
-import javax.el.ELResolver;
import javax.inject.manager.Manager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.el.WebBeansELResolver;
public class ManagerProviderStub implements ManagerProvider
{
- public Manager getRootManager()
- {
- return CurrentManager.rootManager();
- }
-
public Manager getCurrentManager()
{
return CurrentManager.rootManager().getCurrent();
}
-
- public ELResolver getELResolver()
- {
- return new WebBeansELResolver();
- }
}
\ No newline at end of file
Property changes on: modules/trunk/jndi-bridge
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Added: modules/trunk/jndi-bridge/pom.xml
===================================================================
--- modules/trunk/jndi-bridge/pom.xml (rev 0)
+++ modules/trunk/jndi-bridge/pom.xml 2009-05-26 15:31:37 UTC (rev 10989)
@@ -0,0 +1,51 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>seam-parent</artifactId>
+ <groupId>org.jboss.seam</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>seam-jndi-bridge</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>Seam Web Beans Bridge</name>
+ <description>An implementation of the Seam Bridge SPI to obtain a Manager generically via JNDI.</description>
+
+ <build>
+ <plugins>
+
+ <!--
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+ <suiteXmlFile>src/test/resources/test-suite.xml</suiteXmlFile>
+ </suiteXmlFiles>
+ </configuration>
+ </plugin>
+ -->
+
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${seam.groupId}</groupId>
+ <artifactId>seam-bridge-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${webbeans.groupId}</groupId>
+ <artifactId>jsr299-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java
===================================================================
--- modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java (rev 0)
+++ modules/trunk/jndi-bridge/src/main/java/org/jboss/seam/bridge/jndi/JndiManagerProvider.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -0,0 +1,59 @@
+package org.jboss.seam.bridge.jndi;
+
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.seam.bridge.spi.ManagerProvider;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * An implementation of Seam's Manager SPI interface for integrating Seam with
+ * a JCDI Manager that is register in JNDI. This implementation has a limitation
+ * that it cannot distinguish between the root manager and the current manager.
+ *
+ * @author Dan Allen
+ */
+public class JndiManagerProvider implements ManagerProvider
+{
+ private static final String JCDI_MANAGER_JNDI_NAME = "java:app/Manager";
+
+ private static final String JCDI_MANAGER_ALT_JNDI_NAME = "java:comp/env/app/Manager";
+
+ private LogProvider log = Logging.getLogProvider(JndiManagerProvider.class);
+
+ private Manager manager;
+
+ public JndiManagerProvider()
+ {
+ lookupManager();
+ }
+
+ public Manager getCurrentManager()
+ {
+ return manager;
+ }
+
+ private void lookupManager()
+ {
+ try
+ {
+ InitialContext initialContext = new InitialContext();
+ try
+ {
+ manager = (Manager) initialContext.lookup(JCDI_MANAGER_JNDI_NAME);
+ }
+ catch (NamingException e)
+ {
+ manager = (Manager) initialContext.lookup(JCDI_MANAGER_ALT_JNDI_NAME);
+ }
+ }
+ catch (NamingException e)
+ {
+ log.debug("Could not locate a Manager in JNDI");
+ }
+
+ }
+
+}
Added: modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider
===================================================================
--- modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider (rev 0)
+++ modules/trunk/jndi-bridge/src/main/resources/META-INF/services/org.jboss.seam.bridge.spi.ManagerProvider 2009-05-26 15:31:37 UTC (rev 10989)
@@ -0,0 +1 @@
+org.jboss.seam.bridge.jndi.JndiManagerProvider
Modified: modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java
===================================================================
--- modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/openwebbeans-bridge/src/main/java/org/jboss/seam/bridge/openwebbeans/OpenWebBeansManagerProvider.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -19,15 +19,4 @@
{
return ActivityManager.getInstance().getCurrentActivity();
}
-
- public Manager getRootManager()
- {
- return ActivityManager.getInstance().getRootActivity();
- }
-
- public ELResolver getELResolver()
- {
- return new WebBeansELResolver();
- }
-
}
Modified: modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java
===================================================================
--- modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/web/src/main/java/org/jboss/seam/web/SeamFilter.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -60,7 +60,7 @@
private void registerSession(HttpSession session)
{
- ManagerBridge.getProvider().getRootManager().getInstanceByType(HttpSessionManager.class).setSession(session);
+ ManagerBridge.getProvider().getCurrentManager().getInstanceByType(HttpSessionManager.class).setSession(session);
registeredSession = session;
}
Modified: modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java
===================================================================
--- modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/webbeans-bridge/src/main/java/org/jboss/seam/bridge/webbeans/WebBeansManagerProvider.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -1,11 +1,9 @@
package org.jboss.seam.bridge.webbeans;
-import javax.el.ELResolver;
import javax.inject.manager.Manager;
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.el.WebBeansELResolver;
/**
* An implementation of Seam's Manager SPI interface for integrating Seam with
@@ -19,15 +17,4 @@
{
return CurrentManager.rootManager().getCurrent();
}
-
- public Manager getRootManager()
- {
- return CurrentManager.rootManager();
- }
-
- public ELResolver getELResolver()
- {
- return new WebBeansELResolver();
- }
-
}
Modified: modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java
===================================================================
--- modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java 2009-05-26 15:25:15 UTC (rev 10988)
+++ modules/trunk/webbeans-bridge/src/test/java/org/jboss/seam/bridge/webbeans/WebBeansManagerBridgeTest.java 2009-05-26 15:31:37 UTC (rev 10989)
@@ -10,7 +10,6 @@
import org.jboss.seam.bridge.spi.ManagerProvider;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.webbeans.el.WebBeansELResolver;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -37,11 +36,9 @@
{
ManagerProvider provider = ManagerBridge.getProvider();
assertTrue(provider instanceof WebBeansManagerProvider);
- assertSame(provider.getRootManager(), getCurrentManager());
assertSame(provider.getCurrentManager(), getCurrentManager());
Manager currentManager = getCurrentManager().setCurrent(RequestScoped.class);
assertSame(provider.getCurrentManager(), currentManager);
- assertTrue(provider.getELResolver() instanceof WebBeansELResolver);
}
}
15 years, 6 months
Seam SVN: r10988 - modules/trunk/el/src/main/java/org/jboss/seam/el.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-26 11:25:15 -0400 (Tue, 26 May 2009)
New Revision: 10988
Modified:
modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
Log:
add some convenience methods
Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-05-26 15:24:28 UTC (rev 10987)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java 2009-05-26 15:25:15 UTC (rev 10988)
@@ -79,6 +79,58 @@
}
/**
+ * Get the value of a unified ValueExpression, coercing it to the expected type.
+ *
+ * @param expression a unified ValueExpression
+ * @param type the expected value type
+ *
+ * @return the value of the unified ValueExpression
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T getValue(javax.el.ValueExpression expression, Class<T> type)
+ {
+ return (T) expression.getValue(getELContext());
+ }
+
+ /**
+ * Inspect the unified ValueExpression and return the value's expected type.
+ *
+ * @param expression a unified ValueExpression
+ *
+ * @return the value's expected type
+ */
+ public Class<?> getType(javax.el.ValueExpression expression)
+ {
+ return expression.getType(getELContext());
+ }
+
+ /**
+ * Assign the specified value to the unified ValueExpression.
+ *
+ * @param expression a unified ValueExpression
+ * @param value the value to assign to the ValueExpression
+ */
+ public void setValue(javax.el.ValueExpression expression, Object value)
+ {
+ expression.setValue(getELContext(), value);
+ }
+
+ /**
+ * Invoke the unified MethodExpression, coercing the result to the expected return type.
+ *
+ * @param expression a unified MethodExpression
+ * @param returnType the expected return type
+ * @param args method arguments
+ *
+ * @return the return value of the underlying method represented by the unified MethodExpression
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T invoke(javax.el.MethodExpression expression, Class<T> returnType, Object... args)
+ {
+ return (T) expression.invoke(getELContext(), args);
+ }
+
+ /**
* Create a value expression.
*
* @param expression a JBoss EL value expression
@@ -117,6 +169,7 @@
return getExpressionFactory().createValueExpression( getELContext(), expression, type );
}
+ @SuppressWarnings("unchecked")
public T getValue()
{
return (T) toUnifiedValueExpression().getValue( getELContext() );
@@ -132,6 +185,7 @@
return expression;
}
+ @SuppressWarnings("unchecked")
public Class<T> getType()
{
// QUESTION shouldn't we use the type provided in the constructor?
15 years, 6 months