Java 类org.xml.sax.EntityResolver 实例源码

项目:support-for-xmleditor    文件:Adapter.java   
public void initialize(String pipelineURI, String uriResolverClassName, String entityResolverClassName) {
    try{
        if (uriResolverClassName != null && uriResolverClassName.trim().length()!=0)
            theURIResolver = (URIResolver) getClass().getClassLoader().loadClass(uriResolverClassName).newInstance();
        else
            theURIResolver = null;
        if (entityResolverClassName != null && entityResolverClassName.trim().length()!=0)
            theEntityResolver = (EntityResolver) getClass().getClassLoader().loadClass(entityResolverClassName).newInstance();
        else
            theEntityResolver = null;
        if (pipelineURI != null && pipelineURI.trim().length()!=0)
            thePipelineURI = pipelineURI;
        else
            thePipelineURI = null;
    }
    catch (Throwable t){
        compilationErrors.clear();
        compilationErrors.add(new DocumentPositionedInfo(DocumentPositionedInfo.SEVERITY_ERROR, "Error initializing adapter: "+t.getMessage()));
        dumpStackTrace(t);
    }
}
项目:incubator-netbeans    文件:MakeNBM.java   
static void validateAgainstAUDTDs(InputSource input, final Path updaterJar, final Task task) throws IOException, SAXException {
    XMLUtil.parse(input, true, false, XMLUtil.rethrowHandler(), new EntityResolver() {
        ClassLoader loader = new AntClassLoader(task.getProject(), updaterJar);
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            String remote = "http://www.netbeans.org/dtds/";
            if (systemId.startsWith(remote)) {
                String rsrc = "org/netbeans/updater/resources/" + systemId.substring(remote.length());
                URL u = loader.getResource(rsrc);
                if (u != null) {
                    return new InputSource(u.toString());
                } else {
                    task.log(rsrc + " not found in " + updaterJar, Project.MSG_WARN);
                }
            }
            return null;
        }
    });
}
项目:OpenJSharp    文件:AbstractSAXParser.java   
/**
 * Return the current entity resolver.
 *
 * @return The current entity resolver, or null if none
 *         has been registered.
 * @see #setEntityResolver
 */
