[jboss-dev-forums] [Design of POJO Server] - Re: Allowing multiple AbstractParsingDeployer to work with t

scott.stark@jboss.org do-not-reply at jboss.com
Wed Oct 4 13:14:43 EDT 2006


I have committed a change that allows propagation of an existing deployment type instance if the AbstractParsingDeployer.allowsReparse() is true. Here is the patch:


  | Index: C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/ObjectModelFactoryDeployer.java
  | ===================================================================
  | --- C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/ObjectModelFactoryDeployer.java	(revision 57411)
  | +++ C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/ObjectModelFactoryDeployer.java	(working copy)
  | @@ -61,7 +61,7 @@
  |      * @return the metadata
  |      * @throws Exception for any error
  |      */
  | -   protected T parse(DeploymentUnit unit, VirtualFile file) throws Exception
  | +   protected T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception
  |     {
  |        if (file == null)
  |           throw new IllegalArgumentException("Null file");
  | @@ -70,8 +70,7 @@
  |        Object parsed = null;
  |        try
  |        {
  | -         ObjectModelFactory factory = getObjectModelFactory();
  | -         Object root = null;
  | +         ObjectModelFactory factory = getObjectModelFactory(root);
  |           URL url = file.toURL();
  |           parsed = unmarshaller.unmarshal(url.toString(), factory, root);
  |        }
  | @@ -90,5 +89,5 @@
  |      * 
  |      * @return the object model factory
  |      */
  | -   protected abstract ObjectModelFactory getObjectModelFactory();
  | +   protected abstract ObjectModelFactory getObjectModelFactory(T root);
  |  }
  | Index: C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java
  | ===================================================================
  | --- C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java	(revision 57411)
  | +++ C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java	(working copy)
  | @@ -65,7 +65,7 @@
  |      * @return the metadata
  |      * @throws Exception for any error
  |      */
  | -   protected T parse(DeploymentUnit unit, VirtualFile file) throws Exception
  | +   protected T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception
  |     {
  |        if (file == null)
  |           throw new IllegalArgumentException("Null file");
  | Index: C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXPDeployer.java
  | ===================================================================
  | --- C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXPDeployer.java	(revision 57411)
  | +++ C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXPDeployer.java	(working copy)
  | @@ -142,7 +142,7 @@
  |      * @return the metadata
  |      * @throws Exception for any error
  |      */
  | -   protected T parse(DeploymentUnit unit, VirtualFile file) throws Exception
  | +   protected T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception
  |     {
  |        Document document = doParse(unit, file);
  |        return parse(unit, file, document);
  | Index: C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java
  | ===================================================================
  | --- C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java	(revision 57411)
  | +++ C:/svn/JBossMC/jbossmc/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java	(working copy)
  | @@ -28,7 +28,9 @@
  |  import org.jboss.virtual.VirtualFile;
  |  
  |  /**
  | - * AbstractParsingDeployer.
  | + * AbstractParsingDeployer. Extends AbstractTypedDeployer to add a notion of obtaining an instance of the
  | + * deploymentType by parsing a metadata file. Subclasses need to override
  | + * parse(DeploymentUnit, VirtualFile) to define this behavior. 
  |   *
  |   * @param <T> the expected type
  |   * @author <a href="adrian at jboss.com">Adrian Brock</a>
  | @@ -51,8 +53,19 @@
  |     {
  |        return PARSER_DEPLOYER;
  |     }
  | -   
  | +
  |     /**
  | +    * A flag indicating whether createMetaData should execute a parse even if a non-null metadata value exists.
  | +    * 
  | +    * @return false if a parse should be performed only if there is no existing metadata value. True indicates
  | +    * that parse should be done regardless of an existing metadata value.
  | +    */
  | +   protected boolean allowsReparse()
  | +   {
  | +      return false;
  | +   }
  | +
  | +   /**
  |      * Get some meta data
  |      * 
  |      * @param unit the deployment unit
  | @@ -65,7 +78,7 @@
  |     }
  |     
  |     /**
  | -    * Create some meta data
  | +    * Create some meta data. Calls createMetaData(unit, name, suffix, getDeploymentType().getName()).
  |      * 
  |      * @param unit the deployment unit
  |      * @param name the name
  | @@ -78,7 +91,8 @@
  |     }
  |     
  |     /**
  | -    * Create some meta data
  | +    * Create some meta data. Invokes parse(unit, name, suffix) if there is not already a
  | +    * metadata
  |      * 
  |      * @param unit the deployment unit
  |      * @param name the name
  | @@ -90,16 +104,16 @@
  |     {
  |        // First see whether it already exists
  |        T result = getMetaData(unit, key);
  | -      if (result != null)
  | +      if (result != null && allowsReparse() == false)
  |           return;
  |  
  |        // Create it
  |        try
  |        {
  |           if (suffix == null)
  | -            result = parse(unit, name);
  | +            result = parse(unit, name, result);
  |           else
  | -            result = parse(unit, name, suffix);
  | +            result = parse(unit, name, suffix, result);
  |        }
  |        catch (Exception e)
  |        {
  | @@ -122,14 +136,14 @@
  |      * @return the metadata or null if it doesn't exist
  |      * @throws Exception for any error
  |      */
  | -   protected T parse(DeploymentUnit unit, String name) throws Exception
  | +   protected T parse(DeploymentUnit unit, String name, T root) throws Exception
  |     {
  |        // Try to find the metadata
  |        VirtualFile file = unit.getMetaDataFile(name);
  |        if (file == null)
  |           return null;
  |        
  | -      T result = parse(unit, file);
  | +      T result = parse(unit, file, root);
  |        init(unit, result, file);
  |        return result;
  |     }
  | @@ -143,7 +157,7 @@
  |      * @return the metadata or null if it doesn't exist
  |      * @throws Exception for any error
  |      */
  | -   protected T parse(DeploymentUnit unit, String name, String suffix) throws Exception
  | +   protected T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception
  |     {
  |        // Try to find the metadata
  |        List<VirtualFile> files = unit.getMetaDataFiles(name, suffix);
  | @@ -156,7 +170,7 @@
  |  
  |        VirtualFile file = files.get(0);
  |        
  | -      T result = parse(unit, file);
  | +      T result = parse(unit, file, root);
  |        init(unit, result, file);
  |        return result;
  |     }
  | @@ -169,7 +183,7 @@
  |      * @return the metadata
  |      * @throws Exception for any error
  |      */
  | -   protected abstract T parse(DeploymentUnit unit, VirtualFile file) throws Exception;
  | +   protected abstract T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception;
  |     
  |     /**
  |      * Initialise the metadata
  | 


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976108#3976108

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976108



More information about the jboss-dev-forums mailing list