Package org.auraframework.instance

Examples of org.auraframework.instance.InstanceStack$CreationPathSorter


    private BaseComponentImpl(DefDescriptor<D> descriptor, BaseComponent<?, ?> attributeValueProvider,
            Map<String, Object> valueProviders, I extender, D def) throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<? extends RootDefinition> desc = null;

        InstanceStack instanceStack = context.getInstanceStack();
        Instance<?> parent = instanceStack.peek();

        this.descriptor = descriptor;
        this.originalDescriptor = descriptor;
        this.path = instanceStack.getPath();
        instanceStack.pushInstance(this, descriptor);

        if (def == null) {
            try {
                def = descriptor.getDef();
                if (extender == null && (def.isAbstract() || def.getLocalProviderDef() != null)) {
View Full Code Here


     *
     * @param modelDef the definition for the model.
     */
    public JavaModel(JavaModelDefImpl modelDef) {
        this.modelDef = modelDef;
        InstanceStack iStack = Aura.getContextService().getCurrentContext().getInstanceStack();
        iStack.pushInstance(this, modelDef.getDescriptor());
        iStack.setAttributeName("m");
        this.path = iStack.getPath();
        try {
            if (modelDef.isBean()) {
                this.bean = Aura.getBeanAdapter().getModelBean(modelDef);
            } else {
                this.bean = BeanAdapterImpl.buildValidatedClass(modelDef.getJavaType());
            }
        } catch (AuraRuntimeException are) {
            throw are;
        } catch(Exception e){
            throw makeException(e.getMessage(),e,this.modelDef);
        }
        iStack.clearAttributeName("m");
        iStack.popInstance(this);
    }
View Full Code Here

        } else {
            attribute = new AttributeImpl(attributeDef.getDescriptor());
        }

        Object value = attributeDefRef.getValue();
        InstanceStack iStack = Aura.getContextService().getCurrentContext().getInstanceStack();
        iStack.markParent(parent);
        iStack.setAttributeName(attributeDef.getDescriptor().toString());
        value = attributeDef.getTypeDef().initialize(value, valueProvider);
        iStack.clearAttributeName(attributeDef.getDescriptor().toString());
        iStack.clearParent(parent);
        attribute.setValue(value);

        set(attribute);
    }
View Full Code Here

        AttributeImpl att = new AttributeImpl(desc);
        if (value instanceof Expression) {
            att.setValue(value);
        } else {
            InstanceStack iStack = Aura.getContextService().getCurrentContext().getInstanceStack();

            iStack.markParent(parent);
            iStack.setAttributeName(desc.toString());
            att.setValue(rootDefDescriptor.getDef().getAttributeDef(att.getName()).getTypeDef().initialize(value, null));
            iStack.clearAttributeName(desc.toString());
            iStack.clearParent(parent);
        }
        set(att);
    }
View Full Code Here

    public ComponentConfig provide() throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> component = context.getCurrentComponent();
        ComponentConfig cc = new ComponentConfig();
        List<Component> components = Lists.newArrayList();
        InstanceStack iStack = context.getInstanceStack();
        Map<String, Object> m = Maps.newHashMapWithExpectedSize(1);
        m.put("body", components);
        cc.setAttributes(m);

        AttributeSet atts = component.getAttributes();
        Iterable<?> value = atts.getValue("items", Iterable.class);
        if (value != null) {
            List<?> items = Lists.newArrayList(value);
            if (!items.isEmpty()) {
                String var = atts.getValue("var", String.class);
                String indexVar = atts.getValue("indexVar", String.class);

                int realstart = 0;
                int realend = items.size();

                ComponentDefRefArrayImpl template = atts.getValue("body", ComponentDefRefArrayImpl.class);
                m.put("template",template);
                Integer start = getIntValue(atts.getValue("start"));
                Integer end = getIntValue(atts.getValue("end"));
                if (start == null && end == null) {
                    // int page = (Integer)atts.getValue("page");
                    // int pageSize = (Integer)atts.getValue("pageSize");
                } else {
                    if (start != null && start > realstart) {
                        realstart = start;
                    }

                    if (end != null && end < realend) {
                        realend = end;
                    }
                }

                // boolean reverse = (Boolean)atts.getValue("reverse");
                iStack.setAttributeName("body");
                for (int i = realstart; i < realend; i++) {
                    iStack.setAttributeIndex(i);
                    iStack.pushInstance(component, component.getDescriptor());
                    iStack.setAttributeName("body");
                    Map<String, Object> providers = Maps.newHashMap();
                    providers.put(var, items.get(i));
                    if (indexVar != null) {
                        providers.put(indexVar, i);
                    }
                    components.addAll(template.newInstance(atts.getValueProvider(), providers));
                    iStack.clearAttributeName("body");
                    iStack.popInstance(component);
                    iStack.clearAttributeIndex(i);
                }
                iStack.clearAttributeName("body");
            }
        }

        return cc;
    }