public EntityResolver getEntityResolver() {

    EntityResolver entityResolver = null;
    try {
        XMLEntityResolver xmlEntityResolver =
            (XMLEntityResolver)fConfiguration.getProperty(ENTITY_RESOLVER);
        if (xmlEntityResolver != null) {
            if (xmlEntityResolver instanceof EntityResolverWrapper) {
                entityResolver =
                    ((EntityResolverWrapper) xmlEntityResolver).getEntityResolver();
            }
            else if (xmlEntityResolver instanceof EntityResolver2Wrapper) {
                entityResolver =
                    ((EntityResolver2Wrapper) xmlEntityResolver).getEntityResolver();
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }
    return entityResolver;

}
项目:openjdk-jdk10    文件:DOMForestParser.java   
public void parse(InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver)

            throws SAXException, IOException {
        String systemId = source.getSystemId();
        Document dom = forest.get(systemId);

        if (dom == null) {
            // if no DOM tree is built for it,
            // let the fall back parser parse the original document.
            //
            // for example, XSOM parses datatypes.xsd (XML Schema part 2)
            // but this will never be built into the forest.
            fallbackParser.parse(source, handler, errorHandler, entityResolver);
            return;
        }

        scanner.scan(dom, handler);

    }
项目:gemini.blueprint    文件:OsgiBundleXmlApplicationContext.java   
/**
 * Similar to {@link #createNamespaceHandlerResolver(BundleContext, String, ClassLoader)} , this method creates
 * a special OSGi entity resolver that considers the bundle class path first, falling back to the entity resolver
 * service provided by the Spring DM extender.
 * 
 * @param bundleContext the OSGi context of which the resolver should be aware of
 * @param filter OSGi service filter
 * @param bundleClassLoader classloader for creating the OSGi namespace resolver proxy
 * @return a OSGi aware entity resolver
 */
private EntityResolver createEntityResolver(BundleContext bundleContext, String filter,
        ClassLoader bundleClassLoader) {
    Assert.notNull(bundleContext, "bundleContext is required");
    // create local namespace resolver
    EntityResolver localEntityResolver = new DelegatingEntityResolver(bundleClassLoader);
    // hook in OSGi namespace resolver
    EntityResolver osgiServiceEntityResolver = lookupEntityResolver(bundleContext, filter, localEntityResolver);

    ChainedEntityResolver delegate = new ChainedEntityResolver();
    delegate.addEntityResolver(localEntityResolver, "LocalEntityResolver for bundle "
            + OsgiStringUtils.nullSafeNameAndSymName(bundleContext.getBundle()));

    // hook in OSGi namespace resolver
    delegate.addEntityResolver(osgiServiceEntityResolver, "OSGi Service resolver");

    return delegate;
}
项目:openjdk-jdk10    文件:ModelLoader.java   
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
项目:openjdk-jdk10    文件:DOMForestParser.java   
public void parse(
    InputSource source,
    ContentHandler contentHandler,
    ErrorHandler errorHandler,
    EntityResolver entityResolver )
    throws SAXException, IOException {

    String systemId = source.getSystemId();
    Document dom = forest.get(systemId);

    if(dom==null) {
        // if no DOM tree is built for it,
        // let the fall back parser parse the original document.
        //
        // for example, XSOM parses datatypes.xsd (XML Schema part 2)
        // but this will never be built into the forest.
        fallbackParser.parse( source, contentHandler, errorHandler, entityResolver );
        return;
    }

    scanner.scan( dom, contentHandler );
}
项目:OpenJSharp    文件:TransformInputOutput.java   
protected static EntityResolver createRelativePathResolver(final String workingDirectory) {
    return new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            if (systemId != null && systemId.startsWith("file:/")) {
                URI workingDirectoryURI = new File(workingDirectory).toURI();
                URI workingFile;
                try {
                    // Construction new File(new URI(String)).toURI() is used to be sure URI has correct representation without redundant '/'
                    workingFile = convertToNewWorkingDirectory(currentJavaWorkingDirectory, workingDirectoryURI, new File(new URI(systemId)).toURI());
                    return new InputSource(workingFile.toString());
                } catch (URISyntaxException ex) {
                    //Should not get here
                }
            }
            return null;
        }
    };
}
项目:ChronoBike    文件:XmlHelper.java   
public static Document Load(URL url, EntityResolver er) {
//      try {
//          InputStream is = url.openStream();
//          BufferedInputStream buffer = new BufferedInputStream(is); 
//          return Load(buffer,er);
//      } catch (IOException e) {
//          throw new ProgrammingException("XMLHELPER","Error accessing to '"+url.toExternalForm()+"'",e);
//      }
        return null;
    }
项目:openjdk-jdk10    文件:SchemaConstraintChecker.java   
/**
     * convert an array of {@link InputSource InputSource} into an
     * array of {@link Source Source}
     *
     * @param schemas array of {@link InputSource InputSource}
     * @return array of {@link Source Source}
     */
    private static Source[] getSchemaSource(InputSource[] schemas, EntityResolver entityResolver) throws SAXException {
        SAXSource[] sources = new SAXSource[schemas.length];
        for (int i = 0; i < schemas.length; i++) {
            sources[i] = new SAXSource(schemas[i]);
//            sources[i].getXMLReader().setEntityResolver(entityResolver);
        }
        return sources;
    }
项目:incubator-netbeans    文件:PersistenceManager.java   
/** Returns a XML parser. The same parser can be returned assuming that config files
 * are parser sequentially.
 *
 * @return XML parser with set content handler, errror handler
 * and entity resolver.
 */
