Skip to content

Commit

Permalink
Updated to latest changes in SE module
Browse files Browse the repository at this point in the history
  • Loading branch information
peteroyle authored and peteroyle committed Sep 24, 2009
1 parent 8b8d12b commit b3ed5db
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
Expand Up @@ -22,7 +22,6 @@

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import org.jboss.webbeans.environment.se.bindings.Parameters;

/**
Expand All @@ -34,20 +33,23 @@
public class CommandLineArgsValidator
{

@Inject
@Parameters
private List<String> validParams;
private List<String> errors = new ArrayList<String>();
@Inject
private @Parameters List<String> validParams;
private List<String> errors = new ArrayList<String>();

@Inject
public void checkParameters()
{
if (validParams.size() != 1)
{
errors.add("Please supply just one parameter: your first name");
validParams = Collections.EMPTY_LIST;
}
}
public CommandLineArgsValidator()
{
}

@Inject
public void checkParameters()
{
if (validParams.size() != 1)
{
errors.add( "Please supply just one parameter: your first name" );
validParams = Collections.EMPTY_LIST;
}
}

public boolean hasErrors()
{
Expand Down
Expand Up @@ -16,33 +16,39 @@
*/
package org.jboss.webbeans.environment.se.example.simple;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterDeploymentValidation;
import javax.inject.Inject;
import org.jboss.webbeans.environment.se.events.ContainerInitialized;
import javax.inject.Inject;

/**
* @author Peter Royle
*/
@ApplicationScoped
public class HelloWorld
{

@Inject
CommandLineArgsValidator argsVlidator;
@Inject
CommandLineArgsValidator argsValidator;

public HelloWorld()
{
}

/**
* Prints a hello message using the first name.
* @param firstName The first name.
*/
public void printHello( @Observes ContainerInitialized init )
{
if (!argsValidator.hasErrors())
{
System.out.println( "Hello " + argsValidator.getValidParameters().get( 0 ) );
} else
{
System.out.println( "Please provide just one argument: your first name" );
}
}

/**
* Prints a hello message using the first name.
*
* @param firstName The first name.
*/
public void printHello(@Observes AfterDeploymentValidation after)
{
if (!argsVlidator.hasErrors())
{
System.out.println("Hello " + argsVlidator.getValidParameters().get(0));
}
else
{
System.out.println("Please provide just one argument: your first name");
}
}
}

0 comments on commit b3ed5db

Please sign in to comment.