1 37 38 package com.sun.j2ee.blueprints.opc.webservicebroker.provider; 39 40 import org.xml.sax.*; 41 import java.io.*; 42 43 44 public class BrokerEntityResolver implements EntityResolver { 45 46 private static String PACKAGE_LOCATION = "/com/sun/j2ee/blueprints/opc/webservicebroker/provider/"; 47 private static String BLUEPRINTS_NS = "http://java.sun.com/blueprints/schemas/"; 48 49 public InputSource resolveEntity (String publicId, String systemId) { 50 if (systemId.equals(BLUEPRINTS_NS + "invoice.xsd")) { 51 return getClassPathSource("invoice.xsd"); 52 } else if (systemId.equals(BLUEPRINTS_NS + "invoice-activity.xsd")) { 53 return getClassPathSource("invoice-activity.xsd"); 54 } else if (systemId.equals(BLUEPRINTS_NS + "invoice-airline.xsd")) { 55 return getClassPathSource("invoice-airline.xsd"); 56 } else if (systemId.equals(BLUEPRINTS_NS + "invoice-lodging.xsd")) { 57 return getClassPathSource("invoice-lodging.xsd"); 58 } else { 59 return null; 61 } 62 } 63 64 private InputSource getClassPathSource(String name) { 65 InputStream is = null; 66 try { 67 is = getClass().getResourceAsStream(PACKAGE_LOCATION + name); 68 return new InputSource(is); 69 } catch (Exception e) { 70 System.err.println("BrokerEntityResolver error resolving: " + name); 71 e.printStackTrace(); 72 } 73 return null; 75 } 76 } 77 78 | Popular Tags |