public XMLReader getXMLParser (DefaultHandler h) throws SAXException {
    if (parser == null) {
        // get non validating, not namespace aware parser
        parser = XMLUtil.createXMLReader();
        parser.setEntityResolver(new EntityResolver () {
            /** Implementation of entity resolver. Points to the local DTD
             * for our public ID */
            public InputSource resolveEntity (String publicId, String systemId)
            throws SAXException {
                if (ModeParser.INSTANCE_DTD_ID_1_0.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_1_1.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_1_2.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_1.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_2.equals(publicId)
                || ModeParser.INSTANCE_DTD_ID_2_3.equals(publicId)
                || GroupParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || TCGroupParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_1_0.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_2_1.equals(publicId)
                || TCRefParser.INSTANCE_DTD_ID_2_2.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_1_0.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_1_1.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_2_0.equals(publicId)
                || WindowManagerParser.INSTANCE_DTD_ID_2_1.equals(publicId)) {
                    InputStream is = new ByteArrayInputStream(new byte[0]);
                    return new InputSource(is);
                }
                return null; // i.e. follow advice of systemID
            }
        });
    }
    parser.setContentHandler(h);
    parser.setErrorHandler(h);
    return parser;
}
项目:openjdk-jdk10    文件:XmlCatalogUtil.java   
/**
 * Instantiate catalog resolver using new catalog API (javax.xml.catalog.*)
 * added in JDK9. Usage of new API removes dependency on internal API
 * (com.sun.org.apache.xml.internal) for modular runtime.
 */
private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception {
    // Prepare array of catalog URIs
    URI[] uris = urls.stream()
                         .map(u -> URI.create(u.toExternalForm()))
                         .toArray(URI[]::new);

    //Create CatalogResolver with new JDK9+ API
    return (EntityResolver) CatalogManager.catalogResolver(CATALOG_FEATURES, uris);
}
项目:openjdk-jdk10    文件:DOMParser.java   
/**
 * Sets the resolver used to resolve external entities. The EntityResolver
 * interface supports resolution of public and system identifiers.
 *
 * @param resolver The new entity resolver. Passing a null value will
 *                 uninstall the currently installed resolver.
 */
