示例#1
0
 private String getIncludeReference(final IncludeDirective directive) {
   if (null == m_parent) {
     return directive.getValue();
   } else {
     if (IncludeDirective.REF.equals(directive.getMode())) {
       return directive.getValue();
     } else {
       String path = m_parent.getResourcePath();
       if ("".equals(path)) {
         return directive.getValue();
       } else {
         String key = directive.getValue();
         return path + "/" + key;
       }
     }
   }
 }
示例#2
0
 DefaultResource[] getLocalDefaultProviders(final Scope scope, final Category category) {
   if (null == m_directive) {
     return new DefaultResource[0];
   }
   IncludeDirective[] includes = getLocalIncludes(scope, category);
   DefaultResource[] resources = new DefaultResource[includes.length];
   for (int i = 0; i < includes.length; i++) {
     IncludeDirective include = includes[i];
     if (include.getMode().equals(IncludeDirective.URI)) {
       try {
         String value = include.getValue();
         String urn = resolve(value);
         Properties properties = include.getProperties();
         resources[i] = m_library.getAnonymousResource(urn, properties);
       } catch (URISyntaxException e) {
         final String error = "Invalid uri value: " + include.getValue();
         throw new RuntimeException(error, e);
       } catch (InvalidNameException e) {
         final String error =
             "An anonomous dependency include reference to ["
                 + include
                 + "] within the resource ["
                 + getResourcePath()
                 + "] could not be resolved.";
         throw new InvalidNameException(error, e);
       } catch (Exception e) {
         final String error = "Unexpected error during dynamic resource creation.";
         throw new RuntimeException(error, e);
       }
     } else {
       String ref = getIncludeReference(include);
       try {
         DefaultResource resource = m_library.getDefaultResource(ref);
         resources[i] = resource;
       } catch (InvalidNameException e) {
         if (null == category) {
           final String error =
               "A dependency include ["
                   + ref
                   + "] within ["
                   + this
                   + "] referencing ["
                   + ref
                   + "] under the scope ["
                   + scope
                   + "] is unknown.";
           throw new InvalidNameException(error);
         } else {
           final String error =
               "A dependency include within ["
                   + this
                   + "] referencing ["
                   + ref
                   + "] under the scope ["
                   + scope
                   + "] and category ["
                   + category
                   + "] is unknown.";
           throw new InvalidNameException(error);
         }
       }
     }
   }
   return resources;
 }