Package org.auraframework.def

Examples of org.auraframework.def.ApplicationDef


        BuilderService builderService = Aura.getBuilderService();
        DefinitionService definitionService = Aura.getDefinitionService();
        String descriptors = (String) getAttributes().get("descriptor");
        String[] split = CreateComponentDefQuickFix.descriptorPattern.split(descriptors);
        for (String descriptor : split) {
            ApplicationDef def = builderService.getApplicationDefBuilder().setDescriptor(descriptor).build();
            definitionService.save(def);

            if (getBooleanAttribute("client.css")) {
                DefDescriptor<StyleDef> styleDescriptor = definitionService.getDefDescriptor(def.getDescriptor(),
                        "css", StyleDef.class);
                new CreateStyleDefQuickFix(styleDescriptor).fix();
            }
            resetCache(def.getDescriptor());
        }
    }
View Full Code Here


    }

    @Override
    public void write(Object value, Map<String, Object> args, Appendable out) throws IOException {

        ApplicationDef def = (ApplicationDef) value;

        String outputPath = (String) args.get("outputPath");
        if (outputPath == null) {
            throw new AuraRuntimeException(
                    "'outputPath' directory path is required as an attribute to use this FormatAdapter");
        }

        String appName = def.getDescriptor().getName();
        File outputDir = new File(outputPath, appName);
        if (outputDir.exists()) {
            throw new AuraRuntimeException(String.format("%s exists.  Please select another location.",
                    outputDir.getAbsolutePath()));
        } else {
            outputDir.mkdirs();
        }

        File html = new File(outputDir, "index.html");

        InstanceService instanceService = Aura.getInstanceService();
        RenderingService renderingService = Aura.getRenderingService();

        ContextService contextService = Aura.getContextService();
        AuraContext context = contextService.getCurrentContext();

        Writer htmlWriter = new FileWriter(html);
        try {
            String uid = context.getDefRegistry().getUid(null, def.getDescriptor());
            Set<DefDescriptor<?>> dependencies = context.getDefRegistry().getDependencies(uid);

            ComponentDef templateDef = def.getTemplateDef();
            Map<String, Object> attributes = Maps.newHashMap();

            StringBuilder sb = new StringBuilder();
            // Get the preload css
            List<String> styles = Lists.newArrayList(String.format("%s.css", appName));
            this.writeHtmlStyles(styles, sb);
            File css = new File(outputDir, String.format("%s.css", appName));
            FileWriter cssWriter = new FileWriter(css);
            try {
                Aura.getServerService().writeAppCss(dependencies, cssWriter);
            } finally {
                cssWriter.close();
            }
            attributes.put("auraStyleTags", sb.toString());

            // Clear sb out
            sb.setLength(0);

            List<String> scripts = Lists.newArrayList("aura.js", String.format("%s.js", appName));
            writeHtmlScripts(scripts, sb);

            // Get the framework js
            File auraJs = new File(outputDir, "aura.js");
            FileWriter auraJsWriter = new FileWriter(auraJs);
            InputStream in = Aura.getConfigAdapter().getResourceLoader()
                    .getResourceAsStream("aura/javascript/aura_dev.js");
            InputStreamReader reader = new InputStreamReader(in);
            try {
                Aura.getConfigAdapter().regenerateAuraJS();
                IOUtil.copyStream(reader, auraJsWriter);
            } finally {
                try {
                    auraJsWriter.close();
                } finally {
                    reader.close();
                }
            }

            Application instance = instanceService.getInstance(def, null);

            // Get the preload js
            File js = new File(outputDir, String.format("%s.js", appName));
            FileWriter jsWriter = new FileWriter(js);
            try {
                Aura.getServerService().writeDefinitions(dependencies, jsWriter);

                // Write the app at the bottom of the same file

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

                auraInit.put("instance", instance);
                auraInit.put("token", AuraServlet.getToken());
                auraInit.put("host", context.getContextPath());

                contextService.startContext(Mode.PROD, Format.HTML, Authentication.AUTHENTICATED, def.getDescriptor());
                auraInit.put("context", contextService.getCurrentContext());
                jsWriter.append("\n$A.initConfig($A.util.json.resolveRefs(");
                Json.serialize(auraInit, jsWriter, context.getJsonSerializationContext());
                jsWriter.append("));\n");
            } finally {
View Full Code Here

    @Override
    public void write(Object value, Map<String, Object> componentAttributes, Appendable out) throws IOException {
        InstanceService instanceService = Aura.getInstanceService();
        RenderingService renderingService = Aura.getRenderingService();
        ApplicationDef def = (ApplicationDef) value;
        AuraContext context = Aura.getContextService().getCurrentContext();

        try {
            ComponentDef templateDef = def.getTemplateDef();
            Map<String, Object> attributes = Maps.newHashMap();

            StringBuilder sb = new StringBuilder();
            writeHtmlStyles(AuraServlet.getStyles(), sb);
            attributes.put("auraStyleTags", sb.toString());
View Full Code Here

     * @throws QuickFixException
     */
    @Override
    public DefDescriptor<EventDef> getLocationChangeEventDescriptor() throws QuickFixException {
        if (locationChangeEventDescriptor == null) {
            ApplicationDef superDef = getSuperDef();
            if (superDef != null) {
                return superDef.getLocationChangeEventDescriptor();
            }
            return null;
        } else {
            return locationChangeEventDescriptor;
        }
View Full Code Here

        super(descriptor, extender, attributeValueProvider, concreteApplication);
    }

    @Override
    protected void createSuper() throws QuickFixException {
        ApplicationDef def = getComponentDef();
        if (!remoteProvider) {
            DefDescriptor<ApplicationDef> superDefDescriptor = def.getExtendsDescriptor();
            if (superDefDescriptor != null) {
              Aura.getDefinitionService().getDefRegistry().assertAccess(descriptor, superDefDescriptor.getDef());

              Application concrete = concreteComponent == null ? this : concreteComponent;
                superComponent = new ApplicationImpl(superDefDescriptor, this, this, concrete);
View Full Code Here

     *
     * @hierarchy Aura.Runtime.Service
     * @userStory a07B0000000EYU4
     */
    public void testGetApplicationDef() throws Exception {
        ApplicationDef application = Aura.getDefinitionService().getDefinition("auratest:testApplication1",
                ApplicationDef.class);

        Map<String, RegisterEventDef> red = application.getRegisterEventDefs();
        assertEquals(1, red.size());
        assertNotNull(red.get("testEvent"));

        Collection<EventHandlerDef> ehd = application.getHandlerDefs();
        assertEquals(0, ehd.size());

        List<DefDescriptor<ModelDef>> mdd = application.getModelDefDescriptors();
        assertEquals(1, mdd.size());
        assertEquals("TestJavaModel", mdd.get(0).getName());

        List<DefDescriptor<ControllerDef>> cds = application.getControllerDefDescriptors();
        assertEquals(1, cds.size());
        assertEquals("JavaTestController", cds.get(0).getName());

        DefDescriptor<ModelDef> lmdd = application.getLocalModelDefDescriptor();
        assertEquals("TestJavaModel", lmdd.getName());

        ModelDef model = application.getModelDef();
        assertEquals("TestJavaModel", model.getName());

        ControllerDef controller = application.getControllerDef();
        assertEquals("testApplication1", controller.getName());

        DefDescriptor<RendererDef> rd = application.getRendererDescriptor();
        assertEquals("testApplication1", rd.getName());

        DefDescriptor<StyleDef> td = application.getStyleDescriptor();
        assertEquals("testApplication1", td.getName());
    }
View Full Code Here

        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());
View Full Code Here

    private void writeApplication(Appendable out) throws IOException, AuraRuntimeException, QuickFixException {
        if (isSupportedClient(client)) {
            // ensure that we have a context.
            AuraContext context = getContext(null);
            try {
                ApplicationDef appDef = getApplicationDescriptor(application).getDef();

                if (observer != null) {
                    observer.beforeApplicationWritten(this, context, appDef);
                }

                Aura.getSerializationService().write(appDef, null,
                        appDef.getDescriptor().getDefType().getPrimaryInterface(), out, "EMBEDDED_HTML");
            } catch (QuickFixException e) {
                throw new AuraRuntimeException(e);
            } finally {
                releaseContext();
            }
View Full Code Here

        assertTrue("Failed to load style resource", ((ResourceDefImpl)def).getContents().contains(".clientLibraryTestStyle"));
    }

    public void testResourceDefAsPartOfComponentDef()throws Exception{
        DefDescriptor<ApplicationDef> cmpDesc = Aura.getDefinitionService().getDefDescriptor("clientLibraryTest:clientLibraryTest", ApplicationDef.class);
        ApplicationDef def = cmpDesc.getDef();

        Set<ResourceDef> resourceDefs = def.getResourceDefs();

        DefDescriptor<ResourceDef> jsResourceDefDesc = Aura.getDefinitionService().getDefDescriptor("js://clientLibraryTest.clientLibraryTest", ResourceDef.class);
        ResourceDef jsResourceDef = jsResourceDefDesc.getDef();
        DefDescriptor<ResourceDef> cssResourceDefDesc = Aura.getDefinitionService().getDefDescriptor("css://clientLibraryTest.clientLibraryTest", ResourceDef.class);
        ResourceDef cssResourceDef = cssResourceDefDesc.getDef();
View Full Code Here

                ApplicationDef.class);
        StringSource<ApplicationDef> source = new StringSource<>(descriptor,
                "<aura:application><aura:attribute name=\"implNumber\" type=\"String\"/>"
                        + "<aura:attribute name=\"implNumber\" type=\"String\"/></aura:application>", "myID",
                Format.XML);
        ApplicationDef ad = parser.parse(descriptor, source);
        try {
            ad.validateDefinition();
            fail("Should have thrown Exception. Two attributes with the same name cannot exist");
        } catch (Exception e) {
            checkExceptionContains(e, InvalidDefinitionException.class,
                    "Duplicate definitions for attribute implNumber");
        }
View Full Code Here

TOP

Related Classes of org.auraframework.def.ApplicationDef

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.