Skip to content

Instantly share code, notes, and snippets.

View mojavelinux's full-sized avatar

Dan Allen mojavelinux

View GitHub Profile
@mojavelinux
mojavelinux / ApplicationInitializer.java
Created October 21, 2010 04:53
A bridge between the ServletContext life cycle events and CDI observers (with example observer ApplicationInitializer)
// uncomment line if you want the instance to be retained in application scope
// @ApplicationScoped
public class ApplicationInitializer
{
public void onStartup(@Observes @Initialized ServletContext ctx)
{
System.out.println("Initialized web application at context path " + ctx.getContextPath());
}
}
@mojavelinux
mojavelinux / DisabledBean.java
Created October 21, 2010 23:28
Extension to allow a bean to be declaratively vetoed
@Veto
DisabledBean
{
}
@mojavelinux
mojavelinux / ConfigInfo.java
Created October 24, 2010 23:02
Example of using the resource producer from Seam Solder to inject descriptor instances
public class ConfigInfo
{
@Inject @Standard
private WebAppDescriptor webXml;
@Inject @Resource("WEB-INF/beans.xml")
private BeansDescriptor beansXml;
public int getFilterCount()
{
@mojavelinux
mojavelinux / CatchExceptionHandler.java
Created December 9, 2010 16:52
Catch JSF integration
import java.util.Iterator;
import javax.enterprise.inject.spi.BeanManager;
import javax.faces.FacesException;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerWrapper;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ExceptionQueuedEvent;
import org.jboss.seam.exception.control.ExceptionToCatch;
@mojavelinux
mojavelinux / FooMethodStackTraceFilter.java
Created December 9, 2010 21:31
Seam Catch exception stack trace filter API
public class FooMethodStackTraceFilter implements StackTraceFilter<StackTraceElement> {
public boolean discard(StackTraceElement element) {
return element.getMethodName().equals("foo");
}
}
@mojavelinux
mojavelinux / Consumer.java
Created December 21, 2010 18:25
Seam TransactionWorker API
public class Consumer
{
private static final String[] GAME_TITLES = {"Game 1", "Game 2"};
@Inject
private TransactionWorkExecutor txWorkExecutor;
public void insertRecords()
{
txWorkExecutor.execute(new VoidTransactionWorker()
<!-- An unmapped Servlet that is used to fire the post-startup application event in the init() method -->
<servlet>
<servlet-name>Servlet Event Bridge Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.event.ServletEventBridgeServlet</servlet-class>
<!-- Make load-on-startup large enough to be initialized last (thus destroyed first) -->
<load-on-startup>99999</load-on-startup>
</servlet>
@mojavelinux
mojavelinux / pom.xml
Created October 5, 2011 07:46
Arquillian Getting Started Guide - No Containers
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.arquillian.example</groupId>
<artifactId>arquillian-tutorial</artifactId>
@mojavelinux
mojavelinux / pom.xml
Created October 5, 2011 08:34
Arquillian Getting Started Guide - With Containers
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.arquillian.example</groupId>
<artifactId>arquillian-tutorial</artifactId>
@mojavelinux
mojavelinux / proposal.md
Created January 13, 2012 08:38
OSCON 2012 Proposal: Continuous Enterprise Development in Java

Submission Date: Jan 12, 2012

Proposed Title: Continuous Enterprise Development in Java

Summary:

Are you confident enough to push your application to production right now? Will it deploy? Integrate all the components? Keep the fail whale at bay? Confidence comes from tests. Real tests. Discover how to use Arquillian to develop tests that execute inside a container and gain confidence that keeps you developing, knowing your application will remain standing when faced with the real world.

Topics: