Author: dallen6
Date: 2009-03-18 12:53:17 -0400 (Wed, 18 Mar 2009)
New Revision: 2092
Added:
extensions/trunk/logger/
extensions/trunk/logger/.settings/
extensions/trunk/logger/.settings/org.maven.ide.eclipse.prefs
extensions/trunk/logger/pom.xml
extensions/trunk/logger/src/
extensions/trunk/logger/src/main/
extensions/trunk/logger/src/main/java/
extensions/trunk/logger/src/main/java/org/
extensions/trunk/logger/src/main/java/org/jboss/
extensions/trunk/logger/src/main/java/org/jboss/webbeans/
extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/
extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java
extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/
extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java
extensions/trunk/logger/src/test/
extensions/trunk/logger/src/test/java/
extensions/trunk/logger/src/test/java/org/
extensions/trunk/logger/src/test/java/org/jboss/
extensions/trunk/logger/src/test/java/org/jboss/webbeans/
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/AbstractLogTest.java
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/StandaloneContainersImpl.java
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Sparrow.java
extensions/trunk/logger/src/test/resources/
extensions/trunk/logger/src/test/resources/META-INF/
extensions/trunk/logger/src/test/resources/META-INF/web-beans-tck.properties
extensions/trunk/logger/src/test/resources/jndi.properties
extensions/trunk/logger/src/test/resources/org/
extensions/trunk/logger/src/test/resources/org/jboss/
extensions/trunk/logger/src/test/resources/org/jboss/testharness/
extensions/trunk/logger/src/test/resources/org/jboss/testharness/impl/
extensions/trunk/logger/src/test/resources/org/jboss/testharness/impl/packaging/
extensions/trunk/logger/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/
extensions/trunk/logger/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/
extensions/trunk/logger/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
Log:
New logger project that provides new binding type @Logger
Property changes on: extensions/trunk/logger
___________________________________________________________________
Name: svn:ignore
+ target
.project
.classpath
temp-testng-customsuite.xml
Added: extensions/trunk/logger/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- extensions/trunk/logger/.settings/org.maven.ide.eclipse.prefs
(rev 0)
+++ extensions/trunk/logger/.settings/org.maven.ide.eclipse.prefs 2009-03-18 16:53:17 UTC
(rev 2092)
@@ -0,0 +1,8 @@
+#Wed Mar 18 12:02:59 CET 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+version=1
Property changes on: extensions/trunk/logger/.settings/org.maven.ide.eclipse.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logger/pom.xml
===================================================================
--- extensions/trunk/logger/pom.xml (rev 0)
+++ extensions/trunk/logger/pom.xml 2009-03-18 16:53:17 UTC (rev 2092)
@@ -0,0 +1,75 @@
+<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">
+ <parent>
+ <artifactId>webbeans-parent</artifactId>
+ <groupId>org.jboss.webbeans</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-logger</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>Web Beans Injectable Logger</name>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>jsr299-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-jboss-as-5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jbossws</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-transaction-api</artifactId>
+ <groupId>org.jboss.javaee</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jboss-jaxrpc</artifactId>
+ <groupId>jboss.jbossws</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ </build>
+
+</project>
Property changes on: extensions/trunk/logger/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java
===================================================================
--- extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java
(rev 0)
+++
extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java 2009-03-18
16:53:17 UTC (rev 2092)
@@ -0,0 +1,27 @@
+package org.jboss.webbeans.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+/**
+ * Injects a log
+ *
+ * @author Gavin King
+ */
+@Target(FIELD)
+@Retention(RUNTIME)
+@Documented
+@BindingType
+public @interface Logger
+{
+ /**
+ * @return the log category
+ */
+ String value() default "";
+}
Property changes on:
extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java
===================================================================
--- extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java
(rev 0)
+++
extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java 2009-03-18
16:53:17 UTC (rev 2092)
@@ -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.producer;
+
+import javax.context.ApplicationScoped;
+import javax.inject.Current;
+import javax.inject.DefinitionException;
+import javax.inject.Produces;
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.annotation.Logger;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * The <code>LoggerProducer</code> provides a producer method for all
+ * @Logger annotated log objects. Each logger is application scoped
+ * since the logger applies to the class, not each instance of the
+ * class.
+ *
+ * @author David Allen
+ *
+ */
+public class LoggerProducer
+{
+ @Produces @ApplicationScoped
+ public Log produceLog(@Current InjectionPoint injectionPoint)
+ {
+ Log log = null;
+ String category = null;
+ if (injectionPoint.getType().equals(Log.class))
+ {
+ throw new DefinitionException("Cannot use @Logger on any type other than
org.jboss.webbeans.log.Log: " + injectionPoint);
+ }
+ category = injectionPoint.getAnnotation(Logger.class).value();
+ if (category == null)
+ {
+ log = Logging.getLog((Class<?>)
injectionPoint.getMember().getDeclaringClass());
+ }
+ else
+ {
+ log = Logging.getLog(category);
+ }
+ return log;
+ }
+}
Property changes on:
extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/AbstractLogTest.java
===================================================================
--- extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/AbstractLogTest.java
(rev 0)
+++
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/AbstractLogTest.java 2009-03-18
16:53:17 UTC (rev 2092)
@@ -0,0 +1,66 @@
+/*
+ * 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.test;
+
+import org.jboss.testharness.AbstractTest;
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
+import org.testng.ITestContext;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+
+/**
+ * Some basic abstractions useful for tests in this project.
+ *
+ * @author David Allen
+ *
+ */
+public abstract class AbstractLogTest extends AbstractTest
+{
+ private ManagerImpl manager;
+
+ @Override
+ @BeforeSuite
+ public void beforeSuite(ITestContext context) throws Exception
+ {
+ if (!isInContainer())
+ {
+ getCurrentConfiguration().setStandaloneContainers(new
StandaloneContainersImpl());
+
getCurrentConfiguration().getExtraPackages().add(AbstractLogTest.class.getPackage().getName());
+ }
+ super.beforeSuite(context);
+ }
+
+ @BeforeMethod
+ public void before() throws Exception
+ {
+ this.manager = CurrentManager.rootManager();
+ }
+
+ @AfterMethod
+ public void after() throws Exception
+ {
+ manager = null;
+ }
+
+ public ManagerImpl getCurrentManager()
+ {
+ return manager;
+ }
+}
Property changes on:
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/AbstractLogTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/StandaloneContainersImpl.java
(from rev 2086,
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/StandaloneContainersImpl.java)
===================================================================
---
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/StandaloneContainersImpl.java
(rev 0)
+++
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/StandaloneContainersImpl.java 2009-03-18
16:53:17 UTC (rev 2092)
@@ -0,0 +1,78 @@
+package org.jboss.webbeans.test;
+
+import java.net.URL;
+
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.testharness.spi.StandaloneContainers;
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.mock.MockServletLifecycle;
+import org.jboss.webbeans.mock.MockWebBeanDiscovery;
+
+public class StandaloneContainersImpl implements StandaloneContainers
+{
+
+ // TODO this is a hack ;-)
+ public static Class<? extends MockServletLifecycle> lifecycleClass =
MockEELifecycle.class;
+
+ private MockServletLifecycle lifecycle;
+
+ public void deploy(Iterable<Class<?>> classes, Iterable<URL>
beansXml) throws DeploymentException
+ {
+ try
+ {
+ this.lifecycle = lifecycleClass.newInstance();
+ }
+ catch (InstantiationException e1)
+ {
+ throw new DeploymentException("Error instantiating lifeycle", e1);
+ }
+ catch (IllegalAccessException e1)
+ {
+ throw new DeploymentException("Error instantiating lifeycle", e1);
+ }
+ lifecycle.initialize();
+ try
+ {
+ MockWebBeanDiscovery discovery = lifecycle.getWebBeanDiscovery();
+ discovery.setWebBeanClasses(classes);
+ if (beansXml != null)
+ {
+ discovery.setWebBeansXmlFiles(beansXml);
+ }
+ lifecycle.beginApplication();
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Error deploying beans", e);
+ }
+ lifecycle.beginSession();
+ lifecycle.beginRequest();
+ }
+
+ public void deploy(Iterable<Class<?>> classes) throws DeploymentException
+ {
+ deploy(classes, null);
+ }
+
+ public void cleanup()
+ {
+ // Np-op
+
+ }
+
+ public void setup()
+ {
+ // No-op
+ }
+
+ public void undeploy()
+ {
+ lifecycle.endRequest();
+ lifecycle.endSession();
+ lifecycle.endApplication();
+ CurrentManager.setRootManager(null);
+ lifecycle = null;
+ }
+
+}
Added:
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java
===================================================================
---
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java
(rev 0)
+++
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java 2009-03-18
16:53:17 UTC (rev 2092)
@@ -0,0 +1,39 @@
+/*
+ * 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.test.log;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.webbeans.test.AbstractLogTest;
+import org.testng.annotations.Test;
+
+/**
+ * All the tests related to the @Logger binding type and injection.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+public class LoggerInjectionTest extends AbstractLogTest
+{
+ @Test( groups = { "broken" } )
+ public void testBasicLogInjection()
+ {
+ Sparrow bird = getCurrentManager().getInstanceByType(Sparrow.class);
+ bird.generateLogMessage();
+ }
+}
Property changes on:
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Sparrow.java
===================================================================
--- extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Sparrow.java
(rev 0)
+++
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Sparrow.java 2009-03-18
16:53:17 UTC (rev 2092)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.test.log;
+
+import org.jboss.webbeans.annotation.Logger;
+import org.jboss.webbeans.log.Log;
+
+class Sparrow
+{
+ @Logger
+ private Log log;
+
+ public void generateLogMessage()
+ {
+ log.info("A test message");
+ }
+}
Property changes on:
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Sparrow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logger/src/test/resources/META-INF/web-beans-tck.properties
===================================================================
--- extensions/trunk/logger/src/test/resources/META-INF/web-beans-tck.properties
(rev 0)
+++
extensions/trunk/logger/src/test/resources/META-INF/web-beans-tck.properties 2009-03-18
16:53:17 UTC (rev 2092)
@@ -0,0 +1,3 @@
+org.jboss.testharness.spi.StandaloneContainers=org.jboss.webbeans.test.StandaloneContainersImpl
+org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.servlet.ServletTestLauncher
+org.jboss.testharness.testPackage=org.jboss.webbeans.test
\ No newline at end of file
Property changes on:
extensions/trunk/logger/src/test/resources/META-INF/web-beans-tck.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logger/src/test/resources/jndi.properties
===================================================================
--- extensions/trunk/logger/src/test/resources/jndi.properties
(rev 0)
+++ extensions/trunk/logger/src/test/resources/jndi.properties 2009-03-18 16:53:17 UTC
(rev 2092)
@@ -0,0 +1,4 @@
+#jboss JNDI properties
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
\ No newline at end of file
Property changes on: extensions/trunk/logger/src/test/resources/jndi.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
extensions/trunk/logger/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
===================================================================
Property changes on:
extensions/trunk/logger/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain