Examples of FeatureRegistry


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

  @Before
  public void setUp() {
    String featureContent = "THE_FEATURE_CONTENT";
    String debugContent = "FEATURE_DEBUG_CONTENT";
    featureChecksum = HashUtil.checksum((featureContent + debugContent).getBytes());
    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

  private String allFeatures;

  @Inject
  public void setFeatureRegistryProvider(FeatureRegistryProvider provider) {
    try {
      FeatureRegistry registry = provider.get(null);
      Set<String> allFeatureNames = registry.getAllFeatureNames();

      // TODO(felix8a): Temporary hack for caja
      HashSet<String> someFeatureNames = new HashSet<String>(allFeatureNames);
      someFeatureNames.remove("es53-guest-frame");
      someFeatureNames.remove("es53-guest-frame.opt");
View Full Code Here

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

   *
   * @throws ProcessingException If there is a problem processing the gadget.
   */
  public Gadget process(GadgetContext context) throws ProcessingException {
    GadgetSpec spec;
    FeatureRegistry featureRegistry;

    try {
      spec = gadgetSpecFactory.getGadgetSpec(context);
      spec = substituter.substitute(context, spec);

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 {
    // 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

      if(gadgetAdminStore.isAllowedFeature(feature, gadget)) {
        featureNames.add(feature.getName());
      }
    }
    try {
      FeatureRegistry featureRegistry = featureRegistryProvider.get(context.getRepository());
      LookupResult result = featureRegistry.getFeatureResources(context,
          featureRegistry.getFeatures(featureNames), null);
      List<FeatureBundle> bundles = result.getBundles();
      for (FeatureBundle bundle : bundles) {
        rpcEndpoints.addAll(bundle.getApis(ApiDirective.Type.RPC, false));
      }
    } catch (GadgetException e) {
View Full Code Here

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

  private String allFeatures;

  @Inject
  public void setFeatureRegistryProvider(FeatureRegistryProvider provider) {
    try {
      FeatureRegistry registry = provider.get(null);
      Set<String> allFeatureNames = registry.getAllFeatureNames();

      // TODO(felix8a): Temporary hack for caja
      HashSet<String> someFeatureNames = new HashSet<String>(allFeatureNames);
      someFeatureNames.remove("es53-guest-frame");
      someFeatureNames.remove("es53-guest-frame.opt");
View Full Code Here

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

      if(gadgetAdminStore.isAllowedFeature(feature, gadget)) {
        featureNames.add(feature.getName());
      }
    }
    try {
      FeatureRegistry featureRegistry = featureRegistryProvider.get(context.getRepository());
      LookupResult result = featureRegistry.getFeatureResources(context,
          featureRegistry.getFeatures(featureNames), null);
      List<FeatureBundle> bundles = result.getBundles();
      for (FeatureBundle bundle : bundles) {
        rpcEndpoints.addAll(bundle.getApis(ApiDirective.Type.RPC, false));
      }
    } catch (GadgetException e) {
View Full Code Here

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

      spec = new GadgetSpec(Uri.parse(url), gadgetXml);
    } catch (GadgetException e) {
      return null;
    }

    FeatureRegistry registry = mock(FeatureRegistry.class);
    expect(registry.getFeatures(isA(Collection.class))).andReturn(gadgetFeatures).anyTimes();

    return new Gadget().setSpec(spec).setContext(new GadgetContext()).setGadgetFeatureRegistry(registry);
  }
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.