Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jboss.spring.deployers;
  
  import java.net.URL;
  import java.util.List;
  
Utility class that implements the deployer behaviour that is common to VFS2 and VFS3 in a manner that is agnostic of the VFS version.

VFS-version specific deployers will delegate to this class for the actual work

Author(s):
Marius Bogoevici
 
 public class SpringParserDeployerHandler {
 
     boolean useLegacyDefaultName;
 
     public SpringParserDeployerHandler() {
     }

    
Get the use name flag.

Returns:
true if the default name should be determined from deployment unit
 
     protected boolean isUseLegacyDefaultName() {
         return ;
     }

    
Should we use deployment unit's name as default. e.g. using string before .jar|spring|... as the name

Previous versions used string before .spring as the name, setting this to true results in this legacy behaviour.

Current default is string before -spring.xml.

Parameters:
useLegacyDefaultName the flag
 
     public void setUseLegacyDefaultName(boolean useLegacyDefaultName) {
         this. = useLegacyDefaultName;
     }

    
Get default name from meta file.

Parameters:
file the virtual file
Returns:
default name
 
     String getDefaultNameForFile(Object filethrows IOException {
         String shortName = VFSUtil.invokeVfsMethod(.file);
         int p = shortName.indexOf("-spring.xml");
         return shortName.substring(0, p);
     }

    
Get default name from unit.

Parameters:
unit the deployment unit
Returns:
default name
 
         String shortName = unit.getSimpleName();
         int p = shortName.lastIndexOf(".");
         return shortName.substring(0, p);
     }
 
     public SpringMetaData parse(DeploymentUnit unitObject filethrows IOExceptionURISyntaxException {
         String defaultName;
         if (isUseLegacyDefaultName()) {
             defaultName = getDefaultNameForUnit(unit);
         } else {
             defaultName = getDefaultNameForFile(file);
         }
 
         return new SpringMetaData(Collections.singletonList(createSpringContextDescriptor(filedefaultName)));
     }
 
 
     private SpringContextDescriptor createSpringContextDescriptor(Object fileString defaultNamethrows IOException {
         return new SpringContextDescriptor(VFSUtil.<URL>invokeVfsMethod(.file), defaultName);
     }
 
     public SpringMetaData handleMultipleFiles(List<?> filesthrows IOException {
         List<SpringContextDescriptordescriptors = new ArrayList<SpringContextDescriptor>();
         for (Object virtualFile : files) {
             String defaultName;
             if (isUseLegacyDefaultName()) {
                 throw new IllegalStateException("Cannot use the legacy default name for multiple Spring configuration files");
             } else {
                 defaultName = getDefaultNameForFile(virtualFile);
            }
            descriptors.add(new SpringContextDescriptor(VFSUtil.<URL>invokeVfsMethod(.virtualFile), defaultName));
        }
        return new SpringMetaData(descriptors);
    }
New to GrepCode? Check out our FAQ X