1 17 18 package org.sape.carbon.services.config.classloader; 19 20 import org.sape.carbon.core.config.format.ConfigurationFormatService; 21 import org.sape.carbon.core.config.format.DefaultConfigurationFormatService; 22 import org.sape.carbon.core.config.node.Node; 23 import org.sape.carbon.core.config.node.NodeCreationException; 24 import org.sape.carbon.core.config.node.NodeFactory; 25 import org.sape.carbon.core.exception.InvalidParameterException; 26 27 36 public abstract class AbstractClassloaderConfigurationDocumentFactory 37 implements NodeFactory { 38 39 private static final ConfigurationFormatService FORMAT_SERVICE = 40 new DefaultConfigurationFormatService(); 41 42 49 public Node getInstance(Node parent, String name) 50 throws NodeCreationException { 51 52 ClassloaderFolder parentFolder; 53 try { 54 parentFolder = (ClassloaderFolder) parent; 55 } catch(ClassCastException cce) { 56 throw new InvalidParameterException( 57 this.getClass(), 58 "parent is not assignable from ClassloaderFolder", cce); 59 } 60 61 if (name == null) { 64 throw new InvalidParameterException( 65 this.getClass(), 66 "name cannot be null"); 67 } 68 69 String entryName = 70 parentFolder.getResourcePath() + 71 name + getFileExtension(); 72 73 return new ClassloaderConfigurationDocument( 74 parent, 75 name, 76 getConfigurationFormatService(), 77 entryName, 78 parentFolder.getConfigSource()); 79 } 80 81 88 protected abstract String getFileExtension(); 89 90 101 protected ConfigurationFormatService getConfigurationFormatService() { 102 return AbstractClassloaderConfigurationDocumentFactory.FORMAT_SERVICE; 103 } 104 } | Popular Tags |