[jboss-cvs] JBossAS SVN: r65657 - in projects/metadata/trunk/src: test/java/org/jboss/test/metadata/annotation/ejb3 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 27 07:05:19 EDT 2007


Author: wolfc
Date: 2007-09-27 07:05:19 -0400 (Thu, 27 Sep 2007)
New Revision: 65657

Added:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyApplicationException.java
   projects/metadata/trunk/src/test/resources/log4j.xml
Removed:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java
Modified:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java
Log:
More annotation translation

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java	2007-09-27 10:25:53 UTC (rev 65656)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractEnterpriseBeanProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -22,6 +22,8 @@
 package org.jboss.metadata.annotation.creator;
 
 import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -41,6 +43,8 @@
    protected abstract MD create(Class<?> beanClass);
    
    protected final List<Processor<MD, Class<?>>> typeProcessors;
+   protected final List<Processor<MD, Field>> fieldProcessors;
+   protected final List<Processor<MD, Method>> methodProcessors;
    
    protected AbstractEnterpriseBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
    {
@@ -49,7 +53,12 @@
       // TODO: configure somehow
       
       typeProcessors = new ArrayList<Processor<MD,Class<?>>>();
-      typeProcessors.add(new TransactionAttributeProcessor<MD>(finder));
+      typeProcessors.add(new TransactionAttributeClassProcessor<MD>(finder));
+      
+      fieldProcessors = new ArrayList<Processor<MD,Field>>();
+      
+      methodProcessors = new ArrayList<Processor<MD,Method>>();
+      methodProcessors.add(new TransactionAttributeMethodProcessor<MD>(finder));
    }
    
    public void process(EjbJar3xMetaData ejbJarMetaData, Class<?> beanClass)
@@ -81,6 +90,22 @@
          }
       }
       
