Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
<artifactId>weld-core</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package org.jboss.seam.wicket;

import javax.enterprise.inject.spi.BeanManager;

import org.apache.wicket.Request;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebRequestCycle;
import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.request.IRequestCycleProcessor;
import org.jboss.seam.solder.beanManager.BeanManagerLocator;
import org.jboss.seam.wicket.util.NonContextual;

/**
* A convenience subclass of wicket's WebApplication which adds the hooks
* necessary to use JSR-299 injections in wicket components.
*
* If you have your own
* WebApplication subclass, and can't subclass this class, you just need to do
* the three things that this class does, i.e. register the
* SeamComponentInstantiationListener, and override the two methods below to
* return the RequestCycle and IRequestCycleProcessor subclasses specific to
* Seam, or your subclasses of those classes.
*
* @author cpopetz
* @author pmuir
* @author ivaynberg
* @see WebApplication
* @see SeamWebRequestCycleProcessor
* @see SeamRequestCycle
*/
public abstract class InjectingSeamApplication extends WebApplication {

private NonContextual<SeamComponentInstantiationListener> seamComponentInstantiationListener;
private NonContextual<WebRequestCycleProcessor> seamWebRequestCycleProcessor;


/**
* Add our component instantiation listener
*
* @see SeamComponentInstantiationListener
*/
@Override
protected void internalInit() {
super.internalInit();
BeanManager manager = new BeanManagerLocator().getBeanManager();
this.seamComponentInstantiationListener = NonContextual.of(SeamComponentInstantiationListener.class, manager);
this.seamWebRequestCycleProcessor = NonContextual.of(getWebRequestCycleProcessorClass(), manager);
addComponentInstantiationListener(seamComponentInstantiationListener.newInstance().produce().inject().get());
}

protected Class<? extends WebRequestCycleProcessor>
getWebRequestCycleProcessorClass() {
return WebRequestCycleProcessor.class;
}

/**
* Override to return our Seam-specific request cycle processor
*
* @see SeamWebRequestCycleProcessor
*/
@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return seamWebRequestCycleProcessor.newInstance().produce().inject().get();
}

/**
* Override to return our Seam-specific request cycle
*
* @see SeamRequestCycle
*/
@Override
public RequestCycle newRequestCycle(final Request request, final Response response) {
return new WebRequestCycle(this, (WebRequest) request, (WebResponse) response);
}
}
41 changes: 7 additions & 34 deletions impl/src/main/java/org/jboss/seam/wicket/SeamApplication.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package org.jboss.seam.wicket;

import javax.enterprise.inject.spi.BeanManager;

import org.apache.wicket.Request;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.request.IRequestCycleProcessor;
import org.jboss.seam.solder.beanManager.BeanManagerLocator;
import org.jboss.seam.wicket.util.NonContextual;

/**
* A convenience subclass of wicket's WebApplication which adds the hooks
* necessary to use JSR-299 injections in wicket components, as well as manage
* JSR-299 conversation scopes with Wicket page metadata. If you have your own
* A subclass of InjectingSeamApplication which adds management of
* JSR-299 conversation scopes with Wicket page metadata.
*
* If you have your own
* WebApplication subclass, and can't subclass this class, you just need to do
* the three things that this class does, i.e. register the
* SeamComponentInstantiationListener, and override the two methods below to
Expand All @@ -29,45 +26,21 @@
* @see SeamWebRequestCycleProcessor
* @see SeamRequestCycle
*/
public abstract class SeamApplication extends WebApplication {
public abstract class SeamApplication extends InjectingSeamApplication {

private NonContextual<SeamComponentInstantiationListener> seamComponentInstantiationListener;
private NonContextual<SeamWebRequestCycleProcessor> seamWebRequestCycleProcessor;


/**
*/
public SeamApplication() {
}

/**
* Add our component instantiation listener
*
* @see SeamComponentInstantiationListener
* @returns SeamWebRequestCycleProcessor
*/
@Override
protected void internalInit() {
super.internalInit();
BeanManager manager = new BeanManagerLocator().getBeanManager();
this.seamComponentInstantiationListener = NonContextual.of(SeamComponentInstantiationListener.class, manager);
this.seamWebRequestCycleProcessor = NonContextual.of(getWebRequestCycleProcessorClass(), manager);
addComponentInstantiationListener(seamComponentInstantiationListener.newInstance().produce().inject().get());
}

protected Class<? extends SeamWebRequestCycleProcessor>
getWebRequestCycleProcessorClass() {
return SeamWebRequestCycleProcessor.class;
}

/**
* Override to return our Seam-specific request cycle processor
*
* @see SeamWebRequestCycleProcessor
*/
@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return seamWebRequestCycleProcessor.newInstance().produce().inject().get();
}

/**
* Override to return our Seam-specific request cycle
*
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
<!-- FIXME scope should be in seam-parent -->
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<version>1.1.2-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down