public void setEntityResolver(EntityResolver resolver) {

    try {
        XMLEntityResolver xer = (XMLEntityResolver) fConfiguration.getProperty(ENTITY_RESOLVER);
        if (fUseEntityResolver2 && resolver instanceof EntityResolver2) {
            if (xer instanceof EntityResolver2Wrapper) {
                EntityResolver2Wrapper er2w = (EntityResolver2Wrapper) xer;
                er2w.setEntityResolver((EntityResolver2) resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolver2Wrapper((EntityResolver2) resolver));
            }
        }
        else {
            if (xer instanceof EntityResolverWrapper) {
                EntityResolverWrapper erw = (EntityResolverWrapper) xer;
                erw.setEntityResolver(resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolverWrapper(resolver));
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }

}
项目:incubator-netbeans    文件:TopComponentProcessorTest.java   
private static void assertValidate(String xml) throws Exception {
    XMLUtil.parse(new InputSource(new ByteArrayInputStream(xml.getBytes("UTF-8"))), false, true, XMLUtil.defaultErrorHandler(), new EntityResolver() {
        public @Override InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            return new InputSource(new ByteArrayInputStream(new byte[0]));
            /* XXX when #192595 is implemented, can move DTDs here from core.windows, set validate=true above, and use:
            InputSource r = EntityCatalog.getDefault().resolveEntity(publicId, systemId);
            if (r != null) {
                return r;
            } else {
                throw new IOException("network connection to " + systemId);
            }
             */
        }
    });
}
项目:java-9-wtf    文件:EntityResolverFactory.java   
public static EntityResolver create(String configuration) {
    switch (configuration) {
        case "blank":
            return blank();
        case "simple":
            return withDefaultSimpleCatalogManager();
        case "simpleConfigured":
            return withConfiguredSimpleCatalogManager();
        case "":
        case "asPlugin":
            return asInPlugin();
        default:
            throw new IllegalArgumentException("Unknown configuration: " + configuration);
    }
}
项目:java-9-wtf    文件:ReResolvingInputSourceWrapper.java   
public ReResolvingInputSourceWrapper(EntityResolver entityResolver,
                                     InputSource inputSource, String publicId, String systemId) {
    this.entityResolver = entityResolver;
    this.inputSource = inputSource;
    this.setPublicId(publicId);
    this.setSystemId(systemId);
}
项目:java-9-wtf    文件:ReResolvingEntityResolverWrapper.java   
public ReResolvingEntityResolverWrapper(EntityResolver entityResolver) {
    if (entityResolver == null) {
        throw new IllegalArgumentException(
                "Provided entity resolver must not be null.");
    }
    this.entityResolver = entityResolver;
}
项目:OpenJSharp    文件:SchemaConstraintChecker.java   
/**
     * convert an array of {@link InputSource InputSource} into an
     * array of {@link Source Source}
     *
     * @param schemas array of {@link InputSource InputSource}
     * @return array of {@link Source Source}
     */
    private static Source[] getSchemaSource(InputSource[] schemas, EntityResolver entityResolver) throws SAXException {
        SAXSource[] sources = new SAXSource[schemas.length];
        for (int i = 0; i < schemas.length; i++) {
            sources[i] = new SAXSource(schemas[i]);
//            sources[i].getXMLReader().setEntityResolver(entityResolver);
        }
        return sources;
    }
项目:lams    文件:XmlBeanDefinitionReader.java   
/**
 * Return the EntityResolver to use, building a default resolver
 * if none specified.
 */
protected EntityResolver getEntityResolver() {
    if (this.entityResolver == null) {
        // Determine default EntityResolver to use.
        ResourceLoader resourceLoader = getResourceLoader();
        if (resourceLoader != null) {
            this.entityResolver = new ResourceEntityResolver(resourceLoader);
        }
        else {
            this.entityResolver = new DelegatingEntityResolver(getBeanClassLoader());
        }
    }
    return this.entityResolver;
}
项目:lams    文件:DefaultDocumentLoader.java   
/**
 * Create a JAXP DocumentBuilder that this bean definition reader
 * will use for parsing XML documents. Can be overridden in subclasses,
 * adding further initialization of the builder.
 * @param factory the JAXP DocumentBuilderFactory that the DocumentBuilder
 * should be created with
 * @param entityResolver the SAX EntityResolver to use
 * @param errorHandler the SAX ErrorHandler to use
 * @return the JAXP DocumentBuilder
 * @throws ParserConfigurationException if thrown by JAXP methods
 */
protected DocumentBuilder createDocumentBuilder(
        DocumentBuilderFactory factory, EntityResolver entityResolver, ErrorHandler errorHandler)
        throws ParserConfigurationException {

    DocumentBuilder docBuilder = factory.newDocumentBuilder();
    if (entityResolver != null) {
        docBuilder.setEntityResolver(entityResolver);
    }
    if (errorHandler != null) {
        docBuilder.setErrorHandler(errorHandler);
    }
    return docBuilder;
}
项目:OpenJSharp    文件:RuntimeWSDLParser.java   
/**
 * Parses the WSDL and gives WSDLModel. If wsdl parameter is null, then wsdlLoc is used to get the WSDL. If the WSDL
 * document could not be obtained then {@link MetadataResolverFactory} is tried to get the WSDL document, if not found
 * then as last option, if the wsdlLoc has no '?wsdl' as query parameter then it is tried by appending '?wsdl'.
 *
 * @param wsdlLoc
 *      Either this or <tt>wsdl</tt> parameter must be given.
 *      Null location means the system won't be able to resolve relative references in the WSDL,
 */
public static WSDLModel parse(@Nullable URL wsdlLoc, @NotNull Source wsdlSource, @NotNull EntityResolver resolver,
                                  boolean isClientSide, Container container, Class serviceClass,
                                  @NotNull PolicyResolver policyResolver,
                                  boolean isUseStreamFromEntityResolverWrapper,
                                  WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException {
    assert resolver != null;

    RuntimeWSDLParser wsdlParser = new RuntimeWSDLParser(wsdlSource.getSystemId(), new EntityResolverWrapper(resolver, isUseStreamFromEntityResolverWrapper), isClientSide, container, policyResolver, extensions);
    Parser parser;
    try{
        parser = wsdlParser.resolveWSDL(wsdlLoc, wsdlSource, serviceClass);
        if(!hasWSDLDefinitions(parser.parser)){
            throw new XMLStreamException(ClientMessages.RUNTIME_WSDLPARSER_INVALID_WSDL(parser.systemId,
                    WSDLConstants.QNAME_DEFINITIONS, parser.parser.getName(), parser.parser.getLocation()));
        }
    }catch(XMLStreamException e){
        //Try MEX if there is WSDLLoc available
        if(wsdlLoc == null)
            throw e;
        return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions);

    }catch(IOException e){
        //Try MEX if there is WSDLLoc available
        if(wsdlLoc == null)
            throw e;
        return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions);
    }
    wsdlParser.extensionFacade.start(wsdlParser.context);
    wsdlParser.parseWSDL(parser, false);
    wsdlParser.wsdlDoc.freeze();
    wsdlParser.extensionFacade.finished(wsdlParser.context);
    wsdlParser.extensionFacade.postFinished(wsdlParser.context);

    if(wsdlParser.wsdlDoc.getServices().isEmpty())
        throw new WebServiceException(ClientMessages.WSDL_CONTAINS_NO_SERVICE(wsdlLoc));

    return wsdlParser.wsdlDoc;
}
项目:openjdk-jdk10    文件:WSEndpoint.java   
/**
 * Deprecated version that assumes {@code isTransportSynchronous==false}
 */
