Skip to content

Commit

Permalink
initial checkin of webbeans se module, hello world example
Browse files Browse the repository at this point in the history
  • Loading branch information
peteroyle authored and peteroyle committed Feb 24, 2009
1 parent 09f8b8c commit 5fa53fe
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 0 deletions.
57 changes: 57 additions & 0 deletions se/hello-world/nbactions.xml
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
JBoss, Home of Professional Open Source
Copyright 2008, Red Hat Middleware LLC, and individual contributors
by the @authors tag. See the copyright.txt in the distribution for a
full listing of individual contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--><actions>
<action>
<actionName>run</actionName>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath org.jboss.webbeans.environment.se.StartMain Possums</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.1:exec</goal>
</goals>
<properties>
<exec.args>-Xdebug -Djava.compiler=none -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.jboss.webbeans.environment.se.StartMain Possums</exec.args>
<jpda.listen>true</jpda.listen>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>CUSTOM-Jalopy Format</actionName>
<displayName>Jalopy Format</displayName>
<goals>
<goal>jalopy:format</goal>
</goals>
</action>
<action>
<actionName>CUSTOM-License Format</actionName>
<displayName>License Format</displayName>
<goals>
<goal>license:format</goal>
</goals>
</action>
</actions>
103 changes: 103 additions & 0 deletions se/hello-world/pom.xml
@@ -0,0 +1,103 @@
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.webbeans</groupId>
<artifactId>hello-world-se</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Hello World SE</name>
<url>http://maven.apache.org</url>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jalopy-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<!-- This wipes out UNDO in IDEs. Run manually instead.
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
-->
</plugin>
<plugin>
<groupId>com.google.code.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<basedir>${basedir}</basedir>
<header>${basedir}/src/etc/header.txt</header>
<quiet>false</quiet>
<failIfMissing>true</failIfMissing>
<aggregate>false</aggregate>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>repository.jboss.org</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2</url>
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots.jboss.org</id>
<name>JBoss Snapshots Repository</name>
<url>http://snapshots.jboss.org/maven2</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>repository.codehaus.org</id>
<name>Codehaus Repository</name>
<url>http://repository.codehaus.org</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>se-module</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
14 changes: 14 additions & 0 deletions se/hello-world/src/etc/header.txt
@@ -0,0 +1,14 @@
JBoss, Home of Professional Open Source
Copyright 2008, Red Hat Middleware LLC, and individual contributors
by the @authors tag. See the copyright.txt in the distribution for a
full listing of individual contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -0,0 +1,61 @@
/**
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.webbeans.environment.se.example.simple;

import java.util.ArrayList;
import java.util.List;
import javax.context.ApplicationScoped;
import javax.inject.Current;
import javax.inject.Initializer;
import org.jboss.webbeans.environment.se.bindings.Parameters;

/**
* Validates command line arguments, producing errors where applicable.
* @author Peter Royle
*/
@ApplicationScoped
public class CommandLineArgsValidator
{

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

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

public boolean hasErrors()
{
return !this.errors.isEmpty();
}

public List<String> getErrors()
{
return errors;
}

public List<String> getValidParameters()
{
return validParams;
}
}
@@ -0,0 +1,48 @@
/**
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.webbeans.environment.se.example.simple;

import javax.event.Observes;
import javax.inject.Current;
import javax.inject.manager.Deployed;
import javax.inject.manager.Manager;

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

@Current
CommandLineArgsValidator argsVlidator;

/**
* Prints a hello message using the first name.
* @param firstName The first name.
*/
public void printHello( @Observes
@Deployed Manager manager )
{
if (!argsVlidator.hasErrors())
{
System.out.println( "Hello " + argsVlidator.getValidParameters().get( 0 ) );
} else
{
System.out.println( "Please provide just one argument: your first name" );
}
}
}
19 changes: 19 additions & 0 deletions se/hello-world/src/main/resources/beans.xml
@@ -0,0 +1,19 @@
<!--
JBoss, Home of Professional Open Source
Copyright 2008, Red Hat Middleware LLC, and individual contributors
by the @authors tag. See the copyright.txt in the distribution for a
full listing of individual contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans></beans>
25 changes: 25 additions & 0 deletions se/hello-world/src/main/resources/log4j.properties
@@ -0,0 +1,25 @@
#
# JBoss, Home of Professional Open Source
# Copyright 2008, Red Hat Middleware LLC, and individual contributors
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=WARN, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
@@ -0,0 +1,54 @@
/**
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.screamingcoder.plebeians.example.helloworld;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite( )
{
return new TestSuite( AppTest.class );
}

/**
* Rigourous Test :-)
*/
public void testApp( )
{
assertTrue( true );
}
}

0 comments on commit 5fa53fe

Please sign in to comment.