Seam SVN: r7538 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-03-11 21:21:29 -0400 (Tue, 11 Mar 2008)
New Revision: 7538
Added:
trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
Log:
first hack of the ldap identity store, work in progress
Added: trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java 2008-03-12 01:21:29 UTC (rev 7538)
@@ -0,0 +1,466 @@
+package org.jboss.seam.security.management;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.InitialLdapContext;
+
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+
+/**
+ * An IdentityStore implementation that integrates with a directory service.
+ *
+ * @author Shane Bryzak
+ */
+@Scope(APPLICATION)
+@BypassInterceptors
+public class LdapIdentityStore implements IdentityStore
+{
+
+ private String serverAddress = "localhost";
+
+ private int serverPort = 389;
+
+ private String userCtxDN = "ou=Person,dc=acme,dc=com";
+
+ private String roleCtxDN = "ou=Role,dc=acme,dc=com";
+
+ private String principalDNPrefix = "uid=";
+
+ private String principalDNSuffix = ",ou=Person,dc=acme,dc=com";
+
+ private String bindDN;
+
+ private String bindCredentials;
+
+ // TODO make configurable
+ private boolean roleAttributeIsDN = true;
+
+ public String getServerAddress()
+ {
+ return serverAddress;
+ }
+
+ public void setServerAddress(String serverAddress)
+ {
+ this.serverAddress = serverAddress;
+ }
+
+ public int getServerPort()
+ {
+ return serverPort;
+ }
+
+ public void setServerPort(int serverPort)
+ {
+ this.serverPort = serverPort;
+ }
+
+ public String getUserCtxDN()
+ {
+ return userCtxDN;
+ }
+
+ public void setUserCtxDN(String userCtxDN)
+ {
+ this.userCtxDN = userCtxDN;
+ }
+
+ public String getRoleCtxDN()
+ {
+ return roleCtxDN;
+ }
+
+ public void setRoleCtxDN(String roleCtxDN)
+ {
+ this.roleCtxDN = roleCtxDN;
+ }
+
+ public String getPrincipalDNPrefix()
+ {
+ return principalDNPrefix;
+ }
+
+ public void setPrincipalDNPrefix(String value)
+ {
+ this.principalDNPrefix = value;
+ }
+
+ public String getPrincipalDNSuffix()
+ {
+ return principalDNSuffix;
+ }
+
+ public void setPrincipalDNSuffix(String value)
+ {
+ this.principalDNSuffix = value;
+ }
+
+ public String getBindDN()
+ {
+ return bindDN;
+ }
+
+ public void setBindDN(String bindDN)
+ {
+ this.bindDN = bindDN;
+ }
+
+ public String getBindCredentials()
+ {
+ return bindCredentials;
+ }
+
+ public void setBindCredentials(String bindCredentials)
+ {
+ this.bindCredentials = bindCredentials;
+ }
+
+ protected final InitialLdapContext initialiseContext()
+ throws NamingException
+ {
+ return initialiseContext(bindDN, bindCredentials);
+ }
+
+ protected final InitialLdapContext initialiseContext(String principal, String credentials)
+ throws NamingException
+ {
+ Properties env = new Properties();
+
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
+
+ String providerUrl = String.format("ldap://%s:%d", getServerAddress(), getServerPort());
+ env.setProperty(Context.PROVIDER_URL, providerUrl);
+
+ env.setProperty(Context.SECURITY_PRINCIPAL, principal);
+ env.setProperty(Context.SECURITY_CREDENTIALS, credentials);
+
+ InitialLdapContext ctx = new InitialLdapContext(env, null);
+ return ctx;
+ }
+
+ protected String getUserDN(String username)
+ {
+ return String.format("%s%s%s", getPrincipalDNPrefix(), username, getPrincipalDNSuffix());
+ }
+
+ public boolean authenticate(String username, String password)
+ {
+ String securityPrincipal = getUserDN(username);
+
+ try
+ {
+ InitialLdapContext ctx = initialiseContext(securityPrincipal, password);
+ ctx.close();
+ return true;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Authentication error", ex);
+ }
+ }
+
+ public boolean changePassword(String name, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createRole(String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createUser(String username, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteRole(String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteUser(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean disableUser(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean enableUser(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public List<String> getGrantedRoles(String name)
+ {
+ Set<String> userRoles = new HashSet<String>();
+
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ String roleFilter = "(uid={0})";
+
+ // TODO make configurable
+ int searchScope = SearchControls.SUBTREE_SCOPE;
+ int searchTimeLimit = 10000;
+
+ // TODO make configurable
+ String roleAttrName = "roles";
+ String[] roleAttr = {roleAttrName};
+
+ // TODO make configurable
+ String roleNameAttribute = "cn";
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(searchScope);
+ controls.setReturningAttributes(roleAttr);
+ controls.setTimeLimit(searchTimeLimit);
+ Object[] filterArgs = {name};
+
+ NamingEnumeration answer = ctx.search(userCtxDN, roleFilter, filterArgs, controls);
+ while (answer.hasMore())
+ {
+ SearchResult sr = (SearchResult) answer.next();
+ Attributes attrs = sr.getAttributes();
+ Attribute roles = attrs.get(roleAttrName);
+ for (int r = 0; r < roles.size(); r++)
+ {
+ Object value = roles.get(r);
+ String roleName = null;
+ if (roleAttributeIsDN == true)
+ {
+ String roleDN = value.toString();
+ String[] returnAttribute = {roleNameAttribute};
+ try
+ {
+ Attributes result2 = ctx.getAttributes(roleDN, returnAttribute);
+ Attribute roles2 = result2.get(roleNameAttribute);
+ if( roles2 != null )
+ {
+ for(int m = 0; m < roles2.size(); m ++)
+ {
+ roleName = (String) roles2.get(m);
+ userRoles.add(roleName);
+ }
+ }
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Failed to query roles", ex);
+ }
+ }
+ else
+ {
+ // The role attribute value is the role name
+ roleName = value.toString();
+ userRoles.add(roleName);
+ }
+ }
+ }
+ answer.close();
+
+ return new ArrayList<String>(userRoles);
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Error getting roles", ex);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
+ }
+
+ public List<String> getImpliedRoles(String name)
+ {
+ return getGrantedRoles(name);
+ }
+
+ public boolean grantRole(String name, String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isUserEnabled(String name)
+ {
+ // TODO implement this somehow
+ return true;
+ }
+
+ public List<String> listRoles()
+ {
+ List<String> roles = new ArrayList<String>();
+
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ // TODO make configurable
+ int searchScope = SearchControls.SUBTREE_SCOPE;
+ int searchTimeLimit = 10000;
+
+ // TODO make configurable
+ String roleAttrName = "cn";
+ String[] roleAttr = {roleAttrName};
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(searchScope);
+ controls.setReturningAttributes(roleAttr);
+ controls.setTimeLimit(searchTimeLimit);
+
+ // TODO make these configurable
+ String roleFilter = "(objectClass={0})";
+ Object[] filterArgs = {"organizationalRole"};
+
+ NamingEnumeration answer = ctx.search(roleCtxDN, roleFilter, filterArgs, controls);
+ while (answer.hasMore())
+ {
+ SearchResult sr = (SearchResult) answer.next();
+ Attributes attrs = sr.getAttributes();
+ Attribute user = attrs.get(roleAttrName);
+
+ for (int i = 0; i < user.size(); i++)
+ {
+ Object value = user.get(i);
+ roles.add(value.toString());
+ }
+ }
+ answer.close();
+ return roles;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Error getting roles", ex);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
+ }
+
+ public List<String> listUsers()
+ {
+ List<String> users = new ArrayList<String>();
+
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ // TODO make configurable
+ int searchScope = SearchControls.SUBTREE_SCOPE;
+ int searchTimeLimit = 10000;
+
+ // TODO make configurable
+ String userAttrName = "uid";
+ String[] userAttr = {userAttrName};
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(searchScope);
+ controls.setReturningAttributes(userAttr);
+ controls.setTimeLimit(searchTimeLimit);
+
+ // TODO make these configurable
+ String userFilter = "(objectClass={0})";
+ Object[] filterArgs = {"person"};
+
+ NamingEnumeration answer = ctx.search(userCtxDN, userFilter, filterArgs, controls);
+ while (answer.hasMore())
+ {
+ SearchResult sr = (SearchResult) answer.next();
+ Attributes attrs = sr.getAttributes();
+ Attribute user = attrs.get(userAttrName);
+
+ for (int i = 0; i < user.size(); i++)
+ {
+ Object value = user.get(i);
+ users.add(value.toString());
+ }
+ }
+ answer.close();
+ return users;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Error getting users", ex);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
+ }
+
+ public List<String> listUsers(String filter)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean revokeRole(String name, String role)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean roleExists(String name)
+ {
+ return true;
+ }
+
+ public boolean userExists(String name)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
18 years, 1 month
Seam SVN: r7537 - branches/Seam_2_0/src/main/org/jboss/seam/navigation.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-03-11 18:33:02 -0400 (Tue, 11 Mar 2008)
New Revision: 7537
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/navigation/Pages.java
Log:
JBSEAM-2698
Modified: branches/Seam_2_0/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/navigation/Pages.java 2008-03-11 22:25:31 UTC (rev 7536)
+++ branches/Seam_2_0/src/main/org/jboss/seam/navigation/Pages.java 2008-03-11 22:33:02 UTC (rev 7537)
@@ -169,24 +169,29 @@
* Create a new Page object for a JSF view id,
* by searching for a viewId.page.xml file.
*/
- private Page createPage(String viewId)
- {
- String resourceName = replaceExtension(viewId, ".page.xml");
- InputStream stream = resourceName==null ?
- null : ResourceLoader.instance().getResourceAsStream( resourceName.substring(1) );
- if ( stream==null )
- {
- Page result = new Page(viewId);
- pagesByViewId.put(viewId, result);
- return result;
- }
- else
- {
- parse(stream, viewId);
- return getCachedPage(viewId);
- }
- }
+ private Page createPage(String viewId)
+ {
+ String resourceName = replaceExtension(viewId, ".page.xml");
+ InputStream stream = null;
+
+ if (resourceName!=null) {
+ stream = ResourceLoader.instance().getResourceAsStream(resourceName.substring(1));
+
+ if (stream == null) {
+ stream = ResourceLoader.instance().getResourceAsStream(resourceName);
+ }
+ }
+ if (stream==null) {
+ Page result = new Page(viewId);
+ pagesByViewId.put(viewId, result);
+ return result;
+ } else {
+ parse(stream, viewId);
+ return getCachedPage(viewId);
+ }
+ }
+
private Page getCachedPage(String viewId)
{
Page result = pagesByViewId.get(viewId);
18 years, 1 month
Seam SVN: r7536 - trunk/src/main/org/jboss/seam/navigation.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-03-11 18:25:31 -0400 (Tue, 11 Mar 2008)
New Revision: 7536
Modified:
trunk/src/main/org/jboss/seam/navigation/Pages.java
Log:
JBSEAM-2698
Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-03-11 21:29:56 UTC (rev 7535)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java 2008-03-11 22:25:31 UTC (rev 7536)
@@ -174,16 +174,21 @@
private Page createPage(String viewId)
{
String resourceName = replaceExtension(viewId, ".page.xml");
- InputStream stream = resourceName==null ?
- null : ResourceLoader.instance().getResourceAsStream( resourceName.substring(1) );
- if ( stream==null )
- {
+ InputStream stream = null;
+
+ if (resourceName!=null) {
+ stream = ResourceLoader.instance().getResourceAsStream(resourceName.substring(1));
+
+ if (stream == null) {
+ stream = ResourceLoader.instance().getResourceAsStream(resourceName);
+ }
+ }
+
+ if (stream==null) {
Page result = new Page(viewId);
pagesByViewId.put(viewId, result);
return result;
- }
- else
- {
+ } else {
parse(stream, viewId);
return getCachedPage(viewId);
}
18 years, 1 month
Seam SVN: r7535 - trunk/ui/src/main/java/org/jboss/seam/ui/renderkit.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-11 17:29:56 -0400 (Tue, 11 Mar 2008)
New Revision: 7535
Modified:
trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java
Log:
JBSEAM-2727
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java 2008-03-11 19:18:02 UTC (rev 7534)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/CacheRendererBase.java 2008-03-11 21:29:56 UTC (rev 7535)
@@ -7,6 +7,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.jboss.seam.core.Init;
import org.jboss.seam.core.PojoCache;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
@@ -47,11 +48,7 @@
else
{
log.debug("rendering from cache: " + key);
- writer.write("<!-- cached content for: ");
- writer.write(key);
- writer.write(" -->");
writer.write(cachedContent);
- writer.write("<!-- end of cached content -->");
}
}
else
18 years, 1 month
Seam SVN: r7534 - trunk/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-11 15:18:02 -0400 (Tue, 11 Mar 2008)
New Revision: 7534
Modified:
trunk/build/ui.pom.xml
Log:
JBSEAM-2676
Modified: trunk/build/ui.pom.xml
===================================================================
--- trunk/build/ui.pom.xml 2008-03-11 18:42:07 UTC (rev 7533)
+++ trunk/build/ui.pom.xml 2008-03-11 19:18:02 UTC (rev 7534)
@@ -83,13 +83,6 @@
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam-jul</artifactId>
- <exclusions>
- <!-- Odd, causes jdk 6 (only) build to fail if this isn't in. Some commons-logging conflict I think -->
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
@@ -191,6 +184,11 @@
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
18 years, 1 month
Seam SVN: r7533 - trunk/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-11 14:42:07 -0400 (Tue, 11 Mar 2008)
New Revision: 7533
Modified:
trunk/build/ui.pom.xml
Log:
JBSEAM-2676
Modified: trunk/build/ui.pom.xml
===================================================================
--- trunk/build/ui.pom.xml 2008-03-11 18:28:40 UTC (rev 7532)
+++ trunk/build/ui.pom.xml 2008-03-11 18:42:07 UTC (rev 7533)
@@ -83,6 +83,13 @@
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam-jul</artifactId>
+ <exclusions>
+ <!-- Odd, causes jdk 6 (only) build to fail if this isn't in. Some commons-logging conflict I think -->
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
18 years, 1 month
Seam SVN: r7532 - in trunk: src/main/org/jboss/seam/deployment and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-11 14:28:40 -0400 (Tue, 11 Mar 2008)
New Revision: 7532
Added:
trunk/src/main/org/jboss/seam/deployment/AnnotationDeploymentHandler.java
Modified:
trunk/doc/reference/en/modules/configuration.xml
trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java
Log:
JBSEAM-2726
Modified: trunk/doc/reference/en/modules/configuration.xml
===================================================================
--- trunk/doc/reference/en/modules/configuration.xml 2008-03-11 15:26:21 UTC (rev 7531)
+++ trunk/doc/reference/en/modules/configuration.xml 2008-03-11 18:28:40 UTC (rev 7532)
@@ -884,11 +884,49 @@
</para>
<para>
- You may also want Seam to handle custom resources. For example, you
- could use this to process classes with a custom annotation at
- startup. To do this, we need to write a custom deployment handler:
+ You may also want Seam to handle custom resources. A common use case
+ is to handle a specific annotation and Seam provides specific
+ support for this. First, tell Seam which annotations to handle in
+ <literal>/META-INF/seam-deployment.properties</literal>:
</para>
+ <programlisting><![CDATA[# A comma separated list of annotation types to handle
+org.jboss.seam.deployment.annotationTypes=com.acme.Foo]]></programlisting>
+
+ <para>
+ Then, during application startup you can get hold of all classes
+ annotated with <literal>@Foo</literal>:
+ </para>
+
+ <programlisting><![CDATA[@Name("fooStartup")
+@Scope(APPLICATION)
+@Startup
+public class FooStartup {
+
+ @In("#{deploymentStrategy.annotatedClasses['com.acme.Foo']}")
+ private Set<Class<Object>> fooClasses;
+
+ @In("#{hotDeploymentStrategy.annotatedClasses['com.acme.Foo']}")
+ private Set<Class<Object>> hotFooClasses;
+
+ @Create
+ public void create() {
+ for (Class clazz : fooClasses) {
+ handleClass(clazz);
+ }
+ for (Class clazz : hotFooClasses) {
+ handleClass(clazz);
+ }
+ }
+
+}]]></programlisting>
+
+ <para>
+ You can also handle <emphasis>any</emphasis> resource. For example,
+ you process any files with the extension <literal>.foo.xml</literal>.
+ To do this, we need to write a custom deployment handler:
+ </para>
+
<programlisting><![CDATA[public class FooDeploymentHandler implements DeploymentHandler {
private Set<InputStream> files = new HashSet<InputStream>();
@@ -941,10 +979,10 @@
@Startup
public class FooStartup {
- @In("#{org.jboss.seam.deployment.deploymentStrategy['fooDeploymentHandler']}")
+ @In("#{deploymentStrategy['fooDeploymentHandler']}")
private MyDeploymentHandler myDeploymentHandler;
- @In("#{org.jboss.seam.deployment.hotDeploymentStrategy['fooDeploymentHandler']}")
+ @In("#{hotDeploymentStrategy['fooDeploymentHandler']}")
private MyDeploymentHandler myHotDeploymentHandler;
@Create
Added: trunk/src/main/org/jboss/seam/deployment/AnnotationDeploymentHandler.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/AnnotationDeploymentHandler.java (rev 0)
+++ trunk/src/main/org/jboss/seam/deployment/AnnotationDeploymentHandler.java 2008-03-11 18:28:40 UTC (rev 7532)
@@ -0,0 +1,116 @@
+package org.jboss.seam.deployment;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javassist.bytecode.ClassFile;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+
+public class AnnotationDeploymentHandler extends AbstractDeploymentHandler
+{
+
+ /**
+ * Name under which this {@link DeploymentHandler} is registered
+ */
+ public static final String NAME = "org.jboss.seam.deployment.AnnotationDeploymentHandler";
+
+ public static final String ANNOTATIONS_KEY = "org.jboss.seam.deployment.annotationTypes";
+
+ private Map<String, Set<Class<Object>>> classes;
+ private Set<Class<? extends Annotation>> annotations;
+
+ private static final LogProvider log = Logging.getLogProvider(AnnotationDeploymentHandler.class);
+
+ public AnnotationDeploymentHandler(List<String> annotationTypes, ClassLoader classLoader)
+ {
+ annotations = new HashSet<Class<? extends Annotation>>();
+ for (String classname: annotationTypes)
+ {
+ try
+ {
+ annotations.add((Class<? extends Annotation>) classLoader.loadClass(classname));
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ log.warn("could not load annotation class: " + classname, cnfe);
+ }
+ catch (NoClassDefFoundError ncdfe)
+ {
+ log.warn("could not load annotation class (missing dependency): " + classname, ncdfe);
+ }
+ catch (ClassCastException cce)
+ {
+ log.warn("could not load annotation class (not an annotation): " + classname, cce);
+ }
+ }
+
+ classes = new HashMap<String, Set<Class<Object>>>();
+ for (Class annotation: annotations)
+ {
+ classes.put(annotation.getName(), new HashSet<Class<Object>>());
+ }
+ }
+
+ /**
+ * Get annotated classes
+ */
+ public Map<String, Set<Class<Object>>> getClasses()
+ {
+ return Collections.unmodifiableMap(classes);
+ }
+
+
+ public String getName()
+ {
+ return NAME;
+ }
+
+ public void handle(String name, ClassLoader classLoader)
+ {
+ if (name.endsWith(".class"))
+ {
+ String classname = filenameToClassname(name);
+ try
+ {
+ ClassFile classFile = getClassFile(name, classLoader);
+ Class clazz = null;
+ for (Class<? extends Annotation> annotationType: annotations)
+ {
+ if (hasAnnotation(classFile, annotationType))
+ {
+ log.trace("found class annotated with " + annotationType + ": " + name);
+ if (clazz == null)
+ {
+ try
+ {
+ clazz = classLoader.loadClass(classname);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ log.debug("could not load class: " + classname, cnfe);
+ }
+ catch (NoClassDefFoundError ncdfe)
+ {
+ log.debug("could not load class (missing dependency): " + classname, ncdfe);
+ }
+ }
+ classes.get(annotationType.getName()).add( clazz );
+ }
+ }
+ }
+ catch (IOException ioe)
+ {
+ log.debug("could not load classfile: " + classname, ioe);
+ }
+ }
+
+ }
+
+}
Property changes on: trunk/src/main/org/jboss/seam/deployment/AnnotationDeploymentHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java 2008-03-11 15:26:21 UTC (rev 7531)
+++ trunk/src/main/org/jboss/seam/deployment/HotDeploymentStrategy.java 2008-03-11 18:28:40 UTC (rev 7532)
@@ -1,10 +1,12 @@
package org.jboss.seam.deployment;
import java.io.File;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Map;
import java.util.Set;
import org.jboss.seam.contexts.Contexts;
@@ -27,7 +29,7 @@
* The contextual variable name this deployment strategy is made available at
* during Seam startup.
*/
- public static final String NAME = "org.jboss.seam.deployment.hotDeploymentStrategy";
+ public static final String NAME = "hotDeploymentStrategy";
/**
* The key under which to list extra hot deployment directories
@@ -50,6 +52,7 @@
private File[] hotDeploymentPaths;
private ComponentDeploymentHandler componentDeploymentHandler;
+ private AnnotationDeploymentHandler annotationDeploymentHandler;
/**
* @param classLoader The parent classloader of the hot deployment classloader
@@ -60,7 +63,9 @@
{
initHotDeployClassLoader(classLoader, hotDeployDirectory);
componentDeploymentHandler = new ComponentDeploymentHandler();
- getDeploymentHandlers().put(ComponentDeploymentHandler.NAME, componentDeploymentHandler);
+ getDeploymentHandlers().put(ComponentDeploymentHandler.NAME, componentDeploymentHandler);
+ annotationDeploymentHandler = new AnnotationDeploymentHandler(getPropertyValues(AnnotationDeploymentHandler.ANNOTATIONS_KEY), classLoader);
+ getDeploymentHandlers().put(AnnotationDeploymentHandler.NAME, annotationDeploymentHandler);
}
private void initHotDeployClassLoader(ClassLoader classLoader, File hotDeployDirectory)
@@ -141,6 +146,11 @@
return componentDeploymentHandler.getClasses();
}
+ public Map<String, Set<Class<Object>>> getAnnotatedClasses()
+ {
+ return annotationDeploymentHandler.getClasses();
+ }
+
@Override
public void scan()
{
Modified: trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java 2008-03-11 15:26:21 UTC (rev 7531)
+++ trunk/src/main/org/jboss/seam/deployment/StandardDeploymentStrategy.java 2008-03-11 18:28:40 UTC (rev 7532)
@@ -1,5 +1,7 @@
package org.jboss.seam.deployment;
+import java.lang.annotation.Annotation;
+import java.util.Map;
import java.util.Set;
import org.jboss.seam.contexts.Contexts;
@@ -25,7 +27,7 @@
* The contextual variable name this deployment strategy is made available at
* during Seam startup.
*/
- public static final String NAME = "org.jboss.seam.deployment.deploymentStrategy";
+ public static final String NAME = "deploymentStrategy";
/**
* The key under which to list extra deployment handlers.
@@ -37,6 +39,7 @@
private ComponentDeploymentHandler componentDeploymentHandler;
private NamespaceDeploymentHandler namespaceDeploymentHandler;
+ private AnnotationDeploymentHandler annotationDeploymentHandler;
/**
* @param classLoader The classloader used to load and handle resources
@@ -48,6 +51,8 @@
getDeploymentHandlers().put(ComponentDeploymentHandler.NAME, componentDeploymentHandler);
namespaceDeploymentHandler = new NamespaceDeploymentHandler();
getDeploymentHandlers().put(NamespaceDeploymentHandler.NAME, namespaceDeploymentHandler);
+ annotationDeploymentHandler = new AnnotationDeploymentHandler(getPropertyValues(AnnotationDeploymentHandler.ANNOTATIONS_KEY), classLoader);
+ getDeploymentHandlers().put(AnnotationDeploymentHandler.NAME, annotationDeploymentHandler);
}
@Override
@@ -86,6 +91,11 @@
return namespaceDeploymentHandler.getPackages();
}
+ public Map<String, Set<Class<Object>>> getAnnotatedClasses()
+ {
+ return annotationDeploymentHandler.getClasses();
+ }
+
@Override
public void scan()
{
18 years, 1 month
Seam SVN: r7531 - in branches/Seam_2_0: src/debug/org/jboss/seam/debug and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-11 11:26:21 -0400 (Tue, 11 Mar 2008)
New Revision: 7531
Modified:
branches/Seam_2_0/doc/reference/en/modules/events.xml
branches/Seam_2_0/src/debug/org/jboss/seam/debug/Contexts.java
branches/Seam_2_0/src/main/org/jboss/seam/exception/Exceptions.java
Log:
Backport r7528, JBSEAM-2660
Modified: branches/Seam_2_0/doc/reference/en/modules/events.xml
===================================================================
--- branches/Seam_2_0/doc/reference/en/modules/events.xml 2008-03-11 15:25:32 UTC (rev 7530)
+++ branches/Seam_2_0/doc/reference/en/modules/events.xml 2008-03-11 15:26:21 UTC (rev 7531)
@@ -983,7 +983,7 @@
<para>
<literal>org.jboss.seam.handledException</literal> holds the nested exception that
was actually handled by an exception handler. The outermost (wrapper) exception is
- also available, as <literal>org.jboss.seam.exception</literal>.
+ also available, as <literal>org.jboss.seam.caughtException</literal>.
</para>
</sect2>
Modified: branches/Seam_2_0/src/debug/org/jboss/seam/debug/Contexts.java
===================================================================
--- branches/Seam_2_0/src/debug/org/jboss/seam/debug/Contexts.java 2008-03-11 15:25:32 UTC (rev 7530)
+++ branches/Seam_2_0/src/debug/org/jboss/seam/debug/Contexts.java 2008-03-11 15:26:21 UTC (rev 7531)
@@ -61,7 +61,7 @@
public Exception getException()
{
- return (Exception) org.jboss.seam.contexts.Contexts.getConversationContext().get("org.jboss.seam.exception");
+ return (Exception) org.jboss.seam.contexts.Contexts.getConversationContext().get("org.jboss.seam.caughtException");
}
public List<Exception> getExceptionCauses()
Modified: branches/Seam_2_0/src/main/org/jboss/seam/exception/Exceptions.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/exception/Exceptions.java 2008-03-11 15:25:32 UTC (rev 7530)
+++ branches/Seam_2_0/src/main/org/jboss/seam/exception/Exceptions.java 2008-03-11 15:26:21 UTC (rev 7531)
@@ -50,7 +50,7 @@
{
if ( Contexts.isConversationContextActive() )
{
- Contexts.getConversationContext().set("org.jboss.seam.exception", e);
+ Contexts.getConversationContext().set("org.jboss.seam.caughtException", e);
}
//build a list of the nested exceptions
18 years, 1 month
Seam SVN: r7530 - in branches/Seam_2_0/examples: contactlist and 16 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-11 11:25:32 -0400 (Tue, 11 Mar 2008)
New Revision: 7530
Modified:
branches/Seam_2_0/examples/booking/
branches/Seam_2_0/examples/contactlist/
branches/Seam_2_0/examples/drools/
branches/Seam_2_0/examples/dvdstore/
branches/Seam_2_0/examples/hibernate/
branches/Seam_2_0/examples/itext/
branches/Seam_2_0/examples/jpa/
branches/Seam_2_0/examples/mail/
branches/Seam_2_0/examples/messages/
branches/Seam_2_0/examples/nestedbooking/
branches/Seam_2_0/examples/numberguess/
branches/Seam_2_0/examples/quartz/
branches/Seam_2_0/examples/registration/
branches/Seam_2_0/examples/seambay/
branches/Seam_2_0/examples/seamdiscs/
branches/Seam_2_0/examples/seampay/
branches/Seam_2_0/examples/todo/
branches/Seam_2_0/examples/wiki/
Log:
ignores
Property changes on: branches/Seam_2_0/examples/booking
___________________________________________________________________
Name: svn:ignore
- build
test-output
dist
exploded-archives
+ build
test-output
dist
exploded-archives
test-build
Property changes on: branches/Seam_2_0/examples/contactlist
___________________________________________________________________
Name: svn:ignore
- output
build
test-output
+ output
build
test-output
exploded-archives
dist
test-build
Property changes on: branches/Seam_2_0/examples/drools
___________________________________________________________________
Name: svn:ignore
- build
test-output
+ build
test-output
dist
test-build
exploded-archives
Property changes on: branches/Seam_2_0/examples/dvdstore
___________________________________________________________________
Name: svn:ignore
- build
+ build
dist
test-build
exploded-archives
Property changes on: branches/Seam_2_0/examples/hibernate
___________________________________________________________________
Name: svn:ignore
- build
test-output
+ build
test-output
test-build
exploded-archives-jboss
dist-jboss
Property changes on: branches/Seam_2_0/examples/itext
___________________________________________________________________
Name: svn:ignore
+ exploded-archives
dist
test-build
Property changes on: branches/Seam_2_0/examples/jpa
___________________________________________________________________
Name: svn:ignore
+ test-build
exploded-archives-jboss
dist-jboss
Property changes on: branches/Seam_2_0/examples/mail
___________________________________________________________________
Name: svn:ignore
+ dist
test-build
exploded-archives
Property changes on: branches/Seam_2_0/examples/messages
___________________________________________________________________
Name: svn:ignore
- build
test-output
+ build
test-output
exploded-archives
dist
test-build
Property changes on: branches/Seam_2_0/examples/nestedbooking
___________________________________________________________________
Name: svn:ignore
+ test-build
dist
exploded-archives
Property changes on: branches/Seam_2_0/examples/numberguess
___________________________________________________________________
Name: svn:ignore
- build
test-output
+ build
test-output
test-build
exploded-archives
dist
Property changes on: branches/Seam_2_0/examples/quartz
___________________________________________________________________
Name: svn:ignore
+ dist
exploded-archives
test-build
Property changes on: branches/Seam_2_0/examples/registration
___________________________________________________________________
Name: svn:ignore
- output
build
test-output
+ output
build
test-output
dist
exploded-archives
test-build
Property changes on: branches/Seam_2_0/examples/seambay
___________________________________________________________________
Name: svn:ignore
- build
+ build
exploded-archives
dist
test-build
Property changes on: branches/Seam_2_0/examples/seamdiscs
___________________________________________________________________
Name: svn:ignore
+ exploded-archives
dist
test-build
Property changes on: branches/Seam_2_0/examples/seampay
___________________________________________________________________
Name: svn:ignore
+ exploded-archives
test-build
dist
Property changes on: branches/Seam_2_0/examples/todo
___________________________________________________________________
Name: svn:ignore
- build
test-output
+ build
test-output
test-build
exploded-archives
dist
Property changes on: branches/Seam_2_0/examples/wiki
___________________________________________________________________
Name: svn:ignore
+ build
18 years, 1 month