Java 类org.springframework.core.NestedIOException 实例源码

项目:lams    文件:ConfigurationClassParser.java   
/**
 * Recursively collect all declared {@code @Import} values. Unlike most
 * meta-annotations it is valid to have several {@code @Import}s declared with
 * different values; the usual process of returning values from the first
 * meta-annotation on a class is not sufficient.
 * <p>For example, it is common for a {@code @Configuration} class to declare direct
 * {@code @Import}s in addition to meta-imports originating from an {@code @Enable}
 * annotation.
 * @param sourceClass the class to search
 * @param imports the imports collected so far
 * @param visited used to track visited classes to prevent infinite recursion
 * @throws IOException if there is any problem reading metadata from the named class
 */
private void collectImports(SourceClass sourceClass, Set<SourceClass> imports, Set<SourceClass> visited) throws IOException {
    try {
        if (visited.add(sourceClass)) {
            for (SourceClass annotation : sourceClass.getAnnotations()) {
                String annName = annotation.getMetadata().getClassName();
                if (!annName.startsWith("java") && !annName.equals(Import.class.getName())) {
                    collectImports(annotation, imports, visited);
                }
            }
            imports.addAll(sourceClass.getAnnotationAttributes(Import.class.getName(), "value"));
        }
    }
    catch (ClassNotFoundException ex) {
        throw new NestedIOException("Unable to collect imports", ex);
    }
}
项目:spring4-understanding    文件:ConfigurationClassParser.java   
private SourceClass getRelated(String className) throws IOException {
    if (this.source instanceof Class<?>) {
        try {
            Class<?> clazz = resourceLoader.getClassLoader().loadClass(className);
            return asSourceClass(clazz);
        }
        catch (ClassNotFoundException ex) {
            // Ignore -> fall back to ASM next, except for core java types.
            if (className.startsWith("java")) {
                throw new NestedIOException("Failed to load class [" + className + "]", ex);
            }
            return new SourceClass(metadataReaderFactory.getMetadataReader(className));
        }
    }
    return asSourceClass(className);
}
项目:my-spring-cache-redis    文件:ConfigurationClassParser.java   
/**
 * Recursively collect all declared {@code @Import} values. Unlike most
 * meta-annotations it is valid to have several {@code @Import}s declared with
 * different values; the usual process of returning values from the first
 * meta-annotation on a class is not sufficient.
 * <p>For example, it is common for a {@code @Configuration} class to declare direct
 * {@code @Import}s in addition to meta-imports originating from an {@code @Enable}
 * annotation.
 * @param sourceClass the class to search
 * @param imports the imports collected so far
 * @param visited used to track visited classes to prevent infinite recursion
 * @throws IOException if there is any problem reading metadata from the named class
 */
private void collectImports(SourceClass sourceClass, Set<SourceClass> imports, Set<SourceClass> visited) throws IOException {
    try {
        if (visited.add(sourceClass)) {
            for (SourceClass annotation : sourceClass.getAnnotations()) {
                String annName = annotation.getMetadata().getClassName();
                if (!annName.startsWith("java") && !annName.equals(Import.class.getName())) {
                    collectImports(annotation, imports, visited);
                }
            }
            imports.addAll(sourceClass.getAnnotationAttributes(Import.class.getName(), "value"));
        }
    }
    catch (ClassNotFoundException ex) {
        throw new NestedIOException("Unable to collect imports", ex);
    }
}
项目:Shop-for-JavaWeb    文件:SqlSessionFactoryBean.java   
/**
 * TODO 刷新
 * 
 * @param inputStream
 * @param resource
 * @param configuration
 * @throws NestedIOException
 */
public static void refresh(java.io.InputStream inputStream,
        String resource, Configuration configuration)
        throws NestedIOException {

    try {
        XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(
                inputStream, configuration, resource,
                configuration.getSqlFragments());
        xmlMapperBuilder.parse1();
    } catch (Exception e) {
        throw new NestedIOException("Failed to parse mapping resource: '"
                + resource + "'", e);
    } finally {
        ErrorContext.instance().reset();
    }

}
项目:spring    文件:ConfigurationClassParser.java   
private SourceClass getRelated(String className) throws IOException {
    if (this.source instanceof Class<?>) {
        try {
            Class<?> clazz = resourceLoader.getClassLoader().loadClass(className);
            return asSourceClass(clazz);
        }
        catch (ClassNotFoundException ex) {
            // Ignore -> fall back to ASM next, except for core java types.
            if (className.startsWith("java")) {
                throw new NestedIOException("Failed to load class [" + className + "]", ex);
            }
            return new SourceClass(metadataReaderFactory.getMetadataReader(className));
        }
    }
    return asSourceClass(className);
}
项目:spring-boot-sample    文件:SqlSessionFactoryBean.java   
/**
 * TODO 刷新
 *
 * @param inputStream
 * @param resource
 * @param configuration
 * @throws NestedIOException
 */
