[jboss-cvs] JBossAS SVN: r79515 - in projects/metadata/trunk/src/main/java/org/jboss/metadata: annotation/creator/ejb/jboss and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 15 04:30:51 EDT 2008


Author: ALRubinger
Date: 2008-10-15 04:30:51 -0400 (Wed, 15 Oct 2008)
New Revision: 79515

Added:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/ProcessingException.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ProcessorChain.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ejb/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ejb/jboss/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ejb/jboss/JBossMetaDataProcessorChain.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/JBossMetaDataProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/JBoss50MetaDataValidatorChainProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java
Modified:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java
Log:
[JBMETA-121] Implemented a ProcessorChain for merged metadata

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java	2008-10-15 08:15:39 UTC (rev 79514)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java	2008-10-15 08:30:51 UTC (rev 79515)
@@ -39,6 +39,9 @@
 import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
 import org.jboss.metadata.ejb.spec.SessionType;
+import org.jboss.metadata.process.chain.ProcessorChain;
+import org.jboss.metadata.process.chain.ejb.jboss.JBossMetaDataProcessorChain;
+import org.jboss.metadata.process.processor.ejb.jboss.JBoss50MetaDataValidatorChainProcessor;
 import org.jboss.metadata.validation.chain.ejb.jboss.JBoss50MetaDataValidatorChain;
 
 /**
@@ -107,9 +110,20 @@
       // Process annotations
       processMetaData(classes, metaData);
       
-      // Validate
-      new JBoss50MetaDataValidatorChain().validate(metaData);
+      /*
+       * Run a ProcessorChain on the merged metadata
+       */
+      
+      // Make the chain
+      ProcessorChain<JBoss50MetaData> chain = new JBossMetaDataProcessorChain<JBoss50MetaData>();
 
