Package com.alibaba.citrus.service.resource

Examples of com.alibaba.citrus.service.resource.ResourceNotFoundException


        } catch (ResourceNotFoundException e) {
            xsltRes = null;
        }

        if (xsltRes == null && failIfNotFound) {
            throw new ResourceNotFoundException("Could not find XSLT file for " + this + ", resourceName="
                    + filterMatchResult.getResourceName());
        }

        Resource resource = chain.doFilter(filterMatchResult, options);
View Full Code Here


            transformer.transform(source, result);

            return new ByteArrayResource(baos.toByteArray());
        } catch (Exception e) {
            throw new ResourceNotFoundException("Could not apply XSLT \"" + xsltResName + "\" to resource \""
                    + xmlResName + "\"", e);
        }
    }
View Full Code Here

    /**
     * �жϷǿա�
     */
    private <T> T checkResource(T resource, String resourceName, Class<T> type) throws ResourceNotFoundException {
        if (resource == null) {
            throw new ResourceNotFoundException(String.format("Could not get %s of resource \"%s\"",
                    type.getSimpleName(), resourceName));
        }

        return resource;
    }
View Full Code Here

        options = newOptions;

        log.trace("Looking for resource: name={}", resourceName);

        R resource = null;
        ResourceNotFoundException chainingException = null;

        if (visitedMappings == null) {
            visitedMappings = createLinkedList();
        }

        if (findBestMatch()) {
            // findBestMatch() ���1. �ҵ�alias����û���ҵ����յ�resource mapping
            if (lastMatchedPattern instanceof ResourceAlias) {
                if (parent != null) {
                    log.trace("Resource \"{}\" not found.  Trying to find it in super ResourceLoadingService",
                            resourceName);

                    try {
                        resource = loadParentResource(resourceName, options);
                    } catch (ResourceNotFoundException e) {
                        // alias���ı�resourceName���ʱ����쳣��Ϊcaused by�쳣
                        chainingException = e;
                    }
                }
            } else {
                // findBestMatch() ���2, 3. �ҵ�resource mapping
                ResourceLoaderMapping mapping = (ResourceLoaderMapping) lastMatchedPattern;

                resource = loadMappedResource(mapping, options);

                if (resource == null) {
                    // ����resourceName���ı䣬�򱣴��쳣��Ϊcaused by�쳣
                    if (!isEquals(resourceName, originalResourceName)) {
                        logResourceNotFound(resourceName);
                        chainingException = new ResourceNotFoundException(String.format(
                                "Could not find resource \"%s\"", resourceName));
                    }
                }
            }
        }

        // findBestMatch() ���4. ʲôҲû�ҵ�
        else {
            if (parent != null) {
                log.trace("Resource \"{}\" not found.  " + "Trying to find it in super ResourceLoadingService",
                        resourceName);

                // ֱ���׳��쳣����Ϊ�͸�parent��resourceName��δ�ı䣬û��Ҫ�����ظ����쳣��Ϣ
                resource = loadParentResource(resourceName, options);
            }
        }

        if (resource == null) {
            logResourceNotFound(originalResourceName);
            throw new ResourceNotFoundException(String.format("Could not find resource \"%s\"", originalResourceName),
                    chainingException);
        }

        log.debug("Found resource \"{}\": {}", originalResourceName, resource);
View Full Code Here

        options = newOptions;

        log.trace("Looking for resource: name={}", resourceName);

        R resource = null;
        ResourceNotFoundException chainingException = null;

        if (visitedMappings == null) {
            visitedMappings = createLinkedList();
        }

        if (findBestMatch()) {
            // findBestMatch() 情况1. 找到alias,但没有找到最终的resource mapping
            if (lastMatchedPattern instanceof ResourceAlias) {
                if (parent != null) {
                    log.trace("Resource \"{}\" not found.  Trying to find it in super ResourceLoadingService",
                              resourceName);

                    try {
                        resource = loadParentResource(resourceName, options);
                    } catch (ResourceNotFoundException e) {
                        // alias将改变resourceName,故保存异常作为caused by异常
                        chainingException = e;
                    }
                }
            } else {
                // findBestMatch() 情况2, 3. 找到resource mapping
                ResourceLoaderMapping mapping = (ResourceLoaderMapping) lastMatchedPattern;

                resource = loadMappedResource(mapping, options);

                if (resource == null) {
                    // 假如resourceName被改变,则保存异常作为caused by异常
                    if (!isEquals(resourceName, originalResourceName)) {
                        logResourceNotFound(resourceName);
                        chainingException = new ResourceNotFoundException(String.format(
                                "Could not find resource \"%s\"", resourceName));
                    }
                }
            }
        }

        // findBestMatch() 情况4. 什么也没找到
        else {
            if (parent != null) {
                log.trace("Resource \"{}\" not found.  " + "Trying to find it in super ResourceLoadingService",
                          resourceName);

                // 直接抛出异常,因为送给parent的resourceName并未改变,没必要创建重复的异常信息
                resource = loadParentResource(resourceName, options);
            }
        }

        if (resource == null) {
            logResourceNotFound(originalResourceName);
            throw new ResourceNotFoundException(String.format("Could not find resource \"%s\"", originalResourceName),
                                                chainingException);
        }

        log.debug("Found resource \"{}\": {}", originalResourceName, resource);