+      for(Field field : cls.getDeclaredFields())
+      {
+         for(Processor<MD, Field> processor : fieldProcessors)
+         {
+            processor.process(bean, field);
+         }
+      }
+      
+      for(Method method : cls.getDeclaredMethods())
+      {
+         for(Processor<MD, Method> processor : methodProcessors)
+         {
+            processor.process(bean, method);
+         }
+      }
+      
       if(cls.getSuperclass() != null)
          processClass(bean, cls.getSuperclass());
    }

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java	2007-09-27 10:25:53 UTC (rev 65656)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractSessionBeanProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -22,8 +22,6 @@
 package org.jboss.metadata.annotation.creator;
 
 import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -35,7 +33,8 @@
 import org.jboss.metadata.javaee.spec.DescriptionsImpl;
 
 /**
- * Comment
+ * Abstract processor for helping a processor which creates
+ * session bean meta data.
  *
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @version $Revision: $
@@ -43,8 +42,6 @@
 public abstract class AbstractSessionBeanProcessor extends AbstractEnterpriseBeanProcessor<SessionBeanMetaData> implements Creator<Class<?>, SessionBeanMetaData>, Processor<EjbJar3xMetaData, Class<?>>
 {
    private List<Processor<SessionBeanMetaData, Class<?>>> topLevelProcessors;
-   private List<Processor<SessionBeanMetaData, Method>> methodProcessors;
-   private List<Processor<SessionBeanMetaData, Field>> fieldProcessors;
    
    protected AbstractSessionBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
    {
@@ -56,6 +53,9 @@
       topLevelProcessors.add(new LocalHomeProcessor(finder));
       
       typeProcessors.add(new LocalProcessor(finder));
+      typeProcessors.add(new RemoteProcessor(finder));
+      
+      methodProcessors.add(new InitProcessor(finder));
    }
    
    public abstract SessionBeanMetaData create(Class<?> beanClass);

Copied: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java (from rev 65648, projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java)
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractTransactionAttributeProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.TransactionAttribute;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.ContainerTransactionsMetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.MethodMetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.MethodsMetaData;
+import org.jboss.metadata.ejb.spec.TransAttributeType;
+
+/**
+ * E defines the actual annotated element we're working for.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractTransactionAttributeProcessor<E extends AnnotatedElement, T extends EnterpriseBeanMetaData> extends AbstractFinderUser
+{
+   protected AbstractTransactionAttributeProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+   
+   protected abstract ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, E element);
+   
+   private MethodMetaData createMethod(String ejbName, Method method)
+   {
+      MethodMetaData methodMetaData = new MethodMetaData();
+      methodMetaData.setEjbName(ejbName);
+      if(method == null)
+         methodMetaData.setMethodName("*");
+      else
+      {
+         methodMetaData.setMethodName(method.getName());
+         MethodParametersMetaData methodParameters = MethodParametersHelper.create(method);
+         if(methodParameters != null)
+            methodMetaData.setMethodParams(methodParameters);
+      }
+      return methodMetaData;
+   }
+   
+   protected MethodsMetaData createMethods(String ejbName, Method method)
+   {
+      MethodsMetaData methods = new MethodsMetaData();
+      methods.add(createMethod(ejbName, method));
+      return methods;
+   }
+   
+   protected TransAttributeType createTransAttributeType(TransactionAttribute annotation)
+   {
+      switch(annotation.value())
+      {
+         case MANDATORY:
+            return TransAttributeType.Mandatory;
+         case NEVER:
+            return TransAttributeType.Never;
+         case NOT_SUPPORTED:
+            return TransAttributeType.NotSupported;
+         case REQUIRED:
+            return TransAttributeType.Required;
+         case REQUIRES_NEW:
+            return TransAttributeType.RequiresNew;
+         case SUPPORTS:
+            return TransAttributeType.Supports;
+      }
+      throw new IllegalArgumentException("Unknown transaction attribute value " + annotation.value());
+   }
+
+   public void process(T bean, E element)
+   {
+      TransactionAttribute annotation = finder.getAnnotation(element, TransactionAttribute.class);
+      if(annotation == null)
+         return;
+      
+      EjbJarMetaData ejbJarMetaData = bean.getEjbJarMetaData();
+      
+      if(ejbJarMetaData.getAssemblyDescriptor() == null)
+         ejbJarMetaData.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
+      if(ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions() == null)
+         ejbJarMetaData.getAssemblyDescriptor().setContainerTransactions(new ContainerTransactionsMetaData());
+      
+      ContainerTransactionMetaData transaction = createContainerTransaction(bean.getEjbName(), annotation, element);
+      ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions().add(transaction);
+   }
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.ApplicationException;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData;
+import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
+
+/**
+ * Process an application exception annotation.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ApplicationExceptionProcessor extends AbstractFinderUser implements Creator<Class<?>, ApplicationExceptionMetaData>, Processor<EjbJar3xMetaData, Class<?>>
+{
+   protected ApplicationExceptionProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   public ApplicationExceptionMetaData create(Class<?> element)
+   {
+      ApplicationException annotation = finder.getAnnotation(element, ApplicationException.class);
+      if(annotation == null)
+         return null;
+      
+      if(!Exception.class.isAssignableFrom(element))
+         throw new IllegalArgumentException("ApplicationException is only valid on an Exception");
+      
+      ApplicationExceptionMetaData metaData = new ApplicationExceptionMetaData();
+      metaData.setExceptionClass(element.getName());
+      metaData.setRollback(annotation.rollback());
+      
+      return metaData;
+   }
+
+   public void process(EjbJar3xMetaData ejbJar, Class<?> type)
+   {
+      ApplicationExceptionMetaData applicationException = create(type);
+      if(applicationException == null)
+         return;
+      
+      if(ejbJar.getAssemblyDescriptor() == null)
+         ejbJar.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
+      if(ejbJar.getAssemblyDescriptor().getApplicationExceptions() == null)
+         ejbJar.getAssemblyDescriptor().setApplicationExceptions(new ApplicationExceptionsMetaData());
+      
+      ejbJar.getAssemblyDescriptor().getApplicationExceptions().add(applicationException);
+   }
+}


Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ApplicationExceptionProcessor.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java	2007-09-27 10:25:53 UTC (rev 65656)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/Creator.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -22,12 +22,26 @@
 package org.jboss.metadata.annotation.creator;
 
 /**
- * Based on the element meta data is created.
+ * Based on the element meta data is created by scanning
+ * the appropriate annotation and creating the right meta data.
+ * If no annotation is found the creator does nothing.
+ * 
+ * Usually the element is an object implementing AnnotatedElement,
+ * but it could also be an array of annotated elements. So E
+ * does not extend AnnotatedElement.
+ * 
+ * There is no common denominator for meta data.
  *
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @version $Revision: $
  */
 public interface Creator<E, MD>
 {
+   /**
+    * Create a piece of meta data based on the given element.
+    * 
+    * @param element    the element
+    * @return           the meta data or null if nothing interesting is found
+    */
    MD create(E element);
 }

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java	2007-09-27 10:25:53 UTC (rev 65656)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/InitProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -32,9 +32,10 @@
 import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
 import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
 import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
 
 /**
- * Comment
+ * Process an init annotation.
  *
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @version $Revision: $
@@ -85,6 +86,9 @@
       if(initMethod == null)
          return;
       
+      if(bean.getSessionType() != SessionType.Stateful)
+         throw new IllegalArgumentException("Init annotation is only valid on a stateful bean");
+      
       if(bean.getInitMethods() == null)
          bean.setInitMethods(new InitMethodsMetaData());
       

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.Remote;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+
+/**
+ * Remote annotation processor.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RemoteProcessor extends AbstractFinderUser implements Processor<SessionBeanMetaData, Class<?>>
+{  
+   public RemoteProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+   
+   public void process(SessionBeanMetaData metaData, Class<?> type)
+   {
+      Remote remote = finder.getAnnotation(type, Remote.class);
+      if(remote == null)
+         return;
+      
+      if(type.isInterface())
+      {
+         if(metaData.getHome() != null)
+         {
+            if(metaData.getRemote() != null)
+               throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + type.getName());
+            metaData.setRemote(type.getName());
+         }
+         else
+         {
+            if(metaData.getBusinessRemotes() == null)
+               metaData.setBusinessRemotes(new BusinessRemotesMetaData());
+            
+            metaData.getBusinessRemotes().add(type.getName());
+         }
+      }
+      else
+      {
+         if(remote.value() == null || remote.value().length == 0)
+            throw new IllegalArgumentException("Empty @Remote on bean class " + type.getName() + " is not allowed");
+         
+         if(metaData.getHome() != null)
+         {
+            if(metaData.getRemote() != null)
+               throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + type.getName());
+            if(remote.value().length > 1)
+               throw new IllegalArgumentException("2.1 bean " + type.getName() + " has more than one remote interface defined");
+            metaData.setRemote(remote.value()[0].getName());
+         }
+         else
+         {
+            if(metaData.getBusinessRemotes() == null)
+               metaData.setBusinessRemotes(new BusinessRemotesMetaData());
+            
+            for(Class<?> businessInterface : remote.value())
+            {
+               metaData.getBusinessRemotes().add(businessInterface.getName());
+            }
+         }
+      }
+   }
+}


Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/RemoteProcessor.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.ejb.TransactionAttribute;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+
+/**
+ * Process transaction attribute annotations on classes.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TransactionAttributeClassProcessor<T extends EnterpriseBeanMetaData> extends AbstractTransactionAttributeProcessor<Class<?>, T> implements Processor<T, Class<?>>
+{
+   private static final Logger log = Logger.getLogger(TransactionAttributeClassProcessor.class);
+   
+   public TransactionAttributeClassProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   @Override
+   protected ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Class<?> cls)
+   {
+      ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
+      log.info(containerTransaction);
+      containerTransaction.setMethods(createMethods(ejbName, null));
+      containerTransaction.setTransAttribute(createTransAttributeType(annotation));
+      return containerTransaction;
+   }
+}


Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeClassProcessor.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import javax.ejb.TransactionAttribute;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+
+/**
+ * Process transaction attribute annotations on methods.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TransactionAttributeMethodProcessor<T extends EnterpriseBeanMetaData> extends AbstractTransactionAttributeProcessor<Method, T> implements Processor<T, Method>
+{
+   private static final Logger log = Logger.getLogger(TransactionAttributeMethodProcessor.class);
+   
+   public TransactionAttributeMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   @Override
+   protected ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Method method)
+   {
+      ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
+      log.info(containerTransaction);
+      containerTransaction.setMethods(createMethods(ejbName, method));
+      containerTransaction.setTransAttribute(createTransAttributeType(annotation));
+      return containerTransaction;
+   }
+}


Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeMethodProcessor.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Deleted: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java	2007-09-27 10:25:53 UTC (rev 65656)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/TransactionAttributeProcessor.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -1,143 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.metadata.annotation.creator;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-
-import javax.ejb.TransactionAttribute;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
-import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
-import org.jboss.metadata.ejb.spec.ContainerTransactionsMetaData;
-import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
-import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.spec.MethodMetaData;
-import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
-import org.jboss.metadata.ejb.spec.MethodsMetaData;
-import org.jboss.metadata.ejb.spec.TransAttributeType;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class TransactionAttributeProcessor<T extends EnterpriseBeanMetaData> extends AbstractFinderUser implements Processor<T, Class<?>>
-{
-   public TransactionAttributeProcessor(AnnotationFinder<AnnotatedElement> finder)
-   {
-      super(finder);
-   }
-   
-   private ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Class<?> beanClass)
-   {
-      ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
-      containerTransaction.setMethods(createMethods(ejbName, null));
-      containerTransaction.setTransAttribute(createTransAttributeType(annotation));
-      return containerTransaction;
-   }
-   
-//   private ContainerTransactionMetaData createContainerTransaction(String ejbName, TransactionAttribute annotation, Method method)
-//   {
-//      ContainerTransactionMetaData containerTransaction = new ContainerTransactionMetaData();
-//      containerTransaction.setMethods(createMethods(ejbName, method));
-//      containerTransaction.setTransAttribute(createTransAttributeType(annotation));
-//      return containerTransaction;
-//   }
-   
-   private MethodMetaData createMethod(String ejbName, Method method)
-   {
-      MethodMetaData methodMetaData = new MethodMetaData();
-      methodMetaData.setEjbName(ejbName);
-      if(method == null)
-         methodMetaData.setMethodName("*");
-      else
-      {
-         methodMetaData.setMethodName(method.getName());
-         MethodParametersMetaData methodParameters = MethodParametersHelper.create(method);
-         if(methodParameters != null)
-            methodMetaData.setMethodParams(methodParameters);
-      }
-      return methodMetaData;
-   }
-   
-   private MethodsMetaData createMethods(String ejbName, Method method)
-   {
-      MethodsMetaData methods = new MethodsMetaData();
-      methods.add(createMethod(ejbName, method));
-      return methods;
-   }
-   
-   private TransAttributeType createTransAttributeType(TransactionAttribute annotation)
-   {
-      switch(annotation.value())
-      {
-         case MANDATORY:
-            return TransAttributeType.Mandatory;
-         case NEVER:
-            return TransAttributeType.Never;
-         case NOT_SUPPORTED:
-            return TransAttributeType.NotSupported;
-         case REQUIRED:
-            return TransAttributeType.Required;
-         case REQUIRES_NEW:
-            return TransAttributeType.RequiresNew;
-         case SUPPORTS:
-            return TransAttributeType.Supports;
-      }
-      throw new IllegalArgumentException("Unknown transaction attribute value " + annotation.value());
-   }
-
-   private EnterpriseBeanMetaData findEnterpriseBean(EjbJar3xMetaData ejbJar, String ejbClass)
-   {
-      if(ejbJar.getEnterpriseBeans() == null)
-         return null;
-      
-      for(EnterpriseBeanMetaData bean : ejbJar.getEnterpriseBeans())
-      {
-         if(bean.getEjbClass().equals(ejbClass))
-         {
-            return bean;
-         }
-      }
-      return null;
-   }
-   
-   public void process(T bean, Class<?> cls)
-   {
-      TransactionAttribute annotation = finder.getAnnotation(cls, TransactionAttribute.class);
-      if(annotation == null)
-         return;
-      
-      EjbJarMetaData ejbJarMetaData = bean.getEjbJarMetaData();
-      
-      if(ejbJarMetaData.getAssemblyDescriptor() == null)
-         ejbJarMetaData.setAssemblyDescriptor(new AssemblyDescriptorMetaData());
-      if(ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions() == null)
-         ejbJarMetaData.getAssemblyDescriptor().setContainerTransactions(new ContainerTransactionsMetaData());
-      
-      ejbJarMetaData.getAssemblyDescriptor().getContainerTransactions().add(createContainerTransaction(bean.getEjbName(), annotation, cls));      
-   }
-}

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java	2007-09-27 10:25:53 UTC (rev 65656)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -21,18 +21,32 @@
  */
 package org.jboss.test.metadata.annotation.ejb3;
 
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
 import java.lang.reflect.AnnotatedElement;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLDecoder;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
 
 import junit.framework.TestCase;
 
 import org.jboss.metadata.annotation.creator.EjbJar30Creator;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.ContainerTransactionsMetaData;
 import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.InitMethodMetaData;
 import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
 import org.jboss.metadata.ejb.spec.SessionType;