+      
+      // Validation Processor
+      chain.addProcessor(JBoss50MetaDataValidatorChainProcessor.INSTANCE);
+      
+      // Process the chain
+      metaData = chain.process(metaData);
+
       return metaData;
    }
    

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/process/ProcessingException.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/process/ProcessingException.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/process/ProcessingException.java	2008-10-15 08:30:51 UTC (rev 79515)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.process;
+
+/**
+ * ProcessingException
+ * 
+ * Indicates a problem with processing metadata
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProcessingException extends RuntimeException
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final long serialVersionUID = 1L;
+
+   // --------------------------------------------------------------------------------||
+   // Constructors -------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * 
+    */
+   public ProcessingException()
+   {
+      super();
+   }
+
+   /**
+    * @param message
+    */
+   public ProcessingException(String message)
+   {
+      super(message);
+   }
+
+   /**
+    * @param cause
+    */
+   public ProcessingException(Throwable cause)
+   {
+      super(cause);
+   }
+
+   /**
+    * @param message
+    * @param cause
+    */
+   public ProcessingException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ProcessorChain.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ProcessorChain.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ProcessorChain.java	2008-10-15 08:30:51 UTC (rev 79515)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.process.chain;
+
+import java.util.List;
+
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.process.ProcessingException;
+import org.jboss.metadata.process.processor.JBossMetaDataProcessor;
+
+/**
+ * ProcessorChain
+ * 
+ * Defines the contract for a chain of Processors upon 
+ * metadata
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ProcessorChain<T extends JBossMetaData>
+{
+   // --------------------------------------------------------------------------------||
+   // Contracts ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Processes the specified metadata against the configured
+    * processors, returning the output
+    * 
+    * @param metadata
+    */
+   T process(T metadata) throws ProcessingException;
+
+   /**
+    * Obtains all processors in the chain.  Will return
+    * an immutable view of the configured processors as to not allow
+    * published mutation of the List except as provided 
+    * 
+    * @return
+    */
+   List<JBossMetaDataProcessor<T>> getProcessors();
+
+   /**
+    * Adds the specified processor to the chain
+    * 
+    * @param processor
+    */
+   void addProcessor(JBossMetaDataProcessor<T> processor);
+
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ejb/jboss/JBossMetaDataProcessorChain.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ejb/jboss/JBossMetaDataProcessorChain.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/process/chain/ejb/jboss/JBossMetaDataProcessorChain.java	2008-10-15 08:30:51 UTC (rev 79515)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.process.chain.ejb.jboss;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.process.ProcessingException;
+import org.jboss.metadata.process.chain.ProcessorChain;
+import org.jboss.metadata.process.processor.JBossMetaDataProcessor;
+
+/**
+ * JBossMetaDataProcessorChain
+ * 
+ * A Processor Chain for JBossMetaData
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossMetaDataProcessorChain<T extends JBossMetaData> implements ProcessorChain<T>
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(JBossMetaDataProcessorChain.class);
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * The processors to apply to the metadata
+    */
+   private List<JBossMetaDataProcessor<T>> processors;
+
+   // --------------------------------------------------------------------------------||
+   // Constructors -------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new chain with empty processor list
+    */
+   public JBossMetaDataProcessorChain()
+   {
+      this.setProcessors(new ArrayList<JBossMetaDataProcessor<T>>());
+   }
+
+   /** Creates a new chain with the specified Processors
+    * 
+    */
+   public JBossMetaDataProcessorChain(List<JBossMetaDataProcessor<T>> initialProcessors)
+   {
+      this.setProcessors(initialProcessors);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.metadata.process.chain.ProcessorChain#addProcessor(org.jboss.metadata.process.processor.JBossMetaDataProcessor)
+    */
+   public void addProcessor(JBossMetaDataProcessor<T> processor)
+   {
+      assert processor != null : "Specified processor was null";
+      this._getProcessors().add(processor);
+      log.debug("Added Processor " + processor + " to Chain " + this);
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.metadata.process.chain.ProcessorChain#getProcessors()
+    */
+   public List<JBossMetaDataProcessor<T>> getProcessors()
+   {
+      // Return an immutable view; don't publish the List
+      List<JBossMetaDataProcessor<T>> processors = this._getProcessors();
+      return Collections.unmodifiableList(processors);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.metadata.process.chain.ProcessorChain#process(org.jboss.metadata.ejb.jboss.JBossMetaData)
+    */
+   public T process(T metadata) throws ProcessingException
+   {
+      // For each processor in the chain
+      for (JBossMetaDataProcessor<T> processor : this._getProcessors())
+      {
+         // Process
+         log.trace("Processing " + metadata + " on " + processor + "...");
+         metadata = processor.process(metadata);
+      }
+
+      // Return 
+      log.debug(metadata + " has been processed on " + this);
+      return metadata;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   protected List<JBossMetaDataProcessor<T>> _getProcessors()
+   {
+      return this.processors;
+   }
+
+   protected void setProcessors(List<JBossMetaDataProcessor<T>> processors)
+   {
+      this.processors = processors;
+   }
+
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/JBossMetaDataProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/JBossMetaDataProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/JBossMetaDataProcessor.java	2008-10-15 08:30:51 UTC (rev 79515)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.process.processor;
+
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.process.ProcessingException;
+
+/**
+ * JBossMetaDataProcessor
+ * 
+ * A JBossMetaDataProcessor may alter, switch, 
+ * or otherwise transpose metadata in a
+ * generic fashion
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface JBossMetaDataProcessor<T extends JBossMetaData>
+{
+
+   // --------------------------------------------------------------------------------||
+   // Contracts ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Performs processing of the specified metadata, returning
+    * the result (which is not guaranteed to be the same instance 
+    * as the input)
+    * 
+    * @param metadata
+    * @throws ProcessingExceptions
+    */
+   T process(T metadata) throws ProcessingException;
+
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/JBoss50MetaDataValidatorChainProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/JBoss50MetaDataValidatorChainProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/JBoss50MetaDataValidatorChainProcessor.java	2008-10-15 08:30:51 UTC (rev 79515)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.process.processor.ejb.jboss;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
+import org.jboss.metadata.process.ProcessingException;
+import org.jboss.metadata.process.processor.JBossMetaDataProcessor;
+import org.jboss.metadata.validation.chain.ejb.jboss.JBoss50MetaDataValidatorChain;
+
+/**
+ * JBoss50MetaDataValidatorChainProcessor
+ * 
+ * Processor to send the specified metadata
+ * through the default validation chain
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBoss50MetaDataValidatorChainProcessor implements JBossMetaDataProcessor<JBoss50MetaData>
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(JBoss50MetaDataValidatorChainProcessor.class);
+
+   public static final JBoss50MetaDataValidatorChainProcessor INSTANCE = new JBoss50MetaDataValidatorChainProcessor();
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.metadata.process.processor.JBossMetaDataProcessor#process(org.jboss.metadata.ejb.jboss.JBoss50MetaData)
+    */
+   public JBoss50MetaData process(JBoss50MetaData metadata) throws ProcessingException
+   {
+      // Sanity check
+      assert metadata != null : "Specified metadata was null";
+
+      // Set up the default validator chain
+      JBoss50MetaDataValidatorChain chain = new JBoss50MetaDataValidatorChain();
+
+      // Validate
+      chain.validate(metadata);
+
+      // Return
+      log.debug(metadata + " has been validated by " + chain);
+      return metadata;
+
+   }
+
+}

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/process/processor/ejb/jboss/SetDefaultLocalBusinessInterfaceProcessor.java	2008-10-15 08:30:51 UTC (rev 79515)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.process.processor.ejb.jboss;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
+import org.jboss.metadata.process.ProcessingException;
+import org.jboss.metadata.process.processor.JBossMetaDataProcessor;
+
+/**
+ * SetDefaultLocalBusinessInterfaceProcessor
+ * 
+ * Processor to set the default local business interface
+ * on EJBs with only one interface implemented, and not 
+ * explicitly marked as either @Local or @Remote
+ * 
+ * EJB3 Core Spec 4.6.6
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class SetDefaultLocalBusinessInterfaceProcessor implements JBossMetaDataProcessor<JBoss50MetaData>
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(SetDefaultLocalBusinessInterfaceProcessor.class);
+
+   public static final SetDefaultLocalBusinessInterfaceProcessor INSTANCE = new SetDefaultLocalBusinessInterfaceProcessor();
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.metadata.process.processor.JBossMetaDataProcessor#process(org.jboss.metadata.ejb.jboss.JBoss50MetaData)
+    */
+   public JBoss50MetaData process(JBoss50MetaData metadata) throws ProcessingException
+   {
+      // Sanity check
+      assert metadata != null : "Specified metadata was null";
+
+      //TODO
+
+      // Return
+      return metadata;
+
+   }
+
+}




More information about the jboss-cvs-commits mailing list