View Full Code Here

    @Override
    public ComponentConfig provide() throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> component = context.getCurrentComponent();
        InstanceStack iStack = context.getInstanceStack();
        ComponentConfig cc = new ComponentConfig();
        List<Component> components = new ArrayList<Component>();
        Map<String, Object> m = Maps.newHashMapWithExpectedSize(1);
        m.put("body", components);
        cc.setAttributes(m);

        AttributeSet atts = component.getAttributes();
        m.put("template", atts.getValue("body"));
        Object o = atts.getValue("isTrue");
        Boolean isTrue = (Boolean) o;
        ComponentDefRefArrayImpl facet;
        // get body facet if true, else facet if false
        if (isTrue != null && isTrue.booleanValue()) {
            facet = (ComponentDefRefArrayImpl) atts.getValue("body");
        } else {
            facet = (ComponentDefRefArrayImpl) atts.getValue("else");
        }
        if (facet != null) {
            iStack.setAttributeName("body");
            components.addAll(facet.newInstance(atts.getValueProvider()));
            iStack.clearAttributeName("body");
        }
        return cc;
    }
View Full Code Here

    private final AttributeSet attributeSet;
    private final String path;

    public EventImpl(DefDescriptor<EventDef> eventDefDescriptor, Map<String, Object> attributes,
            BaseComponent<?, ?> valueProvider) throws QuickFixException {
      InstanceStack iStack = Aura.getContextService().getCurrentContext().getInstanceStack();
      iStack.pushInstance(this, eventDefDescriptor);
        this.path = iStack.getPath();
        this.eventDefDescriptor = eventDefDescriptor;
        this.attributeSet = new AttributeSetImpl(eventDefDescriptor, valueProvider, this);
        this.attributeSet.set(attributes);
        iStack.popInstance(this);
    }
View Full Code Here

    private final JavascriptModelDef modelDef;
    private final String path;

    public JavascriptModel(JavascriptModelDef modelDef) {
        this.modelDef = modelDef;
        InstanceStack iStack = Aura.getContextService().getCurrentContext().getInstanceStack();
        iStack.pushInstance(this, modelDef.getDescriptor());
        iStack.setAttributeName("m");
        this.path = iStack.getPath();
        for (JavascriptValueDef member : this.modelDef.getAllMembers()) {
            bean.put(member.getName(), clone(member.getDefaultValue()));
        }
        iStack.clearAttributeName("m");
        iStack.popInstance(this);
    }
View Full Code Here

    public InstanceStack getInstanceStack() {
        if (currentAction != null) {
            return currentAction.getInstanceStack();
        } else {
            if (fakeInstanceStack == null) {
                fakeInstanceStack = new InstanceStack();
            }
            return fakeInstanceStack;
        }
    }
View Full Code Here

        }
    };

    @Override
    public void registerComponent(BaseComponent<?, ?> component) {
        InstanceStack iStack = getInstanceStack();
        if (iStack.isUnprivileged()) {
            if (componentCount++ > MAX_COMPONENT_COUNT) {
                //
                // This is bad, try to give the poor user an idea of what happened.
                //
                Action tmp = getCurrentAction();
                StringBuffer sb = new StringBuffer();
                if (tmp != null) {
                    sb.append(tmp);
                    sb.append("(");
                    tmp.logParams(new SBKeyValueLogger(sb));
                    sb.append(")");
                } else {
                    sb.append("request");
                }
                throw new SystemErrorException("Too many components for "+sb.toString());
            }
        }
        iStack.registerComponent(component);
    }
View Full Code Here

TOP

Related Classes of org.auraframework.instance.InstanceStack$CreationPathSorter

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.