Examples of MasterDefRegistry


Examples of org.auraframework.system.MasterDefRegistry

        assertFalse("nsCmp is not in cache", isInDefsCache(nsCmpDef, mdri2));
    }

    public void testDescriptorFilterCache() throws Exception {
        ConfigAdapter configAdapter = Aura.getConfigAdapter();
        MasterDefRegistry mdr = getAuraMDR();
        MasterDefRegistryImpl mdri = (MasterDefRegistryImpl) mdr;
        Map<DefType, DefDescriptor<?>> defs = addDefsToCaches(mdri);
        Map<DefType, DefDescriptor<?>> nonPrivDefs = addNonPriveledgedDefsToMDR(mdri);

        DefDescriptor<?> nsDef = defs.get(DefType.NAMESPACE);
        DefDescriptor<?> layoutDef = defs.get(DefType.LAYOUTS);
        DefDescriptor<?> rendererDef = defs.get(DefType.RENDERER);

        DefDescriptor<?> npNSDef = nonPrivDefs.get(DefType.NAMESPACE);
        DefDescriptor<?> npLayoutDef = nonPrivDefs.get(DefType.LAYOUTS);
        DefDescriptor<?> npRendererDef = nonPrivDefs.get(DefType.RENDERER);

        // only picking 3 defs to test the ns as they are mostly dupes
        assertTrue(nsDef.getNamespace() + "  should have been isPriveleged",
                configAdapter.isPrivilegedNamespace(nsDef.getNamespace()));
        assertTrue(layoutDef.getNamespace() + "  should have been isPriveleged",
                configAdapter.isPrivilegedNamespace(layoutDef.getNamespace()));
        assertTrue(rendererDef.getNamespace() + "  should have been isPriveleged",
                configAdapter.isPrivilegedNamespace(rendererDef.getNamespace()));

        assertFalse(npLayoutDef.getNamespace() + "  should not have been isPriveleged",
                configAdapter.isPrivilegedNamespace(npLayoutDef.getNamespace()));
        assertFalse(npNSDef.getNamespace() + "  should not have been isPriveleged",
                configAdapter.isPrivilegedNamespace(npNSDef.getNamespace()));
        assertFalse(npRendererDef.getNamespace() + "  should not have been isPriveleged",
                configAdapter.isPrivilegedNamespace(npRendererDef.getNamespace()));

        DescriptorFilter filter = new DescriptorFilter("*://test:*");
        Set<DefDescriptor<?>> results = mdr.find(filter);
        assertTrue("results should be cached", isInDescriptorFilterCache(filter, results, mdri));
        DescriptorFilter filter2 = new DescriptorFilter("*://gvpTest:*");
        Set<DefDescriptor<?>> results2 = mdr.find(filter2);
        assertTrue("results2 should be cached", isInDescriptorFilterCache(filter2, results2, mdri));

        DescriptorFilter filter3 = new DescriptorFilter("*://cstring:*");
        Set<DefDescriptor<?>> results3 = mdr.find(filter3);
        assertFalse("results3 should not be cached", isInDescriptorFilterCache(filter3, results3, mdri));
        DescriptorFilter filter4 = new DescriptorFilter("*://cstring1:*");
        Set<DefDescriptor<?>> results4 = mdr.find(filter4);
        assertFalse("results4 should be cached", isInDescriptorFilterCache(filter4, results4, mdri));

        DescriptorFilter filter5 = new DescriptorFilter("*://*:*");
        Set<DefDescriptor<?>> results5 = mdr.find(filter5);
        assertFalse("results5 should not be cached", isInDescriptorFilterCache(filter5, results5, mdri));
        // DescriptorFilter filter6 = new DescriptorFilter("*://*test:*");
        // Set<DefDescriptor<?>> results6 = mdr.find(filter6);
        // assertFalse("results6 should be cached", isInDescriptorFilterCache(filter6, results6, mdri));

        MasterDefRegistry mdr2 = restartContextGetNewMDR();
        MasterDefRegistryImpl mdri2 = (MasterDefRegistryImpl) mdr2;
        assertTrue("results should still be cached", isInDescriptorFilterCache(filter, results, mdri2));
        assertTrue("results2 should still be cached", isInDescriptorFilterCache(filter2, results2, mdri2));
        assertFalse("results3 should not be cached", isInDescriptorFilterCache(filter3, results3, mdri2));
        assertFalse("results4 should not be cached", isInDescriptorFilterCache(filter4, results4, mdri2));
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

        ConfigAdapter configAdapter = Aura.getConfigAdapter();
        assertTrue(configAdapter.isPrivilegedNamespace(privilegedCmp.getNamespace()));
        assertFalse(configAdapter.isPrivilegedNamespace(unprivilegedCmp.getNamespace()));
        assertTrue(configAdapter.isPrivilegedNamespace(privilegedRoot.getNamespace()));

        MasterDefRegistry mdr = Aura.getContextService().getCurrentContext().getDefRegistry();
        MasterDefRegistryImpl mdri = (MasterDefRegistryImpl) mdr;
        mdr.getDef(privilegedCmp);
        assertTrue(isInDepsCache(privilegedCmp, mdri));
        assertFalse(isInDepsCache(unprivilegedCmp, mdri));
        assertFalse(isInDepsCache(privilegedRoot, mdri));

        mdr.invalidate(DefDescriptorImpl.getInstance("aura:component", ComponentDef.class)); // invalidate the world
        mdr.getDef(unprivilegedCmp);
        assertFalse(isInDepsCache(privilegedCmp, mdri));
        assertFalse(isInDepsCache(unprivilegedCmp, mdri));
        assertFalse(isInDepsCache(privilegedRoot, mdri));

        mdr.invalidate(DefDescriptorImpl.getInstance("aura:component", ComponentDef.class)); // invalidate the world
        try {
            mdr.getDef(privilegedRoot);
            fail("Shouldn't be able to have a privileged cmp depend on an unprivileged cmp");
        } catch (Throwable t) {
            this.assertExceptionMessageStartsWith(t,
                    DefinitionNotFoundException.class, String.format(
                            "No COMPONENT named %s found",
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

        assertEquals(prefix, "java");

        ConfigAdapter configAdapter = Aura.getConfigAdapter();
        assertFalse(configAdapter.isPrivilegedNamespace(controllerDef.getNamespace()));

        MasterDefRegistry mdr = Aura.getContextService().getCurrentContext().getDefRegistry();
        // mdr.getDef(controllerDef);
        MasterDefRegistryImpl mdri = (MasterDefRegistryImpl) mdr;
        assertTrue(isInDepsCache(controllerDef, mdri));
    }
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

            if (extended.getEventType() != getEventType()) {
                throw new InvalidDefinitionException(String.format("Event %s cannot extend %s", getDescriptor(),
                        getExtendsDescriptor()), getLocation());
            }
           
            MasterDefRegistry registry = Aura.getDefinitionService().getDefRegistry();
            registry.assertAccess(descriptor, extended);

            // need to resolve duplicated attributes from supers
        }
       
        for (AttributeDef att : this.attributeDefs.values()) {
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

        }
       
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<?> referencingDesc = context.getCurrentCallingDescriptor();
      if (referencingDesc != null) {
          MasterDefRegistry registry = Aura.getDefinitionService().getDefRegistry();
        registry.assertAccess(referencingDesc, getComponentDef());
      }

        validateAttributesValues(referencingDesc);

        // validateMissingAttributes();
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

     */
    private void validateAttributesValues(DefDescriptor<?> referencingDesc) throws QuickFixException, AttributeNotFoundException {
        RootDefinition rootDef = getComponentDef();
        Map<DefDescriptor<AttributeDef>, AttributeDef> atts = rootDef.getAttributeDefs();
        Map<String, RegisterEventDef> registeredEvents = rootDef.getRegisterEventDefs();
        MasterDefRegistry registry = Aura.getDefinitionService().getDefRegistry();
        for (Entry<DefDescriptor<AttributeDef>, AttributeDefRef> entry : getAttributeValues().entrySet()) {
            DefDescriptor<AttributeDef> attributeDefDesc = entry.getKey();
            AttributeDef attributeDef = atts.get(attributeDefDesc);
            if (attributeDef == null) {
                // didn't find an attribute by that name, check if there's an
                // event
                RegisterEventDef registeredEvent = registeredEvents.get(attributeDefDesc.getName());
                if (registeredEvent == null) {
                    throw new AttributeNotFoundException(rootDef.getDescriptor(), attributeDefDesc.getName(),
                            getLocation());
                }
               
              registry.assertAccess(referencingDesc, registeredEvent);
            } else {
              if (referencingDesc != null) {
                // Validate that the referencing component has access to the attribute
                registry.assertAccess(referencingDesc, attributeDef);
              }
             
                // so it was an attribute, make sure to parse it
                entry.getValue().parseValue(attributeDef.getTypeDef());
            }
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

        assertTrue(isInDepsCache(controllerDef, mdri));
    }

    private MasterDefRegistry restartContextGetNewMDR() {
        // simulate new request
        MasterDefRegistry mdr = getAuraMDR();
        AuraContext ctx = Aura.getContextService().getCurrentContext();
        Mode mode = ctx.getMode();
        Format format = ctx.getFormat();
        Authentication access = ctx.getAccess();
        Aura.getContextService().endContext();

        Aura.getContextService().startContext(mode, format, access);
        MasterDefRegistry mdr2 = getAuraMDR();
        assertFalse("MasterDefRegistry should be different after restart of context", mdr == mdr2);
        return mdr2;
    }
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

@Model
public class ReferenceTreeModel {
    public static boolean hasAccess(Definition def) throws QuickFixException {
        DefinitionService definitionService = Aura.getDefinitionService();
        MasterDefRegistry registry = definitionService.getDefRegistry();
        return registry.hasAccess(getReferencingDescriptor(), def) == null;
    }
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

        return registry.hasAccess(getReferencingDescriptor(), def) == null;
    }

    public static void assertAccess(Definition def) throws QuickFixException {
        DefinitionService definitionService = Aura.getDefinitionService();
        MasterDefRegistry registry = definitionService.getDefRegistry();
        registry.assertAccess(getReferencingDescriptor(), def);
    }
View Full Code Here

Examples of org.auraframework.system.MasterDefRegistry

                    AttributeDef.SerializeToType.BOTH, null, null));
      builder.attributeDefs = attributeDefs;
            ComponentDef cmpDef = builder.build();
            AuraContext context = Aura.getContextService().getCurrentContext();
            //add dynamic namespace to MasterDefRegistry so later we can getDef from it during the injectComponent();
            MasterDefRegistry mdr = context.getDefRegistry();
            mdr.addLocalDef(cmpDef);
            config.setDescriptor(cmpDef.getDescriptor());
        }
        return config;
    }
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.