@Deprecated
public static <T> WSEndpoint<T> create(
    @NotNull Class<T> implType,
    boolean processHandlerAnnotation,
    @Nullable Invoker invoker,
    @Nullable QName serviceName,
    @Nullable QName portName,
    @Nullable Container container,
    @Nullable WSBinding binding,
    @Nullable SDDocumentSource primaryWsdl,
    @Nullable Collection<? extends SDDocumentSource> metadata,
    @Nullable EntityResolver resolver) {
    return create(implType,processHandlerAnnotation,invoker,serviceName,portName,container,binding,primaryWsdl,metadata,resolver,false);
}
项目:openjdk-jdk10    文件:EndpointFactory.java   
public static <T> WSEndpoint<T> createEndpoint(
        Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker,
        @Nullable QName serviceName, @Nullable QName portName,
        @Nullable Container container, @Nullable WSBinding binding,
        @Nullable SDDocumentSource primaryWsdl,
        @Nullable Collection<? extends SDDocumentSource> metadata,
        EntityResolver resolver, boolean isTransportSynchronous, boolean isStandard) {
    EndpointFactory factory = container != null ? container.getSPI(EndpointFactory.class) : null;
    if (factory == null)
            factory = EndpointFactory.getInstance();

    return factory.create(
            implType,processHandlerAnnotation, invoker,serviceName,portName,container,binding,primaryWsdl,metadata,resolver,isTransportSynchronous,isStandard);
}
项目:openjdk-jdk10    文件:EndpointFactory.java   
/**
 * Implements {@link WSEndpoint#create}.
 *
 * No need to take WebServiceContext implementation. When InvokerPipe is
 * instantiated, it calls InstanceResolver to set up a WebServiceContext.
 * We shall only take delegate to getUserPrincipal and isUserInRole from adapter.
 *
 * <p>
 * Nobody else should be calling this method.
 */