+import org.jboss.metadata.ejb.spec.TransAttributeType;
 
 /**
  * This tests the annotation translation framework.
@@ -42,16 +56,107 @@
  */
 public class AnnotationEjb3UnitTestCase extends TestCase
 {
-   public void test1() throws Exception
+   private void assertMyStatefulBean(EnterpriseBeanMetaData enterpriseBean)
    {
-      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      assertTrue(enterpriseBean instanceof SessionBeanMetaData);
       
+      SessionBeanMetaData bean = (SessionBeanMetaData) enterpriseBean;
+      assertEquals(SessionType.Stateful, bean.getSessionType());
+      assertEquals(MyStatefulBean.class.getName(), bean.getEjbClass());
+      assertEquals("AnotherName", bean.getEjbName());
+      
+      assertNotNull("bean has no business remotes", bean.getBusinessRemotes());
+      assertEquals(1, bean.getBusinessRemotes().size());
+      assertTrue(bean.getBusinessRemotes().contains(MyStateful.class.getName()));
+      
+      assertNotNull("bean has no init methods", bean.getInitMethods());
+      assertEquals(1, bean.getInitMethods().size());
+      InitMethodMetaData initMethod = bean.getInitMethods().iterator().next();
+      assertEquals("init", initMethod.getBeanMethod().getMethodName());
+   }
+   
+   private void assertMyStateless21Bean(EnterpriseBeanMetaData enterpriseBean)
+   {
+      assertTrue(enterpriseBean instanceof SessionBeanMetaData);
+      SessionBeanMetaData bean = (SessionBeanMetaData) enterpriseBean;
+      assertEquals(SessionType.Stateless, bean.getSessionType());
+      assertEquals(MyStateless21Bean.class.getName(), bean.getEjbClass());
+      assertEquals("MyStateless21Bean", bean.getEjbName());
+      
+      assertNull("bean has business locals (instead of local interface)", bean.getBusinessLocals());
+      
+      assertEquals(MyStatelessLocal.class.getName(), bean.getLocal());
+      assertEquals(MyStateless21Home.class.getName(), bean.getLocalHome());
+   }
+   
+   private void assertMyStatelessBean(EnterpriseBeanMetaData enterpriseBean)
+   {
+      assertTrue(enterpriseBean instanceof SessionBeanMetaData);
+      SessionBeanMetaData bean = (SessionBeanMetaData) enterpriseBean;
+      assertEquals(SessionType.Stateless, bean.getSessionType());
+      assertEquals(MyStatelessBean.class.getName(), bean.getEjbClass());
+      assertEquals("MyStatelessBean", bean.getEjbName());
+      
+      assertNotNull("bean has no business locals", bean.getBusinessLocals());
+      assertEquals(1, bean.getBusinessLocals().size());
+      assertTrue(bean.getBusinessLocals().contains(MyStatelessLocal.class.getName()));
+      
+      assertNotNull("bean has no container transactions", bean.getContainerTransactions());
+      Iterator<ContainerTransactionMetaData> it = bean.getContainerTransactions().iterator();
+      ContainerTransactionMetaData tx1 = it.next();
+      assertEquals(TransAttributeType.Never, tx1.getTransAttribute());
+      // TODO: methods
+      ContainerTransactionMetaData tx2 = it.next();
+      assertEquals(TransAttributeType.Supports, tx2.getTransAttribute());
+      // TODO: methods
+   }
+   
+   private Collection<Class<?>> loadClassesFromCurrentClassDir()
+   {
       // In real life the deployer will pass probably pass a class scanner
       Collection<Class<?>> classes = new ArrayList<Class<?>>();
-      classes.add(MyStatelessBean.class);
-      classes.add(MyStateless21Bean.class);
-      classes.add(MyStatefulBean.class);
+      URL currentClassDirURL = getClass().getResource(".");
+      File currentDir;
+      try
+      {
+         currentDir = new File(currentClassDirURL.toURI());
+      }
+      catch (URISyntaxException e)
+      {
+         throw new RuntimeException(e);
+      }
+      String classFileNames[] = currentDir.list(new FilenameFilter() {
+         public boolean accept(File dir, String name)
+         {
+            return name.endsWith(".class");
+         }
+      });
+      if(classFileNames == null)
+         throw new RuntimeException("list failed");
       
+      Arrays.sort(classFileNames);
+      
+      for(String classFileName : classFileNames)
+      {
+         String className = getClass().getPackage().getName() + "." + classFileName.substring(0, classFileName.length() - 6);
+         try
+         {
+            classes.add(Class.forName(className));
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+      return classes;
+   }
+   
+   public void test1() throws Exception
+   {
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      
+      Collection<Class<?>> classes = loadClassesFromCurrentClassDir();
+      
       EjbJar30Creator creator = new EjbJar30Creator(finder);
       
       EjbJar30MetaData metaData = creator.create(classes);
@@ -59,16 +164,25 @@
       assertTrue(metaData.isEJB3x());
       assertEquals("3.0", metaData.getVersion());
       
+      assertNotNull("no beans defined", metaData.getEnterpriseBeans());
+      assertNotNull("no assembly descriptor defined", metaData.getAssemblyDescriptor());
+      
+      // There is a bug in IdMetaDataImpl.hashCode which isn't unique when id is not set.
+      for(ContainerTransactionMetaData transaction : metaData.getAssemblyDescriptor().getContainerTransactions())
+      {
+         System.out.println(transaction);
+      }
+      
       assertEquals(3, metaData.getEnterpriseBeans().size());
-      SessionBeanMetaData bean = (SessionBeanMetaData) metaData.getEnterpriseBeans().iterator().next();
-      assertEquals(SessionType.Stateless, bean.getSessionType());
-      assertEquals(MyStatelessBean.class.getName(), bean.getEjbClass());
-      assertEquals("MyStatelessBean", bean.getEjbName());
       
-      assertNotNull("bean has no business locals", bean.getBusinessLocals());
-      assertEquals(1, bean.getBusinessLocals().size());
-      assertTrue(bean.getBusinessLocals().contains(MyStatelessLocal.class.getName()));
+      Iterator<EnterpriseBeanMetaData> it = metaData.getEnterpriseBeans().iterator();
       
+      assertMyStatefulBean(it.next());
+      assertMyStateless21Bean(it.next());
+      assertMyStatelessBean(it.next());
+      
+      assertNotNull("no application exceptions defined", metaData.getAssemblyDescriptor().getApplicationExceptions());
+      assertEquals(1, metaData.getAssemblyDescriptor().getApplicationExceptions().size());
       System.out.println(metaData.getAssemblyDescriptor().getContainerTransactionsByEjbName("MyStatelessBean"));
    }
 }

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyApplicationException.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyApplicationException.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyApplicationException.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.metadata.annotation.ejb3;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at ApplicationException(rollback=true)
+public class MyApplicationException extends Exception
+{
+   private static final long serialVersionUID = 1L;
+
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyApplicationException.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java	2007-09-27 10:25:53 UTC (rev 65656)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulBean.java	2007-09-27 11:05:19 UTC (rev 65657)
@@ -31,7 +31,7 @@
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  * @version $Revision: $
  */
- at Stateful
+ at Stateful(name="AnotherName")
 @Remote(MyStateful.class)
 public class MyStatefulBean
 {

Added: projects/metadata/trunk/src/test/resources/log4j.xml
===================================================================
--- projects/metadata/trunk/src/test/resources/log4j.xml	                        (rev 0)
+++ projects/metadata/trunk/src/test/resources/log4j.xml	2007-09-27 11:05:19 UTC (rev 65657)
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id$ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+  <!-- ================================= -->
+  <!-- Preserve messages in a local file -->
+  <!-- ================================= -->
+
+  <!-- A time/date based rolling appender -->
+  <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+    <param name="File" value="target/test.log"/>
+    <param name="Append" value="false"/>
+
+    <!-- Rollover at midnight each day -->
+    <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+    <!-- Rollover at the top of each hour
+    <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+    -->
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <!-- The default pattern: Date Priority [Category] Message\n -->
+      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+      <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+      <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+       -->
+    </layout>	    
+  </appender>
+
+  <!-- A size based file rolling appender
+  <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+    <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
+    <param name="Append" value="false"/>
+    <param name="MaxFileSize" value="500KB"/>
+    <param name="MaxBackupIndex" value="1"/>
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+    </layout>	    
+  </appender>
+  -->
+
+  <!-- ============================== -->
+  <!-- Append messages to the console -->
+  <!-- ============================== -->
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <!--param name="Threshold" value="FATAL"/-->
+    <param name="Target" value="System.out"/>
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <!-- The default pattern: Date Priority [Category] Message\n -->
+      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+    </layout>
+  </appender>
+
+
+  <!-- ====================== -->
+  <!-- More Appender examples -->
+  <!-- ====================== -->
+
+  <!-- Buffer events and log them asynchronously
+  <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+    <appender-ref ref="FILE"/>
+    <appender-ref ref="CONSOLE"/>
+  </appender>
+  -->
+
+  <!-- EMail events to an administrator
+  <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+    <param name="Threshold" value="ERROR"/>
+    <param name="To" value="admin at myhost.domain.com"/>
+    <param name="From" value="nobody at myhost.domain.com"/>
+    <param name="Subject" value="JBoss Sever Errors"/>
+    <param name="SMTPHost" value="localhost"/>
+    <param name="BufferSize" value="10"/>
+  </appender>
+  -->
+
+  <!-- Syslog events
+  <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+    <param name="Facility" value="LOCAL7"/>
+    <param name="FacilityPrinting" value="true"/>
+    <param name="SyslogHost" value="localhost"/>
+  </appender>
+  -->
+
+  <!-- Log events to JMS (requires a topic to be created)
+  <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+    <param name="Threshold" value="ERROR"/>
+    <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+    <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+  </appender>
+  -->
+
+  <!-- ================ -->
+  <!-- Limit categories -->
+  <!-- ================ -->
+
+  <!-- Limit JBoss categories to INFO -->
+  <category name="org.jboss">
+    <priority value="INFO" class="org.jboss.logging.XLevel"/>
+  </category>
+
+  <!-- Increase the priority threshold for the DefaultDS category
+  <category name="DefaultDS">
+    <priority value="FATAL"/>
+  </category>
+  -->
+
+  <!-- Decrease the priority threshold for the org.jboss.varia category
+  <category name="org.jboss.varia">
+    <priority value="DEBUG"/>
+  </category>
+  -->
+
+  <!--
+     | An example of enabling the custom TRACE level priority that is used
+     | by the JBoss internals to diagnose low level details. This example
+     | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+     | subpackages. This will produce A LOT of logging output.
+  <category name="org.jboss.system">
+    <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+  </category>
+  -->
+
+  <!-- ======================= -->
+  <!-- Setup the Root category -->
+  <!-- ======================= -->
+
+  <root>
+    <appender-ref ref="CONSOLE"/>
+    <appender-ref ref="FILE"/>
+  </root>
+  
+</log4j:configuration>


Property changes on: projects/metadata/trunk/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list