1 24 25 package org.objectweb.dream.message.codec; 26 27 import java.io.IOException ; 28 import java.io.InputStream ; 29 import java.util.Properties ; 30 31 import org.objectweb.dream.AbstractComponent; 32 import org.objectweb.dream.util.EmptyStringArray; 33 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 34 35 44 public class CodecRepositoryImpl extends AbstractComponent 45 implements 46 CodecRepository, 47 CodecRepositoryAttributeController 48 { 49 50 protected String repositoryRessourceName; 51 protected Properties repository; 52 53 56 public String getCodecADL(String codecName) 57 { 58 return repository.getProperty(codecName); 59 } 60 61 65 68 public String getPropertiesRessourceName() 69 { 70 return repositoryRessourceName; 71 } 72 73 76 public void setPropertiesRessourceName(String name) 77 throws CodecManagerException 78 { 79 InputStream is = ClassLoader.getSystemResourceAsStream(name); 80 if (is == null) 81 { 82 throw new CodecManagerException(null, "Can't find properties file :" 83 + name); 84 } 85 repository = new Properties (); 86 try 87 { 88 repository.load(is); 89 } 90 catch (IOException e) 91 { 92 throw new CodecManagerException(null, 93 "Error while reading properties file : " + e.getLocalizedMessage()); 94 } 95 repositoryRessourceName = name; 96 } 97 98 102 105 public String [] listFc() 106 { 107 return EmptyStringArray.EMPTY_STRING_ARRAY; 108 } 109 110 114 117 public void startFc() throws IllegalLifeCycleException 118 { 119 super.startFc(); 120 if (repository == null) 121 { 122 throw new IllegalLifeCycleException( 123 "Properties Ressource Name attribute not set"); 124 } 125 } 126 } | Popular Tags |