public static <T> WSEndpoint<T> createEndpoint(
    Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker,
    @Nullable QName serviceName, @Nullable QName portName,
    @Nullable Container container, @Nullable WSBinding binding,
    @Nullable SDDocumentSource primaryWsdl,
    @Nullable Collection<? extends SDDocumentSource> metadata,
    EntityResolver resolver, boolean isTransportSynchronous) {
    return createEndpoint(implType, processHandlerAnnotation, invoker, serviceName,
                    portName, container, binding, primaryWsdl, metadata, resolver, isTransportSynchronous, true);
}
项目:openjdk-jdk10    文件:RuntimeWSDLParser.java   
/**
 * Parses the WSDL and gives WSDLModel. If wsdl parameter is null, then wsdlLoc is used to get the WSDL. If the WSDL
 * document could not be obtained then {@link MetadataResolverFactory} is tried to get the WSDL document, if not found
 * then as last option, if the wsdlLoc has no '?wsdl' as query parameter then it is tried by appending '?wsdl'.
 *
 * @param wsdlLoc
 *      Either this or {@code wsdl} parameter must be given.
 *      Null location means the system won't be able to resolve relative references in the WSDL,
 */
public static WSDLModel parse(@Nullable URL wsdlLoc, @NotNull Source wsdlSource, @NotNull EntityResolver resolver,
                                  boolean isClientSide, Container container, Class serviceClass,
                                  @NotNull PolicyResolver policyResolver,
                                  boolean isUseStreamFromEntityResolverWrapper,
                                  WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException {
    assert resolver != null;

    RuntimeWSDLParser wsdlParser = new RuntimeWSDLParser(wsdlSource.getSystemId(), new EntityResolverWrapper(resolver, isUseStreamFromEntityResolverWrapper), isClientSide, container, policyResolver, extensions);
    Parser parser;
    try{
        parser = wsdlParser.resolveWSDL(wsdlLoc, wsdlSource, serviceClass);
        if(!hasWSDLDefinitions(parser.parser)){
            throw new XMLStreamException(ClientMessages.RUNTIME_WSDLPARSER_INVALID_WSDL(parser.systemId,
                    WSDLConstants.QNAME_DEFINITIONS, parser.parser.getName(), parser.parser.getLocation()));
        }
    }catch(XMLStreamException e){
        //Try MEX if there is WSDLLoc available
        if(wsdlLoc == null)
            throw e;
        return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions);

    }catch(IOException e){
        //Try MEX if there is WSDLLoc available
        if(wsdlLoc == null)
            throw e;
        return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions);
    }
    wsdlParser.extensionFacade.start(wsdlParser.context);
    wsdlParser.parseWSDL(parser, false);
    wsdlParser.wsdlDoc.freeze();
    wsdlParser.extensionFacade.finished(wsdlParser.context);
    wsdlParser.extensionFacade.postFinished(wsdlParser.context);

    if(wsdlParser.wsdlDoc.getServices().isEmpty())
        throw new WebServiceException(ClientMessages.WSDL_CONTAINS_NO_SERVICE(wsdlLoc));

    return wsdlParser.wsdlDoc;
}
项目:OpenJSharp    文件:SAXParseable.java   
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
项目:OpenJSharp    文件:AbstractSAXParser.java   
/**
 * Sets the resolver used to resolve external entities. The EntityResolver
 * interface supports resolution of public and system identifiers.
 *
 * @param resolver The new entity resolver. Passing a null value will
 *                 uninstall the currently installed resolver.
 */