public static void refresh(java.io.InputStream inputStream,
                           String resource, Configuration configuration)
        throws NestedIOException {

    try {
        XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(
                inputStream, configuration, resource,
                configuration.getSqlFragments());
        xmlMapperBuilder.parse();
    } catch (Exception e) {
        throw new NestedIOException("Failed to parse mapping resource: '"
                + resource + "'", e);
    } finally {
        ErrorContext.instance().reset();
    }

}
项目:class-guard    文件:VfsUtils.java   
static File getFile(Object vfsResource) throws IOException {
    if (VFS_VER.V2.equals(version)) {
        if ((Boolean) invokeVfsMethod(VFS_UTILS_METHOD_IS_NESTED_FILE, null, vfsResource)) {
            throw new IOException("File resolution not supported for nested resource: " + vfsResource);
        }
        try {
            return new File((URI) invokeVfsMethod(VFS_UTILS_METHOD_GET_COMPATIBLE_URI, null, vfsResource));
        }
        catch (Exception ex) {
            throw new NestedIOException("Failed to obtain File reference for " + vfsResource, ex);
        }
    }
    else {
        return (File) invokeVfsMethod(GET_PHYSICAL_FILE, vfsResource);
    }
}
项目:mongodb-orm    文件:MongoORMFactoryBean.java   
public void init() throws Exception {
  MqlMapConfigParser configParser = new MqlMapConfigParser();
  for (Resource configLocation : configLocations) {
    InputStream is = configLocation.getInputStream();
    try {
      logger.debug("Mql configuration parse resource file. File name is "+configLocation.getFilename());
      configParser.parse(is);
      logger.debug("Mql configuration parse resource file finished. File name is "+configLocation.getFilename());
    } catch (RuntimeException ex) {
      throw new NestedIOException("Failed to parse config configuration. File name is " + configLocation.getFilename(), ex.getCause());
    }
  }
  configParser.validateMapping();
  this.configParser = configParser;
  logger.info("Mongodb orm framework has ready.");
}
项目:SSMFrameBase    文件:LocalSqlSessionFactory.java   
@Override
protected SqlSessionFactory buildSqlSessionFactory() throws IOException {
    try {
        return super.buildSqlSessionFactory();
    } catch (NestedIOException e) {
        logger.error("mapper.xml解析报错:",e);
        throw new NestedIOException("Failed to parse mapping resource: ", e);
    } finally {
        ErrorContext.instance().reset();
    }
}
项目:spring4-understanding    文件:ConfigurationClassParser.java   
/**
 * Factory method to obtain a {@link SourceClass} from a class name.
 */
public SourceClass asSourceClass(String className) throws IOException {
    if (className.startsWith("java")) {
        // Never use ASM for core java types
        try {
            return new SourceClass(this.resourceLoader.getClassLoader().loadClass(className));
        }
        catch (ClassNotFoundException ex) {
            throw new NestedIOException("Failed to load class [" + className + "]", ex);
        }
    }
    return new SourceClass(this.metadataReaderFactory.getMetadataReader(className));
}
项目:spring4-understanding    文件:DefaultDeserializer.java   
/**
 * Read from the supplied {@code InputStream} and deserialize the contents
 * into an object.
 * @see ObjectInputStream#readObject()
 */
