Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move from weld to seam, make match format of seam modules, add docume…
…ntation
- Loading branch information
Showing
38 changed files
with
1,623 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>seam-wicket-parent</artifactId> | ||
<groupId>org.jboss.seam.wicket</groupId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>seam-wicket-api</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
|
||
<packaging>jar</packaging> | ||
<name>Seam Wicket Module API</name> | ||
|
||
<build> | ||
<plugins> | ||
<!-- No tests in the api, skip phase --> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/seam/wicket.git</connection> | ||
<developerConnection>scm:git:git@github.com:seam/wicket.git</developerConnection> | ||
<url>http://github.com/seam/wicket</url> | ||
</scm> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.wicket</groupId> | ||
<artifactId>wicket</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-api</artifactId> | ||
<version>${weld.api.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-core</artifactId> | ||
<version>${weld.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-extensions</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>2.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
</project> |
87 changes: 87 additions & 0 deletions
87
api/src/main/java/org/jboss/seam/wicket/SeamApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
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.wicket.util.NonContextual; | ||
import org.jboss.weld.extensions.beanManager.BeanManagerAccessor; | ||
|
||
/** | ||
* 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 | ||
* 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 SeamApplication extends WebApplication | ||
{ | ||
|
||
private NonContextual<SeamComponentInstantiationListener> seamComponentInstantiationListener; | ||
private NonContextual<SeamWebRequestCycleProcessor> seamWebRequestCycleProcessor; | ||
|
||
/** | ||
*/ | ||
public SeamApplication() | ||
{ | ||
} | ||
|
||
/** | ||
* Add our component instantiation listener | ||
* | ||
* @see SeamComponentInstantiationListener | ||
*/ | ||
@Override | ||
protected void internalInit() | ||
{ | ||
super.internalInit(); | ||
BeanManager manager = BeanManagerAccessor.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 | ||
* | ||
* @see SeamRequestCycle | ||
*/ | ||
@Override | ||
public RequestCycle newRequestCycle(final Request request, final Response response) | ||
{ | ||
return new SeamRequestCycle(this, (WebRequest) request, (WebResponse) response); | ||
} | ||
} |
17 changes: 8 additions & 9 deletions
17
...t/WeldComponentInstantiationListener.java → ...t/SeamComponentInstantiationListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
package org.jboss.weld.wicket; | ||
package org.jboss.seam.wicket; | ||
|
||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.inject.Inject; | ||
|
||
import org.apache.wicket.Component; | ||
import org.apache.wicket.application.IComponentInstantiationListener; | ||
import org.jboss.weld.wicket.util.NonContextual; | ||
import org.jboss.seam.wicket.util.NonContextual; | ||
|
||
/** | ||
* This listener uses the BeanManager to handle injections for all wicket components. | ||
* | ||
* @author cpopetz | ||
* | ||
*/ | ||
public class WeldComponentInstantiationListener implements IComponentInstantiationListener | ||
public class SeamComponentInstantiationListener implements IComponentInstantiationListener | ||
{ | ||
|
||
@Inject | ||
private BeanManager manager; | ||
private BeanManager manager; | ||
|
||
public void onInstantiation(Component component) | ||
{ | ||
/* | ||
* The manager could be null in unit testing environments | ||
*/ | ||
if (manager != null) | ||
{ | ||
// TODO Cache the NonContextual! | ||
new NonContextual<Component>(manager, component.getClass()).existingInstance(component).inject(); | ||
} | ||
if (manager != null) { | ||
NonContextual.of(component.getClass(), manager) | ||
.existingInstance(component).inject(); | ||
} | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...a/org/jboss/weld/wicket/WeldMetaData.java → ...a/org/jboss/seam/wicket/SeamMetaData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.