Examples of FeatureRegistry


Examples of org.apache.shindig.gadgets.features.FeatureRegistry

  public boolean process(JsRequest request, JsResponseBuilder builder) throws JsException {
    // Get JavaScript content from features aliases request.
    JsUri jsUri = request.getJsUri();
    GadgetContext ctx = new JsGadgetContext(jsUri);

    FeatureRegistry registry;
    try {
      registry = registryProvider.get(jsUri.getRepository());
    } catch (GadgetException e) {
      throw new JsException(e.getHttpStatusCode(), e.getMessage());
    }

    // TODO: possibly warn on unknown/unrecognized libs.
    List<FeatureBundle> requestedBundles = registry.getFeatureResources(
        ctx, jsUri.getLibs(), null).getBundles();
    List<FeatureBundle> loadedBundles = registry.getFeatureResources(
        ctx, jsUri.getLoadedLibs(), null).getBundles();

    Set<String> loadedFeatures = Sets.newHashSet();
    for (FeatureBundle bundle : loadedBundles) {
      loadedFeatures.add(bundle.getName());
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry

          throws GadgetException {
    // TODO: If there isn't any js in the document, we can skip this. Unfortunately, that means
    // both script tags (easy to detect) and event handlers (much more complex).
    GadgetContext context = gadget.getContext();
    String repository = getFeatureRepositoryId(gadget);
    FeatureRegistry featureRegistry = featureRegistryProvider.get(repository);

    checkRequiredFeatures(gadget, featureRegistry);
    //Check to make sure all the required features that are about to be injected are allowed
    if(!gadgetAdminStore.checkFeatureAdminInfo(gadget)) {
      throw new GadgetException(Code.GADGET_ADMIN_FEATURE_NOT_ALLOWED);
    }

    // Set of extern libraries requested by the container
    Set<String> externForcedLibs = defaultExternLibs;

    // gather the libraries we'll need to generate the extern script for
    String externParam = context.getParameter("libs");
    if (StringUtils.isNotBlank(externParam)) {
      externForcedLibs = Sets.newTreeSet(Splitter.on(':').split(externParam));
    }

    // Inject extern script
    if (!externForcedLibs.isEmpty()) {
      injectScript(externForcedLibs, null, false, gadget, headTag, firstHeadChild, "");
    }

    Collection<String> gadgetLibs = Lists.newArrayList(gadget.getDirectFeatureDeps());
    List<Feature> gadgetFeatures = gadget.getSpec().getModulePrefs().getAllFeatures();
    for(Feature feature : gadgetFeatures) {
      if(!feature.getRequired() &&
              !gadgetAdminStore.isAllowedFeature(feature, gadget)) {
        //If the feature is optional and the admin has not allowed it don't include it
        gadgetLibs.remove(feature.getName());
      }
    }

    // Get config for all features
    Set<String> allLibs = ImmutableSet.<String>builder()
        .addAll(externForcedLibs).addAll(gadgetLibs).build();
    String libraryConfig =
      getLibraryConfig(gadget, featureRegistry.getFeatures(allLibs));

    // Inject internal script
    injectScript(gadgetLibs, externForcedLibs, !externalizeFeatures,
        gadget, headTag, firstHeadChild, libraryConfig);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry

  }

  public boolean process(JsRequest request, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = request.getJsUri();
    GadgetContext ctx = new JsGadgetContext(jsUri);
    FeatureRegistry registry;
    try {
      registry = registryProvider.get(jsUri.getRepository());
    } catch (GadgetException e) {
      throw new JsException(e.getHttpStatusCode(), e.getMessage());
    }

    // Append gadgets.config initialization if not in standard gadget mode.
    if (ctx.getRenderingContext() != RenderingContext.GADGET) {
      List<String> allReq = registry.getFeatures(jsUri.getLibs());
      Collection<String> loaded = jsUri.getLoadedLibs();

      // Only inject config for features not already present and configured.
      List<String> newReq = subtractCollection(allReq, loaded);
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry

  }

  public boolean process(JsRequest jsRequest, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = jsRequest.getJsUri();

    FeatureRegistry registry = null;
    String repository = jsUri.getRepository();
    try {
      registry = featureRegistryProvider.get(jsUri.getRepository());
    } catch (GadgetException e) {
      if (LOG.isLoggable(Level.WARNING)) {
        LOG.log(Level.WARNING, "No registry found for repository: " + repository, e);
      }
    }

    if (registry != null && !jsUri.isNohint()) {
      Set<String> allfeatures = registry.getAllFeatureNames();

      Set<String> libs = Sets.newTreeSet();
      libs.addAll(jsUri.getLibs());
      libs.removeAll(jsUri.getLoadedLibs());
      libs.retainAll(allfeatures);
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry

  }

  public boolean process(JsRequest jsRequest, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = jsRequest.getJsUri();
    ImmutableList.Builder<JsContent> resp = ImmutableList.builder();
    FeatureRegistry featureRegistry = getFeatureRegistry(jsUri);

    boolean needDefers = false;
    if (jsUri.isJsload()) {
      // append all exports for deferred symbols
      List<FeatureBundle> bundles = getSupportDeferBundles(featureRegistry, jsRequest);
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry

  }

  public boolean process(JsRequest jsRequest, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = jsRequest.getJsUri();
    ImmutableList.Builder<JsContent> resp = ImmutableList.builder();
    FeatureRegistry featureRegistry = getFeatureRegistry(jsUri);

    boolean needExports = false;
    FeatureBundle last = null;
    if (!jsUri.isJsload()) {
      for (JsContent jsc : builder.build().getAllJsContent()) {
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry

    } catch (UnsupportedEncodingException e) {
      digest.update(debugContent.getBytes());
    }

    featureChecksum = HashUtil.bytesToHex(digest.digest());
    FeatureRegistry registry = createMock(FeatureRegistry.class);
    FeatureResource resource = new FeatureResource.Simple(featureContent, debugContent, "js");
    List<FeatureResource> allResources = Lists.newArrayList(resource);
    final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
    expect(lr.getResources()).andReturn(allResources);
    replay(lr);
    expect(registry.getAllFeatures()).andReturn(lr).once();
    replay(registry);
    versioner = new AllJsIframeVersioner(registry);
    verify(registry);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry

          throws GadgetException {
    // TODO: If there isn't any js in the document, we can skip this. Unfortunately, that means
    // both script tags (easy to detect) and event handlers (much more complex).
    GadgetContext context = gadget.getContext();
    String repository = getFeatureRepositoryId(gadget);
    FeatureRegistry featureRegistry = featureRegistryProvider.get(repository);

    checkRequiredFeatures(gadget, featureRegistry);
    //Check to make sure all the required features that are about to be injected are allowed
    if(!gadgetAdminStore.checkFeatureAdminInfo(gadget)) {
      throw new GadgetException(Code.GADGET_ADMIN_FEATURE_NOT_ALLOWED);
    }

    // Set of extern libraries requested by the container
    Set<String> externForcedLibs = defaultExternLibs;

    // gather the libraries we'll need to generate the extern script for
    String externParam = context.getParameter("libs");
    if (StringUtils.isNotBlank(externParam)) {
      externForcedLibs = Sets.newTreeSet(Splitter.on(':').split(externParam));
    }

    // Inject extern script
    if (!externForcedLibs.isEmpty()) {
      injectScript(externForcedLibs, null, false, gadget, headTag, firstHeadChild, "");
    }

    Collection<String> gadgetLibs = Lists.newArrayList(gadget.getDirectFeatureDeps());
    List<Feature> gadgetFeatures = gadget.getSpec().getModulePrefs().getAllFeatures();
    for(Feature feature : gadgetFeatures) {
      if(!feature.getRequired() &&
              !gadgetAdminStore.isAllowedFeature(feature, gadget)) {
        //If the feature is optional and the admin has not allowed it don't include it
        gadgetLibs.remove(feature.getName());
      }
    }

    // Get config for all features
    Set<String> allLibs = ImmutableSet.<String>builder()
        .addAll(externForcedLibs).addAll(gadgetLibs).build();
    String libraryConfig =
      getLibraryConfig(gadget, featureRegistry.getFeatures(allLibs));

    // Inject internal script
    injectScript(gadgetLibs, externForcedLibs, !externalizeFeatures,
        gadget, headTag, firstHeadChild, libraryConfig);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.