• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java WebJarAssetLocator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.webjars.WebJarAssetLocator的典型用法代码示例。如果您正苦于以下问题:Java WebJarAssetLocator类的具体用法?Java WebJarAssetLocator怎么用?Java WebJarAssetLocator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebJarAssetLocator类属于org.webjars包,在下文中一共展示了WebJarAssetLocator类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: resolveURL

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
private void resolveURL() {
  try {
    upgradeReadLockToWriteLock();

    if (!urlResolved) {
      String path = getPath();
      if (path.startsWith(WebJarAssetLocator.WEBJARS_PATH_PREFIX)) {
        url = classLoader.getResource(path);
        validateURL(url);
      }
      urlResolved = true;
    }
  } finally {
    downgradeWriteLockToReadLock();
  }
}
 
开发者ID:eddyson-de,项目名称:tapestry-webjars,代码行数:17,代码来源:WebjarsResource.java


示例2: HumptyBootstrap

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
public HumptyBootstrap(Configuration configuration, Object... resources) {
  this.configuration = configuration;
  this.resources = resources;
  this.humptyOptions = configuration.getOptionsFor(this);
  this.pipelineElements = loadPipelineElements();
  this.bundleResolvers = getElements(BundleResolver.class, getConfiguration("bundleResolvers"));
  this.resolvers = getElements(Resolver.class, Optional.empty());
  this.sourceProcessors = getElements(SourceProcessor.class, getConfiguration("sources"));
  this.assetProcessors = getElements(AssetProcessor.class, getConfiguration("assets"));
  this.bundleProcessors = getElements(BundleProcessor.class, getConfiguration("bundles"));
  this.pipelineListeners = getElements(PipelineListener.class, getConfiguration("listeners"));
  this.locator = Arrays.stream(resources)
    .filter(resource -> resource instanceof WebJarAssetLocator)
    .map(resource -> (WebJarAssetLocator) resource)
    .findFirst()
    .orElseGet(this::getDefaultLocator);
  this.pipeline = new Pipeline(bundleResolvers, resolvers, sourceProcessors, assetProcessors, bundleProcessors, pipelineListeners);
  
  bundleResolvers.forEach(this::inject);
  resolvers.forEach(this::inject);
  sourceProcessors.forEach(this::inject);
  assetProcessors.forEach(this::inject);
  bundleProcessors.forEach(this::inject);
  pipelineListeners.forEach(this::inject);
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:26,代码来源:HumptyBootstrap.java


示例3: inject

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
private void inject(PipelineElement element) {
  Stream.of(element.getClass().getMethods())
  .filter(m -> m.isAnnotationPresent(Inject.class))
  .forEach(method -> {
    Class<?>[] parameterTypes = method.getParameterTypes();
    Object[] args = new Object[parameterTypes.length];
    for (int i = 0; i < parameterTypes.length; i++) {
      Class<?> parameterType = parameterTypes[i];
      if (parameterType == Pipeline.class) {
        args[i] = pipeline;
      } else if (parameterType == WebJarAssetLocator.class) {
        args[i] = locator;
      } else if (parameterType == Configuration.class) {
        args[i] = configuration;
      } else if (parameterType == Configuration.Options.class) {
        args[i] = configuration.getOptionsFor(element);
      } else if (parameterType == Configuration.GlobalOptions.class) {
        args[i] = configuration.getGlobalOptions();
      } else {
        args[i] = getExtra(parameterType).orElseThrow(() -> new IllegalArgumentException("Cannot inject the type " + parameterType.getName() + " into " + element.getClass().getName()));
      }
    }

    try {
      method.invoke(element, args);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  });
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:31,代码来源:HumptyBootstrap.java


示例4: getDefaultLocator

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
private WebJarAssetLocator getDefaultLocator() {
  try {
    String assetsDir = configuration.getGlobalOptions().getAssetsDir().toString();
    Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(assetsDir);
    if (!assetsDir.startsWith("/")) {
      assetsDir = "/" + assetsDir;
    }
    if (!assetsDir.endsWith("/")) {
      assetsDir += "/";
    }
    String fullAssetsDir = assetsDir;
    
    Set<String> assetPaths = new HashSet<>();
    
    while (urls.hasMoreElements()) {
      URL url = urls.nextElement();
      Files.walk(Paths.get(url.getFile()))
        .filter(path -> path.toFile().isFile())
        .map(Path::toString)
        .map(path -> path.substring(path.indexOf(fullAssetsDir) + 1))
        .forEach(assetPaths::add);
    }
    
    assetPaths.addAll(new WebJarAssetLocator().getFullPathIndex().values());
    
    return new WebJarAssetLocator(assetPaths);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:31,代码来源:HumptyBootstrap.java


示例5: should_not_provide_minified_asset_when_preferMin_is_false

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@Test
public void should_not_provide_minified_asset_when_preferMin_is_false() throws Exception {
  HashMap<String, Object> options = new HashMap<String, Object>();
  options.put("preferMin", Boolean.FALSE);
  resolver.configure(new WebJarAssetLocator(), new Configuration.Options(options));
  
  Context context = new Context(Configuration.Mode.PRODUCTION, libs);
  List<String> assetFilePaths = resolver.resolve("jquery.js", context).stream().map(AssetFile::getPath).collect(toList());
  assetFilePaths.addAll(resolver.resolve("web_server.js", context).stream().map(AssetFile::getPath).collect(toList()));

  assertThat(assetFilePaths, contains("META-INF/resources/webjars/jquery/2.1.1/jquery.js", "META-INF/resources/webjars/humpty/1.0.0/web_server.js"));
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:13,代码来源:WebJarResolverTest.java


示例6: createFromRequestPath

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
public Resource createFromRequestPath(final String path) {
  return new WebjarsResource(WebJarAssetLocator.WEBJARS_PATH_PREFIX + "/" + path, assetPathResolver, classLoader);
}
 
开发者ID:eddyson-de,项目名称:tapestry-webjars,代码行数:4,代码来源:WebjarsResource.java


示例7: createAsset

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@Override
public Asset createAsset(final Resource resource) {
  return createAsset(resource, "webjars",
      ((WebjarsResource) resource).getPath().substring(WebJarAssetLocator.WEBJARS_PATH_PREFIX.length() + 1));
}
 
开发者ID:eddyson-de,项目名称:tapestry-webjars,代码行数:6,代码来源:WebjarsAssetFactory.java


示例8: AssetPathResolverImpl

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
public AssetPathResolverImpl(final WebJarAssetLocator webJarAssetLocator, final LoggerSource loggerSource) {
  this.webJarAssetLocator = webJarAssetLocator;
  this.logger = loggerSource.getLogger(AssetPathResolverImpl.class);
  this.webjars = Collections.unmodifiableMap(webJarAssetLocator.getWebJars());

}
 
开发者ID:eddyson-de,项目名称:tapestry-webjars,代码行数:7,代码来源:AssetPathResolverImpl.java


示例9: buildWebJarAssetLocator

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@EagerLoad
public static WebJarAssetLocator buildWebJarAssetLocator() {
  SortedMap<String, String> pathIndex = WebJarAssetLocator.getFullPathIndex(Pattern.compile(".*"),
      Thread.currentThread().getContextClassLoader());
  return new WebJarAssetLocator(pathIndex);
}
 
开发者ID:eddyson-de,项目名称:tapestry-webjars,代码行数:7,代码来源:WebjarsModule.java


示例10: build

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
public static AssetPathResolver build(final WebJarAssetLocator webJarAssetLocator, final LoggerSource loggerSource) {
  return new AssetPathResolverImpl(webJarAssetLocator, loggerSource);
}
 
开发者ID:eddyson-de,项目名称:tapestry-webjars,代码行数:4,代码来源:WebjarsModule.java


示例11: configure

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@Inject
public void configure(Configuration configuration, WebJarAssetLocator locator) {
  this.locator = locator;
  this.bundles = configuration.getBundles();
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:6,代码来源:WebJarAssetBundleResolver.java


示例12: configure

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@Inject
public void configure(WebJarAssetLocator webJarAssetLocator, Configuration.Options options) {
  this.webJarAssetLocator = webJarAssetLocator;
  this.preferMin = options.get("preferMin");
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:6,代码来源:WebJarResolver.java


示例13: should_find_source_maps

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@Test
public void should_find_source_maps() throws Exception {
  String sourceMap = pipeline.process("jquery.min.map").getAsset();
  
  assertEquals(IOUtils.toString(getClass().getClassLoader().getResourceAsStream(new WebJarAssetLocator().getFullPath("jquery.min.map"))), sourceMap.trim());
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:7,代码来源:Pipeline_SpecialBundlesTest.java


示例14: should_find_loose_webjar

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@Test
public void should_find_loose_webjar() throws Exception {
  String jquery = pipeline.process("jquery.min.js").getAsset();
  
  assertEquals(IOUtils.toString(getClass().getClassLoader().getResourceAsStream(new WebJarAssetLocator().getFullPath("jquery.min.js"))).trim(), jquery.trim());
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:7,代码来源:Pipeline_SpecialBundlesTest.java


示例15: should_reject_existing_bundle

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
public void should_reject_existing_bundle() {
  WebJarAssetBundleResolver resolver = new WebJarAssetBundleResolver();
  resolver.configure(Configuration.load("/humpty-special-bundles.toml"), new WebJarAssetLocator());
  
  assertFalse(resolver.accepts("asset.js"));
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:7,代码来源:Pipeline_SpecialBundlesTest.java


示例16: before

import org.webjars.WebJarAssetLocator; //导入依赖的package包/类
@Before
public void before() {
  resolver.configure(new WebJarAssetLocator(), configuration.getOptionsFor(() -> "webjars"));
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:5,代码来源:WebJarResolverTest.java



注:本文中的org.webjars.WebJarAssetLocator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Producer类代码示例发布时间:2022-05-22
下一篇:
Java CommitLogDescriptor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap