Seam SVN: r8500 - in trunk: examples/wicket/resources/WEB-INF and 5 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-27 14:54:48 -0400 (Sun, 27 Jul 2008)
New Revision: 8500
Added:
trunk/doc/Seam_Reference_Guide/en-US/Wicket.xml
trunk/src/main/org/jboss/seam/wicket-2.1.xsd
trunk/src/wicket/org/jboss/seam/wicket/WebApplication.java
trunk/src/wicket/org/jboss/seam/wicket/package-info.java
Modified:
trunk/doc/Seam_Reference_Guide/en-US/master.xml
trunk/examples/wicket/resources/WEB-INF/components.xml
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java
trunk/src/main/org/jboss/seam/web/WicketFilter.java
trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java
trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
Log:
Initial pass at Wicket documentation
Added: trunk/doc/Seam_Reference_Guide/en-US/Wicket.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Wicket.xml (rev 0)
+++ trunk/doc/Seam_Reference_Guide/en-US/Wicket.xml 2008-07-27 18:54:48 UTC (rev 8500)
@@ -0,0 +1,265 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+]>
+
+<chapter id="wicket">
+ <title>Writing your presentation layer using Apache Wicket</title>
+
+ <para>
+ Seam supports Wicket as an alternative presentation layer to JSF. Take a
+ look at the <code>wicket</code> example in Seam which shows the Booking
+ Example ported to Wicket.
+ </para>
+
+ <note>
+ <para>
+ Wicket support is new to Seam, so some features which are
+ available in JSF are not yet available when you use Wicket
+ (e.g. pageflow). You'll also notice that the documentation is
+ very JSF-centric and needs reorganization to reflect the first
+ class support for Wicket.
+ </para>
+ </note>
+
+ <section>
+ <title>Adding Seam to your wicket application</title>
+
+ <para>
+ The features added to your Wicket application can be split into two
+ categories: bijection and orchestration; these are discussed in detail
+ below.
+ </para>
+
+ <para>
+ Extensive use of inner classes is common when building Wicket
+ applications, with the component tree being built in the constructor.
+ Seam fully supports the use of annotation based control in inner
+ classes and constructors (unlike regular Seam components).
+ </para>
+
+ <para>
+ Annotations are processed <emphasis>after</emphasis> any call to
+ a superclass. This mean's that any injected attributes cannot be
+ passed as an argument in a call to <code>this()</code> or
+ <code>super()</code>.
+ </para>
+
+ <note>
+ <para>
+ We are working to improve this.
+ </para>
+ </note>
+
+ <para>
+ When a method is called in an inner class, bijection occurs for any
+ class which encloses it. This allows you to place your bijected
+ variables in the outer class, and refer to them in any inner class.
+ </para>
+
+ <section>
+ <title>Bijection</title>
+
+ <para>
+ A Seam enabled Wicket application has full access to the all the
+ standard Seam contexts (<code>EVENT</code>, <code>CONVERSATION</code>,
+ <code>SESSION</code>, <code>APPLICATION</code> and
+ <code>BUSINESS_PROCESS</code>).
+ </para>
+
+ <para>
+ To access Seam component's from Wicket, you just need to inject it
+ using <code>@In</code>:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[@In(create=true)
+private HotelBooking hotelBooking;]]></programlisting>
+
+ <tip>
+ <para>
+ As your Wicket class isn't a full Seam component, there is no
+ need to annotate it <code>@Name</code>.
+ </para>
+ </tip>
+
+ <para>
+ You can also outject an object into the Seam contexts from a Wicket
+ component:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[(a)Out(scope=ScopeType.EVENT, required=false)
+private String verify;]]></programlisting>
+
+ <para>
+ TODO Make this more use case driven
+ </para>
+
+ </section>
+
+ <section>
+ <title>Orchestration</title>
+
+ <para>
+ You can secure a Wicket component by using the
+ <code>@Restrict</code> annotation. This can be placed on the outer
+ component or any inner components. If <code>@Restrict</code> is
+ specified, the component will automatically be restricted to logged
+ in users. You can optionally use an EL expression in the
+ <code>value</code> attribute to specify a restriction to be applied.
+ For more refer to the <xref linkend="security"/>.
+ </para>
+
+ <para>
+ For example:
+ </para>
+
+ <programlisting><![CDATA[@Restrict
+public class Main extends WebPage {
+
+ ...]]></programlisting>
+
+ <tip>
+ <para>
+ Seam will automatically apply the restriction to any nested
+ classes.
+ </para>
+ <para>
+ TODO - Implement this (See JBSEAM-3192)
+ </para>
+ </tip>
+
+ <para>
+ You can demarcate conversations from within a Wicket component
+ through the use of <code>@Begin</code> and <code>@End</code>. The
+ semantics for these annotations are the same as when used in a Seam
+ component. You can place <code>@Begin</code> and <code>@End</code>
+ on any method.
+ </para>
+
+ <note>
+ <para>
+ The deprecated <code>ifOutcome</code> attribute is not supported.
+ </para>
+ </note>
+
+ <para>
+ For example:
+ </para>
+
+ <programlisting><![CDATA[item.add(new Link("viewHotel") {
+
+ @Override
+ @Begin
+ public void onClick() {
+ hotelBooking.selectHotel(hotel);
+ setResponsePage(org.jboss.seam.example.wicket.Hotel.class);
+ }
+};]]></programlisting>
+
+ <para>
+ If you want to further decouple your application classes, you can
+ use Seam events. Of course, you can raise an event using
+ <code>Events.instance().raiseEvent("foo")</code>. Alternatively, you
+ can annotate a method <code>@RaiseEvent("foo")</code>; if the method
+ returns a non-null outcome without exception, the event will be
+ raised.
+ </para>
+
+ <para>
+ You can also control tasks and processes in Wicket classes through
+ the use of <code>@CreateProcess</code>, <code>@ResumeTask</code>,
+ <code>@BeginTask</code>, <code>@EndTask</code>,
+ <code>@StartTask</code> and <code>@Transition</code>.
+ </para>
+
+ <para>
+ TODO - Implement BPM control - JBSEAM-3194
+ </para>
+ </section>
+
+ </section>
+
+ <section>
+ <title>Setting up your project</title>
+
+ <para>
+ To enable bijection and orchestration control via annotations in Wicket
+ you must place your classes in <code>WEB-INF/wicket</code>. Seam needs
+ to instrument the bytecode of your Wicket classes to be able to
+ intercept the annotations you use.
+ </para>
+
+ <note>
+ <para>
+ Currently only bytecode instrumentation using a custom classloader
+ which reads classes in <code>WEB-INF/wicket</code> is supported. In the
+ an Ant task or Maven plugin may be developed to support bytecode
+ instrumentation when the project artifacts are built.
+ </para>
+ </note>
+
+ <section>
+ <title>Defining the Application</title>
+
+ <para>
+ A Wicket web application which uses Seam should use
+ <code>SeamWebApplication</code> as the base class; this creates hooks
+ into the Wicket lifecycle allowing Seam to automagically propagate the
+ conversation as needed. It also adds status messages to the page.
+ </para>
+
+ <para>
+ For example:
+ </para>
+
+ <para>
+ The <code>SeamAuthorizationStrategy</code> delegates authorization
+ to Seam Security, allowing the use of <code>@Restrict</code> on Wicket
+ components. <code>SeamWebApplication</code> installs the authorization
+ strategy for you. You can specify the login page by implementing the
+ <code>getLoginPage()</code> method.
+ </para>
+
+ <para>
+ You'll also need to set the home page of the application by
+ implementing the <code>getHomePage()</code> method.
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[public class WicketBookingApplication extends SeamWebApplication {
+
+ @Override
+ public Class getHomePage() {
+ return Home.class;
+ }
+
+ @Override
+ protected Class getLoginPage() {
+ return Home.class;
+ }
+
+}
+]]></programlisting>
+
+ <para>
+ Seam automatically installs the Wicket filter for you (ensuring that
+ it is inserted in the correct place for you). But you still need to
+ tell Wicket which <code>WebApplication</code> class to use:
+ </para>
+
+ <programlisting role="XML"><![CDATA[<components xmlns="http://jboss.com/products/seam/components"
+ xmlns:wicket="http://jboss.com/products/seam/wicket"
+
+ <wicket:web-application application-class="org.jboss.seam.example.wicket.WicketBookingApplication" />
+</components]]></programlisting>
+
+ <tip>
+ <para>
+ Take a look at the Wicket documentation for more on authorization
+ strategies and other methods you can override on the
+ <code>Application</code> class.
+ </para>
+ </tip>
+ </section>
+
+ </section>
+
+</chapter>
Property changes on: trunk/doc/Seam_Reference_Guide/en-US/Wicket.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Modified: trunk/doc/Seam_Reference_Guide/en-US/master.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/master.xml 2008-07-27 12:43:35 UTC (rev 8499)
+++ trunk/doc/Seam_Reference_Guide/en-US/master.xml 2008-07-27 18:54:48 UTC (rev 8500)
@@ -15,6 +15,7 @@
<xi:include href= "Persistence.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href= "Validation.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href= "Groovy.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href= "Wicket.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href= "Framework.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href= "Drools.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href= "Security.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
Modified: trunk/examples/wicket/resources/WEB-INF/components.xml
===================================================================
--- trunk/examples/wicket/resources/WEB-INF/components.xml 2008-07-27 12:43:35 UTC (rev 8499)
+++ trunk/examples/wicket/resources/WEB-INF/components.xml 2008-07-27 18:54:48 UTC (rev 8500)
@@ -4,11 +4,13 @@
xmlns:security="http://jboss.com/products/seam/security"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:web="http://jboss.com/products/seam/web"
+ xmlns:wicket="http://jboss.com/products/seam/wicket"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd
http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd
+ http://jboss.com/products/seam/wicket http://jboss.com/products/seam/wicket-2.1.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
@@ -22,7 +24,6 @@
<security:identity authenticate-method="#{authenticator.authenticate}"/>
- <!-- TODO Move this onto a wicekt namespace -->
- <web:wicket-filter application-class="org.jboss.seam.example.wicket.WicketBookingApplication" />
+ <wicket:web-application application-class="org.jboss.seam.example.wicket.WicketBookingApplication" />
</components>
Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java 2008-07-27 12:43:35 UTC (rev 8499)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java 2008-07-27 18:54:48 UTC (rev 8500)
@@ -1,19 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
package org.jboss.seam.example.wicket;
import java.util.Arrays;
Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java 2008-07-27 12:43:35 UTC (rev 8499)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java 2008-07-27 18:54:48 UTC (rev 8500)
@@ -7,7 +7,8 @@
/**
* Port of Booking Application to Wicket
*/
-public class WicketBookingApplication extends SeamWebApplication {
+public class WicketBookingApplication extends SeamWebApplication
+{
@Override
public Class getHomePage()
Modified: trunk/src/main/org/jboss/seam/web/WicketFilter.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/WicketFilter.java 2008-07-27 12:43:35 UTC (rev 8499)
+++ trunk/src/main/org/jboss/seam/web/WicketFilter.java 2008-07-27 18:54:48 UTC (rev 8500)
@@ -75,10 +75,6 @@
{
parameters.put( "applicationClassName", getApplicationClass() );
}
- else
- {
- throw new IllegalStateException("Must set application-class in <web:wicket-filter /> in components.xml");
- }
if ( getUrlPattern() != null )
{
parameters.put("filterMappingUrlPattern", getUrlPattern());
Added: trunk/src/main/org/jboss/seam/wicket-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/wicket-2.1.xsd (rev 0)
+++ trunk/src/main/org/jboss/seam/wicket-2.1.xsd 2008-07-27 18:54:48 UTC (rev 8500)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
+ targetNamespace="http://jboss.com/products/seam/wicket"
+ xmlns:wicket="http://jboss.com/products/seam/wicket"
+ xmlns:components="http://jboss.com/products/seam/components" attributeFormDefault="unqualified">
+
+ <xs:import namespace="http://jboss.com/products/seam/components" schemaLocation="components-2.1.xsd"/>
+
+ <xs:element name="web-application">
+ <xs:annotation>
+ <xs:documentation></xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attributeGroup ref="components:attlist.component" />
+ <xs:attributeGroup ref="wicket:attlist.webApplication" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:attributeGroup name="attlist.webApplication">
+ <xs:attribute name="application-class" type="components:string" />
+ </xs:attributeGroup>
+
+</xs:schema>
Property changes on: trunk/src/main/org/jboss/seam/wicket-2.1.xsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java 2008-07-27 12:43:35 UTC (rev 8499)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java 2008-07-27 18:54:48 UTC (rev 8500)
@@ -23,8 +23,6 @@
/**
* The base class for Seam Web Applications
*
- * TODO Remove the need to extend this
- *
* @author Pete Muir
*
*/
Added: trunk/src/wicket/org/jboss/seam/wicket/WebApplication.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WebApplication.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/WebApplication.java 2008-07-27 18:54:48 UTC (rev 8500)
@@ -0,0 +1,43 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import org.jboss.seam.Component;
+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;
+
+@Name("org.jboss.seam.wicket.WebApplication")
+@Scope(APPLICATION)
+@Install(precedence=21, classDependencies="org.apache.wicket.Application")
+@BypassInterceptors
+public class WebApplication
+{
+
+ private String applicationClass;
+
+ public String getApplicationClass()
+ {
+ return applicationClass;
+ }
+
+ public void setApplicationClass(String applicationClass)
+ {
+ this.applicationClass = applicationClass;
+ }
+
+ public static WebApplication instance()
+ {
+ if (Contexts.isApplicationContextActive())
+ {
+ return (WebApplication) Component.getInstance(WebApplication.class);
+ }
+ else
+ {
+ throw new IllegalStateException("Application context is not active");
+ }
+ }
+
+}
Property changes on: trunk/src/wicket/org/jboss/seam/wicket/WebApplication.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/wicket/org/jboss/seam/wicket/package-info.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/package-info.java (rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/package-info.java 2008-07-27 18:54:48 UTC (rev 8500)
@@ -0,0 +1,9 @@
+/**
+ * A set of classes and Seam component for supporting Wicket
+ */
+@Namespace(value="http://jboss.com/products/seam/wicket", prefix="org.jboss.seam.wicket")
+@AutoCreate
+package org.jboss.seam.wicket;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Namespace;
Property changes on: trunk/src/wicket/org/jboss/seam/wicket/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java 2008-07-27 12:43:35 UTC (rev 8499)
+++ trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java 2008-07-27 18:54:48 UTC (rev 8500)
@@ -4,6 +4,10 @@
package org.jboss.seam.wicket.web;
import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.util.HashMap;
+import java.util.Map;
+
import javassist.CannotCompileException;
import javassist.NotFoundException;
@@ -18,6 +22,10 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Unwrap;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.util.Reflections;
+import org.jboss.seam.web.FilterConfigWrapper;
+import org.jboss.seam.wicket.WebApplication;
+import org.jboss.seam.wicket.SeamWebApplication;
import org.jboss.seam.wicket.ioc.JavassistInstrumentor;
@Name("org.jboss.seam.wicket.web.wicketFilterInstantiator")
@@ -36,8 +44,9 @@
private ClassLoader classLoader;
@Override
- public void init(final FilterConfig filterConfig) throws ServletException
+ public void init(FilterConfig filterConfig) throws ServletException
{
+ Map<String, String> parameters = new HashMap<String, String>();
try
{
JavassistInstrumentor javassistInstrumentor = new JavassistInstrumentor(filterConfig.getServletContext());
@@ -55,8 +64,20 @@
catch (ClassNotFoundException e)
{
throw new ServletException(e);
- }
- super.init(filterConfig);
+ }
+ if (filterConfig.getInitParameter("applicationClassName") == null)
+ {
+ String applicationClass = WebApplication.instance().getApplicationClass();
+ if (applicationClass != null)
+ {
+ parameters.put("applicationClassName", applicationClass);
+ }
+ else
+ {
+ throw new IllegalStateException("Must set application-class using <wicket:web-application /> in components.xml");
+ }
+ }
+ super.init(new FilterConfigWrapper(filterConfig, parameters));
}
@Override
16 years, 6 months
Seam SVN: r8499 - trunk/build.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-27 08:43:35 -0400 (Sun, 27 Jul 2008)
New Revision: 8499
Modified:
trunk/build/default.build.properties
Log:
Update to JBoss 4.2.3
Modified: trunk/build/default.build.properties
===================================================================
--- trunk/build/default.build.properties 2008-07-27 12:33:17 UTC (rev 8498)
+++ trunk/build/default.build.properties 2008-07-27 12:43:35 UTC (rev 8499)
@@ -12,5 +12,5 @@
#
# Other program locations
# -----------------------
-jboss.home /Applications/jboss-4.2.2.GA
+jboss.home /Applications/jboss-4.2.3.GA
tomcat.home /Applications/apache-tomcat-6.0
16 years, 6 months
Seam SVN: r8498 - trunk/doc/Seam_Reference_Guide/en-US and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-07-27 08:33:17 -0400 (Sun, 27 Jul 2008)
New Revision: 8498
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Security.xml
trunk/doc/Seam_Reference_Guide/en-US/Security.xml
Log:
Correct name for cpatcha component
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Security.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Security.xml 2008-07-24 13:02:30 UTC (rev 8497)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Security.xml 2008-07-27 12:33:17 UTC (rev 8498)
@@ -1358,7 +1358,7 @@
You may customize the CAPTCHA algorithm by overriding the built-in component:
</para>
- <programlisting role="JAVA"><![CDATA[@Name("org.jboss.seam.captcha")
+ <programlisting role="JAVA"><![CDATA[@Name("org.jboss.seam.captcha.captcha")
@Scope(SESSION)
public class HitchhikersCaptcha extends Captcha
{
Modified: trunk/doc/Seam_Reference_Guide/en-US/Security.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-07-24 13:02:30 UTC (rev 8497)
+++ trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-07-27 12:33:17 UTC (rev 8498)
@@ -4637,7 +4637,7 @@
You may customize the CAPTCHA algorithm by overriding the built-in component:
</para>
- <programlisting role="JAVA"><![CDATA[@Name("org.jboss.seam.captcha")
+ <programlisting role="JAVA"><![CDATA[@Name("org.jboss.seam.captcha.captcha")
@Scope(SESSION)
public class HitchhikersCaptcha extends Captcha
{
16 years, 6 months
Seam SVN: r8497 - trunk/src/main/org/jboss/seam/contexts.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-07-24 09:02:30 -0400 (Thu, 24 Jul 2008)
New Revision: 8497
Modified:
trunk/src/main/org/jboss/seam/contexts/Lifecycle.java
Log:
JBSEAM-3133
Modified: trunk/src/main/org/jboss/seam/contexts/Lifecycle.java
===================================================================
--- trunk/src/main/org/jboss/seam/contexts/Lifecycle.java 2008-07-24 08:30:20 UTC (rev 8496)
+++ trunk/src/main/org/jboss/seam/contexts/Lifecycle.java 2008-07-24 13:02:30 UTC (rev 8497)
@@ -33,7 +33,7 @@
{
if (!isApplicationInitialized())
{
- throw new IllegalStateException("Attempted to invoke a Seam component outside the an initialized application");
+ throw new IllegalStateException("Attempted to invoke a Seam component outside an initialized application");
}
return application;
}
16 years, 7 months
Seam SVN: r8496 - in trunk/src/remoting/org/jboss/seam/remoting: wrapper and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-07-24 04:30:20 -0400 (Thu, 24 Jul 2008)
New Revision: 8496
Modified:
trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java
trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java
trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java
Log:
JBSEAM-3174
Modified: trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java 2008-07-23 06:55:53 UTC (rev 8495)
+++ trunk/src/remoting/org/jboss/seam/remoting/InterfaceGenerator.java 2008-07-24 08:30:20 UTC (rev 8496)
@@ -10,6 +10,7 @@
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
@@ -658,7 +659,7 @@
else if (type instanceof Class)
{
Class cls = (Class) type;
- if (Date.class.isAssignableFrom(cls))
+ if (Date.class.isAssignableFrom(cls) || Calendar.class.isAssignableFrom(cls))
return "date";
else if (cls.isArray())
return "bag";
Modified: trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java 2008-07-23 06:55:53 UTC (rev 8495)
+++ trunk/src/remoting/org/jboss/seam/remoting/wrapper/DateWrapper.java 2008-07-24 08:30:20 UTC (rev 8496)
@@ -6,6 +6,7 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
/**
@@ -22,7 +23,14 @@
public void marshal(OutputStream out) throws IOException
{
out.write(DATE_TAG_OPEN);
- out.write(df.format(value).getBytes());
+ if (Date.class.isAssignableFrom(value.getClass()))
+ {
+ out.write(df.format(value).getBytes());
+ }
+ else if (Calendar.class.isAssignableFrom(value.getClass()))
+ {
+ out.write(df.format(((Calendar) value).getTime()).getBytes());
+ }
out.write(DATE_TAG_CLOSE);
}
@@ -35,11 +43,26 @@
try {
value = df.parse(element.getStringValue());
}
- catch (ParseException ex) {
+ catch (ParseException ex)
+ {
throw new ConversionException(String.format(
"Date value [%s] is not in a valid format.", element.getStringValue()));
}
}
+ else if ((type instanceof Class && Calendar.class.isAssignableFrom((Class) type)))
+ {
+ try
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(df.parse(element.getStringValue()));
+ value = cal;
+ }
+ catch (ParseException ex)
+ {
+ throw new ConversionException(String.format(
+ "Date value [%s] is not in a valid format.", element.getStringValue()));
+ }
+ }
else
throw new ConversionException(String.format(
"Value [%s] cannot be converted to type [%s].", element.getStringValue(),
@@ -50,7 +73,7 @@
public ConversionScore conversionScore(Class cls)
{
- if (Date.class.isAssignableFrom(cls))
+ if (Date.class.isAssignableFrom(cls) || Calendar.class.isAssignableFrom(cls))
return ConversionScore.exact;
else if (cls.equals(Object.class))
return ConversionScore.compatible;
Modified: trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java 2008-07-23 06:55:53 UTC (rev 8495)
+++ trunk/src/remoting/org/jboss/seam/remoting/wrapper/WrapperFactory.java 2008-07-24 08:30:20 UTC (rev 8496)
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -106,7 +107,7 @@
w = new BooleanWrapper();
else if (obj.getClass().isEnum())
w = new StringWrapper();
- else if (Date.class.isAssignableFrom(obj.getClass()))
+ else if (Date.class.isAssignableFrom(obj.getClass()) || Calendar.class.isAssignableFrom(obj.getClass()))
w = new DateWrapper();
else if (classRegistry.containsKey(obj.getClass()))
{
16 years, 7 months
Seam SVN: r8495 - trunk/src/resteasy/org/jboss/seam/resteasy.
by seam-commits@lists.jboss.org
Author: christian.bauer(a)jboss.com
Date: 2008-07-23 02:55:53 -0400 (Wed, 23 Jul 2008)
New Revision: 8495
Modified:
trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java
trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java
trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd
Log:
Added UrlInfo path filtering for RESTEasy
Modified: trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java 2008-07-23 06:30:53 UTC (rev 8494)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java 2008-07-23 06:55:53 UTC (rev 8495)
@@ -36,6 +36,9 @@
private boolean scanResources = true;
private boolean useBuiltinProviders = true;
+ private String resourcePathPrefix = "/rest";
+ private boolean stripSeamResourcePath = true;
+
public ApplicationConfig()
{
super();
@@ -156,4 +159,24 @@
{
this.useBuiltinProviders = useBuiltinProviders;
}
+
+ public String getResourcePathPrefix()
+ {
+ return resourcePathPrefix;
+ }
+
+ public void setResourcePathPrefix(String resourcePathPrefix)
+ {
+ this.resourcePathPrefix = resourcePathPrefix;
+ }
+
+ public boolean isStripSeamResourcePath()
+ {
+ return stripSeamResourcePath;
+ }
+
+ public void setStripSeamResourcePath(boolean stripSeamResourcePath)
+ {
+ this.stripSeamResourcePath = stripSeamResourcePath;
+ }
}
Modified: trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java 2008-07-23 06:30:53 UTC (rev 8494)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java 2008-07-23 06:55:53 UTC (rev 8495)
@@ -2,25 +2,40 @@
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.log.Log;
import org.jboss.seam.servlet.ContextualHttpServletRequest;
import org.jboss.seam.web.AbstractResource;
+import org.resteasy.plugins.server.servlet.HttpServletDispatcher;
+import org.resteasy.plugins.server.servlet.HttpServletInputMessage;
+import org.resteasy.plugins.server.servlet.HttpServletResponseWrapper;
+import org.resteasy.plugins.server.servlet.ServletSecurityContext;
+import org.resteasy.specimpl.PathSegmentImpl;
+import org.resteasy.specimpl.UriBuilderImpl;
+import org.resteasy.specimpl.UriInfoImpl;
+import org.resteasy.spi.HttpRequest;
+import org.resteasy.spi.HttpResponse;
+import org.resteasy.spi.ResteasyProviderFactory;
+import org.resteasy.util.PathHelper;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.SecurityContext;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
/**
- * Accepts incoming HTTP request under the Seam resource-servlet URL mapping and
+ * Accepts incoming HTTP request throug the SeamResourceServlet and
* dispatches the call to RESTEasy. Wraps the call in Seam contexts.
- * <p>
- * Hardcoded URL path is <tt>/rest</tt>. Subclass and override the
- * <tt>getResourcePath()</tt> method to customize this.
- * </p>
*
* @author Christian Bauer
*/
@@ -30,12 +45,14 @@
public class ResteasyResourceAdapter extends AbstractResource
{
- public static final String RESTEASY_RESOURCE_BASEPATH = "/rest";
+ @Logger
+ Log log;
@Override
public String getResourcePath()
{
- return RESTEASY_RESOURCE_BASEPATH;
+ ApplicationConfig appConfig = (ApplicationConfig)Component.getInstance(ApplicationConfig.class);
+ return appConfig.getResourcePathPrefix();
}
@Override
@@ -43,31 +60,77 @@
throws ServletException, IOException
{
- // Wrap this in Seam contexts
- new ContextualHttpServletRequest(request)
- {
- @Override
- public void process() throws ServletException, IOException
+ // Wrap in RESTEasy contexts
+ try {
+ log.debug("processing REST request");
+ ResteasyProviderFactory.pushContext(HttpServletRequest.class, request);
+ ResteasyProviderFactory.pushContext(HttpServletResponse.class, response);
+ ResteasyProviderFactory.pushContext(SecurityContext.class, new ServletSecurityContext(request));
+
+ // Wrap in Seam contexts
+ new ContextualHttpServletRequest(request)
{
+ @Override
+ public void process() throws ServletException, IOException
+ {
- ResteasyDispatcher dispatcher =
- (ResteasyDispatcher) Component.getInstance(ResteasyDispatcher.class);
- if (dispatcher == null)
- {
- throw new IllegalStateException("RESTEasy is not installed, check your classpath");
+ HttpHeaders headers = HttpServletDispatcher.extractHttpHeaders(request);
+ String path = PathHelper.getEncodedPathInfo(request.getRequestURI(), request.getContextPath());
+ URI absolutePath;
+ try
+ {
+ URL absolute = new URL(request.getRequestURL().toString());
+
+ UriBuilderImpl builder = new UriBuilderImpl();
+ builder.scheme(absolute.getProtocol());
+ builder.host(absolute.getHost());
+ builder.port(absolute.getPort());
+ builder.path(absolute.getPath());
+ builder.replaceQueryParams(absolute.getQuery());
+ absolutePath = builder.build();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ ApplicationConfig appConfig = (ApplicationConfig)Component.getInstance(ApplicationConfig.class);
+ if (appConfig.isStripSeamResourcePath()) {
+ log.debug("removing SeamResourceServlet url-pattern and dispatcher prefix from request path");
+ path = path.substring(path.indexOf(getResourcePath())+getResourcePath().length());
+ }
+
+ log.debug("final request path: " + path);
+ List<PathSegment> pathSegments = PathSegmentImpl.parseSegments(path);
+ UriInfoImpl uriInfo = new UriInfoImpl(absolutePath, path, request.getQueryString(), pathSegments);
+
+ HttpRequest in;
+ try
+ {
+ in =
+ new HttpServletInputMessage(
+ headers,
+ request.getInputStream(),
+ uriInfo,
+ request.getMethod().toUpperCase()
+ );
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ ResteasyDispatcher dispatcher =
+ (ResteasyDispatcher) Component.getInstance(ResteasyDispatcher.class);
+ HttpResponse theResponse =
+ new HttpServletResponseWrapper(response, dispatcher.getDispatcher().getProviderFactory());
+ dispatcher.getDispatcher().invoke(in, theResponse);
}
- dispatcher.invoke(
- new HttpServletRequestWrapper(request)
- {
- // TODO: Strip out the /seam/resource/rest stuff
- public String getPathInfo()
- {
- return super.getPathInfo();
- }
- },
- response
- );
- }
- }.run();
+ }.run();
+
+ } finally {
+ ResteasyProviderFactory.clearContextData();
+ log.debug("completed processing of REST request");
+ }
}
}
Modified: trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd 2008-07-23 06:30:53 UTC (rev 8494)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd 2008-07-23 06:55:53 UTC (rev 8495)
@@ -57,6 +57,24 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="resource-path-prefix" type="components:string">
+ <xs:annotation>
+ <xs:documentation>
+ Append this prefix to any request path, after the SeamResourceServlet
+ url-pattern prefix (configured in web.xml). Defaults to "/rest".
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="strip-seam-resource-path" type="components:boolean">
+ <xs:annotation>
+ <xs:documentation>
+ Remove the "/<url-pattern-of-seam-resource-servlet>/<resource-path-prefix>" part
+ of the request path before the request is mapped to a @Path resource. If disabled,
+ all @Path definitions must use the full prefix of the SeamResourceServlet as
+ mapped with the url-pattern in web.xml, plus the resourcePathPrefix.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:attributeGroup>
</xs:schema>
16 years, 7 months
Seam SVN: r8494 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-07-23 02:30:53 -0400 (Wed, 23 Jul 2008)
New Revision: 8494
Modified:
trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
exclude conditional roles from role list
Modified: trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-07-23 05:51:33 UTC (rev 8493)
+++ trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-07-23 06:30:53 UTC (rev 8494)
@@ -104,7 +104,7 @@
if (userClass == null)
{
- log.debug("Error in JpaIdentityStore configuration - userClass must be configured.");
+ log.error("Error in JpaIdentityStore configuration - userClass must be configured.");
return;
}
@@ -716,9 +716,22 @@
public List<String> listRoles()
{
- return lookupEntityManager().createQuery(
- "select r." + roleNameProperty.getName() + " from " + roleClass.getName() + " r")
- .getResultList();
+ StringBuilder roleQuery = new StringBuilder();
+
+ roleQuery.append("select r.");
+ roleQuery.append(roleNameProperty.getName());
+ roleQuery.append(" from ");
+ roleQuery.append(roleClass.getName());
+ roleQuery.append(" r");
+
+ if (roleConditionalProperty != null)
+ {
+ roleQuery.append(" where r.");
+ roleQuery.append(roleConditionalProperty.getName());
+ roleQuery.append(" = false");
+ }
+
+ return lookupEntityManager().createQuery(roleQuery.toString()).getResultList();
}
protected void persistEntity(Object entity)
16 years, 7 months
Seam SVN: r8493 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-07-23 01:51:33 -0400 (Wed, 23 Jul 2008)
New Revision: 8493
Modified:
trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
create new user if grantRole() can't find an existing user
Modified: trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-07-23 05:39:44 UTC (rev 8492)
+++ trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-07-23 05:51:33 UTC (rev 8493)
@@ -223,10 +223,30 @@
public boolean grantRole(String username, String role)
{
+ if (roleClass == null) return false;
+
Object user = lookupUser(username);
if (user == null)
{
- throw new NoSuchUserException("Could not grant role, no such user '" + username + "'");
+ if (userPasswordProperty != null)
+ {
+ // If no userPasswordProperty is set, it means that authentication is being performed
+ // by another identity store and this one is just managing roles
+ throw new NoSuchUserException("Could not grant role, no such user '" + username + "'");
+ }
+ else
+ {
+ // We need to create a new user object
+ if (createUser(username, null))
+ {
+ user = lookupUser(username);
+ }
+ else
+ {
+ throw new IdentityManagementException(
+ "Could not grant role - user does not exist and an attempt to create the user failed.");
+ }
+ }
}
Object roleToGrant = lookupRole(role);
16 years, 7 months
Seam SVN: r8492 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-07-23 01:39:44 -0400 (Wed, 23 Jul 2008)
New Revision: 8492
Modified:
trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
only user-class is required
Modified: trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-07-23 05:39:00 UTC (rev 8491)
+++ trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-07-23 05:39:44 UTC (rev 8492)
@@ -90,19 +90,7 @@
@Create
public void init()
- {
- if (userClass == null)
- {
- log.debug("No userClass set, JpaIdentityStore will be unavailable.");
- return;
- }
-
- if (roleClass == null)
- {
- log.debug("No roleClass set, JpaIdentityStore will be unavailable.");
- return;
- }
-
+ {
if (featureSet == null)
{
featureSet = new FeatureSet();
@@ -114,6 +102,12 @@
entityManager = Expressions.instance().createValueExpression("#{entityManager}", EntityManager.class);
}
+ if (userClass == null)
+ {
+ log.debug("Error in JpaIdentityStore configuration - userClass must be configured.");
+ return;
+ }
+
initProperties();
}
@@ -125,30 +119,27 @@
userEnabledProperty = AnnotatedBeanProperty.scanForProperty(userClass, UserEnabled.class);
userFirstNameProperty = AnnotatedBeanProperty.scanForProperty(userClass, UserFirstName.class);
userLastNameProperty = AnnotatedBeanProperty.scanForProperty(userClass, UserLastName.class);
+
+ if (roleClass != null)
+ {
+ roleNameProperty = AnnotatedBeanProperty.scanForProperty(roleClass, RoleName.class);
+ roleGroupsProperty = AnnotatedBeanProperty.scanForProperty(roleClass, RoleGroups.class);
+ roleConditionalProperty = AnnotatedBeanProperty.scanForProperty(roleClass, RoleConditional.class);
+ }
- roleNameProperty = AnnotatedBeanProperty.scanForProperty(roleClass, RoleName.class);
- roleGroupsProperty = AnnotatedBeanProperty.scanForProperty(roleClass, RoleGroups.class);
- roleConditionalProperty = AnnotatedBeanProperty.scanForProperty(roleClass, RoleConditional.class);
-
if (userPrincipalProperty == null)
{
throw new IdentityManagementException("Invalid userClass " + userClass.getName() +
" - required annotation @UserPrincipal not found on any Field or Method.");
}
- if (userPasswordProperty == null)
- {
- throw new IdentityManagementException("Invalid userClass " + userClass.getName() +
- " - required annotation @UserPassword not found on any Field or Method.");
- }
-
if (userRolesProperty == null)
{
throw new IdentityManagementException("Invalid userClass " + userClass.getName() +
" - required annotation @UserRoles not found on any Field or Method.");
}
- if (roleNameProperty == null)
+ if (roleClass != null && roleNameProperty == null)
{
throw new IdentityManagementException("Invalid roleClass " + roleClass.getName() +
" - required annotation @RoleName not found on any Field or Method.");
16 years, 7 months
Seam SVN: r8491 - trunk/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-07-23 01:39:00 -0400 (Wed, 23 Jul 2008)
New Revision: 8491
Modified:
trunk/src/main/org/jboss/seam/security-2.1.xsd
Log:
user-class is required
Modified: trunk/src/main/org/jboss/seam/security-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/security-2.1.xsd 2008-07-22 15:58:20 UTC (rev 8490)
+++ trunk/src/main/org/jboss/seam/security-2.1.xsd 2008-07-23 05:39:00 UTC (rev 8491)
@@ -64,7 +64,7 @@
<xs:attributeGroup name="attlist.jpa-identity-store">
<xs:attribute name="entity-manager" type="components:string"/>
- <xs:attribute name="user-class" type="components:string"/>
+ <xs:attribute name="user-class" type="components:string" use="required"/>
<xs:attribute name="role-class" type="components:string"/>
<xs:attribute name="features" type="components:string"/>
</xs:attributeGroup>
16 years, 7 months