public void setEntityResolver(EntityResolver resolver) {

    try {
        XMLEntityResolver xer = (XMLEntityResolver) fConfiguration.getProperty(ENTITY_RESOLVER);
        if (fUseEntityResolver2 && resolver instanceof EntityResolver2) {
            if (xer instanceof EntityResolver2Wrapper) {
                EntityResolver2Wrapper er2w = (EntityResolver2Wrapper) xer;
                er2w.setEntityResolver((EntityResolver2) resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolver2Wrapper((EntityResolver2) resolver));
            }
        }
        else {
            if (xer instanceof EntityResolverWrapper) {
                EntityResolverWrapper erw = (EntityResolverWrapper) xer;
                erw.setEntityResolver(resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolverWrapper(resolver));
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }

}
项目:OpenJSharp    文件:DeploymentDescriptorParser.java   
/**
 * Creates an {@link EntityResolver} that consults {@code /WEB-INF/jax-ws-catalog.xml}.
 */
private EntityResolver createEntityResolver() {
    try {
        return XmlUtil.createEntityResolver(loader.getCatalogFile());
    } catch (MalformedURLException e) {
        throw new WebServiceException(e);
    }
}
项目:OpenJSharp    文件:EndpointImpl.java   
private void createEndpoint(String urlPattern) {
    // Checks permission for "publishEndpoint"
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(ENDPOINT_PUBLISH_PERMISSION);
    }

    // See if HttpServer implementation is available
    try {
        Class.forName("com.sun.net.httpserver.HttpServer");
    } catch (Exception e) {
        throw new UnsupportedOperationException("Couldn't load light weight http server", e);
    }
    container = getContainer();
    MetadataReader metadataReader = EndpointFactory.getExternalMetadatReader(implClass, binding);
    WSEndpoint wse = WSEndpoint.create(
            implClass, true,
            invoker,
            getProperty(QName.class, Endpoint.WSDL_SERVICE),
            getProperty(QName.class, Endpoint.WSDL_PORT),
            container,
            binding,
            getPrimaryWsdl(metadataReader),
            buildDocList(),
            (EntityResolver) null,
            false
    );
    // Don't load HttpEndpoint class before as it may load HttpServer classes
    actualEndpoint = new HttpEndpoint(executor, getAdapter(wse, urlPattern));
}
项目:OpenJSharp    文件:EndpointFactory.java   
public static <T> WSEndpoint<T> createEndpoint(
        Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker,
        @Nullable QName serviceName, @Nullable QName portName,
        @Nullable Container container, @Nullable WSBinding binding,
        @Nullable SDDocumentSource primaryWsdl,
        @Nullable Collection<? extends SDDocumentSource> metadata,
        EntityResolver resolver, boolean isTransportSynchronous, boolean isStandard) {
    EndpointFactory factory = container != null ? container.getSPI(EndpointFactory.class) : null;
    if (factory == null)
            factory = EndpointFactory.getInstance();

    return factory.create(
            implType,processHandlerAnnotation, invoker,serviceName,portName,container,binding,primaryWsdl,metadata,resolver,isTransportSynchronous,isStandard);
}
项目:OpenJSharp    文件:EndpointFactory.java   
/**
 * Implements {@link WSEndpoint#create}.
 *
 * No need to take WebServiceContext implementation. When InvokerPipe is
 * instantiated, it calls InstanceResolver to set up a WebServiceContext.
 * We shall only take delegate to getUserPrincipal and isUserInRole from adapter.
 *
 * <p>
 * Nobody else should be calling this method.
 */
public <T> WSEndpoint<T> create(
        Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker,
        @Nullable QName serviceName, @Nullable QName portName,
        @Nullable Container container, @Nullable WSBinding binding,
        @Nullable SDDocumentSource primaryWsdl,
        @Nullable Collection<? extends SDDocumentSource> metadata,
        EntityResolver resolver, boolean isTransportSynchronous) {
    return create(implType, processHandlerAnnotation, invoker, serviceName,
                    portName, container, binding, primaryWsdl, metadata, resolver, isTransportSynchronous,
                    true);

}
项目:trashjam2017    文件:InkscapeLoader.java   
/**
 * Load a SVG document into a diagram
 * 
 * @param in
 *            The input stream from which to read the SVG
 * @param offset
 *            Offset the diagram for the height of the document
 * @return The diagram loaded
 * @throws SlickException
 *             Indicates a failure to process the document
 */
private Diagram loadDiagram(InputStream in, boolean offset)
        throws SlickException {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory
                .newInstance();
        factory.setValidating(false);
        factory.setNamespaceAware(true);

        DocumentBuilder builder = factory.newDocumentBuilder();
        builder.setEntityResolver(new EntityResolver() {
            public InputSource resolveEntity(String publicId,
                    String systemId) throws SAXException, IOException {
                return new InputSource(
                        new ByteArrayInputStream(new byte[0]));
            }
        });

        Document doc = builder.parse(in);
        Element root = doc.getDocumentElement();

        String widthString = root.getAttribute("width");
        while (Character.isLetter(widthString
                .charAt(widthString.length() - 1))) {
            widthString = widthString.substring(0, widthString.length() - 1);
        }

        String heightString = root.getAttribute("height");
        while (Character.isLetter(heightString
                .charAt(heightString.length() - 1))) {
            heightString = heightString.substring(0,heightString.length() - 1);
        }

        float docWidth = Float.parseFloat(widthString);
        float docHeight = Float.parseFloat(heightString);

        diagram = new Diagram(docWidth, docHeight);
        if (!offset) {
            docHeight = 0;
        }
        loadChildren(root, Transform
                .createTranslateTransform(0, -docHeight));

        return diagram;
    } catch (Exception e) {
        throw new SlickException("Failed to load inkscape document", e);
    }
}
项目:OpenJSharp    文件:WsimportTool.java   
public void setEntityResolver(EntityResolver resolver){
    this.options.entityResolver = resolver;
}
项目:incubator-netbeans    文件:LayerTestBase.java   
public EntityResolver getEntityResolver() {
    return EntityCatalog.getDefault();
}
项目:openjdk-jdk10    文件:WhitespaceStripper.java   
public WhitespaceStripper(ContentHandler handler,ErrorHandler eh,EntityResolver er) {
    setContentHandler(handler);
    if(eh!=null)    setErrorHandler(eh);
    if(er!=null)    setEntityResolver(er);
}
项目:OpenJSharp    文件:DocumentBuilderImpl.java   
public void setEntityResolver(EntityResolver er) {
    domParser.setEntityResolver(er);
}
项目:openjdk-jdk10    文件:DefaultAnnotationParser.java   
public ContentHandler getContentHandler(
    AnnotationContext contest, String elementName,
    ErrorHandler errorHandler, EntityResolver entityResolver ) {
    return new DefaultHandler();
}
项目:OpenJSharp    文件:EntityResolverWrapper.java   
/** Sets the SAX entity resolver. */
public void setEntityResolver(EntityResolver entityResolver) {
    fEntityResolver = entityResolver;
}
项目:incubator-netbeans    文件:XMLUtil.java   
/** Entity resolver that knows about AU DTDs, so no network is needed.
 * @author Jesse Glick
 */
