List Info

Thread: - Re: Multiple parsing implementation in RAR




- Re: Multiple parsing implementation in RAR
country flaguser name
United States
2008-05-30 05:27:02
I have noticed that the init(..) does not get called in the
parse(..) implemetations of AbstractVFSParsingDeployer ,
here is the code 

  | Override
  |    protected T parse(DeploymentUnit unit, String name,
String suffix, T root) throws Exception
  |    {
  |       // Should we include the deployment
  |       // The infrastructure will only check leafs anyway
so no need to check here
  |       if (name == null &&
isIncludeDeploymentFile())
  |          name = unit.getName();
  |       
  |       // Try to find the metadata
  |       VFSDeploymentUnit vfsDeploymentUnit =
(VFSDeploymentUnit) unit;
  |       List<VirtualFile> files =
vfsDeploymentUnit.getMetaDataFiles(name, suffix);
  | 
  |       if (files.size() == 0)
  |       {
  |          return null;
  |       }
  |       else if (files.size() > 1)
  |       {
  |          return handleMultipleFiles(vfsDeploymentUnit,
root, files);
  |       }
  |       else
  |       {
  |          VirtualFile file = (VirtualFile)
unit.getAttachment(getOutput().getName() +
".altDD");
  |          if(file == null)
  |             file = files.get(0);
  | 
  |          T result = parse(vfsDeploymentUnit, file,
root);
  |          if (result != null)
  |             init(vfsDeploymentUnit, result, file);
  |          return result;
  |       }
  |    }
  | 
  |    protected T parse(DeploymentUnit unit,
Set<String> names, String suffix, T root) throws
Exception
  |    {
  |       if (names == null || names.isEmpty())
  |          throw new IllegalArgumentException("Null
or empty names.");
  | 
  |       VFSDeploymentUnit  vfsDeploymentUnit =
(VFSDeploymentUnit)unit;
  | 
  |       List<VirtualFile> files = new
ArrayList<VirtualFile>();
  |       Set<String> missingFiles = new
HashSet<String>();
  | 
  |       for (String name : names)
  |       {
  |          List<VirtualFile> matched =
vfsDeploymentUnit.getMetaDataFiles(name, suffix);
  |          if (matched != null &&
matched.isEmpty() == false)
  |             files.addAll(matched);
  |          else
  |             missingFiles.add(name);
  |       }
  | 
  |       if (missingFiles.size() == names.size())
  |          return null;
  | 
  |       return mergeFiles(vfsDeploymentUnit, root, files,
missingFiles);
  |    }
  | 
  | 

So if I am am overriding some functionality in the Deployer
implementation of type MultipleObjectModelFactoryDeployer ,
the init(..) does not kick in .

I have a hack to get the MetaData processing out from the
init() and place in the mergeMetaData(...) but I wanted to
make sure that the flow of the parse(..) is ok .
Ales you need to check this .


Here is the hack 
protected  RARDeploymentMetaData
mergeMetaData(VFSDeploymentUnit unit, Map<Class<?>,
List<Object>> metadata) throws Exception
  |    {	   
  | 	   RARDeploymentMetaData deployment = new
RARDeploymentMetaData();
  | 	   
  | 	   // Getting the List of MetaData Objects
  | 	   List<Object> cmdInstances =
metadata.get(ConnectorMetaData.class);
  | 	   if(cmdInstances != null &&
!cmdInstances.isEmpty())
  | 		  
deployment.setConnectorMetaData(ConnectorMetaData.class.cast
(cmdInstances.get(0)));
  | 	   
  | 	   List<Object> jmdInstances =
metadata.get(JBossRAMetaData.class);
  | 	   if(jmdInstances != null &&
!jmdInstances.isEmpty())
  | 		  
deployment.setRaXmlMetaData(JBossRAMetaData.class.cast(jmdIn
stances.get(0)));
  | 	   
  | 	   // This is moved from the init() , got to verify if
this in not a HACK .....	  
  | 	   /*
  | 	   VFSDeploymentUnit parent = unit.getParent();
  | 	   String name = unit.getSimpleName();
  | 	   if( parent != null )
  | 		   name = parent.getSimpleName() + "#" +
name;
  | 	   System.out.println("--------> name
-->"+name);
  | 	   metaDataRepository.addConnectorMetaData(name,
deployment.getConnectorMetaData());
  | 	   */	     
  | 	   // Check if this is hack.
  | 
  | 	   return deployment;	   
  |    }

The actual code which was part of the init(..) is 

 Override 
  |    protected void init(VFSDeploymentUnit unit,
RARDeploymentMetaData rdmd, VirtualFile file) throws
Exception
  |    { 
  | 	  ConnectorMetaData cmd = rdmd.getConnectorMetaData();
  |       cmd.setURL(file.toURL());
  |       VFSDeploymentUnit parent = unit.getParent();
  |       String name = unit.getSimpleName();
  |       if( parent != null )
  |          name = parent.getSimpleName() + "#" +
name;
  |       metaDataRepository.addConnectorMetaData(name,
cmd);      
  |    }
  | 

Right now I am not able to call    
cmd.setURL(file.toURL());  within the mergeMetaData(...) , I
think I should be getting the VirtualFile reference from the
VirtualDeploymentUnit.
I am look at this .

The URL set in the ConnectorMetaData is being used in the
RARDeployment at here 

protected void startService() throws Exception
  |    {
  |       URL url = cmd.getURL();      
  |       if (cmd.getLicense().getRequired())
  |       {    	  
  |          //log.info ("Required license terms exist,
view " +
ServerConfigUtil.shortUrlFromServerHome(url.toString()));   
     
  |          log.debug("License terms full URL: "
+ url);
  |       }           
  |       //resourceAdapter =
ResourceAdapterFactory.createResourceAdapter(cmd);
  |       resourceAdapter =
ResourceAdapterFactory.createResourceAdapter(rdmd);
  |       resourceAdapter.start(this);
  |    }

Please note that url.toString() is yielding the NPE as it is
not being set in RARParserDeployer .


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

Reply to the post : http://www.jboss.com/index.
html?module=bb&op=posting&mode=reply&p=4154570
_______________________________________________
jboss-dev-forums mailing list
jboss-dev-forumslists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-dev-foru
ms

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )