1 26 27 package org.objectweb.openccm.descriptor; 28 29 import org.xml.sax.InputSource ; 31 32 import org.objectweb.openccm.descriptor.componentassembly.beans.ComponentassemblyBeanImpl; 34 import org.objectweb.openccm.descriptor.corbacomponent.beans.CorbacomponentBeanImpl; 35 import org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBeanImpl; 36 import org.objectweb.openccm.descriptor.properties.beans.PropertiesBeanImpl; 37 38 public class EntityResolver implements org.xml.sax.EntityResolver { 39 40 46 50 public static final String CSD_FPI_3_0 = "-//OMG//DTD CORBA Software Descriptor 3.0//EN"; 51 52 56 public static final String CCD_FPI_3_0 = "-//OMG//DTD CORBA Component Descriptor 3.0//EN"; 57 58 62 public static final String CAD_FPI_3_0 = "-//OMG//DTD Component Assembly Descriptor 3.0//EN"; 63 64 68 public static final String CPF_FPI_3_0 = "-//OMG//DTD Component Property File 3.0//EN"; 69 70 71 private static EntityResolver resolver_singleton=null; 72 73 79 85 93 protected java.io.Reader getReaderInMem(String name) { 94 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 95 return new java.io.InputStreamReader (loader.getResourceAsStream(name)); 96 } 97 98 104 119 public InputSource resolveEntity (String publicId, String systemId) 120 { 121 java.io.Reader reader = null; 122 if (publicId != null) { 123 if (publicId.equals(CPF_FPI_3_0)) { 124 reader = getReaderInMem("properties.dtd"); 125 } else if (publicId.equals(CCD_FPI_3_0)) { 126 reader = getReaderInMem("corbacomponent.dtd"); 127 } else if (publicId.equals(CSD_FPI_3_0)) { 128 reader = getReaderInMem("softpkg.dtd"); 129 } else if (publicId.equals(CAD_FPI_3_0)) { 130 reader = getReaderInMem("componentassembly.dtd"); 131 } 132 } 133 if (systemId != null && reader == null) { 134 return new InputSource (systemId); 135 } 136 if (reader == null) return null; 137 return new InputSource (reader); 138 } 139 140 143 public static void setCCMResolver() { 144 if (resolver_singleton == null) { 145 resolver_singleton = new EntityResolver(); 146 ComponentassemblyBeanImpl.setEntityResolver(resolver_singleton); 147 CorbacomponentBeanImpl.setEntityResolver(resolver_singleton); 148 SoftpkgBeanImpl.setEntityResolver(resolver_singleton); 149 PropertiesBeanImpl.setEntityResolver(resolver_singleton); 150 } 151 } 152 } 153 | Popular Tags |