@Override
@SuppressWarnings("resource")
public Object deserialize(InputStream inputStream) throws IOException {
    ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, this.classLoader);
    try {
        return objectInputStream.readObject();
    }
    catch (ClassNotFoundException ex) {
        throw new NestedIOException("Failed to deserialize object type", ex);
    }
}
项目:spring4-understanding    文件:AbstractResource.java   
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
@Override
public URI getURI() throws IOException {
    URL url = getURL();
    try {
        return ResourceUtils.toURI(url);
    }
    catch (URISyntaxException ex) {
        throw new NestedIOException("Invalid URI [" + url + "]", ex);
    }
}
项目:spring4-understanding    文件:VfsResource.java   
@Override
public URL getURL() throws IOException {
    try {
        return VfsUtils.getURL(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
    }
}
项目:spring4-understanding    文件:VfsResource.java   
@Override
public URI getURI() throws IOException {
    try {
        return VfsUtils.getURI(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
    }
}
项目:Shop-for-JavaWeb    文件:MapperLoader.java   
public void reloadXML() throws Exception {
    SqlSessionFactory factory = context.getBean(SqlSessionFactory.class);
    Configuration configuration = factory.getConfiguration();
    // 移除加载项
    removeConfig(configuration);
    // 重新扫描加载
    for (String basePackage : basePackages) {
        Resource[] resources = getResource(basePackage, XML_RESOURCE_PATTERN);
        if (resources != null) {
            for (int i = 0; i < resources.length; i++) {
                if (resources[i] == null) {
                    continue;
                }
                try {
                    XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(resources[i].getInputStream(),
                            configuration, resources[i].toString(), configuration.getSqlFragments());
                    xmlMapperBuilder.parse();
                } catch (Exception e) {
                    throw new NestedIOException("Failed to parse mapping resource: '" + resources[i] + "'", e);
                } finally {
                    ErrorContext.instance().reset();
                }
            }
        }
    }

}
项目:spring    文件:ConfigurationClassParser.java   
/**
 * Factory method to obtain a {@link SourceClass} from a class name.
 */
public SourceClass asSourceClass(String className) throws IOException {
    if (className.startsWith("java")) {
        // Never use ASM for core java types
        try {
            return new SourceClass(this.resourceLoader.getClassLoader().loadClass(className));
        }
        catch (ClassNotFoundException ex) {
            throw new NestedIOException("Failed to load class [" + className + "]", ex);
        }
    }
    return new SourceClass(this.metadataReaderFactory.getMetadataReader(className));
}
项目:spring    文件:DefaultDeserializer.java   
/**
 * Read from the supplied {@code InputStream} and deserialize the contents
 * into an object.
 * @see ObjectInputStream#readObject()
 */
@Override
@SuppressWarnings("resource")
public Object deserialize(InputStream inputStream) throws IOException {
    ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, this.classLoader);
    try {
        return objectInputStream.readObject();
    }
    catch (ClassNotFoundException ex) {
        throw new NestedIOException("Failed to deserialize object type", ex);
    }
}
项目:spring    文件:AbstractResource.java   
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
@Override
public URI getURI() throws IOException {
    URL url = getURL();
    try {
        return ResourceUtils.toURI(url);
    }
    catch (URISyntaxException ex) {
        throw new NestedIOException("Invalid URI [" + url + "]", ex);
    }
}
项目:spring    文件:VfsResource.java   
@Override
public URL getURL() throws IOException {
    try {
        return VfsUtils.getURL(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
    }
}
项目:spring    文件:VfsResource.java   
@Override
public URI getURI() throws IOException {
    try {
        return VfsUtils.getURI(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
    }
}
项目:rabbitframework    文件:RabbitDbaseFactoryBean.java   
public RabbitDbaseFactory buildRabbitDbaseFactory() throws Exception {
    Configuration configuration = null;
    XMLConfigBuilder configBuilder = null;
    if (configLocation != null) {
        configBuilder = new XMLConfigBuilder(configLocation.getInputStream(), configurationProperties);
        configuration = configBuilder.getConfiguration();
    } else {
        configuration = new Configuration();
        configuration.setVariables(configurationProperties);
    }
    if (configBuilder != null) {
        try {
            configBuilder.parse();
            logger.trace("Parsed configuration file: '" + this.configLocation + "'");
        } catch (Exception ex) {
            throw new NestedIOException("Failed to parse config resource: " + this.configLocation, ex);
        }
    }
    Environment environment = new Environment();
    for (Entry<String, DataSourceBean> entry : dataSourceMap.entrySet()) {
        String name = entry.getKey();
        DataSourceBean dataSource = entry.getValue();
        dataSourceFactory.addDataSource(name, dataSource);
        environment.addCacheDataSource(dataSource.getDataSource());
    }
    environment.setDataSourceFactory(dataSourceFactory);
    configuration.setEnvironment(environment);
    String[] entityPackageNames = StringUtils.tokenizeToStringArray(entityPackages);
    configuration.addEntitys(entityPackageNames);
    String[] mapperPackageNames = StringUtils.tokenizeToStringArray(mapperPackages);
    configuration.addMappers(mapperPackageNames);
    configuration.addCaches(cacheMap);
    return rabbitDbaseFactoryBuilder.build(configuration);
}
项目:ShoppingMall    文件:AbstractResource.java   
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
public URI getURI() throws IOException {
    URL url = getURL();
    try {
        return ResourceUtils.toURI(url);
    }
    catch (URISyntaxException ex) {
        throw new NestedIOException("Invalid URI [" + url + "]", ex);
    }
}
项目:class-guard    文件:DefaultDeserializer.java   
/**
 * Reads the input stream and deserializes into an object.
 */
public Object deserialize(InputStream inputStream) throws IOException {
    ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
    try {
        return objectInputStream.readObject();
    }
    catch (ClassNotFoundException ex) {
        throw new NestedIOException("Failed to deserialize object type", ex);
    }
}
项目:class-guard    文件:AbstractResource.java   
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
public URI getURI() throws IOException {
    URL url = getURL();
    try {
        return ResourceUtils.toURI(url);
    }
    catch (URISyntaxException ex) {
        throw new NestedIOException("Invalid URI [" + url + "]", ex);
    }
}
项目:class-guard    文件:VfsResource.java   
@Override
public URL getURL() throws IOException {
    try {
        return VfsUtils.getURL(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
    }
}
项目:class-guard    文件:VfsResource.java   
@Override
public URI getURI() throws IOException {
    try {
        return VfsUtils.getURI(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
    }
}
项目:haogrgr-test    文件:XMLMapperLoader.java   
public void reloadXML() throws Exception {
    SqlSessionFactory factory = context.getBean(SqlSessionFactory.class);
    Configuration configuration = factory.getConfiguration();
    // 移除加载项
    removeConfig(configuration);
    // 重新扫描加载
    for (String basePackage : basePackages) {
        Resource[] resources = getResource(basePackage, XML_RESOURCE_PATTERN);
        if (resources != null) {
            for (int i = 0; i < resources.length; i++) {
                if (resources[i] == null) {
                    continue;
                }
                try {
                    XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(resources[i].getInputStream(), configuration, resources[i].toString(),
                            configuration.getSqlFragments());
                    xmlMapperBuilder.parse();
                } catch (Exception e) {
                    throw new NestedIOException("Failed to parse mapping resource: '" + resources[i] + "'", e);
                } finally {
                    ErrorContext.instance().reset();
                }
            }
        }
    }

}
项目:mongodb-orm    文件:NodeletParser.java   
/**
 * Begins parsing from the provided Reader.
 */
public void parse(Reader reader) throws NestedIOException {
  try {
    Document doc = createDocument(reader);
    parse(doc.getLastChild());
  } catch (Exception e) {
    throw new NestedIOException("Error parsing XML.  Cause: " + e, e);
  }
}
项目:mongodb-orm    文件:NodeletParser.java   
public void parse(InputStream inputStream) throws NestedIOException {
  try {
    Document doc = createDocument(inputStream);
    parse(doc.getLastChild());
  } catch (Exception e) {
    throw new NestedIOException("Error parsing XML.  Cause: " + e, e);
  }
}
项目:clobaframe    文件:AbstractResource.java   
/**
 * This implementation builds a URI based on the URL returned
 * by {@link #getURL()}.
 */
@Override
public URI getURI() throws IOException {
    URL url = getURL();
    try {
        return ResourceUtils.toURI(url);
    }
    catch (URISyntaxException ex) {
        throw new NestedIOException("Invalid URI [" + url + "]", ex);
    }
}
项目:clobaframe    文件:VfsResource.java   
@Override
public URL getURL() throws IOException {
    try {
        return VfsUtils.getURL(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
    }
}
项目:clobaframe    文件:VfsResource.java   
@Override
public URI getURI() throws IOException {
    try {
        return VfsUtils.getURI(this.resource);
    }
    catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
    }
}
项目:mongodb-orm    文件:MqlMapConfigParser.java   
/**
 * Parse resource.
 * 
 * @param inputStream
 * @throws NestedIOException
 */
public void parse(InputStream inputStream) throws NestedIOException {
  parser.parse(inputStream);
}