Author: pete.muir(a)jboss.org
Date: 2008-02-05 12:37:10 -0500 (Tue, 05 Feb 2008)
New Revision: 7366
Added:
trunk/examples/wicket/resources/jboss-seam-wicket-booking-ds.xml
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/SimpleDataProvider.java
trunk/src/main/org/jboss/seam/web/FilterConfigWrapper.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/ioc/
trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedAttribute.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedField.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedMethod.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedProperty.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/InjectionInterceptor.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/Injector.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/Loggable.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModel.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModelUtils.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/Outjector.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/SeamInjectionListener.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketComponent.java
trunk/src/wicket/org/jboss/seam/wicket/web/
trunk/src/wicket/org/jboss/seam/wicket/web/WicketExceptionFilter.java
trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java
Removed:
trunk/examples/wicket/resources/jboss-seam-booking-ds.xml
trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java
trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java
trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java
trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java
trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java
trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java
trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java
trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java
trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java
trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java
trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java
trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java
trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java
trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java
trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java
trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java
Modified:
trunk/examples/wicket/build.xml
trunk/examples/wicket/resources/META-INF/application.xml
trunk/examples/wicket/resources/META-INF/jboss-app.xml
trunk/examples/wicket/resources/META-INF/persistence.xml
trunk/examples/wicket/resources/WEB-INF/components.xml
trunk/examples/wicket/resources/WEB-INF/web.xml
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java
trunk/src/main/org/jboss/seam/web-2.0.xsd
trunk/src/main/org/jboss/seam/web/Ajax4jsfFilter.java
trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java
trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java
Log:
Move lots of stuff, better filter integration
Modified: trunk/examples/wicket/build.xml
===================================================================
--- trunk/examples/wicket/build.xml 2008-02-05 12:07:18 UTC (rev 7365)
+++ trunk/examples/wicket/build.xml 2008-02-05 17:37:10 UTC (rev 7366)
@@ -4,7 +4,7 @@
<!-- Naming -->
<property name="Name" value="Port of Seam Booking
Example to use Wicket"/>
- <property name="example.name"
value="jboss-seam-wicket"/>
+ <property name="example.name"
value="jboss-seam-wicket-booking"/>
<property name="src.java.dir" value="src/action" />
<property name="src.web.dir" value="src/web" />
@@ -15,7 +15,7 @@
<property name="wicket-extensions.lib" value="yes" />
<!-- Datasource -->
- <property name="example.ds"
value="jboss-seam-wicket-ds.xml"/>
+ <property name="example.ds"
value="jboss-seam-wicket-booking-ds.xml"/>
<import file="../build.xml"/>
Modified: trunk/examples/wicket/resources/META-INF/application.xml
===================================================================
--- trunk/examples/wicket/resources/META-INF/application.xml 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/examples/wicket/resources/META-INF/application.xml 2008-02-05 17:37:10 UTC (rev
7366)
@@ -8,13 +8,13 @@
<module>
<web>
- <web-uri>jboss-seam-wicket.war</web-uri>
+ <web-uri>jboss-seam-wicket-booking.war</web-uri>
<context-root>/seam-wicket</context-root>
</web>
</module>
<module>
- <ejb>jboss-seam-wicket.jar</ejb>
+ <ejb>jboss-seam-wicket-booking.jar</ejb>
</module>
<module>
Modified: trunk/examples/wicket/resources/META-INF/jboss-app.xml
===================================================================
--- trunk/examples/wicket/resources/META-INF/jboss-app.xml 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/examples/wicket/resources/META-INF/jboss-app.xml 2008-02-05 17:37:10 UTC (rev
7366)
@@ -5,6 +5,6 @@
<jboss-app>
<loader-repository>
- seam.jboss.org:loader=seam-wicket
+ seam.jboss.org:loader=seam-wicket-booking
</loader-repository>
</jboss-app>
\ No newline at end of file
Modified: trunk/examples/wicket/resources/META-INF/persistence.xml
===================================================================
--- trunk/examples/wicket/resources/META-INF/persistence.xml 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/examples/wicket/resources/META-INF/persistence.xml 2008-02-05 17:37:10 UTC (rev
7366)
@@ -3,9 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
- <persistence-unit name="bookingDatabase">
+ <persistence-unit name="wicketDatabase">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
- <jta-data-source>java:/bookingDatasource</jta-data-source>
+ <jta-data-source>java:/wicketDatasource</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto"
value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
Modified: trunk/examples/wicket/resources/WEB-INF/components.xml
===================================================================
--- trunk/examples/wicket/resources/WEB-INF/components.xml 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/examples/wicket/resources/WEB-INF/components.xml 2008-02-05 17:37:10 UTC (rev
7366)
@@ -21,5 +21,8 @@
<transaction:ejb-transaction/>
<security:identity
authenticate-method="#{authenticator.authenticate}"/>
+
+ <!-- TODO Move this onto a wicekt namespace -->
+ <web:wicket-filter
application-class="org.jboss.seam.example.wicket.WicketBookingApplication"
/>
</components>
Modified: trunk/examples/wicket/resources/WEB-INF/web.xml
===================================================================
--- trunk/examples/wicket/resources/WEB-INF/web.xml 2008-02-05 12:07:18 UTC (rev 7365)
+++ trunk/examples/wicket/resources/WEB-INF/web.xml 2008-02-05 17:37:10 UTC (rev 7366)
@@ -32,24 +32,6 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
- <filter>
- <filter-name>wicket-booking</filter-name>
- <filter-class>
- org.apache.wicket.protocol.http.WicketFilter
- </filter-class>
- <init-param>
- <param-name>applicationClassName</param-name>
- <param-value>
- org.jboss.seam.example.wicket.WicketBookingApplication
- </param-value>
- </init-param>
- </filter>
-
- <filter-mapping>
- <filter-name>wicket-booking</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
<!-- JSF -->
<session-config>
Deleted: trunk/examples/wicket/resources/jboss-seam-booking-ds.xml
===================================================================
--- trunk/examples/wicket/resources/jboss-seam-booking-ds.xml 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/examples/wicket/resources/jboss-seam-booking-ds.xml 2008-02-05 17:37:10 UTC (rev
7366)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE datasources
- PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
- "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
-
-<datasources>
- <local-tx-datasource>
- <jndi-name>bookingDatasource</jndi-name>
- <connection-url>jdbc:hsqldb:.</connection-url>
- <driver-class>org.hsqldb.jdbcDriver</driver-class>
- <user-name>sa</user-name>
- <password></password>
- </local-tx-datasource>
-</datasources>
-
Copied: trunk/examples/wicket/resources/jboss-seam-wicket-booking-ds.xml (from rev 7364,
trunk/examples/wicket/resources/jboss-seam-booking-ds.xml)
===================================================================
--- trunk/examples/wicket/resources/jboss-seam-wicket-booking-ds.xml
(rev 0)
+++ trunk/examples/wicket/resources/jboss-seam-wicket-booking-ds.xml 2008-02-05 17:37:10
UTC (rev 7366)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE datasources
+ PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>wicketDatasource</jndi-name>
+ <connection-url>jdbc:hsqldb:.</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ </local-tx-datasource>
+</datasources>
+
Property changes on: trunk/examples/wicket/resources/jboss-seam-wicket-booking-ds.xml
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java 2008-02-05
12:07:18 UTC (rev 7365)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -43,7 +43,6 @@
import org.jboss.seam.example.wicket.action.BookingList;
import org.jboss.seam.example.wicket.action.Hotel;
import org.jboss.seam.example.wicket.action.HotelSearching;
-import org.jboss.seam.wicket.SimpleDataProvider;
@Restrict
public class Main extends WebPage
Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java 2008-02-05
12:07:18 UTC (rev 7365)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -55,22 +55,6 @@
setResponsePage(Home.class);
}
- @Override
- protected void onError()
- {
- super.onError();
- System.out.println("onError");
- System.out.println(username.getFeedbackMessage());
- }
-
}
- @Override
- protected void onBeforeRender()
- {
- super.onBeforeRender();
- System.out.println("onBeforeRender");
- System.out.println(username.getFeedbackMessage());
- }
-
}
Copied:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/SimpleDataProvider.java (from
rev 7364, trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java)
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/SimpleDataProvider.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/SimpleDataProvider.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -0,0 +1,22 @@
+package org.jboss.seam.example.wicket;
+
+import java.io.Serializable;
+
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+public abstract class SimpleDataProvider implements IDataProvider
+{
+
+ public IModel model(Object object)
+ {
+ return new Model((Serializable) object);
+ }
+
+ public void detach()
+ {
+ // No - op
+ }
+
+}
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-02-05
12:07:18 UTC (rev 7365)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -1,140 +1,24 @@
-/*
- * 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.Map;
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.Request;
-import org.apache.wicket.RequestCycle;
-import org.apache.wicket.RequestListenerInterface;
-import org.apache.wicket.Response;
-import org.apache.wicket.Session;
-import org.apache.wicket.markup.html.form.IFormSubmitListener;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
-import org.apache.wicket.protocol.http.WebSession;
-import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
-import org.apache.wicket.request.IRequestCodingStrategy;
-import org.apache.wicket.request.IRequestCycleProcessor;
-import org.apache.wicket.request.RequestParameters;
-import org.apache.wicket.request.target.component.IBookmarkablePageRequestTarget;
-import
org.apache.wicket.request.target.component.listener.IListenerInterfaceRequestTarget;
-import org.jboss.seam.core.Conversation;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.wicket.SeamAuthorizationStrategy;
-import org.jboss.seam.wicket.SeamSupport;
+import org.jboss.seam.wicket.SeamWebApplication;
+
/**
- * Test application for Wicket/ Seam/ Jetty.
+ * Port of Booking Application to Wicket
*/
-public class WicketBookingApplication extends WebApplication {
+public class WicketBookingApplication extends SeamWebApplication {
- /**
- * Constructor.
- */
- public WicketBookingApplication() {
- }
-
- /**
- * @see wicket.Application#getHomePage()
- */
- @SuppressWarnings("unchecked")
- public Class getHomePage() {
+ @Override
+ public Class getHomePage()
+ {
return Home.class;
}
- /**
- * Custom session with invalidation override. We can't just let Wicket
- * invalidate the session as Seam might have to do some cleaning up to do.
- */
- @Override
- public Session newSession(Request request, Response response) {
- return new WebSession(WicketBookingApplication.this, request) {
-
- @Override
- public void invalidate() {
- org.jboss.seam.web.Session.getInstance().invalidate();
- }
-
- @Override
- public void invalidateNow() {
- // sorry, can't support this with Seam
- org.jboss.seam.web.Session.getInstance().invalidate();
- }
- };
- }
+ @Override
+ protected Class getLoginPage()
+ {
+ return Home.class;
+ }
- @Override
- protected IRequestCycleProcessor newRequestCycleProcessor()
- {
- return new WebRequestCycleProcessor()
- {
- @Override
- protected IRequestCodingStrategy newRequestCodingStrategy()
- {
- return new WebRequestCodingStrategy()
- {
- @Override
- protected CharSequence encode(RequestCycle requestCycle, final
IListenerInterfaceRequestTarget requestTarget)
- {
- if
(IFormSubmitListener.INTERFACE.getName().equals(requestTarget.getRequestListenerInterface().getName()))
- {
- // TODO Do this nicely
- StringBuilder stringBuilder = new
StringBuilder(super.encode(requestCycle, requestTarget));
- if (Manager.instance().isReallyLongRunningConversation())
- {
- stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
- }
- return stringBuilder.subSequence(0, stringBuilder.length());
- }
- else
- {
- return super.encode(requestCycle, requestTarget);
- }
- }
-
- @Override
- protected CharSequence encode(RequestCycle requestCycle,
IBookmarkablePageRequestTarget requestTarget)
- {
- if (requestCycle.getRequest().getParameter("cid") != null)
- {
- // TODO Do this nicely
- StringBuilder stringBuilder = new
StringBuilder(super.encode(requestCycle, requestTarget));
- if (Manager.instance().isReallyLongRunningConversation())
- {
- stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
- }
- return stringBuilder.subSequence(0, stringBuilder.length());
-
- }
- return super.encode(requestCycle, requestTarget);
- }
-
- };
- }
- };
- }
-
- @Override
- protected void init() {
- super.init();
- SeamSupport.activate(this);
- getSecuritySettings().setAuthorizationStrategy(new
SeamAuthorizationStrategy(Home.class));
- }
-}
\ No newline at end of file
+}
Modified: trunk/src/main/org/jboss/seam/web/Ajax4jsfFilter.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/Ajax4jsfFilter.java 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/src/main/org/jboss/seam/web/Ajax4jsfFilter.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -4,14 +4,11 @@
import static org.jboss.seam.annotations.Install.BUILT_IN;
import java.io.IOException;
-import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@@ -23,7 +20,6 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.annotations.web.Filter;
-import org.jboss.seam.util.EnumerationEnumeration;
/**
* A Seam filter component wrapper for the Ajax4JSF.
@@ -126,50 +122,5 @@
{
this.log4jInitFile = log4jInitFile;
}
-
- private class FilterConfigWrapper implements FilterConfig
- {
-
- private FilterConfig delegate;
- private Map<String, String> parameters;
-
- public FilterConfigWrapper(FilterConfig filterConfig, Map<String, String>
parameters)
- {
- delegate = filterConfig;
- this.parameters = parameters;
- }
-
- public String getFilterName()
- {
- return delegate.getFilterName();
- }
-
- public String getInitParameter(String name)
- {
- if ( parameters.containsKey(name) )
- {
- return parameters.get(name);
- }
- else
- {
- return delegate.getInitParameter(name);
- }
- }
-
- public Enumeration getInitParameterNames()
- {
- Enumeration[] enumerations = {
- delegate.getInitParameterNames(),
- Collections.enumeration( parameters.keySet() )
- };
- return new EnumerationEnumeration(enumerations);
- }
-
- public ServletContext getServletContext()
- {
- return delegate.getServletContext();
- }
-
- }
}
Added: trunk/src/main/org/jboss/seam/web/FilterConfigWrapper.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/FilterConfigWrapper.java
(rev 0)
+++ trunk/src/main/org/jboss/seam/web/FilterConfigWrapper.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -0,0 +1,58 @@
+/**
+ *
+ */
+package org.jboss.seam.web;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+
+import org.jboss.seam.util.EnumerationEnumeration;
+
+public class FilterConfigWrapper implements FilterConfig
+{
+
+ private FilterConfig delegate;
+ private Map<String, String> parameters;
+
+ public FilterConfigWrapper(FilterConfig filterConfig, Map<String, String>
parameters)
+ {
+ delegate = filterConfig;
+ this.parameters = parameters;
+ }
+
+ public String getFilterName()
+ {
+ return delegate.getFilterName();
+ }
+
+ public String getInitParameter(String name)
+ {
+ if ( parameters.containsKey(name) )
+ {
+ return parameters.get(name);
+ }
+ else
+ {
+ return delegate.getInitParameter(name);
+ }
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ Enumeration[] enumerations = {
+ delegate.getInitParameterNames(),
+ Collections.enumeration( parameters.keySet() )
+ };
+ return new EnumerationEnumeration(enumerations);
+ }
+
+ public ServletContext getServletContext()
+ {
+ return delegate.getServletContext();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/src/main/org/jboss/seam/web/FilterConfigWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/main/org/jboss/seam/web/WicketFilter.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/WicketFilter.java (rev 0)
+++ trunk/src/main/org/jboss/seam/web/WicketFilter.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -0,0 +1,132 @@
+package org.jboss.seam.web;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.servlet.ContextualHttpServletRequest;
+
+@Scope(APPLICATION)
+(a)Name("org.jboss.seam.web.wicketFilter")
+@Install(precedence = BUILT_IN,
dependencies="org.jboss.seam.wicket.web.wicketFilterInstantiator")
+@BypassInterceptors
+(a)org.jboss.seam.annotations.web.Filter
+public class WicketFilter extends AbstractFilter
+{
+
+ private Filter delegate = null;
+
+ private String applicationClass;
+
+ private String applicationFactoryClass;
+
+ private boolean detectPortletContext;
+
+
+
+ public void doFilter(final ServletRequest servletRequest, final ServletResponse
servletResponse, final FilterChain chain) throws IOException, ServletException
+ {
+ if (delegate==null)
+ {
+ chain.doFilter(servletRequest, servletResponse);
+ }
+ else
+ {
+ new ContextualHttpServletRequest((HttpServletRequest) servletRequest)
+ {
+ @Override
+ public void process() throws Exception
+ {
+ delegate.doFilter(servletRequest, servletResponse, chain);
+ }
+
+ }.run();
+ }
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ super.init(filterConfig);
+
+ delegate = (javax.servlet.Filter)
Component.getInstance("org.jboss.seam.wicket.web.wicketFilterInstantiator",
ScopeType.STATELESS);
+
+ if (delegate!=null)
+ {
+ Map<String, String> parameters = new HashMap<String, String>();
+ if ( getApplicationClass() != null )
+ {
+ 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());
+ }
+ else
+ {
+ parameters.put("filterMappingUrlPattern", "/*");
+ }
+ if (getApplicationFactoryClass() != null)
+ {
+ parameters.put("applicationFactoryClassName",
getApplicationFactoryClass());
+ }
+ if (isDetectPortletContext())
+ {
+ parameters.put("detectPortletContext", "true");
+ }
+ delegate.init( new FilterConfigWrapper(filterConfig, parameters) );
+ }
+ }
+
+ public String getApplicationClass()
+ {
+ return applicationClass;
+ }
+
+ public void setApplicationClass(String applicationClassName)
+ {
+ this.applicationClass = applicationClassName;
+ }
+
+ public String getApplicationFactoryClass()
+ {
+ return applicationFactoryClass;
+ }
+
+ public void setApplicationFactoryClass(String applicationFactoryClass)
+ {
+ this.applicationFactoryClass = applicationFactoryClass;
+ }
+
+ public boolean isDetectPortletContext()
+ {
+ return detectPortletContext;
+ }
+
+ public void setDetectPortletContext(boolean detectPortletContext)
+ {
+ this.detectPortletContext = detectPortletContext;
+ }
+
+}
Property changes on: trunk/src/main/org/jboss/seam/web/WicketFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/main/org/jboss/seam/web-2.0.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/web-2.0.xsd 2008-02-05 12:07:18 UTC (rev 7365)
+++ trunk/src/main/org/jboss/seam/web-2.0.xsd 2008-02-05 17:37:10 UTC (rev 7366)
@@ -31,6 +31,14 @@
<xs:attributeGroup ref="components:attlist.component"/>
<xs:attributeGroup ref="web:attlist.filter"/>
</xs:complexType>
+ </xs:element>
+
+ <xs:element name="wicket-filter">
+ <xs:complexType mixed="true">
+ <xs:attributeGroup ref="components:attlist.component"/>
+ <xs:attributeGroup ref="web:attlist.filter"/>
+ <xs:attributeGroup ref="web:attlist.wicketFilter"/>
+ </xs:complexType>
</xs:element>
<xs:element name="character-encoding-filter">
@@ -71,9 +79,15 @@
<xs:attributeGroup name="attlist.filter">
<xs:attribute name="url-pattern" type="xs:string"/>
<xs:attribute name="regex-url-pattern"
type="xs:string"/>
- <xs:attribute name="disabled" type="xs:string"
default="false" />
+ <xs:attribute name="disabled" type="xs:boolean"
default="false" />
</xs:attributeGroup>
+ <xs:attributeGroup name="attlist.wicketFilter">
+ <xs:attribute name="application-class"
type="xs:string"/>
+ <xs:attribute name="application-factory-class"
type="xs:string"/>
+ <xs:attribute name="detect-portlet-context"
type="xs:boolean" default="false" />
+ </xs:attributeGroup>
+
<xs:attributeGroup name="attlist.multipartFilter">
<xs:attribute name="create-temp-files">
<xs:simpleType>
Deleted: trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,14 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-
-public interface BijectedAttribute<T extends Annotation>
-{
- public String getName();
- public T getAnnotation();
- public Class getType();
- public void set(Object bean, Object value);
- public Object get(Object bean);
- public MetaModel getMetaModel();
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -1,54 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-public class BijectedField<T extends Annotation> implements
BijectedAttribute<T>
- {
- private String name;
- private Field field;
- private T annotation;
- private MetaModel metaModel;
-
- public BijectedField(String name, Field field, T annotation, MetaModel metaModel)
- {
- this.name = name;
- this.field = field;
- this.annotation = annotation;
- this.metaModel = metaModel;
- }
- public String getName()
- {
- return name;
- }
- public Field getField()
- {
- return field;
- }
- public T getAnnotation()
- {
- return annotation;
- }
- public Class getType()
- {
- return field.getType();
- }
- public void set(Object bean, Object value)
- {
- metaModel.setFieldValue(bean, field, name, value);
- }
- public Object get(Object bean)
- {
- return metaModel.getFieldValue(bean, field, name);
- }
- @Override
- public String toString()
- {
- return "BijectedField(" + name + ')';
- }
-
- public MetaModel getMetaModel()
- {
- return metaModel;
- }
- }
\ No newline at end of file
Deleted: trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,53 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-public class BijectedMethod<T extends Annotation> implements
BijectedAttribute<T>
- {
- private String name;
- private Method method;
- private T annotation;
- private MetaModel metaModel;
-
- public BijectedMethod(String name, Method method, T annotation, MetaModel
metaModel)
- {
- this.name = name;
- this.method = method;
- this.annotation = annotation;
- }
- public String getName()
- {
- return name;
- }
- public Method getMethod()
- {
- return method;
- }
- public T getAnnotation()
- {
- return annotation;
- }
- public void set(Object bean, Object value)
- {
- metaModel.setPropertyValue(bean, method, name, value);
- }
- public Object get(Object bean)
- {
- return metaModel.getPropertyValue(bean, method, name);
- }
- public Class getType()
- {
- return method.getParameterTypes()[0];
- }
- @Override
- public String toString()
- {
- return "BijectedMethod(" + name + ')';
- }
-
- public MetaModel getMetaModel()
- {
- return metaModel;
- }
- }
\ No newline at end of file
Deleted: trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,66 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-import org.jboss.seam.util.Reflections;
-
-public class BijectedProperty<T extends Annotation> implements
BijectedAttribute<T>
- {
-
- private BijectedMethod<T> getter;
- private BijectedMethod<T> setter;
- private MetaModel metaModel;
-
- public BijectedProperty(String name, Method getter, Method setter, T annotation,
MetaModel metaModel)
- {
- this.getter = new BijectedMethod(name, getter, annotation, metaModel);
- this.setter = new BijectedMethod(name, setter, annotation, metaModel);
- }
-
- public BijectedProperty(String name, Method getter, T annotation, MetaModel
metaModel)
- {
- this.getter = new BijectedMethod(name, getter, annotation, metaModel);
- try
- {
- Method setterMethod = Reflections.getSetterMethod(getter.getDeclaringClass(),
name);
- this.setter = new BijectedMethod(name, setterMethod, annotation, metaModel);
- }
- catch (IllegalArgumentException e) {}
- }
-
- public Object get(Object bean)
- {
- return getter.get(bean);
- }
-
- public T getAnnotation()
- {
- return getter.getAnnotation();
- }
-
- public String getName()
- {
- return getter.getName();
- }
-
- public Class getType()
- {
- return getter.getType();
- }
-
- public void set(Object bean, Object value)
- {
- if (setter == null)
- {
- throw new IllegalArgumentException("Component must have a setter for
" + metaModel.getName());
- }
- setter.set(bean, value);
- }
-
- public MetaModel getMetaModel()
- {
- return metaModel;
- }
-
- }
\ No newline at end of file
Deleted: trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java 2008-02-05 12:07:18
UTC (rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java 2008-02-05 17:37:10
UTC (rev 7366)
@@ -1,112 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.ScopeType.STATELESS;
-import static org.jboss.seam.ScopeType.UNSPECIFIED;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.Namespace;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.core.Expressions;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.util.Reflections;
-
-import javassist.util.proxy.MethodHandler;
-
-public class InjectionInterceptor implements MethodHandler, Serializable
-{
-
- private String name;
- private In annotation;
- private String metaModelName;
- private transient MetaModel metaModel;
-
- public InjectionInterceptor(BijectedAttribute<In> in)
- {
- this.name = in.getName();
- this.annotation = in.getAnnotation();
- this.metaModelName = in.getMetaModel().getMetaModelName();
- }
-
- private static LogProvider log = Logging.getLogProvider(InjectionInterceptor.class);
-
- public Object invoke(final Object proxy, final Method method, final Method proceed,
final Object[] params) throws Throwable
- {
- return Reflections.invoke(method, getValueToInject(proxy), params);
- }
-
- private Object getValueToInject(Object bean)
- {
- if ( name.startsWith("#") )
- {
- if ( log.isDebugEnabled() )
- {
- log.trace("trying to inject with EL expression: " + name);
- }
- return Expressions.instance().createValueExpression(name).getValue();
- }
- else if ( annotation.scope()==UNSPECIFIED )
- {
- if ( log.isDebugEnabled() )
- {
- log.trace("trying to inject with hierarchical context search: " +
name);
- }
- return getInstanceInAllNamespaces(name, annotation.create());
- }
- else
- {
- if ( annotation.create() )
- {
- throw new IllegalArgumentException(
- "cannot combine create=true with explicit scope on @In: " +
- getMetaModel().getAttributeMessage(name)
- );
- }
- if ( annotation.scope()==STATELESS )
- {
- throw new IllegalArgumentException(
- "cannot specify explicit scope=STATELESS on @In: " +
- getMetaModel().getAttributeMessage(name)
- );
- }
-
-
- log.trace("trying to inject from specified context: " + name);
-
- if ( annotation.scope().isContextActive() )
- {
- return annotation.scope().getContext().get(name);
- }
- }
- return null;
- }
-
- private Object getInstanceInAllNamespaces(String name, boolean create)
- {
- Object result;
- result = Component.getInstance(name, create);
- if (result==null)
- {
- for ( Namespace namespace: Init.instance().getGlobalImports() )
- {
- result = namespace.getComponentInstance(name, create);
- if (result!=null) break;
- }
- }
- return result;
- }
-
- private MetaModel getMetaModel()
- {
- if (metaModel == null)
- {
- metaModel = MetaModel.forName(metaModelName);
- }
- return metaModel;
- }
-
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,91 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.wicket.MetaModelUtils.createProxyFactory;
-import static org.jboss.seam.wicket.MetaModelUtils.toName;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javassist.util.proxy.ProxyObject;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.Namespace;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.core.Init;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-
-
-public class InjectionSupport
-{
-
- // TODO Ouch
- private static final Map<Class, Class<ProxyObject>> proxyFactories = new
HashMap<Class, Class<ProxyObject>>();
-
- private LogProvider log = Logging.getLogProvider(InjectionSupport.class);
-
- private List<BijectedAttribute<In>> inAttributes = new
ArrayList<BijectedAttribute<In>>();
-
- private MetaModel metaModel;
-
- public InjectionSupport(MetaModel metaModel)
- {
- this.metaModel = metaModel;
- }
-
- public void add(Method method)
- {
- if ( method.isAnnotationPresent(In.class) )
- {
- In in = method.getAnnotation(In.class);
- String name = toName( in.value(), method );
- inAttributes.add( new BijectedMethod(name, method, in, metaModel) );
- }
- }
-
- public void add(Field field)
- {
- if ( field.isAnnotationPresent(In.class) )
- {
- In in = field.getAnnotation(In.class);
- String name = toName( in.value(), field );
- inAttributes.add( new BijectedField(name, field, in, metaModel) );
- }
- }
-
- public void inject(Object instance) throws Exception
- {
- for ( BijectedAttribute<In> in : inAttributes )
- {
- // Currently need a proxy here as Wicket has no native support for interceptors
- // TODO Replace this with a Seam ClientSide interceptor. Needs JBSEAM-699
- in.set( instance, wrap( instance, in ) );
- }
- }
-
- private static Object wrap(Object bean, BijectedAttribute<In> in) throws
Exception
- {
- ProxyObject proxy = getProxyFactory(in.getType()).newInstance();
- proxy.setHandler(new InjectionInterceptor(in));
- return proxy;
- }
-
- private static Class<ProxyObject> getProxyFactory(Class type)
- {
- if (proxyFactories.containsKey(type))
- {
- return proxyFactories.get(type);
- }
- else
- {
- Class<ProxyObject> factory = createProxyFactory( type );
- proxyFactories.put(type, factory);
- return factory;
- }
- }
-
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -1,58 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.seam.util.Reflections;
-
-// TODO Reimplement as Seam ClientSide Interceptor
-public class LoggerSupport
-{
-
- private List<Field> logFields = new ArrayList<Field>();
- private List<org.jboss.seam.log.Log> logInstances = new
ArrayList<org.jboss.seam.log.Log>();
-
- private MetaModel metaModel;
-
- public LoggerSupport(MetaModel metaModel)
- {
- this.metaModel = metaModel;
- }
-
- public void add(Field field)
- {
- if ( field.isAnnotationPresent(org.jboss.seam.annotations.Logger.class) )
- {
- String category =
field.getAnnotation(org.jboss.seam.annotations.Logger.class).value();
- org.jboss.seam.log.Log logInstance;
- if ( "".equals( category ) )
- {
- logInstance = org.jboss.seam.log.Logging.getLog(metaModel.getBeanClass());
- }
- else
- {
- logInstance = org.jboss.seam.log.Logging.getLog(category);
- }
- if ( Modifier.isStatic( field.getModifiers() ) )
- {
- Reflections.setAndWrap(field, null, logInstance);
- }
- else
- {
- logFields.add(field);
- logInstances.add(logInstance);
- }
- }
- }
-
- public void inject(Object instance) throws Exception
- {
- for (int i=0; i<logFields.size(); i++)
- {
- metaModel.setFieldValue( instance, logFields.get(i), "log",
logInstances.get(i) );
- }
- }
-
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -1,144 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.jboss.seam.Model;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.util.Reflections;
-
-public abstract class MetaModel extends Model
-{
-
- private InjectionSupport injectionSupport;
- private OutjectionSupport outjectionSupport;
- private LoggerSupport loggerSupport;
-
- public MetaModel(Class<?> beanClass)
- {
- super(beanClass);
- injectionSupport = new InjectionSupport(this);
- outjectionSupport = new OutjectionSupport(this);
- loggerSupport = new LoggerSupport(this);
- scan();
- }
-
- public void initialize()
- {
- scan();
- }
-
- public void inject(Object instance) throws Exception
- {
- injectionSupport.inject(instance);
- loggerSupport.inject(instance);
- }
-
- public void outject(Object instance)
- {
- outjectionSupport.outject(instance);
- }
-
- private void scan()
- {
- Class clazz = getBeanClass();
- for ( ; clazz!=Object.class; clazz = clazz.getSuperclass() )
- {
- for ( Method method: clazz.getDeclaredMethods() )
- {
- scanMethod(method);
- }
-
- for ( Field field: clazz.getDeclaredFields() )
- {
- scanField(field);
- }
- }
- }
-
- private void scanField(Field field)
- {
- if ( !field.isAccessible() )
- {
- field.setAccessible(true);
- }
- injectionSupport.add(field);
- loggerSupport.add(field);
- }
-
- private void scanMethod(Method method)
- {
- injectionSupport.add(method);
- }
-
- protected void setFieldValue(Object bean, Field field, String name, Object value)
- {
- try
- {
- Reflections.set(field, bean, value);
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not set field value: " +
getAttributeMessage(name), e);
- }
- }
-
- protected Object getFieldValue(Object bean, Field field, String name)
- {
- try {
- return Reflections.get(field, bean);
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not get field value: " +
getAttributeMessage(name), e);
- }
- }
-
- protected String getAttributeMessage(String attributeName)
- {
- return getName() + '.' + attributeName;
- }
-
- protected String getName()
- {
- return getBeanClass().getName();
- }
-
- protected abstract String getMetaModelName();
-
- protected void setPropertyValue(Object bean, Method method, String name, Object
value)
- {
- try
- {
- Reflections.invoke(method, bean, value );
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not set property value: " +
getAttributeMessage(name), e);
- }
- }
-
- public Object getPropertyValue(Object bean, Method method, String name)
- {
- try {
- return Reflections.invoke(method, bean);
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException("could not get property value: " +
getAttributeMessage(name), e);
- }
- }
-
- public static MetaModel forName(String name)
- {
- if (Contexts.isApplicationContextActive())
- {
- return (MetaModel) Contexts.getApplicationContext().get(name);
- }
- else
- {
- throw new IllegalStateException("Application context is not active");
- }
- }
-
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,48 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javassist.util.proxy.ProxyObject;
-
-import org.jboss.seam.util.ProxyFactory;
-
-public class MetaModelUtils
-{
-
- public static String toName(String name, Method method)
- {
- //TODO: does not handle "isFoo"
- if (name==null || name.length() == 0)
- {
- name = method.getName().substring(3, 4).toLowerCase()
- + method.getName().substring(4);
- }
- return name;
- }
-
- public static String toName(String name, Field field)
- {
- if (name==null || name.length() == 0)
- {
- name = field.getName();
- }
- return name;
- }
-
- public static Class<ProxyObject> createProxyFactory(final Class beanClass)
- {
- ProxyFactory factory = new ProxyFactory();
- if (beanClass.isInterface())
- {
- factory.setInterfaces(new Class[] {beanClass, Serializable.class});
- }
- else
- {
- factory.setSuperclass( beanClass );
- }
- return factory.createClass();
- }
-
-}
Modified: trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/ModelValidator.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -12,7 +12,7 @@
/**
*
- * An implementation of Hibernate Model Validation for Wicket
+ * Allows Hibernate Model Validation to be used in Wicket
*
* @author Pete Muir
*
@@ -23,18 +23,28 @@
private Class clazz;
private String property;
+ /**
+ * Create a ModelValidator which will validate the specified property
+ */
public ModelValidator(Class clazz, String property)
{
this.clazz = clazz;
this.property = property;
}
+ /**
+ * Create a model validator that will validate the property specified by the
+ * PropertyModel
+ */
public ModelValidator(PropertyModel propertyModel)
{
this.clazz = propertyModel.getTarget().getClass();
this.property = propertyModel.getPropertyExpression();
}
+ /**
+ * Do the validation, normally called by Wicket
+ */
public void validate(IValidatable validatable)
{
System.out.println("model validator " + property + " / " +
clazz);
Deleted: trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,94 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.ScopeType.STATELESS;
-import static org.jboss.seam.ScopeType.UNSPECIFIED;
-import static org.jboss.seam.wicket.MetaModelUtils.toName;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.seam.RequiredException;
-import org.jboss.seam.annotations.Out;
-
-
-public class OutjectionSupport
-{
-
- private List<BijectedAttribute<Out>> outAttributes = new
ArrayList<BijectedAttribute<Out>>();
-
- private MetaModel metaModel;
-
- public OutjectionSupport(MetaModel metaModel)
- {
- this.metaModel = metaModel;
- }
-
- public void add(Method method)
- {
- Out out = method.getAnnotation(Out.class);
- String name = toName( out.value(), method );
- outAttributes.add( new BijectedMethod(name, method, out, metaModel) );
- }
-
- public void add(Field field)
- {
- if ( field.isAnnotationPresent(Out.class) )
- {
- Out out = field.getAnnotation(Out.class);
- String name = toName( out.value(), field );
- outAttributes.add(new BijectedField(name, field, out, metaModel) );
- }
- }
-
- public void outject(Object instance)
- {
- for ( BijectedAttribute<Out> att: outAttributes )
- {
- outjectAttribute( att.getAnnotation(), att.getName(), instance,
att.get(instance) );
- }
- }
-
- private void outjectAttribute(Out out, String name, Object bean, Object value)
- {
-
- if (value==null && out.required())
- {
- throw new RequiredException(
- "@Out attribute requires non-null value: " +
- metaModel.getAttributeMessage(name)
- );
- }
- else
- {
- if ( out.scope()==UNSPECIFIED )
- {
- throw new IllegalArgumentException(
- "Must specify a scope to outject to: " +
- metaModel.getAttributeMessage(name)
- );
- }
- else if ( out.scope()==STATELESS )
- {
- throw new IllegalArgumentException(
- "cannot specify explicit scope=STATELESS on @Out: " +
- metaModel.getAttributeMessage(name)
- );
- }
-
- if ( out.scope().isContextActive() )
- {
- if (value==null)
- {
- out.scope().getContext().remove(name);
- }
- else
- {
- out.scope().getContext().set(name, value);
- }
- }
- }
- }
-
-}
Modified: trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java 2008-02-05
12:07:18 UTC (rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamAuthorizationStrategy.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -12,17 +12,23 @@
import org.jboss.seam.security.NotLoggedInException;
import org.jboss.seam.util.Strings;
+/**
+ * An authorization strategy for Wicket backed by Seam Security
+ *
+ * @author pmuir
+ *
+ */
public class SeamAuthorizationStrategy implements IAuthorizationStrategy
{
private LogProvider log = Logging.getLogProvider(SeamAuthorizationStrategy.class);
private Class loginPage;
-
- public SeamAuthorizationStrategy()
- {
- this(null);
- }
+ /**
+ * Create the strategy, specifying the page to use for login
+ *
+ * @param loginPage
+ */
public SeamAuthorizationStrategy(final Class loginPage)
{
this.loginPage = loginPage;
@@ -34,6 +40,11 @@
return isInstantiationAuthorized(component.getClass());
}
+ /**
+ * Check whether access is allowed to the given wicket component.
+ *
+ * Uses the @Restrict annotation to control access
+ */
public boolean isInstantiationAuthorized(Class componentClass)
{
Restrict restrict = (Restrict) componentClass.getAnnotation(Restrict.class);
Modified: trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamLink.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -7,6 +7,14 @@
import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Manager;
+/**
+ * A SeamLink is like a Wicket Link, but will propagate the conversation
+ *
+ * This will probably be replaced in the future
+ *
+ * @author pmuir
+ *
+ */
public abstract class SeamLink extends Link
{
Deleted: trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java 2008-02-05 12:07:18 UTC (rev
7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -1,65 +0,0 @@
-/*
- * 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.wicket;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.Component;
-import org.apache.wicket.application.IComponentInstantiationListener;
-
-/**
- * Main support class for letting Wicket work with Seam annotations. Active
- * support by calling {@link #activate(Application) the activate method}
- * preferably from your {@link Application#init() application's init method}.
- *
- * @author eelcohillenius
- * @author Pete Muir
- */
-// TODO handle outjection etc. Might need onAfterRender and may
-// onBeforeRender for that, in which case this class can implement the
-// appropriate interfaces and register itself as a listener for them.
-// TODO handle method level sometime. For starters, see if there is any example/
-// test case/ whatever in Seam first that shows off that kind of usage
-public class SeamSupport implements IComponentInstantiationListener {
-
- /**
- * Activate support for Seam annotations on components for the provided
- * application.
- *
- * @param application
- * The application to active support for
- */
- public static void activate(Application application) {
- SeamSupport listener = new SeamSupport();
- application.addComponentInstantiationListener(listener);
- }
-
- /**
- * @see
org.apache.wicket.application.IComponentInstantiationListener#onInstantiation(org.apache.wicket.Component)
- */
- public void onInstantiation(Component component)
- {
- WicketComponent wicketComponent = WicketComponent.forClass(component.getClass());
- try
- {
- wicketComponent.inject(component);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Added: trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -0,0 +1,141 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.Request;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.Response;
+import org.apache.wicket.Session;
+import org.apache.wicket.markup.html.form.IFormSubmitListener;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
+import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
+import org.apache.wicket.request.IRequestCodingStrategy;
+import org.apache.wicket.request.IRequestCycleProcessor;
+import org.apache.wicket.request.target.component.IBookmarkablePageRequestTarget;
+import
org.apache.wicket.request.target.component.listener.IListenerInterfaceRequestTarget;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.wicket.ioc.SeamInjectionListener;
+
+/**
+ * The base class for Seam Web Applications
+ *
+ * TODO Remove the need to extend this
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class SeamWebApplication extends WebApplication
+{
+
+ /**
+ * Custom session with invalidation override. We can't just let Wicket
+ * invalidate the session as Seam might have to do some cleaning up to do.
+ */
+ @Override
+ public Session newSession(Request request, Response response)
+ {
+ return new WebSession(request)
+ {
+
+ @Override
+ public void invalidate()
+ {
+ org.jboss.seam.web.Session.getInstance().invalidate();
+ }
+
+ @Override
+ public void invalidateNow()
+ {
+ // sorry, can't support this with Seam
+ org.jboss.seam.web.Session.getInstance().invalidate();
+ }
+ };
+ }
+
+ @Override
+ /**
+ * Seam's hooks into Wicket. Required for proper functioning
+ */
+ protected IRequestCycleProcessor newRequestCycleProcessor()
+ {
+ return new WebRequestCycleProcessor()
+ {
+ @Override
+ protected IRequestCodingStrategy newRequestCodingStrategy()
+ {
+ return new WebRequestCodingStrategy()
+ {
+ @Override
+ protected CharSequence encode(RequestCycle requestCycle, final
IListenerInterfaceRequestTarget requestTarget)
+ {
+ if
(IFormSubmitListener.INTERFACE.getName().equals(requestTarget.getRequestListenerInterface().getName()))
+ {
+ // TODO Do this nicely
+ StringBuilder stringBuilder = new
StringBuilder(super.encode(requestCycle, requestTarget));
+ if (Manager.instance().isReallyLongRunningConversation())
+ {
+ stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
+ }
+ return stringBuilder.subSequence(0, stringBuilder.length());
+ }
+ else
+ {
+ return super.encode(requestCycle, requestTarget);
+ }
+ }
+
+ @Override
+ protected CharSequence encode(RequestCycle requestCycle,
IBookmarkablePageRequestTarget requestTarget)
+ {
+ if (requestCycle.getRequest().getParameter("cid") != null)
+ {
+ // TODO Do this nicely
+ StringBuilder stringBuilder = new
StringBuilder(super.encode(requestCycle, requestTarget));
+ if (Manager.instance().isReallyLongRunningConversation())
+ {
+ stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
+ }
+ return stringBuilder.subSequence(0, stringBuilder.length());
+
+ }
+ return super.encode(requestCycle, requestTarget);
+ }
+
+ };
+ }
+ };
+ }
+
+ @Override
+ protected void init()
+ {
+ super.init();
+ inititializeSeamSecurity();
+ initializeSeamInjection();
+ }
+
+ /**
+ * Add Seam Security to the wicket app.
+ *
+ * This allows you to @Restrict your Wicket components. Override this method
+ * to apply a different scheme
+ *
+ */
+ protected void inititializeSeamSecurity()
+ {
+ getSecuritySettings().setAuthorizationStrategy(new
SeamAuthorizationStrategy(getLoginPage()));
+ }
+
+
+ /**
+ * Add Seam injection support to your app. Required for proper functioning
+ */
+ protected void initializeSeamInjection()
+ {
+ addComponentInstantiationListener(new SeamInjectionListener());
+ }
+
+ protected abstract Class getLoginPage();
+
+}
Property changes on: trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/SimpleDataProvider.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,22 +0,0 @@
-package org.jboss.seam.wicket;
-
-import java.io.Serializable;
-
-import org.apache.wicket.markup.repeater.data.IDataProvider;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-
-public abstract class SimpleDataProvider implements IDataProvider
-{
-
- public IModel model(Object object)
- {
- return new Model((Serializable) object);
- }
-
- public void detach()
- {
- // No - op
- }
-
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,47 +0,0 @@
-package org.jboss.seam.wicket;
-
-import org.jboss.seam.contexts.Contexts;
-
-public class WicketComponent extends MetaModel
-{
-
- public WicketComponent(Class<?> beanClass)
- {
- super(beanClass);
- }
-
- @Override
- protected String getMetaModelName()
- {
- return getComponentName(getBeanClass());
- }
-
- protected static String getComponentName(Class clazz)
- {
- return clazz.getName() + ".wicketComponent";
- }
-
- public static WicketComponent forClass(Class clazz)
- {
- if (Contexts.isApplicationContextActive())
- {
- String metaModelName = getComponentName(clazz);
- instantiate(metaModelName, clazz);
- return (WicketComponent) forName(metaModelName);
- }
- else
- {
- throw new IllegalStateException("Application context is not active");
- }
- }
-
- private static void instantiate(String componentName, Class clazz)
- {
- if (!Contexts.getApplicationContext().isSet(componentName))
- {
- WicketComponent component = new WicketComponent(clazz);
- Contexts.getApplicationContext().set(componentName, component);
- }
- }
-
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java 2008-02-05 12:07:18
UTC (rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java 2008-02-05 17:37:10
UTC (rev 7366)
@@ -1,44 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-import static org.jboss.seam.ScopeType.APPLICATION;
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.annotations.web.Filter;
-import org.jboss.seam.web.AbstractFilter;
-
-/**
- * Kill the redirect filter
- * @author
- */
-@Scope(APPLICATION)
-(a)Name("org.jboss.seam.web.exceptionFilter")
-@Install(precedence = FRAMEWORK,
classDependencies="org.apache.wicket.Application")
-@BypassInterceptors
-@Filter()
-public class WicketExceptionFilter extends AbstractFilter
-{
-
-
- @Override
- public boolean isDisabled()
- {
- return true;
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
- {
-
-
- }
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java 2008-02-05 12:07:18
UTC (rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java 2008-02-05 17:37:10
UTC (rev 7366)
@@ -1,43 +0,0 @@
-package org.jboss.seam.wicket;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-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.web.AbstractFilter;
-
-/**
- * Kill the redirect filter
- *
- * @author
- */
-@Scope(APPLICATION)
-(a)Name("org.jboss.seam.web.redirectFilter")
-@Install(precedence = FRAMEWORK,
classDependencies="org.apache.wicket.Application")
-@BypassInterceptors
-public class WicketRedirectFilter extends AbstractFilter
-{
-
-
- @Override
- public boolean isDisabled()
- {
- return true;
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
- {
-
-
- }
-}
Deleted: trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java 2008-02-05 12:07:18 UTC
(rev 7365)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketSeamFilter.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -1,163 +0,0 @@
-/*
- * 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.wicket;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.io.IOException;
-import java.util.Set;
-
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.protocol.http.WicketFilter;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.annotations.web.Filter;
-import org.jboss.seam.contexts.Context;
-import org.jboss.seam.contexts.ServletLifecycle;
-import org.jboss.seam.core.ConversationPropagation;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.servlet.ContextualHttpServletRequest;
-import org.jboss.seam.servlet.ServletRequestSessionMap;
-import org.jboss.seam.web.AbstractFilter;
-import org.jboss.seam.web.ServletContexts;
-
-/**
- * Seam component that delegates requests to the {@link WicketFilter} and sets
- * up and pulls down Seam {@link Context}s for the request.
- * <p>
- * Users do not have to install this filter, but instead just install
- * {@link WicketFilter} like they would normally do. This Seam component
- * automatically attaches to it.
- * </p>
- * <p>
- * The filter automatically picks up the {@link WebApplication} when there is
- * only one active for the web application this filter is configured for. If
- * there are multiple Wicket applications active in the web application, you'll
- * have to explicitly configure which one to use by providing filter init
- * parameter 'applicationName', which corresponds to the filter name of the
- * Wicket filter for the application you want to use this filter with.
- * </p>
- *
- * @author eelcohillenius
- */
-@Scope(APPLICATION)
-(a)Name("org.apache.wicket.seam.WicketSeamFilter")
-@Install(classDependencies = { "org.apache.wicket.protocol.http.WebApplication"
}, precedence = BUILT_IN)
-@BypassInterceptors
-@Filter()
-public class WicketSeamFilter extends AbstractFilter {
-
- private static final class WicketSeamFilterConfigurationException extends
- IllegalStateException {
- public WicketSeamFilterConfigurationException(String msg) {
- super(msg);
- }
- }
-
- private static final String APPLICATION_NONE = "<none>";
-
- private static LogProvider log = Logging.getLogProvider(WicketSeamFilter.class);
-
- private String applicationName = null;
-
- private WicketFilter delegate = null;
-
- /**
- * Construct.
- */
- public WicketSeamFilter() {
- }
-
- @SuppressWarnings("unchecked")
- public void doFilter(final ServletRequest servletRequest,
- final ServletResponse servletResponse, final FilterChain filterChain)
- throws IOException, ServletException {
-
- // Check for the Wicket filter (which might be initialized after this
- // filter, hence the lazy loading). Synchronization is not important.
- if (delegate == null && !APPLICATION_NONE.equals(applicationName)) {
-
- if (applicationName == null) {
- Set<String> applicationKeys = Application.getApplicationKeys();
- if (applicationKeys.size() > 1) {
- throw new WicketSeamFilterConfigurationException(
- "If you run this filter in the context of multiple Wicket "
- + "application instances (/ filters) you have to provide filer "
- + "init parameter 'applicationName' which should correspond to
"
- + "the filter name you want to use this filter with.");
- } else if (applicationKeys.size() == 0) {
- // no Wicket apps configured... set to special name
- applicationName = APPLICATION_NONE;
- } else {
- applicationName = applicationKeys.iterator().next();
- }
- }
- Application application = (!APPLICATION_NONE
- .equals(applicationName)) ? Application
- .get(applicationName) : null;
- if (application != null && !(application instanceof WebApplication)) {
- log
- .warn("This filter can only be used with Wicket WebApplications. Currently,
"
- + "it is configured to work with an application of type "
- + application.getClass().getName());
- applicationName = APPLICATION_NONE;
- filterChain.doFilter(servletRequest, servletResponse);
- return;
- }
-
- WebApplication webApplication = (WebApplication) application;
- if (webApplication == null) {
- log
- .warn("ignoring request: no Wicket web application instance found");
- applicationName = APPLICATION_NONE;
- filterChain.doFilter(servletRequest, servletResponse);
- return;
- }
-
- delegate = webApplication.getWicketFilter();
- }
-
- new ContextualHttpServletRequest((HttpServletRequest) servletRequest)
- {
- @Override
- public void process() throws Exception
- {
- delegate.doFilter(servletRequest, servletResponse, filterChain);
- }
-
- }.run();
- }
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- super.init(filterConfig);
- this.applicationName = filterConfig.getInitParameter("applicationName");
- }
-}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedAttribute.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/BijectedAttribute.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedAttribute.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedAttribute.java 2008-02-05 17:37:10
UTC (rev 7366)
@@ -0,0 +1,20 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * A bijected attribute (field or get/set pair)
+ * @author Pete Muir
+ *
+ *
+ * TODO Move into Seam core
+ */
+public interface BijectedAttribute<T extends Annotation>
+{
+ public String getName();
+ public T getAnnotation();
+ public Class getType();
+ public void set(Object bean, Object value);
+ public Object get(Object bean);
+ public MetaModel getMetaModel();
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedField.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/BijectedField.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedField.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedField.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -0,0 +1,59 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+/**
+ * Implementation of BijectedAttribute for a field
+ * @author Pete Muir
+ *
+ */
+public class BijectedField<T extends Annotation> implements
BijectedAttribute<T>
+ {
+ private String name;
+ private Field field;
+ private T annotation;
+ private MetaModel metaModel;
+
+ public BijectedField(String name, Field field, T annotation, MetaModel metaModel)
+ {
+ this.name = name;
+ this.field = field;
+ this.annotation = annotation;
+ this.metaModel = metaModel;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public Field getField()
+ {
+ return field;
+ }
+ public T getAnnotation()
+ {
+ return annotation;
+ }
+ public Class getType()
+ {
+ return field.getType();
+ }
+ public void set(Object bean, Object value)
+ {
+ metaModel.setFieldValue(bean, field, name, value);
+ }
+ public Object get(Object bean)
+ {
+ return metaModel.getFieldValue(bean, field, name);
+ }
+ @Override
+ public String toString()
+ {
+ return "BijectedField(" + name + ')';
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+ }
\ No newline at end of file
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedMethod.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/BijectedMethod.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedMethod.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedMethod.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -0,0 +1,58 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * Implementation of BijectedAttribute for a method
+ * @author Pete Muir
+ *
+ */
+public class BijectedMethod<T extends Annotation> implements
BijectedAttribute<T>
+ {
+ private String name;
+ private Method method;
+ private T annotation;
+ private MetaModel metaModel;
+
+ public BijectedMethod(String name, Method method, T annotation, MetaModel
metaModel)
+ {
+ this.name = name;
+ this.method = method;
+ this.annotation = annotation;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public Method getMethod()
+ {
+ return method;
+ }
+ public T getAnnotation()
+ {
+ return annotation;
+ }
+ public void set(Object bean, Object value)
+ {
+ metaModel.setPropertyValue(bean, method, name, value);
+ }
+ public Object get(Object bean)
+ {
+ return metaModel.getPropertyValue(bean, method, name);
+ }
+ public Class getType()
+ {
+ return method.getParameterTypes()[0];
+ }
+ @Override
+ public String toString()
+ {
+ return "BijectedMethod(" + name + ')';
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+ }
\ No newline at end of file
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedProperty.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/BijectedProperty.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedProperty.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/BijectedProperty.java 2008-02-05 17:37:10
UTC (rev 7366)
@@ -0,0 +1,71 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.util.Reflections;
+
+/**
+ * Implementation of BijectedAttribute for a pair of methods
+ * @author Pete Muir
+ *
+ */
+public class BijectedProperty<T extends Annotation> implements
BijectedAttribute<T>
+ {
+
+ private BijectedMethod<T> getter;
+ private BijectedMethod<T> setter;
+ private MetaModel metaModel;
+
+ public BijectedProperty(String name, Method getter, Method setter, T annotation,
MetaModel metaModel)
+ {
+ this.getter = new BijectedMethod(name, getter, annotation, metaModel);
+ this.setter = new BijectedMethod(name, setter, annotation, metaModel);
+ }
+
+ public BijectedProperty(String name, Method getter, T annotation, MetaModel
metaModel)
+ {
+ this.getter = new BijectedMethod(name, getter, annotation, metaModel);
+ try
+ {
+ Method setterMethod = Reflections.getSetterMethod(getter.getDeclaringClass(),
name);
+ this.setter = new BijectedMethod(name, setterMethod, annotation, metaModel);
+ }
+ catch (IllegalArgumentException e) {}
+ }
+
+ public Object get(Object bean)
+ {
+ return getter.get(bean);
+ }
+
+ public T getAnnotation()
+ {
+ return getter.getAnnotation();
+ }
+
+ public String getName()
+ {
+ return getter.getName();
+ }
+
+ public Class getType()
+ {
+ return getter.getType();
+ }
+
+ public void set(Object bean, Object value)
+ {
+ if (setter == null)
+ {
+ throw new IllegalArgumentException("Component must have a setter for
" + metaModel.getName());
+ }
+ setter.set(bean, value);
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+
+ }
\ No newline at end of file
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/InjectionInterceptor.java (from rev
7364, trunk/src/wicket/org/jboss/seam/wicket/InjectionInterceptor.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/InjectionInterceptor.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/InjectionInterceptor.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -0,0 +1,113 @@
+package org.jboss.seam.wicket.ioc;
+
+import static org.jboss.seam.ScopeType.STATELESS;
+import static org.jboss.seam.ScopeType.UNSPECIFIED;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.Namespace;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.core.Expressions;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.util.Reflections;
+
+import javassist.util.proxy.MethodHandler;
+
+// TODO Replace with a client side Seam interceptor
+public class InjectionInterceptor implements MethodHandler, Serializable
+{
+
+ private String name;
+ private In annotation;
+ private String metaModelName;
+ private transient MetaModel metaModel;
+
+ public InjectionInterceptor(BijectedAttribute<In> in)
+ {
+ this.name = in.getName();
+ this.annotation = in.getAnnotation();
+ this.metaModelName = in.getMetaModel().getMetaModelName();
+ }
+
+ private static LogProvider log = Logging.getLogProvider(InjectionInterceptor.class);
+
+ public Object invoke(final Object proxy, final Method method, final Method proceed,
final Object[] params) throws Throwable
+ {
+ return Reflections.invoke(method, getValueToInject(proxy), params);
+ }
+
+ private Object getValueToInject(Object bean)
+ {
+ if ( name.startsWith("#") )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.trace("trying to inject with EL expression: " + name);
+ }
+ return Expressions.instance().createValueExpression(name).getValue();
+ }
+ else if ( annotation.scope()==UNSPECIFIED )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.trace("trying to inject with hierarchical context search: " +
name);
+ }
+ return getInstanceInAllNamespaces(name, annotation.create());
+ }
+ else
+ {
+ if ( annotation.create() )
+ {
+ throw new IllegalArgumentException(
+ "cannot combine create=true with explicit scope on @In: " +
+ getMetaModel().getAttributeMessage(name)
+ );
+ }
+ if ( annotation.scope()==STATELESS )
+ {
+ throw new IllegalArgumentException(
+ "cannot specify explicit scope=STATELESS on @In: " +
+ getMetaModel().getAttributeMessage(name)
+ );
+ }
+
+
+ log.trace("trying to inject from specified context: " + name);
+
+ if ( annotation.scope().isContextActive() )
+ {
+ return annotation.scope().getContext().get(name);
+ }
+ }
+ return null;
+ }
+
+ private Object getInstanceInAllNamespaces(String name, boolean create)
+ {
+ Object result;
+ result = Component.getInstance(name, create);
+ if (result==null)
+ {
+ for ( Namespace namespace: Init.instance().getGlobalImports() )
+ {
+ result = namespace.getComponentInstance(name, create);
+ if (result!=null) break;
+ }
+ }
+ return result;
+ }
+
+ private MetaModel getMetaModel()
+ {
+ if (metaModel == null)
+ {
+ metaModel = MetaModel.forName(metaModelName);
+ }
+ return metaModel;
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/Injector.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/InjectionSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/Injector.java (rev
0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/Injector.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -0,0 +1,87 @@
+package org.jboss.seam.wicket.ioc;
+
+import static org.jboss.seam.wicket.ioc.MetaModelUtils.createProxyFactory;
+import static org.jboss.seam.wicket.ioc.MetaModelUtils.toName;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javassist.util.proxy.ProxyObject;
+
+import org.jboss.seam.annotations.In;
+
+/**
+ * Controls injection for a MetaModel
+ *
+ */
+public class Injector
+{
+
+ // TODO Ouch
+ private static final Map<Class, Class<ProxyObject>> proxyFactories = new
HashMap<Class, Class<ProxyObject>>();
+
+ private List<BijectedAttribute<In>> inAttributes = new
ArrayList<BijectedAttribute<In>>();
+
+ private MetaModel metaModel;
+
+ public Injector(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Method method)
+ {
+ if ( method.isAnnotationPresent(In.class) )
+ {
+ In in = method.getAnnotation(In.class);
+ String name = toName( in.value(), method );
+ inAttributes.add( new BijectedMethod(name, method, in, metaModel) );
+ }
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(In.class) )
+ {
+ In in = field.getAnnotation(In.class);
+ String name = toName( in.value(), field );
+ inAttributes.add( new BijectedField(name, field, in, metaModel) );
+ }
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ for ( BijectedAttribute<In> in : inAttributes )
+ {
+ // Currently need a proxy here as Wicket has no native support for interceptors
+ // TODO Replace this with a Seam ClientSide interceptor. Needs JBSEAM-699
+ in.set( instance, wrap( instance, in ) );
+ }
+ }
+
+ private static Object wrap(Object bean, BijectedAttribute<In> in) throws
Exception
+ {
+ ProxyObject proxy = getProxyFactory(in.getType()).newInstance();
+ proxy.setHandler(new InjectionInterceptor(in));
+ return proxy;
+ }
+
+ private static Class<ProxyObject> getProxyFactory(Class type)
+ {
+ if (proxyFactories.containsKey(type))
+ {
+ return proxyFactories.get(type);
+ }
+ else
+ {
+ Class<ProxyObject> factory = createProxyFactory( type );
+ proxyFactories.put(type, factory);
+ return factory;
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/Loggable.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/LoggerSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/Loggable.java (rev
0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/Loggable.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -0,0 +1,61 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.util.Reflections;
+
+/**
+ * Controls logging for a MetaModel
+ *
+ */
+public class Loggable
+{
+
+ private List<Field> logFields = new ArrayList<Field>();
+ private List<org.jboss.seam.log.Log> logInstances = new
ArrayList<org.jboss.seam.log.Log>();
+
+ private MetaModel metaModel;
+
+ public Loggable(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(org.jboss.seam.annotations.Logger.class) )
+ {
+ String category =
field.getAnnotation(org.jboss.seam.annotations.Logger.class).value();
+ org.jboss.seam.log.Log logInstance;
+ if ( "".equals( category ) )
+ {
+ logInstance = org.jboss.seam.log.Logging.getLog(metaModel.getBeanClass());
+ }
+ else
+ {
+ logInstance = org.jboss.seam.log.Logging.getLog(category);
+ }
+ if ( Modifier.isStatic( field.getModifiers() ) )
+ {
+ Reflections.setAndWrap(field, null, logInstance);
+ }
+ else
+ {
+ logFields.add(field);
+ logInstances.add(logInstance);
+ }
+ }
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ for (int i=0; i<logFields.size(); i++)
+ {
+ metaModel.setFieldValue( instance, logFields.get(i), "log",
logInstances.get(i) );
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModel.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/MetaModel.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModel.java (rev
0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModel.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -0,0 +1,149 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.Model;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.util.Reflections;
+
+/**
+ * MetaModel for a component
+ * @author pmuir
+ *
+ */
+public abstract class MetaModel extends Model
+{
+
+ private Injector injectionSupport;
+ private Outjector outjectionSupport;
+ private Loggable loggerSupport;
+
+ public MetaModel(Class<?> beanClass)
+ {
+ super(beanClass);
+ injectionSupport = new Injector(this);
+ outjectionSupport = new Outjector(this);
+ loggerSupport = new Loggable(this);
+ scan();
+ }
+
+ public void initialize()
+ {
+ scan();
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ injectionSupport.inject(instance);
+ loggerSupport.inject(instance);
+ }
+
+ public void outject(Object instance)
+ {
+ outjectionSupport.outject(instance);
+ }
+
+ private void scan()
+ {
+ Class clazz = getBeanClass();
+ for ( ; clazz!=Object.class; clazz = clazz.getSuperclass() )
+ {
+ for ( Method method: clazz.getDeclaredMethods() )
+ {
+ scanMethod(method);
+ }
+
+ for ( Field field: clazz.getDeclaredFields() )
+ {
+ scanField(field);
+ }
+ }
+ }
+
+ private void scanField(Field field)
+ {
+ if ( !field.isAccessible() )
+ {
+ field.setAccessible(true);
+ }
+ injectionSupport.add(field);
+ loggerSupport.add(field);
+ }
+
+ private void scanMethod(Method method)
+ {
+ injectionSupport.add(method);
+ }
+
+ protected void setFieldValue(Object bean, Field field, String name, Object value)
+ {
+ try
+ {
+ Reflections.set(field, bean, value);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not set field value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ protected Object getFieldValue(Object bean, Field field, String name)
+ {
+ try {
+ return Reflections.get(field, bean);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not get field value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ protected String getAttributeMessage(String attributeName)
+ {
+ return getName() + '.' + attributeName;
+ }
+
+ protected String getName()
+ {
+ return getBeanClass().getName();
+ }
+
+ protected abstract String getMetaModelName();
+
+ protected void setPropertyValue(Object bean, Method method, String name, Object
value)
+ {
+ try
+ {
+ Reflections.invoke(method, bean, value );
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not set property value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ public Object getPropertyValue(Object bean, Method method, String name)
+ {
+ try {
+ return Reflections.invoke(method, bean);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not get property value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ public static MetaModel forName(String name)
+ {
+ if (Contexts.isApplicationContextActive())
+ {
+ return (MetaModel) Contexts.getApplicationContext().get(name);
+ }
+ else
+ {
+ throw new IllegalStateException("Application context is not active");
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModelUtils.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/MetaModelUtils.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModelUtils.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/MetaModelUtils.java 2008-02-05 17:37:10 UTC
(rev 7366)
@@ -0,0 +1,53 @@
+package org.jboss.seam.wicket.ioc;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javassist.util.proxy.ProxyObject;
+
+import org.jboss.seam.util.ProxyFactory;
+
+/**
+ * Utilitilies relating to a MetaModel
+ * @author pmuir
+ *
+ */
+public class MetaModelUtils
+{
+
+ public static String toName(String name, Method method)
+ {
+ //TODO: does not handle "isFoo"
+ if (name==null || name.length() == 0)
+ {
+ name = method.getName().substring(3, 4).toLowerCase()
+ + method.getName().substring(4);
+ }
+ return name;
+ }
+
+ public static String toName(String name, Field field)
+ {
+ if (name==null || name.length() == 0)
+ {
+ name = field.getName();
+ }
+ return name;
+ }
+
+ public static Class<ProxyObject> createProxyFactory(final Class beanClass)
+ {
+ ProxyFactory factory = new ProxyFactory();
+ if (beanClass.isInterface())
+ {
+ factory.setInterfaces(new Class[] {beanClass, Serializable.class});
+ }
+ else
+ {
+ factory.setSuperclass( beanClass );
+ }
+ return factory.createClass();
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/Outjector.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/OutjectionSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/Outjector.java (rev
0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/Outjector.java 2008-02-05 17:37:10 UTC (rev
7366)
@@ -0,0 +1,94 @@
+package org.jboss.seam.wicket.ioc;
+
+import static org.jboss.seam.ScopeType.STATELESS;
+import static org.jboss.seam.ScopeType.UNSPECIFIED;
+import static org.jboss.seam.wicket.ioc.MetaModelUtils.toName;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.RequiredException;
+import org.jboss.seam.annotations.Out;
+
+
+public class Outjector
+{
+
+ private List<BijectedAttribute<Out>> outAttributes = new
ArrayList<BijectedAttribute<Out>>();
+
+ private MetaModel metaModel;
+
+ public Outjector(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Method method)
+ {
+ Out out = method.getAnnotation(Out.class);
+ String name = toName( out.value(), method );
+ outAttributes.add( new BijectedMethod(name, method, out, metaModel) );
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(Out.class) )
+ {
+ Out out = field.getAnnotation(Out.class);
+ String name = toName( out.value(), field );
+ outAttributes.add(new BijectedField(name, field, out, metaModel) );
+ }
+ }
+
+ public void outject(Object instance)
+ {
+ for ( BijectedAttribute<Out> att: outAttributes )
+ {
+ outjectAttribute( att.getAnnotation(), att.getName(), instance,
att.get(instance) );
+ }
+ }
+
+ private void outjectAttribute(Out out, String name, Object bean, Object value)
+ {
+
+ if (value==null && out.required())
+ {
+ throw new RequiredException(
+ "@Out attribute requires non-null value: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+ else
+ {
+ if ( out.scope()==UNSPECIFIED )
+ {
+ throw new IllegalArgumentException(
+ "Must specify a scope to outject to: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+ else if ( out.scope()==STATELESS )
+ {
+ throw new IllegalArgumentException(
+ "cannot specify explicit scope=STATELESS on @Out: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+
+ if ( out.scope().isContextActive() )
+ {
+ if (value==null)
+ {
+ out.scope().getContext().remove(name);
+ }
+ else
+ {
+ out.scope().getContext().set(name, value);
+ }
+ }
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/SeamInjectionListener.java (from rev
7364, trunk/src/wicket/org/jboss/seam/wicket/SeamSupport.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/SeamInjectionListener.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/SeamInjectionListener.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -0,0 +1,26 @@
+package org.jboss.seam.wicket.ioc;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.application.IComponentInstantiationListener;
+
+/**
+ * Repsonsible for injecting dynamic proxies into Wicket classes
+ *
+ * @author Pete Muir
+ */
+public class SeamInjectionListener implements IComponentInstantiationListener
+{
+
+ public void onInstantiation(Component component)
+ {
+ WicketComponent wicketComponent = WicketComponent.forClass(component.getClass());
+ try
+ {
+ wicketComponent.inject(component);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketComponent.java (from rev 7364,
trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketComponent.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/WicketComponent.java 2008-02-05 17:37:10
UTC (rev 7366)
@@ -0,0 +1,52 @@
+package org.jboss.seam.wicket.ioc;
+
+import org.jboss.seam.contexts.Contexts;
+
+/**
+ * MetaModel for Wicket components
+ * @author pmuir
+ *
+ */
+public class WicketComponent extends MetaModel
+{
+
+ public WicketComponent(Class<?> beanClass)
+ {
+ super(beanClass);
+ }
+
+ @Override
+ protected String getMetaModelName()
+ {
+ return getComponentName(getBeanClass());
+ }
+
+ protected static String getComponentName(Class clazz)
+ {
+ return clazz.getName() + ".wicketComponent";
+ }
+
+ public static WicketComponent forClass(Class clazz)
+ {
+ if (Contexts.isApplicationContextActive())
+ {
+ String metaModelName = getComponentName(clazz);
+ instantiate(metaModelName, clazz);
+ return (WicketComponent) forName(metaModelName);
+ }
+ else
+ {
+ throw new IllegalStateException("Application context is not active");
+ }
+ }
+
+ private static void instantiate(String componentName, Class clazz)
+ {
+ if (!Contexts.getApplicationContext().isSet(componentName))
+ {
+ WicketComponent component = new WicketComponent(clazz);
+ Contexts.getApplicationContext().set(componentName, component);
+ }
+ }
+
+}
Copied: trunk/src/wicket/org/jboss/seam/wicket/web/WicketExceptionFilter.java (from rev
7364, trunk/src/wicket/org/jboss/seam/wicket/WicketExceptionFilter.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/web/WicketExceptionFilter.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/web/WicketExceptionFilter.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -0,0 +1,45 @@
+package org.jboss.seam.wicket.web;
+
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.annotations.web.Filter;
+import org.jboss.seam.web.AbstractFilter;
+
+/**
+ * Disable the exception filter when using Wicket (as JSF is an EE library, we
+ * can't rely on classDependencies to disable it)
+ * @author
+ */
+@Scope(APPLICATION)
+(a)Name("org.jboss.seam.web.exceptionFilter")
+@Install(precedence = FRAMEWORK,
classDependencies="org.apache.wicket.Application")
+@BypassInterceptors
+@Filter()
+public class WicketExceptionFilter extends AbstractFilter
+{
+
+
+ @Override
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
+ {
+
+
+ }
+}
Property changes on:
trunk/src/wicket/org/jboss/seam/wicket/web/WicketExceptionFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.jboss.seam.wicket.web;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import javax.servlet.Filter;
+
+import org.apache.wicket.protocol.http.WicketFilter;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Unwrap;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+
+(a)Name("org.jboss.seam.wicket.web.wicketFilterInstantiator")
+@Install(precedence = BUILT_IN,
classDependencies={"org.apache.wicket.Application"})
+@BypassInterceptors
+(a)Scope(ScopeType.STATELESS)
+public class WicketFilterInstantiator
+{
+
+ @Unwrap
+ public Filter unrwap()
+ {
+ return new WicketFilter();
+ }
+
+}
Property changes on:
trunk/src/wicket/org/jboss/seam/wicket/web/WicketFilterInstantiator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java (from rev
7364, trunk/src/wicket/org/jboss/seam/wicket/WicketRedirectFilter.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java 2008-02-05
17:37:10 UTC (rev 7366)
@@ -0,0 +1,44 @@
+package org.jboss.seam.wicket.web;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+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.web.AbstractFilter;
+
+/**
+ * Disable the redirect filter when using Wicket (as JSF is an EE library, we
+ * can't rely on classDependencies to disable it)
+ *
+ * @author
+ */
+@Scope(APPLICATION)
+(a)Name("org.jboss.seam.web.redirectFilter")
+@Install(precedence = FRAMEWORK,
classDependencies="org.apache.wicket.Application")
+@BypassInterceptors
+public class WicketRedirectFilter extends AbstractFilter
+{
+
+
+ @Override
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
+ {
+
+
+ }
+}