Seam SVN: r7741 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-03-29 04:52:22 -0400 (Sat, 29 Mar 2008)
New Revision: 7741
Modified:
trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
Log:
enable/disable users
Modified: trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java 2008-03-28 21:35:42 UTC (rev 7740)
+++ trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java 2008-03-29 08:52:22 UTC (rev 7741)
@@ -16,6 +16,8 @@
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
@@ -36,6 +38,10 @@
@BypassInterceptors
public class LdapIdentityStore implements IdentityStore, Serializable
{
+ // constants for LDAP syntax 1.3.6.1.4.1.1466.115.121.1.7 (boolean)
+ private static final String LDAP_BOOLEAN_TRUE = "TRUE";
+ private static final String LDAP_BOOLEAN_FALSE = "FALSE";
+
protected FeatureSet featureSet = new FeatureSet(FeatureSet.FEATURE_ALL);
private String serverAddress = "localhost";
@@ -68,6 +74,8 @@
private String fullNameAttribute = "cn";
+ private String enabledAttribute = null;
+
private String roleNameAttribute = "cn";
private String objectClassAttribute = "objectClass";
@@ -241,6 +249,16 @@
this.fullNameAttribute = fullNameAttribute;
}
+ public String getEnabledAttribute()
+ {
+ return enabledAttribute;
+ }
+
+ public void setEnabledAttribute(String enabledAttribute)
+ {
+ this.enabledAttribute = enabledAttribute;
+ }
+
public String getObjectClassAttribute()
{
return objectClassAttribute;
@@ -329,16 +347,43 @@
{
String securityPrincipal = getUserDN(username);
+ InitialLdapContext ctx = null;
try
{
- InitialLdapContext ctx = initialiseContext(securityPrincipal, password);
- ctx.close();
+ ctx = initialiseContext(securityPrincipal, password);
+
+ if (getEnabledAttribute() != null)
+ {
+ Attributes attribs = ctx.getAttributes(securityPrincipal, new String[] { getEnabledAttribute() });
+ Attribute enabledAttrib = attribs.get( getEnabledAttribute() );
+ if (enabledAttrib != null)
+ {
+ for (int r = 0; r < enabledAttrib.size(); r++)
+ {
+ Object value = enabledAttrib.get(r);
+ if (LDAP_BOOLEAN_TRUE.equals(value)) return true;
+ }
+ }
+ return false;
+ }
+
return true;
}
catch (NamingException ex)
{
throw new IdentityManagementException("Authentication error", ex);
}
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public boolean changePassword(String name, String password)
@@ -362,11 +407,8 @@
roleClass.add(objectClass);
}
- BasicAttribute roleName = new BasicAttribute(getRoleNameAttribute());
- roleName.add(role);
-
roleAttribs.put(roleClass);
- roleAttribs.put(roleName);
+ roleAttribs.put(new BasicAttribute(getRoleNameAttribute(), role));
String roleDN = String.format("%s=%s,%s", getRoleNameAttribute(), role, getRoleContextDN() );
ctx.createSubcontext(roleDN, roleAttribs);
@@ -377,6 +419,17 @@
{
throw new IdentityManagementException("Failed to create role", ex);
}
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public boolean createUser(String username, String password, String firstname, String lastname)
@@ -394,37 +447,30 @@
userClass.add(objectClass);
}
- BasicAttribute usernameAttrib = new BasicAttribute(getUserNameAttribute());
- usernameAttrib.add(username);
-
- BasicAttribute passwordAttrib = new BasicAttribute(getUserPasswordAttribute());
- passwordAttrib.add(PasswordHash.generateHash(password));
-
userAttribs.put(userClass);
- userAttribs.put(usernameAttrib);
- userAttribs.put(passwordAttrib);
+ userAttribs.put(new BasicAttribute(getUserNameAttribute(), username));
+ userAttribs.put(new BasicAttribute(getUserPasswordAttribute(), password));
if (getFirstNameAttribute() != null && firstname != null)
{
- BasicAttribute firstNameAttrib = new BasicAttribute(getFirstNameAttribute());
- firstNameAttrib.add(firstname);
- userAttribs.put(firstNameAttrib);
+ userAttribs.put(new BasicAttribute(getFirstNameAttribute(), firstname));
}
if (getLastNameAttribute() != null && lastname != null)
{
- BasicAttribute lastNameAttrib = new BasicAttribute(getLastNameAttribute());
- lastNameAttrib.add(lastname);
- userAttribs.put(lastNameAttrib);
+ userAttribs.put(new BasicAttribute(getLastNameAttribute(), lastname));
}
if (getFullNameAttribute() != null && firstname != null && lastname != null)
{
- BasicAttribute fullNameAttrib = new BasicAttribute(getFullNameAttribute());
- fullNameAttrib.add(firstname + " " + lastname);
- userAttribs.put(fullNameAttrib);
+ userAttribs.put(new BasicAttribute(getFullNameAttribute(), firstname + " " + lastname));
}
+ if (getEnabledAttribute() != null)
+ {
+ userAttribs.put(new BasicAttribute(getEnabledAttribute(), LDAP_BOOLEAN_TRUE));
+ }
+
String userDN = String.format("%s=%s,%s", getUserNameAttribute(), username, getUserContextDN() );
ctx.createSubcontext(userDN, userAttribs);
@@ -434,6 +480,17 @@
{
throw new IdentityManagementException("Failed to create user", ex);
}
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public boolean createUser(String username, String password)
@@ -456,6 +513,17 @@
{
throw new IdentityManagementException("Failed to delete role", ex);
}
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public boolean roleExists(String role)
@@ -527,24 +595,123 @@
{
throw new IdentityManagementException("Failed to delete user", ex);
}
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public boolean isUserEnabled(String name)
{
- // TODO implement this somehow
- return true;
+ if (getEnabledAttribute() == null) return true;
+
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ String userDN = getUserDN(name);
+ Attributes attribs = ctx.getAttributes(userDN, new String[] { getEnabledAttribute() });
+ Attribute enabledAttrib = attribs.get( getEnabledAttribute() );
+ if (enabledAttrib != null)
+ {
+ for (int r = 0; r < enabledAttrib.size(); r++)
+ {
+ Object value = enabledAttrib.get(r);
+ if (LDAP_BOOLEAN_TRUE.equals(value)) return true;
+ }
+ }
+
+ return false;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Failed to delete user", ex);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public boolean disableUser(String name)
{
- // TODO Auto-generated method stub
- return false;
+ if (getEnabledAttribute() == null) return false;
+
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ String userDN = getUserDN(name);
+ BasicAttribute enabledAttrib = new BasicAttribute(getEnabledAttribute(), LDAP_BOOLEAN_FALSE);
+ ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, enabledAttrib);
+
+ ctx.modifyAttributes(userDN, new ModificationItem[] { mod });
+ return true;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Failed to disable user", ex);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public boolean enableUser(String name)
{
- // TODO Auto-generated method stub
- return false;
+ if (getEnabledAttribute() == null) return false;
+
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = initialiseContext();
+
+ String userDN = getUserDN(name);
+ BasicAttribute enabledAttrib = new BasicAttribute(getEnabledAttribute(), LDAP_BOOLEAN_TRUE);
+ ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, enabledAttrib);
+
+ ctx.modifyAttributes(userDN, new ModificationItem[] { mod });
+ return true;
+ }
+ catch (NamingException ex)
+ {
+ throw new IdentityManagementException("Failed to disable user", ex);
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (NamingException ex) {}
+ }
+ }
}
public List<String> getGrantedRoles(String name)
17 years, 9 months
Seam SVN: r7740 - branches/Seam_2_0/src/main/org/jboss/seam/util.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-03-28 17:35:42 -0400 (Fri, 28 Mar 2008)
New Revision: 7740
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java
Log:
JBSEAM-2309
Modified: branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java 2008-03-28 21:29:17 UTC (rev 7739)
+++ branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java 2008-03-28 21:35:42 UTC (rev 7740)
@@ -1,5 +1,6 @@
package org.jboss.seam.util;
+import javax.transaction.Status;
import javax.transaction.UserTransaction;
import org.jboss.seam.log.LogProvider;
@@ -47,7 +48,7 @@
}
catch (Exception e)
{
- if (begin)
+ if (begin && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION)
{
log.debug("rolling back transaction");
userTransaction.rollback();
17 years, 9 months
Seam SVN: r7739 - trunk/src/main/org/jboss/seam/util.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-03-28 17:29:17 -0400 (Fri, 28 Mar 2008)
New Revision: 7739
Modified:
trunk/src/main/org/jboss/seam/util/Work.java
Log:
JBSEAM-2309
Modified: trunk/src/main/org/jboss/seam/util/Work.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/Work.java 2008-03-28 17:41:31 UTC (rev 7738)
+++ trunk/src/main/org/jboss/seam/util/Work.java 2008-03-28 21:29:17 UTC (rev 7739)
@@ -1,5 +1,6 @@
package org.jboss.seam.util;
+import javax.transaction.Status;
import javax.transaction.UserTransaction;
import org.jboss.seam.log.LogProvider;
@@ -47,7 +48,7 @@
}
catch (Exception e)
{
- if (begin)
+ if (begin && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION)
{
log.debug("rolling back transaction");
userTransaction.rollback();
17 years, 9 months
Seam SVN: r7738 - maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 13:41:31 -0400 (Fri, 28 Mar 2008)
New Revision: 7738
Modified:
maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl
Log:
Better TOC
Modified: maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl
===================================================================
--- maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl 2008-03-28 17:10:29 UTC (rev 7737)
+++ maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl 2008-03-28 17:41:31 UTC (rev 7738)
@@ -225,4 +225,56 @@
</xsl:template>
+ <!--###################################################
+ Custom TOC (bold chapter titles)
+ ################################################### -->
+
+ <!-- Improve the TOC. -->
+ <xsl:template name="toc.line">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id" />
+ </xsl:variable>
+
+ <xsl:variable name="label">
+ <xsl:apply-templates select="." mode="label.markup" />
+ </xsl:variable>
+
+ <fo:block text-align-last="justify" end-indent="{$toc.indent.width}pt"
+ last-line-end-indent="-{$toc.indent.width}pt">
+ <fo:inline keep-with-next.within-line="always">
+ <fo:basic-link internal-destination="{$id}">
+
+ <!-- Chapter titles should be bold. -->
+ <xsl:choose>
+ <xsl:when test="local-name(.) = 'chapter'">
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:if test="$label != ''">
+ <xsl:copy-of select="$label" />
+ <xsl:value-of select="$autotoc.label.separator" />
+ </xsl:if>
+ <xsl:apply-templates select="." mode="titleabbrev.markup" />
+ </fo:basic-link>
+ </fo:inline>
+ <fo:inline keep-together.within-line="always">
+ <xsl:text> </xsl:text>
+ <fo:leader leader-pattern="dots" leader-pattern-width="3pt"
+ leader-alignment="reference-area"
+ keep-with-next.within-line="always" />
+ <xsl:text> </xsl:text>
+ <fo:basic-link internal-destination="{$id}">
+ <fo:page-number-citation ref-id="{$id}" />
+ </fo:basic-link>
+ </fo:inline>
+ </fo:block>
+ </xsl:template>
+
+ <!-- Include the chapter no -->
+ <xsl:param name="section.label.includes.component.label" select="1"/>
+
+ <!-- Make the section depth in the TOC 2, same as html -->
+ <xsl:param name="toc.section.depth">2</xsl:param>
+
</xsl:stylesheet>
17 years, 9 months
Seam SVN: r7737 - in maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss: seam and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 13:10:29 -0400 (Fri, 28 Mar 2008)
New Revision: 7737
Modified:
maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/main-pdf.xsl
maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl
Log:
Customise colour of level 1 section headings
Modified: maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/main-pdf.xsl
===================================================================
--- maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/main-pdf.xsl 2008-03-28 16:27:14 UTC (rev 7736)
+++ maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/main-pdf.xsl 2008-03-28 17:10:29 UTC (rev 7737)
@@ -256,9 +256,11 @@
<xsl:param name="body.start.indent">0pt</xsl:param>
<xsl:param name="title.color">#4a5d75</xsl:param>
+<xsl:param name="chaptertitle.color" select="$title.color" />
+<xsl:param name="section.level1.title.color" select="$title.color" />
<xsl:attribute-set name="section.title.level1.properties">
- <xsl:attribute name="color"><xsl:value-of select="$title.color"/></xsl:attribute>
+ <xsl:attribute name="color"><xsl:value-of select="$section.level1.title.color"/></xsl:attribute>
<xsl:attribute name="font-size">
<xsl:value-of select="$body.font.master * 1.6"/>
<xsl:text>pt</xsl:text>
@@ -346,8 +348,6 @@
<xsl:attribute name="start-indent"><xsl:value-of select="$title.margin.left"/></xsl:attribute>
</xsl:attribute-set>
-<xsl:param name="chaptertitle.color" select="$title.color" />
-
<xsl:attribute-set name="chapter.titlepage.recto.style">
<xsl:attribute name="color"><xsl:value-of select="$chaptertitle.color"/></xsl:attribute>
<xsl:attribute name="background-color">white</xsl:attribute>
Modified: maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl
===================================================================
--- maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl 2008-03-28 16:27:14 UTC (rev 7736)
+++ maven-plugins/trunk/seam-docbook-xslt/src/main/resources/xslt/org/jboss/seam/main-pdf.xsl 2008-03-28 17:10:29 UTC (rev 7737)
@@ -166,6 +166,7 @@
<xsl:param name="title.color">#576C74</xsl:param>
<xsl:param name="titlepage.color">#885324</xsl:param>
<xsl:param name="chaptertitle.color">#BA5624</xsl:param>
+ <xsl:param name="section.level1.title.color">#BA5624</xsl:param>
<!-- Change to monospace font for programlisting, needed to workaround crappy callouts -->
<xsl:param name="programlisting.font" select="$monospace.font.family" />
17 years, 9 months
Seam SVN: r7736 - branches/Seam_2_0/examples/portal and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 12:27:14 -0400 (Fri, 28 Mar 2008)
New Revision: 7736
Removed:
branches/Seam_2_0/examples/portal/build.xml
branches/Seam_2_0/examples/portal/resources/
branches/Seam_2_0/examples/portal/src/
branches/Seam_2_0/examples/portal/view/
trunk/examples/portal/build.xml
trunk/examples/portal/resources/
trunk/examples/portal/src/
trunk/examples/portal/view/
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml
branches/Seam_2_0/examples/portal/readme.txt
trunk/examples/portal/readme.txt
Log:
JBSEAM-2790
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml 2008-03-28 13:28:31 UTC (rev 7735)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en/Configuration.xml 2008-03-28 16:27:14 UTC (rev 7736)
@@ -946,5 +946,18 @@
<literal>web.xml</literal>. </para>
</sect1>
+
+ <sect1>
+ <title>Running Seam in a Portlet</title>
+ <para>
+ If you want to run your Seam application in a portlet, take a look at
+ the JBoss Portlet Bridge, an implementation of JSR-301 that supports
+ JSF within a portlet, with extensions for Seam and RichFaces. See
+ <ulink url="http://labs.jboss.com/portletbridge">http://labs.jboss.com/portletbridge</ulink>
+ for more.
+ </para>
+
+ </sect1>
+
</chapter>
Deleted: branches/Seam_2_0/examples/portal/build.xml
===================================================================
--- branches/Seam_2_0/examples/portal/build.xml 2008-03-28 13:28:31 UTC (rev 7735)
+++ branches/Seam_2_0/examples/portal/build.xml 2008-03-28 16:27:14 UTC (rev 7736)
@@ -1,68 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="Portal Booking" default="deploy" basedir=".">
-
- <!-- Naming -->
- <property name="Name" value="Seam on JBoss Portal/Hibernate3 Example"/>
- <property name="example.name" value="jboss-seam-portal"/>
-
- <!-- Overrides -->
- <property name="unit.ext" value="war" />
- <property name="example.seam.ui.lib" value="yes"/>
- <property name="example.seam.debug.lib" value="yes"/>
- <property name="example.facelets.lib" value="yes"/>
- <property name="example.ds" value="portal-ds.xml"/>
- <property name="src.java.dir" value="src"/>
- <property name="src.test.dir" value="src"/>
- <property name="test.classpath" value="test.eejb.classpath"/>
- <property name="tomcat.conf" value="eejb.conf"/>
-
- <property name="example.webinf.lib.dir" value="" />
-
- <import file="../../build.xml"/>
-
- <target name="ear" depends="ejb3, war" />
-
-
-
- <target name="war" depends="compile">
- <jar jarfile="${build.dir}/${example.name}.jar">
- <fileset refid="example.classes"/>
- <fileset dir="resources">
- <include name="seam.properties"/>
- <include name="import.sql"/>
- <include name="hibernate.cfg.xml"/>
- </fileset>
- </jar>
-
-
- <copy todir="${build.dir}/resources/WEB-INF">
- <fileset refid="example.war.webinf"/>
- <filterset>
- <filter token="jndiPattern" value="${example.name}/#{ejbName}/local"/>
- <filter token="embeddedEjb" value="false"/>
- <filter token="microcontainer" value="false"/>
- </filterset>
- </copy>
-
-
- <jar destfile="${build.dir}/${example.name}.war">
- <zipfileset refid="example.tomcat.seam.jar"/>
- <zipfileset refid="example.war.docroot"/>
- <zipfileset refid="example.war.webinf.lib"/>
- <zipfileset refid="example.facelets.jar"/>
- <zipfileset refid="example.extra.jar"/>
- <zipfileset dir="${lib.dir}" prefix="WEB-INF/lib">
- <include name="el-*.jar"/>
- </zipfileset>
- <zipfileset dir="${build.dir}/resources">
- <include name="WEB-INF/**/*.*"/>
- </zipfileset>
- <zipfileset dir="${build.dir}" prefix="WEB-INF/lib">
- <include name="${example.name}.jar"/>
- </zipfileset>
- </jar>
-
- </target>
-
-</project>
Modified: branches/Seam_2_0/examples/portal/readme.txt
===================================================================
--- branches/Seam_2_0/examples/portal/readme.txt 2008-03-28 13:28:31 UTC (rev 7735)
+++ branches/Seam_2_0/examples/portal/readme.txt 2008-03-28 16:27:14 UTC (rev 7736)
@@ -1,7 +1,6 @@
-Seam Hibernate Portlet Example
-==============================
-This is a port of the Booking example to Hibernate3 with JavaBeans
-for the actions. This example is preconfigured to work as a portlet
-in JBoss Portal 2.4+
+Using Seam with Portal
+----------------------
-THIS EXAMPLE IS CURRENTLY UNMAINTAINED
\ No newline at end of file
+Seam is compatible with the portlet environment through the use of the JBoss
+Portlet Bridge. More information can be found at
+http://labs.jboss.com/portletbridge</ulink>
\ No newline at end of file
Deleted: trunk/examples/portal/build.xml
===================================================================
--- trunk/examples/portal/build.xml 2008-03-28 13:28:31 UTC (rev 7735)
+++ trunk/examples/portal/build.xml 2008-03-28 16:27:14 UTC (rev 7736)
@@ -1,68 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="Portal Booking" default="deploy" basedir=".">
-
- <!-- Naming -->
- <property name="Name" value="Seam on JBoss Portal/Hibernate3 Example"/>
- <property name="example.name" value="jboss-seam-portal"/>
-
- <!-- Overrides -->
- <property name="unit.ext" value="war" />
- <property name="example.seam.ui.lib" value="yes"/>
- <property name="example.seam.debug.lib" value="yes"/>
- <property name="example.facelets.lib" value="yes"/>
- <property name="example.ds" value="portal-ds.xml"/>
- <property name="src.java.dir" value="src"/>
- <property name="src.test.dir" value="src"/>
- <property name="test.classpath" value="test.eejb.classpath"/>
- <property name="tomcat.conf" value="eejb.conf"/>
-
- <property name="example.webinf.lib.dir" value="" />
-
- <import file="../../build.xml"/>
-
- <target name="ear" depends="ejb3, war" />
-
-
-
- <target name="war" depends="compile">
- <jar jarfile="${build.dir}/${example.name}.jar">
- <fileset refid="example.classes"/>
- <fileset dir="resources">
- <include name="seam.properties"/>
- <include name="import.sql"/>
- <include name="hibernate.cfg.xml"/>
- </fileset>
- </jar>
-
-
- <copy todir="${build.dir}/resources/WEB-INF">
- <fileset refid="example.war.webinf"/>
- <filterset>
- <filter token="jndiPattern" value="${example.name}/#{ejbName}/local"/>
- <filter token="embeddedEjb" value="false"/>
- <filter token="microcontainer" value="false"/>
- </filterset>
- </copy>
-
-
- <jar destfile="${build.dir}/${example.name}.war">
- <zipfileset refid="example.tomcat.seam.jar"/>
- <zipfileset refid="example.war.docroot"/>
- <zipfileset refid="example.war.webinf.lib"/>
- <zipfileset refid="example.facelets.jar"/>
- <zipfileset refid="example.extra.jar"/>
- <zipfileset dir="${lib.dir}" prefix="WEB-INF/lib">
- <include name="el-*.jar"/>
- </zipfileset>
- <zipfileset dir="${build.dir}/resources">
- <include name="WEB-INF/**/*.*"/>
- </zipfileset>
- <zipfileset dir="${build.dir}" prefix="WEB-INF/lib">
- <include name="${example.name}.jar"/>
- </zipfileset>
- </jar>
-
- </target>
-
-</project>
Modified: trunk/examples/portal/readme.txt
===================================================================
--- trunk/examples/portal/readme.txt 2008-03-28 13:28:31 UTC (rev 7735)
+++ trunk/examples/portal/readme.txt 2008-03-28 16:27:14 UTC (rev 7736)
@@ -1,7 +1,6 @@
-Seam Hibernate Portlet Example
-==============================
-This is a port of the Booking example to Hibernate3 with JavaBeans
-for the actions. This example is preconfigured to work as a portlet
-in JBoss Portal 2.4+
+Using Seam with Portal
+----------------------
-THIS EXAMPLE IS CURRENTLY UNMAINTAINED
\ No newline at end of file
+Seam is compatible with the portlet environment through the use of the JBoss
+Portlet Bridge. More information can be found at
+http://labs.jboss.com/portletbridge</ulink>
\ No newline at end of file
17 years, 9 months
Seam SVN: r7735 - in branches/Seam_2_0: ui/src/main/java/org/jboss/seam/ui/component and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 09:28:31 -0400 (Fri, 28 Mar 2008)
New Revision: 7735
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/jsf/SeamPhaseListener.java
branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/component/UISeamCommandBase.java
branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/UrlBuilder.java
branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/ViewUrlBuilder.java
Log:
backport r7261, JBSEAM-2341, JBSEAM-2784
Modified: branches/Seam_2_0/src/main/org/jboss/seam/jsf/SeamPhaseListener.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/jsf/SeamPhaseListener.java 2008-03-28 12:52:39 UTC (rev 7734)
+++ branches/Seam_2_0/src/main/org/jboss/seam/jsf/SeamPhaseListener.java 2008-03-28 13:28:31 UTC (rev 7735)
@@ -151,18 +151,28 @@
FacesContext facesContext = event.getFacesContext();
- if ( event.getPhaseId() == RESTORE_VIEW || event.getPhaseId() == RENDER_RESPONSE )
+ boolean notInitialised=false;
+
+ if ( event.getPhaseId() == RESTORE_VIEW )
{
beforeRestoreView(facesContext);
}
+ if ( event.getPhaseId() == RENDER_RESPONSE && !Contexts.isApplicationContextActive() )
+ {
+ beforeRestoreView(facesContext);
+ notInitialised = true;
+ }
//delegate to subclass:
handleTransactionsBeforePhase(event);
- if ( event.getPhaseId() == RENDER_RESPONSE )
+ if (event.getPhaseId() == RENDER_RESPONSE)
{
- afterRestoreView(facesContext);
- beforeRenderResponse( event.getFacesContext() );
+ if (notInitialised)
+ {
+ afterRestoreView(facesContext);
+ }
+ beforeRenderResponse(event.getFacesContext());
}
}
@@ -242,46 +252,47 @@
private void afterPortletPhase(PhaseEvent event)
{
- FacesContext facesContext = event.getFacesContext();
-
- if ( event.getPhaseId() == RESTORE_VIEW )
+ Object portletPhase = event.getFacesContext().getExternalContext().getRequestMap().get("javax.portlet.faces.phase");
+
+ if (event.getPhaseId() == RESTORE_VIEW)
{
- afterRestoreView(facesContext);
+ afterRestoreView(event.getFacesContext());
}
- else if ( event.getPhaseId() == INVOKE_APPLICATION )
+ else if (event.getPhaseId() == INVOKE_APPLICATION)
{
afterInvokeApplication();
}
- else if ( event.getPhaseId() == PROCESS_VALIDATIONS )
+ else if (event.getPhaseId() == PROCESS_VALIDATIONS)
{
- afterProcessValidations(facesContext);
+ afterProcessValidations(event.getFacesContext());
}
-
+
FacesMessages.afterPhase();
-
- //delegate to subclass:
+
+ // delegate to subclass:
handleTransactionsAfterPhase(event);
-
- if ( event.getPhaseId() == RENDER_RESPONSE )
+
+ if (event.getPhaseId() == RENDER_RESPONSE)
{
- //writeConversationIdToResponse( facesContext.getExternalContext().getResponse() );
- afterRenderResponse(facesContext);
+ // writeConversationIdToResponse(
+ // facesContext.getExternalContext().getResponse() );
+ afterRenderResponse(event.getFacesContext());
}
- else if ( event.getPhaseId() == INVOKE_APPLICATION || facesContext.getRenderResponse() || facesContext.getResponseComplete() )
+ else if ( (null != portletPhase && "ActionPhase".equals(portletPhase.toString()) )
+ && (event.getPhaseId() == INVOKE_APPLICATION
+ || event.getFacesContext().getRenderResponse()
+ || event.getFacesContext().getResponseComplete()) )
{
- Manager manager = Manager.instance();
- manager.beforeRedirect();
- if ( manager.isLongRunningConversation() )
+ Manager.instance().beforeRedirect();
+ if ( Manager.instance().isLongRunningConversation() )
{
- setPortletRenderParameter(
- facesContext.getExternalContext().getResponse(),
- manager.getConversationIdParameter(),
- manager.getCurrentConversationId()
- );
+ setPortletRenderParameter(
+ event.getFacesContext().getExternalContext().getResponse(),
+ Manager.instance().getConversationIdParameter(),
+ Manager.instance().getCurrentConversationId() );
}
- afterResponseComplete(facesContext);
+ afterResponseComplete( event.getFacesContext() );
}
-
}
private static void setPortletRenderParameter(Object response, String conversationIdParameter, String conversationId)
Modified: branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/component/UISeamCommandBase.java
===================================================================
--- branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/component/UISeamCommandBase.java 2008-03-28 12:52:39 UTC (rev 7734)
+++ branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/component/UISeamCommandBase.java 2008-03-28 13:28:31 UTC (rev 7735)
@@ -13,6 +13,7 @@
import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionListener;
+import javax.faces.event.PhaseEvent;
import javax.faces.model.DataModel;
import org.jboss.seam.navigation.Pages;
@@ -22,6 +23,17 @@
public abstract class UISeamCommandBase extends UIOutput implements ActionSource2
{
+ private static Class PORTLET_REQUEST;
+
+ static
+ {
+ try
+ {
+ PORTLET_REQUEST = Class.forName("javax.portlet.PortletRequest");
+ }
+ catch (Exception e) {}
+ }
+
public abstract String getView();
public String getUrl() throws UnsupportedEncodingException
@@ -34,7 +46,7 @@
viewId = Pages.getViewId(getFacesContext());
}
- ViewUrlBuilder url = new ViewUrlBuilder(viewId, getFragment());
+ ViewUrlBuilder url = new ViewUrlBuilder(viewId, getFragment(), !isPortletRequest(getFacesContext()));
Set<String> usedParameters = new HashSet<String>();
for (Object child : getChildren())
@@ -203,4 +215,10 @@
return new org.jboss.seam.ui.util.cdk.MethodExpressionToMethodBinding(getActionExpression());
}
+ private static boolean isPortletRequest(FacesContext facesContext)
+ {
+ return PORTLET_REQUEST !=null &&
+ PORTLET_REQUEST.isInstance( facesContext.getExternalContext().getRequest() );
+ }
+
}
Modified: branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/UrlBuilder.java
===================================================================
--- branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/UrlBuilder.java 2008-03-28 12:52:39 UTC (rev 7734)
+++ branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/UrlBuilder.java 2008-03-28 13:28:31 UTC (rev 7735)
@@ -16,6 +16,8 @@
private String fragment;
private String characterEncoding;
+ private boolean urlEncodeParameters = true;
+
private Map<String, String> parameters;
protected UrlBuilder(String fragment, String characterEncoding)
@@ -25,12 +27,24 @@
this.characterEncoding = characterEncoding;
}
+ public UrlBuilder(String fragment, String characterEncoding, boolean urlEncodeParameters)
+ {
+ this(fragment, characterEncoding);
+ this.urlEncodeParameters = urlEncodeParameters;
+ }
+
public UrlBuilder(String url, String fragment, String characterEncoding)
{
this(fragment, characterEncoding);
setUrl(url);
}
+ public UrlBuilder(String url, String fragment, String characterEncoding, boolean urlEncodeParameters)
+ {
+ this(url, fragment, characterEncoding);
+ this.urlEncodeParameters = urlEncodeParameters;
+ }
+
protected void setUrl(String url)
{
if (url == null)
@@ -85,7 +99,7 @@
public void addParameter(String name, String value) throws UnsupportedEncodingException
{
- parameters.put(name, urlEncode(value));
+ parameters.put(name, urlEncodeParameters ? urlEncode(value) : value);
}
public void addParameter(UIParameter parameter) throws UnsupportedEncodingException
Modified: branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/ViewUrlBuilder.java
===================================================================
--- branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/ViewUrlBuilder.java 2008-03-28 12:52:39 UTC (rev 7734)
+++ branches/Seam_2_0/ui/src/main/java/org/jboss/seam/ui/util/ViewUrlBuilder.java 2008-03-28 13:28:31 UTC (rev 7735)
@@ -14,9 +14,9 @@
private Page page;
- public ViewUrlBuilder(String viewId, String fragment)
+ public ViewUrlBuilder(String viewId, String fragment, boolean urlEncodeParameters)
{
- super(fragment, FacesContext.getCurrentInstance().getResponseWriter().getCharacterEncoding());
+ super(fragment, FacesContext.getCurrentInstance().getResponseWriter().getCharacterEncoding(), urlEncodeParameters);
if (viewId == null)
{
throw new NullPointerException("viewId must not be null");
@@ -29,6 +29,12 @@
page = Pages.instance().getPage(viewId);
}
+
+ public ViewUrlBuilder(String viewId, String fragment)
+ {
+ this(viewId, fragment, true);
+
+ }
@Override
public void addParameter(UIParameter parameter) throws UnsupportedEncodingException
17 years, 9 months
Seam SVN: r7734 - branches/Seam_2_0/src/main/org/jboss/seam/async.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 08:52:39 -0400 (Fri, 28 Mar 2008)
New Revision: 7734
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/async/AbstractDispatcher.java
branches/Seam_2_0/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java
branches/Seam_2_0/src/main/org/jboss/seam/async/TimerServiceDispatcher.java
Log:
API safe backport of r773, Use object orientation properly
Modified: branches/Seam_2_0/src/main/org/jboss/seam/async/AbstractDispatcher.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/async/AbstractDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
+++ branches/Seam_2_0/src/main/org/jboss/seam/async/AbstractDispatcher.java 2008-03-28 12:52:39 UTC (rev 7734)
@@ -22,6 +22,58 @@
public abstract class AbstractDispatcher<T, S> implements Dispatcher<T, S>
{
+ public class DispatcherParameters
+ {
+ private Date expiration;
+ private Date finalExpiration;
+ private Long duration;
+ private Long intervalDuration;
+ private String intervalCron;
+
+ public String getIntervalCron()
+ {
+ return intervalCron;
+ }
+ public Long getDuration()
+ {
+ return duration;
+ }
+ public Date getExpiration()
+ {
+ return expiration;
+ }
+ public Date getFinalExpiration()
+ {
+ return finalExpiration;
+ }
+ public Long getIntervalDuration()
+ {
+ return intervalDuration;
+ }
+ public void setIntervalCron(String cron)
+ {
+ this.intervalCron = cron;
+ }
+ public void setDuration(Long duration)
+ {
+ this.duration = duration;
+ }
+ public void setExpiration(Date expiration)
+ {
+ this.expiration = expiration;
+ }
+ public void setFinalExpiration(Date finalExpiration)
+ {
+ this.finalExpiration = finalExpiration;
+ }
+ public void setIntervalDuration(Long intervalDuration)
+ {
+ this.intervalDuration = intervalDuration;
+ }
+
+
+ }
+
public static final String EXECUTING_ASYNCHRONOUS_CALL = "org.jboss.seam.core.executingAsynchronousCall";
public static Dispatcher instance()
@@ -45,58 +97,108 @@
protected Schedule createSchedule(InvocationContext invocation)
{
- Long duration = null;
- Date expiration = null;
- Date finalExpiration = null;
-
- Long intervalDuration = null;
- String cron = null;
-
- int intervalParamCount = 0;
-
- Annotation[][] parameterAnnotations = invocation.getMethod().getParameterAnnotations();
- for ( int i=0; i<parameterAnnotations.length; i++ )
+ DispatcherParameters dispatcherParameters = extractAndValidateParameters(invocation);
+ if (dispatcherParameters.getIntervalCron() == null)
{
- Annotation[] annotations = parameterAnnotations[i];
+ return new TimerSchedule(dispatcherParameters.getDuration(), dispatcherParameters.getExpiration(), dispatcherParameters.getIntervalDuration(), dispatcherParameters.getFinalExpiration());
+ }
+ else
+ {
+ return new CronSchedule(dispatcherParameters.getDuration(), dispatcherParameters.getExpiration(), dispatcherParameters.getIntervalCron(), dispatcherParameters.getFinalExpiration());
+ }
+ }
+
+ protected TimerSchedule createTimerSchedule(InvocationContext invocation)
+ {
+ DispatcherParameters dispatcherParameters = extractAndValidateParameters(invocation);
+ return createTimerSchedule(dispatcherParameters);
+ }
+
+ private TimerSchedule createTimerSchedule(DispatcherParameters dispatcherParameters)
+ {
+ return new TimerSchedule(dispatcherParameters.getDuration(), dispatcherParameters.getExpiration(), dispatcherParameters.getIntervalDuration(), dispatcherParameters.getFinalExpiration());
+ }
+
+ protected DispatcherParameters extractAndValidateParameters(InvocationContext invocation)
+ {
+ DispatcherParameters dispatcherParameters = new DispatcherParameters();
+ for ( int i=0; i < invocation.getMethod().getParameterAnnotations().length; i++ )
+ {
+ Annotation[] annotations = invocation.getMethod().getParameterAnnotations()[i];
for (Annotation annotation: annotations)
{
if ( annotation.annotationType().equals(Duration.class) )
{
- duration = (Long) invocation.getParameters()[i];
+ if (invocation.getParameters()[i] instanceof Long)
+ {
+ dispatcherParameters.setDuration((Long) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@Duration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a Long");
+ }
}
- else if ( annotation.annotationType().equals(IntervalDuration.class) )
- {
- intervalDuration = (Long) invocation.getParameters()[i];
- intervalParamCount++;
- }
else if ( annotation.annotationType().equals(Expiration.class) )
{
- expiration = (Date) invocation.getParameters()[i];
+ if (invocation.getParameters()[i] instanceof Date)
+ {
+ dispatcherParameters.setExpiration((Date) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@Expiration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a java.util.Date");
+ }
}
else if ( annotation.annotationType().equals(FinalExpiration.class) )
{
- finalExpiration = (Date) invocation.getParameters()[i];
+ if (!( this instanceof QuartzDispatcher ))
+ {
+ throw new IllegalArgumentException("Can only use @FinalExpiration with the QuartzDispatcher");
+ }
+ else if (invocation.getParameters()[i] instanceof Date)
+ {
+ dispatcherParameters.setFinalExpiration((Date) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@FinalExpiration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a java.util.Date");
+ }
}
else if ( annotation.annotationType().equals(IntervalCron.class) )
{
- cron = (String) invocation.getParameters()[i];
- intervalParamCount++;
+ if (!( this instanceof QuartzDispatcher ))
+ {
+ throw new IllegalArgumentException("Can only use @IntervalCron with the QuartzDispatcher");
+ }
+ else if (invocation.getParameters()[i] instanceof String)
+ {
+ dispatcherParameters.setIntervalCron((String) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@IntervalCron on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a String");
+ }
}
+ else if ( annotation.annotationType().equals(IntervalDuration.class) )
+ {
+ if (invocation.getParameters()[i] instanceof Long)
+ {
+ dispatcherParameters.setIntervalDuration((Long) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@IntervalDuration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a Long");
+ }
+ }
}
}
-
- if (intervalParamCount > 1) {
- throw new RuntimeException ("Cannot have more than one @Interval arguments in asynchrnous method");
+
+ if ( dispatcherParameters.getIntervalCron() != null && dispatcherParameters.getIntervalDuration() != null )
+ {
+ throw new IllegalArgumentException("Can only use one of @IntervalCron and @IntervalDuration");
}
- if ( cron!=null )
- {
- return new CronSchedule(duration, expiration, cron, finalExpiration);
- }
- else
- {
- return new TimerSchedule(duration, expiration, intervalDuration, finalExpiration);
- }
+ return dispatcherParameters;
}
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
+++ branches/Seam_2_0/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java 2008-03-28 12:52:39 UTC (rev 7734)
@@ -45,7 +45,7 @@
public Future scheduleInvocation(InvocationContext invocation, Component component)
{
return scheduleWithExecutorService(
- (TimerSchedule) createSchedule(invocation),
+ createTimerSchedule(invocation),
new RunnableAsynchronous( new AsynchronousInvocation(invocation, component) )
);
}
Modified: branches/Seam_2_0/src/main/org/jboss/seam/async/TimerServiceDispatcher.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/async/TimerServiceDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
+++ branches/Seam_2_0/src/main/org/jboss/seam/async/TimerServiceDispatcher.java 2008-03-28 12:52:39 UTC (rev 7734)
@@ -63,7 +63,7 @@
public Timer scheduleInvocation(InvocationContext invocation, Component component)
{
return new TimerProxy(
- scheduleWithTimerService( (TimerSchedule) createSchedule(invocation),
+ scheduleWithTimerService( createTimerSchedule(invocation),
new AsynchronousInvocation(invocation, component) ) );
}
17 years, 9 months
Seam SVN: r7733 - in trunk/src: main/org/jboss/seam/async and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 08:39:28 -0400 (Fri, 28 Mar 2008)
New Revision: 7733
Modified:
trunk/src/ioc/org/jboss/seam/ioc/spring/SpringTaskExecutorDispatcher.java
trunk/src/main/org/jboss/seam/async/AbstractDispatcher.java
trunk/src/main/org/jboss/seam/async/CronSchedule.java
trunk/src/main/org/jboss/seam/async/Dispatcher.java
trunk/src/main/org/jboss/seam/async/QuartzDispatcher.java
trunk/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java
trunk/src/main/org/jboss/seam/async/TimerSchedule.java
trunk/src/main/org/jboss/seam/async/TimerServiceDispatcher.java
trunk/src/main/org/jboss/seam/core/Events.java
Log:
Use object orientation properly
Modified: trunk/src/ioc/org/jboss/seam/ioc/spring/SpringTaskExecutorDispatcher.java
===================================================================
--- trunk/src/ioc/org/jboss/seam/ioc/spring/SpringTaskExecutorDispatcher.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/ioc/org/jboss/seam/ioc/spring/SpringTaskExecutorDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -28,7 +28,7 @@
@Scope(ScopeType.APPLICATION)
@Name("org.jboss.seam.async.dispatcher")
@Install(value=false, precedence=BUILT_IN)
-public class SpringTaskExecutorDispatcher<T, S> extends AbstractDispatcher<T, S>
+public class SpringTaskExecutorDispatcher<T, S extends Schedule> extends AbstractDispatcher<T, S>
{
private ValueExpression<Dispatcher<T, S>> scheduleDispatcher;
Modified: trunk/src/main/org/jboss/seam/async/AbstractDispatcher.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/AbstractDispatcher.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/async/AbstractDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -19,9 +19,61 @@
* @author Gavin King
*
*/
-public abstract class AbstractDispatcher<T, S> implements Dispatcher<T, S>
+public abstract class AbstractDispatcher<T, S extends Schedule> implements Dispatcher<T, S>
{
+ public class DispatcherParameters
+ {
+ private Date expiration;
+ private Date finalExpiration;
+ private Long duration;
+ private Long intervalDuration;
+ private String intervalCron;
+
+ public String getIntervalCron()
+ {
+ return intervalCron;
+ }
+ public Long getDuration()
+ {
+ return duration;
+ }
+ public Date getExpiration()
+ {
+ return expiration;
+ }
+ public Date getFinalExpiration()
+ {
+ return finalExpiration;
+ }
+ public Long getIntervalDuration()
+ {
+ return intervalDuration;
+ }
+ public void setIntervalCron(String cron)
+ {
+ this.intervalCron = cron;
+ }
+ public void setDuration(Long duration)
+ {
+ this.duration = duration;
+ }
+ public void setExpiration(Date expiration)
+ {
+ this.expiration = expiration;
+ }
+ public void setFinalExpiration(Date finalExpiration)
+ {
+ this.finalExpiration = finalExpiration;
+ }
+ public void setIntervalDuration(Long intervalDuration)
+ {
+ this.intervalDuration = intervalDuration;
+ }
+
+
+ }
+
public static final String EXECUTING_ASYNCHRONOUS_CALL = "org.jboss.seam.core.executingAsynchronousCall";
public static Dispatcher instance()
@@ -42,61 +94,111 @@
{
Transaction.instance().registerSynchronization( new TransactionCompletionEvent(type, parameters) );
}
-
+
protected Schedule createSchedule(InvocationContext invocation)
{
- Long duration = null;
- Date expiration = null;
- Date finalExpiration = null;
-
- Long intervalDuration = null;
- String cron = null;
-
- int intervalParamCount = 0;
-
- Annotation[][] parameterAnnotations = invocation.getMethod().getParameterAnnotations();
- for ( int i=0; i<parameterAnnotations.length; i++ )
+ DispatcherParameters dispatcherParameters = extractAndValidateParameters(invocation);
+ if (dispatcherParameters.getIntervalCron() == null)
{
- Annotation[] annotations = parameterAnnotations[i];
+ return new TimerSchedule(dispatcherParameters.getDuration(), dispatcherParameters.getExpiration(), dispatcherParameters.getIntervalDuration(), dispatcherParameters.getFinalExpiration());
+ }
+ else
+ {
+ return new CronSchedule(dispatcherParameters.getDuration(), dispatcherParameters.getExpiration(), dispatcherParameters.getIntervalCron(), dispatcherParameters.getFinalExpiration());
+ }
+ }
+
+ protected TimerSchedule createTimerSchedule(InvocationContext invocation)
+ {
+ DispatcherParameters dispatcherParameters = extractAndValidateParameters(invocation);
+ return createTimerSchedule(dispatcherParameters);
+ }
+
+ private TimerSchedule createTimerSchedule(DispatcherParameters dispatcherParameters)
+ {
+ return new TimerSchedule(dispatcherParameters.getDuration(), dispatcherParameters.getExpiration(), dispatcherParameters.getIntervalDuration(), dispatcherParameters.getFinalExpiration());
+ }
+
+ protected DispatcherParameters extractAndValidateParameters(InvocationContext invocation)
+ {
+ DispatcherParameters dispatcherParameters = new DispatcherParameters();
+ for ( int i=0; i < invocation.getMethod().getParameterAnnotations().length; i++ )
+ {
+ Annotation[] annotations = invocation.getMethod().getParameterAnnotations()[i];
for (Annotation annotation: annotations)
{
if ( annotation.annotationType().equals(Duration.class) )
{
- duration = (Long) invocation.getParameters()[i];
+ if (invocation.getParameters()[i] instanceof Long)
+ {
+ dispatcherParameters.setDuration((Long) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@Duration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a Long");
+ }
}
- else if ( annotation.annotationType().equals(IntervalDuration.class) )
- {
- intervalDuration = (Long) invocation.getParameters()[i];
- intervalParamCount++;
- }
else if ( annotation.annotationType().equals(Expiration.class) )
{
- expiration = (Date) invocation.getParameters()[i];
+ if (invocation.getParameters()[i] instanceof Date)
+ {
+ dispatcherParameters.setExpiration((Date) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@Expiration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a java.util.Date");
+ }
}
else if ( annotation.annotationType().equals(FinalExpiration.class) )
{
- finalExpiration = (Date) invocation.getParameters()[i];
+ if (!( this instanceof QuartzDispatcher ))
+ {
+ throw new IllegalArgumentException("Can only use @FinalExpiration with the QuartzDispatcher");
+ }
+ else if (invocation.getParameters()[i] instanceof Date)
+ {
+ dispatcherParameters.setFinalExpiration((Date) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@FinalExpiration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a java.util.Date");
+ }
}
else if ( annotation.annotationType().equals(IntervalCron.class) )
{
- cron = (String) invocation.getParameters()[i];
- intervalParamCount++;
+ if (!( this instanceof QuartzDispatcher ))
+ {
+ throw new IllegalArgumentException("Can only use @IntervalCron with the QuartzDispatcher");
+ }
+ else if (invocation.getParameters()[i] instanceof String)
+ {
+ dispatcherParameters.setIntervalCron((String) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@IntervalCron on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a String");
+ }
}
+ else if ( annotation.annotationType().equals(IntervalDuration.class) )
+ {
+ if (invocation.getParameters()[i] instanceof Long)
+ {
+ dispatcherParameters.setIntervalDuration((Long) invocation.getParameters()[i]);
+ }
+ else if (invocation.getParameters()[i] != null)
+ {
+ throw new IllegalArgumentException("@IntervalDuration on " + invocation.getTarget().getClass() + ":" + invocation.getMethod().getName() + " must be a Long");
+ }
+ }
}
}
-
- if (intervalParamCount > 1) {
- throw new RuntimeException ("Cannot have more than one @Interval arguments in asynchrnous method");
+
+ if ( dispatcherParameters.getIntervalCron() != null && dispatcherParameters.getIntervalDuration() != null )
+ {
+ throw new IllegalArgumentException("Can only use one of @IntervalCron and @IntervalDuration");
}
- if ( cron!=null )
- {
- return new CronSchedule(duration, expiration, cron, finalExpiration);
- }
- else
- {
- return new TimerSchedule(duration, expiration, intervalDuration, finalExpiration);
- }
+ return dispatcherParameters;
}
}
Modified: trunk/src/main/org/jboss/seam/async/CronSchedule.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/CronSchedule.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/async/CronSchedule.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -43,7 +43,5 @@
super(duration, expiration, finalExpiration);
this.cron = cron;
}
-
- CronSchedule() {}
}
Modified: trunk/src/main/org/jboss/seam/async/Dispatcher.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/Dispatcher.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/async/Dispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -11,7 +11,7 @@
*
* @param <T> the type of the timer object
*/
-public interface Dispatcher<T, S>
+public interface Dispatcher<T, S extends Schedule>
{
/**
* Schedule an asynchronous method call, examining annotations
Modified: trunk/src/main/org/jboss/seam/async/QuartzDispatcher.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/QuartzDispatcher.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/async/QuartzDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -100,7 +100,7 @@
{
return scheduleWithQuartzServiceAndWrapExceptions( createSchedule(invocation), new AsynchronousInvocation(invocation, component) );
}
-
+
private static Date calculateDelayedDate (long delay)
{
Date now = new Date ();
@@ -245,7 +245,9 @@
{
return scheduler;
}
+
+
public static QuartzDispatcher instance()
{
return (QuartzDispatcher) AbstractDispatcher.instance();
Modified: trunk/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/async/ThreadPoolDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -45,7 +45,7 @@
public Future scheduleInvocation(InvocationContext invocation, Component component)
{
return scheduleWithExecutorService(
- (TimerSchedule) createSchedule(invocation),
+ createTimerSchedule(invocation),
new RunnableAsynchronous( new AsynchronousInvocation(invocation, component) )
);
}
Modified: trunk/src/main/org/jboss/seam/async/TimerSchedule.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/TimerSchedule.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/async/TimerSchedule.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -56,19 +56,19 @@
this.intervalDuration = intervalDuration;
}
- TimerSchedule(Long duration, Date expiration, Long intervalDuration)
+ public TimerSchedule(Long duration, Date expiration, Long intervalDuration)
{
super(duration, expiration);
this.intervalDuration = intervalDuration;
}
- TimerSchedule(Long duration, Date expiration, Long intervalDuration, Date finalExpiration)
+ public TimerSchedule(Long duration, Date expiration, Long intervalDuration, Date finalExpiration)
{
super(duration, expiration, finalExpiration);
this.intervalDuration = intervalDuration;
}
- TimerSchedule() {}
+ private TimerSchedule() {}
Modified: trunk/src/main/org/jboss/seam/async/TimerServiceDispatcher.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/TimerServiceDispatcher.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/async/TimerServiceDispatcher.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -63,7 +63,7 @@
public Timer scheduleInvocation(InvocationContext invocation, Component component)
{
return new TimerProxy(
- scheduleWithTimerService( (TimerSchedule) createSchedule(invocation),
+ scheduleWithTimerService( createTimerSchedule(invocation),
new AsynchronousInvocation(invocation, component) ) );
}
@@ -250,4 +250,6 @@
return ( (LocalTimerServiceDispatcher) AbstractDispatcher.instance() );
}
+
+
}
Modified: trunk/src/main/org/jboss/seam/core/Events.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/Events.java 2008-03-28 12:37:11 UTC (rev 7732)
+++ trunk/src/main/org/jboss/seam/core/Events.java 2008-03-28 12:39:28 UTC (rev 7733)
@@ -13,6 +13,7 @@
import org.jboss.seam.async.AbstractDispatcher;
import org.jboss.seam.async.CronSchedule;
import org.jboss.seam.async.Dispatcher;
+import org.jboss.seam.async.Schedule;
import org.jboss.seam.async.TimerSchedule;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Expressions.MethodExpression;
@@ -108,7 +109,7 @@
* @param schedule the schedule object, specific to the dispatcher strategy
* @param parameters parameters to be passes to the listener method
*/
- public void raiseTimedEvent(String type, Object schedule, Object... parameters)
+ public void raiseTimedEvent(String type, Schedule schedule, Object... parameters)
{
getDispatcher().scheduleTimedEvent(type, schedule, parameters);
}
17 years, 9 months
Seam SVN: r7732 - trunk/examples/dvdstore.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-03-28 08:37:11 -0400 (Fri, 28 Mar 2008)
New Revision: 7732
Modified:
trunk/examples/dvdstore/
Log:
ignores
Property changes on: trunk/examples/dvdstore
___________________________________________________________________
Name: svn:ignore
- build
test-build
dist
exploded-archives
+ build
test-build
dist
exploded-archives
dvdindexes
17 years, 9 months