Package org.auraframework.system

Examples of org.auraframework.system.AuraContext


    }

    private void assertBrowserProperties(UserAgent userAgent, boolean isTablet,
            boolean isPhone, boolean isAndroid, String formFactor,
            boolean isIPad, boolean isIPhone, boolean isIOS, boolean isWindowsPhone) throws Exception {
        AuraContext context = Aura.getContextService().getCurrentContext();
        String userAgentString = userAgent == null ? null : userAgent.getUserAgentString();
        context.setClient(new Client(userAgentString));
        BrowserValueProvider bvp = new BrowserValueProvider();
        assertBrowserProperty(bvp, BrowserProperty.isTablet, isTablet, userAgentString);
        assertBrowserProperty(bvp, BrowserProperty.isPhone, isPhone, userAgentString);
        assertBrowserProperty(bvp, BrowserProperty.isAndroid, isAndroid, userAgentString);
        assertBrowserProperty(bvp, BrowserProperty.formFactor, formFactor, userAgentString);
View Full Code Here


                bvp.getValue(property));
    }

    private void assertBrowserTypes(UserAgent userAgent, boolean isWebKit, boolean isFirefox, boolean isIE6,
            boolean isIE7, boolean isIE8, boolean isIE9, boolean isIE10, boolean isIE11) throws Exception {
        AuraContext context = Aura.getContextService().getCurrentContext();
        String userAgentString = userAgent == null ? null : userAgent.getUserAgentString();
        context.setClient(new Client(userAgentString));
        BrowserValueProvider bvp = new BrowserValueProvider();
        assertBrowserType(bvp, BrowserType.isWebKit, isWebKit, userAgentString);
        assertBrowserType(bvp, BrowserType.isFirefox, isFirefox, userAgentString);
        assertBrowserType(bvp, BrowserType.isIE6, isIE6, userAgentString);
        assertBrowserType(bvp, BrowserType.isIE7, isIE7, userAgentString);
View Full Code Here

    /**
     * Manifest is not appended to <html> if system config is set to disable appcache (aura.noappcache = true).
     */
    @ThreadHostileTest("disables AppCache")
    public void testWriteManifestWithConfigDisabled() throws Exception {
        AuraContext context = Aura.getContextService().getCurrentContext();
        ServletConfigController.setAppCacheDisabled(true);
        DefDescriptor<ApplicationDef> desc = addSourceAutoCleanup(ApplicationDef.class,
                "<aura:application useAppcache='true' render='client'></aura:application>");
        context.setApplicationDescriptor(desc);
        context.addLoaded(desc, context.getDefRegistry().getUid(null, desc));
        String body = doWrite(desc.getDef());
        int start = body.indexOf("<html");
        String tag = body.substring(start, body.indexOf('>', start) + 1);
        if (tag.contains("manifest=")) {
            fail("Should not have included a manifest attribute with config disabled:\n" + body);
View Full Code Here

    /**
     * Manifest is not appended to <html> if useAppcache is false.
     */
    public void testWriteManifestWithUseAppCacheFalse() throws Exception {
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<ApplicationDef> desc = addSourceAutoCleanup(ApplicationDef.class,
                "<aura:application render='client' useAppcache='false'></aura:application>");
        context.setApplicationDescriptor(desc);
        context.addLoaded(desc, context.getDefRegistry().getUid(null, desc));
        String body = doWrite(desc.getDef());
        int start = body.indexOf("<html");
        String tag = body.substring(start, body.indexOf('>', start) + 1);
        if (tag.contains(" manifest=")) {
            fail("Should not have included a manifest attribute useAppCache = false:\n" + body);
View Full Code Here

    /**
     * Manifest is not appended to <html> if useAppcache is missing (inherits false from aura:application).
     */
    public void testWriteManifestWithUseAppCacheInherited() throws Exception {
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<ApplicationDef> desc = addSourceAutoCleanup(ApplicationDef.class,
                "<aura:application render='client'></aura:application>");
        context.setApplicationDescriptor(desc);
        context.addLoaded(desc, context.getDefRegistry().getUid(null, desc));
        String body = doWrite(desc.getDef());
        int start = body.indexOf("<html");
        String tag = body.substring(start, body.indexOf('>', start) + 1);
        if (tag.contains(" manifest=")) {
            fail("Should not have included a manifest attribute with inherited useAppCache = false:\n" + body);
View Full Code Here

    /**
     * Manifest is appended to <html> if current app has useAppCache.
     */
    public void testWriteManifest() throws Exception {
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<ApplicationDef> desc = addSourceAutoCleanup(ApplicationDef.class,
                "<aura:application render='client' useAppcache='true'></aura:application>");
        context.setApplicationDescriptor(desc);
        final String uid = context.getDefRegistry().getUid(null, desc);
        context.addLoaded(desc, uid);
        String body = doWrite(desc.getDef());
        int start = body.indexOf("<html");
        String tag = body.substring(start, body.indexOf('>', start) + 1);
        String expectedSubPath = AuraTextUtil.urlencode(String.format(
                "{\"mode\":\"UTEST\",\"app\":\"%s\",\"loaded\":{\"APPLICATION@%s\":\"%s\"},\"test\":\"%s\"}",
View Full Code Here

        BaseComponent<?, ?> valueProvider = this.vp != null ? this.vp : fallbackValueProvider;
        if (extraProviders != null) {
            // TODO: rename this thing
            valueProvider = new IterationValueProvider(valueProvider, extraProviders);
        }
        AuraContext context = Aura.getContextService().getCurrentContext();
        int idx = 0;
        for (ComponentDefRef cdr : this.cdrs) {
            context.getInstanceStack().setAttributeIndex(idx);
            components.add(cdr.newInstance(valueProvider));
            context.getInstanceStack().clearAttributeIndex(idx);
            idx += 1;
        }
        return components;
    }
View Full Code Here

        RootDefinition rootDef = getComponentDef();
        if (rootDef == null) {
            throw new DefinitionNotFoundException(descriptor);
        }
       
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<?> referencingDesc = context.getCurrentCallingDescriptor();
      if (referencingDesc != null) {
          MasterDefRegistry registry = Aura.getDefinitionService().getDefRegistry();
        registry.assertAccess(referencingDesc, getComponentDef());
      }
View Full Code Here

            // specifies async so component configs are not printed to HTML
            writeApplication(out);
            hasApplicationBeenWritten = true;
        }

        AuraContext context = getContext("is");

        try {
            DefinitionService definitionService = Aura.getDefinitionService();
            DefDescriptor<ComponentDef> descriptor = definitionService.getDefDescriptor(tag,
                    ComponentDef.class);

            Map<String, Object> actionAttributes = Maps.newHashMap();
            Map<String, String> actionEventHandlers = Maps.newHashMap();

            ComponentDef componentDef = descriptor.getDef();
            if(attributes!=null) {
              for (Map.Entry<String, Object> entry : attributes.entrySet()) {
                  String key = entry.getKey();

                  AttributeDef attributeDef = componentDef.getAttributeDef(key);
                  if (attributeDef != null) {
                      String name = attributeDef.getName();
                      actionAttributes.put(name, entry.getValue());
                  } else {
                      RegisterEventDef eventDef = componentDef.getRegisterEventDefs().get(key);
                      if (eventDef != null) {
                          // Emit component.addHandler() wired to special global scope value provider
                          String name = eventDef.getAttributeName();
                          actionEventHandlers.put(name, (String) entry.getValue());
                      } else {
                          throw new AuraRuntimeException(String.format("Unknown attribute or event %s - %s", tag, key));
                      }
                  }
              }
            }

            try {

                StringBuilder jsonEventHandlers = null;
                if (!actionEventHandlers.isEmpty()) {
                    // serialize registered event handlers into js object
                    jsonEventHandlers = new StringBuilder();
                    Json.serialize(actionEventHandlers, jsonEventHandlers);
                }

                StringBuilder init = new StringBuilder();

                if (useAsync) {
                    // uses newComponentAsync to create component
                    StringBuilder jsonAttributes = new StringBuilder();
                    Json.serialize(actionAttributes, jsonAttributes);

                    // set event handlers to either js "undefined" or object of event and handler names
                    String eventHandlers = jsonEventHandlers != null ? jsonEventHandlers.toString() : "undefined";
                    String def = String.format(COMPONENT_DEF_TEMPLATE, tag, jsonAttributes.toString(), localId);
                    String newComponentScript = String.format(ASYNC_INJECTION_TEMPLATE, def, locatorDomId, eventHandlers);

                    init.append(newComponentScript);

                } else {
                    // config printed onto HTML page

                    // mark injectee component as loaded
                    // only when not using async because component defs will be printed onto HTML
                    definitionService.updateLoaded(descriptor);

                    ControllerDef componentControllerDef = definitionService.getDefDescriptor("aura://ComponentController",
                            ControllerDef.class).getDef();

                    Map<String, Object> paramValues = Maps.newHashMap();
                    paramValues.put("name", descriptor.getQualifiedName());
                    paramValues.put("attributes", actionAttributes);

                    Action action = componentControllerDef.createAction("getComponent", paramValues);
                    action.setId("ais");

                    Action previous = context.setCurrentAction(action);
                    try {
                        action.run();
                    } finally {
                        context.setCurrentAction(previous);
                    }

                    Message message = new Message(Lists.newArrayList(action));

                    init.append("var config = ");
View Full Code Here

            contextDepthCount += 1;
        }

        DefDescriptor<ApplicationDef> applicationDescriptor = getApplicationDescriptor(application);

        AuraContext context;
        if (contextDepthCount == 0) {
            context = contextService.startContext(mode, Format.JSON, Authentication.AUTHENTICATED, applicationDescriptor);
        } else {
            context = contextService.getCurrentContext();
        }
        String cuid = context.getLoaded().get(applicationDescriptor);
        String uid = context.getDefRegistry().getUid(cuid, applicationDescriptor);
        context.addLoaded(applicationDescriptor, uid);
        context.setPreloadedDefinitions(context.getDefRegistry().getDependencies(uid));

        if (!DEFAULT_APPLICATION.equals(application)) {
            // Check to insure that the app extends aura:integrationServiceApp
            ApplicationDef def = applicationDescriptor.getDef();
            if (!def.isInstanceOf(getApplicationDescriptor(DEFAULT_APPLICATION))) {
                throw new AuraRuntimeException("Application must extend aura:integrationServiceApp.");
            }
        }
        context.setContextPath(contextPath);
        context.setFrameworkUID(Aura.getConfigAdapter().getAuraFrameworkNonce());

        if (num != null) {
            context.setNum(num);
        }

        if (client != null) {
            context.setClient(client);
        }

        if (observer != null) {
            observer.contextEstablished(this, context);
        }
View Full Code Here

TOP

Related Classes of org.auraframework.system.AuraContext

Copyright © 2018 www.massapicom. 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.