Skip to content

Commit

Permalink
move from weld to seam, make match format of seam modules, add docume…
Browse files Browse the repository at this point in the history
…ntation
  • Loading branch information
cpopetz committed Nov 23, 2010
1 parent 774a5ac commit ab97052
Show file tree
Hide file tree
Showing 38 changed files with 1,623 additions and 316 deletions.
74 changes: 74 additions & 0 deletions api/pom.xml
@@ -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 api/src/main/java/org/jboss/seam/wicket/SeamApplication.java
@@ -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);
}
}
@@ -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();
}
}
}
@@ -1,15 +1,15 @@
package org.jboss.weld.wicket;
package org.jboss.seam.wicket;

import org.apache.wicket.MetaDataKey;

/**
* Public storage for the metadata key used by the Weld integration to store
* Public storage for the metadata key used by the Seam integration to store
* conversation ids in wicket page metadata.
*
* @author cpopetz
*
*/
public class WeldMetaData
public class SeamMetaData
{

/**
Expand Down

0 comments on commit ab97052

Please sign in to comment.