public static EntityResolver createAUResolver() {
    return new EntityResolver() {
        @Override
        public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
            if ("-//NetBeans//DTD Autoupdate Catalog 1.0//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-1_0.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Module Info 1.0//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-1_0.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Catalog 2.0//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_0.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Module Info 2.0//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_0.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Catalog 2.2//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_2.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Module Info 2.2//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_2.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Catalog 2.3//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_3.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Module Info 2.3//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_3.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Catalog 2.4//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_4.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Module Info 2.4//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_4.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Catalog 2.5//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_5.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Module Info 2.5//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_5.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Catalog 2.6//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_6.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Catalog 2.7//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_7.dtd").toString()); // NOI18N
            } else if ("-//NetBeans//DTD Autoupdate Module Info 2.7//EN".equals(publicID)) { // NOI18N
                return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_7.dtd").toString()); // NOI18N
            } else {
                if (systemID.endsWith(".dtd")) { // NOI18N
                    return new InputSource(new ByteArrayInputStream(new byte[0]));
                }
                URL u = new URL(systemID);
                URLConnection oc = u.openConnection();
                oc.setConnectTimeout(5000);
                return new InputSource(oc.getInputStream());
            }
        }
    };
}
项目:openjdk-jdk10    文件:SAXBufferProcessor.java   
public EntityResolver getEntityResolver() {
    return _entityResolver;
}