View Full Code Here

    }

    /** 判断非空。 */
    private <T> T checkResource(T resource, String resourceName, Class<T> type) throws ResourceNotFoundException {
        if (resource == null) {
            throw new ResourceNotFoundException(String.format("Could not get %s of resource \"%s\"",
                                                              type.getSimpleName(), resourceName));
        }

        return resource;
    }
View Full Code Here

        } catch (ResourceNotFoundException e) {
            xsltRes = null;
        }

        if (xsltRes == null && failIfNotFound) {
            throw new ResourceNotFoundException("Could not find XSLT file for " + this + ", resourceName="
                                                + filterMatchResult.getResourceName());
        }

        Resource resource = chain.doFilter(filterMatchResult, options);
View Full Code Here

            transformer.transform(source, result);

            return new ByteArrayResource(baos.toByteArray());
        } catch (Exception e) {
            throw new ResourceNotFoundException("Could not apply XSLT \"" + xsltResName + "\" to resource \""
                                                + xmlResName + "\"", e);
        }
    }
View Full Code Here

        options = newOptions;

        log.trace("Looking for resource: name={}", resourceName);

        R resource = null;
        ResourceNotFoundException chainingException = null;

        if (visitedMappings == null) {
            visitedMappings = createLinkedList();
        }

        if (findBestMatch()) {
            // findBestMatch() 情况1. 找到alias,但没有找到最终的resource mapping
            if (lastMatchedPattern instanceof ResourceAlias) {
                if (parent != null) {
                    log.trace("Resource \"{}\" not found.  Trying to find it in super ResourceLoadingService",
                              resourceName);

                    try {
                        resource = loadParentResource(resourceName, options);
                    } catch (ResourceNotFoundException e) {
                        // alias将改变resourceName,故保存异常作为caused by异常
                        chainingException = e;
                    }
                }
            } else {
                // findBestMatch() 情况2, 3. 找到resource mapping
                ResourceLoaderMapping mapping = (ResourceLoaderMapping) lastMatchedPattern;

                resource = loadMappedResource(mapping, options);

                if (resource == null) {
                    // 假如resourceName被改变,则保存异常作为caused by异常
                    if (!isEquals(resourceName, originalResourceName)) {
                        logResourceNotFound(resourceName);
                        chainingException = new ResourceNotFoundException(String.format(
                                "Could not find resource \"%s\"", resourceName));
                    }
                }
            }
        }

        // findBestMatch() 情况4. 什么也没找到
        else {
            if (parent != null) {
                log.trace("Resource \"{}\" not found.  " + "Trying to find it in super ResourceLoadingService",
                          resourceName);

                // 直接抛出异常,因为送给parent的resourceName并未改变,没必要创建重复的异常信息
                resource = loadParentResource(resourceName, options);
            }
        }

        if (resource == null) {
            logResourceNotFound(originalResourceName);
            throw new ResourceNotFoundException(String.format("Could not find resource \"%s\"", originalResourceName),
                                                chainingException);
        }

        log.debug("Found resource \"{}\": {}", originalResourceName, resource);
View Full Code Here

    /**
     * �жϷǿա�
     */
    private <T> T checkResource(T resource, String resourceName, Class<T> type) throws ResourceNotFoundException {
        if (resource == null) {
            throw new ResourceNotFoundException(String.format("Could not get %s of resource \"%s\"",
                    type.getSimpleName(), resourceName));
        }

        return resource;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.resource.ResourceNotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.