Package org.auraframework.system

Examples of org.auraframework.system.AuraContext


            ValueProviderType vpt = ValueProviderType.getTypeByPrefix(root);
            if (vpt == null) {
                // validate that its a foreachs
            } else if (vpt.isGlobal()) {
                AuraContext lc = Aura.getContextService().getCurrentContext();
                GlobalValueProvider gvp = lc.getGlobalProviders().get(vpt);
                if (gvp != null) {
                    PropertyReference stem = e.getStem();
                    if (stem == null) {
                        throw new InvalidExpressionException("Expression didn't have enough terms: " + e, e.getLocation());
                    }
View Full Code Here


     * It doesn't yet include inherited ComponentDefRefs, but maybe it should.
     */
    @Override
    public void serialize(Json json) throws IOException {
        try {
            AuraContext context = Aura.getContextService().getCurrentContext();
            Mode mode = context.getMode();
            boolean preloaded = context.isPreloaded(getDescriptor());
            boolean preloading = context.isPreloading();

            if (preloaded) {
                json.writeValue(descriptor);
            } else {
                json.writeMapBegin();
                json.writeMapEntry("descriptor", descriptor);
                context.pushCallingDescriptor(descriptor);
                try {
                    RendererDef rendererDef = getRendererDef();
                    if (rendererDef != null && !rendererDef.isLocal()) {
                        json.writeMapEntry("rendererDef", rendererDef);
                    }
                } finally {
                    context.popCallingDescriptor();
                }
                HelperDef helperDef = getHelperDef();
                if (helperDef != null && !helperDef.isLocal()) {
                    json.writeMapEntry("helperDef", helperDef);
                }
View Full Code Here

    /**
     * @see ComponentDef#getModelDef()
     */
    @Override
    public ModelDef getModelDef() throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        context.pushCallingDescriptor(descriptor);
        try {
            return modelDefDescriptor == null ? null : modelDefDescriptor.getDef();
        } finally {
            context.popCallingDescriptor();
        }
    }
View Full Code Here

            ControllerDef controllerDef = getControllerDef();
            ActionDef actionDef = controllerDef.getSubDefinition(ref.toString());
            Action action = Aura.getInstanceService().getInstance(actionDef);

            AuraContext context = Aura.getContextService().getCurrentContext();
            Action previous = context.setCurrentAction(action);
            try {
                action.run();
            } finally {
                context.setCurrentAction(previous);
            }

            @SuppressWarnings("unchecked")
            List<String> additionalURLs = (List<String>) action.getReturnValue();
            if (additionalURLs != null) {
View Full Code Here

      map.put("not available", "not available");
      return map;
    }

    public AdminModel() throws JMException {
        AuraContext c = AuraImpl.getContextAdapter().getCurrentContext();
        m = c.getMode();
        MasterDefRegistryImpl mdr = (MasterDefRegistryImpl) c.getDefRegistry();
        DefRegistry<?>[] regs = mdr.getAllRegistries();

        defsData = getMockMap(); //getStats(MasterDefRegistryImpl.getDefsCacheStats());
        //addDefsStats(defsData, MasterDefRegistryImpl.getCachedDefs());
        existsData = getMockMap(); //getStats(MasterDefRegistryImpl.getExistsCacheStats());
View Full Code Here

    private static final Log LOG = LogFactory.getLog(AuraValidationServlet.class);

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        AuraContext context = ValidationUtil.startValidationContext();
        try {
            handle(request, response);
        } catch (Exception ex) {
            handleServletException(ex, false, context, request, response, false);
        } finally {
View Full Code Here

        }
    }

    private void run(List<Action> actions, Json json) throws IOException {
        LoggingService loggingService = Aura.getLoggingService();
        AuraContext context = Aura.getContextService().getCurrentContext();
        for (Action action : actions) {
            StringBuffer actionAndParams = new StringBuffer(action.getDescriptor().getQualifiedName());
            KeyValueLogger logger = loggingService.getKeyValueLogger(actionAndParams);
            if (logger != null) {
                action.logParams(logger);
            }
            String aap = actionAndParams.toString();
            loggingService.startAction(aap);
            Action oldAction = context.setCurrentAction(action);
            try {
                //
                // We clear out action centric references here.
                //
                json.clearReferences();
                // DCHASMAN TODO Look into a common base for Action
                // implementations that we can move the call to
                // context.setCurrentAction() into!
                action.run();
            } catch (AuraExecutionException x) {
                Aura.getExceptionAdapter().handleException(x, action);
            } finally {
                context.setCurrentAction(oldAction);
                loggingService.stopAction(aap);
            }
            loggingService.startTimer(LoggingService.TIMER_SERIALIZATION);
            loggingService.startTimer(LoggingService.TIMER_SERIALIZATION_AURA);
            try {
View Full Code Here

        }
    }

    @Override
    public void writeAppCss(Set<DefDescriptor<?>> dependencies, Writer out) throws IOException, QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        Mode mode = context.getMode();

        // build cache key
        final StringBuilder keyBuilder = new StringBuilder(64);
        keyBuilder.append("CSS:");

        // browser type
        keyBuilder.append(context.getClient().getType());

        keyBuilder.append("$");

        // minified or not
        final boolean minify = !(mode.isTestMode() || mode.isDevMode());
        keyBuilder.append(minify ? "MIN:" : "DEV:");

        // app uid
        DefDescriptor<?> appDesc = context.getLoadingApplicationDescriptor();
        final String uid = context.getUid(appDesc);
        keyBuilder.append(uid);

        // themes uid (themes specified directly to the context (not on the app) need to be considered)
        final ThemeList themeList = context.getThemeList();
        Optional<String> themesUid = themeList.getThemeDescriptorsUid();
        if (themesUid.isPresent()) {
          keyBuilder.append(":").append(themesUid.get());
        }

        // 2) TODONM: If a theme uses a map-provider it will affect the css key too. Current idea is to cache a "pre-themed"
        // version of the CSS (but still ordered and concatenated). Until this is addressed map-providers shouldn't be
        // used. Another idea is to defer cache to fileforce, etc... once a map-provider is involved. (actually right now
        // we are skipping the cache, but when we stop doing that then this needs to be addressed

        final String key = keyBuilder.toString();
        context.setPreloading(true);

        String cached = context.getDefRegistry().getCachedString(uid, appDesc, key);
        boolean skipCache = themeList.hasDynamicVars(); // for now, skip caching css with dynamic var overrides

        if (cached == null || skipCache) {
            Collection<StyleDef> orderedStyleDefs = filterAndLoad(StyleDef.class, dependencies, null);
            StringBuffer sb = new StringBuffer();
            Aura.getSerializationService().writeCollection(orderedStyleDefs, StyleDef.class, sb, "CSS");
            cached = sb.toString();

            if (!skipCache) {
                context.getDefRegistry().putCachedString(uid, appDesc, key, cached);
            }
        }
        out.append(cached);
    }
View Full Code Here

    }

    @Override
    public void writeDefinitions(Set<DefDescriptor<?>> dependencies, Writer out)
            throws IOException, QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();

        Mode mode = context.getMode();
        final boolean minify = !mode.prettyPrint();
        final String mKey = minify ? "MIN:" : "DEV:";
        //
        // create a temp buffer in case anything bad happens while we're processing this.
        // don't want to end up with a half a JS init function
        //
        // TODO: get rid of this buffering by adding functionality to Json.serialize that will help us
        // make sure serialized JS is valid, non-error-producing syntax if an exception happens in the
        // middle of serialization.
        //

        context.setPreloading(true);
        DefDescriptor<?> applicationDescriptor = context.getLoadingApplicationDescriptor();
        final String uid = context.getUid(applicationDescriptor);
        final String key = "JS:" + mKey + uid;
        String cached = context.getDefRegistry().getCachedString(uid, applicationDescriptor, key);

        if (cached == null) {

            StringBuilder sb = new StringBuilder();

            sb.append("$A.clientService.initDefs({");

            // append component definitions
            sb.append("componentDefs:");
            Collection<BaseComponentDef> defs = filterAndLoad(BaseComponentDef.class, dependencies, null);
            Aura.getSerializationService().writeCollection(defs, BaseComponentDef.class, sb, "JSON");
            sb.append(",");

            // append event definitions
            sb.append("eventDefs:");
            Collection<EventDef> events = filterAndLoad(EventDef.class, dependencies, null);
            Aura.getSerializationService().writeCollection(events, EventDef.class, sb, "JSON");
            sb.append(",");

            // append library definitions
            sb.append("libraryDefs:");
            Collection<LibraryDef> libraries = filterAndLoad(LibraryDef.class, dependencies, null);
            Aura.getSerializationService().writeCollection(libraries, LibraryDef.class, sb, "JSON");
            sb.append(",");

            //
            // append controller definitions
            // Dunno how this got to be this way. The code in the Format adaptor was twisted and stupid,
            // as it walked the namespaces looking up the same descriptor, with a string.format that had
            // the namespace but did not use it. This ends up just getting a single controller.
            //
            sb.append("controllerDefs:");
            Collection<ControllerDef> controllers = filterAndLoad(ControllerDef.class, dependencies, ACF);
            Aura.getSerializationService().writeCollection(controllers, ControllerDef.class, sb, "JSON");

            sb.append("});");

            cached = sb.toString();
            // only use closure compiler in prod mode, due to compile cost
            if (minify) {
                StringWriter sw = new StringWriter();
                List<JavascriptProcessingError> errors = JavascriptWriter.CLOSURE_SIMPLE.compress(cached, sw, key);
                if (errors == null || errors.isEmpty()) {
                    // For now, just use the non-compressed version if we can't get
                    // the compression to work.
                    cached = sw.toString();
                } else {
                    // if unable to compress, add error comments to the end.
                    // ONLY if not production instance
                    if (!Aura.getConfigAdapter().isProduction()) {
                        sb.append(commentedJavascriptErrors(errors));
                    }
                    cached = sb.toString();
                }
            }
            context.getDefRegistry().putCachedString(uid, applicationDescriptor, key, cached);
        }

        out.append(cached);
    }
View Full Code Here

    }

    @Override
    public void writeComponents(Set<DefDescriptor<?>> dependencies, Writer out)
            throws IOException, QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();

        context.setPreloading(true);
        Aura.getSerializationService().writeCollection(filterAndLoad(BaseComponentDef.class, dependencies, null),
                BaseComponentDef.class, out);
    }
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.