Package com.volantis.mcs.protocols.assets

Examples of com.volantis.mcs.protocols.assets.ScriptAssetReference


     * @throws IllegalStateException if the manager is closed
     */
    public void writeScriptElements() {
        checkClosed();
        for (Iterator iter = scriptReferences.iterator(); iter.hasNext(); ) {
            final ScriptAssetReference scriptVariant =
                (ScriptAssetReference) iter.next();

            // collect the attributes
            final ScriptAttributes attributes =
                assetToAttributes(scriptVariant);
View Full Code Here


            ListenerEvent listenerEvent) {

        ExpandedName eventType = listenerEvent.getEventType();
        Mapper mapper = (Mapper) eventType2SetterMap.get(eventType);
        if (mapper != null) {
            ScriptAssetReference handlerScript =
                    listenerEvent.getHandlerScript();
            mapper.map(handlerScript, eventAttributes);
        } else {
            // no event setter is available for this event type
            // so this event type is unknown for this element
View Full Code Here

        // Get the textual script. Should be easy as handler is PCDATA.
        String script = bodyContentBuffer.getPCDATAValue();
        if (script != null) {
            // Turn the textual script into a literal script reference.
            ScriptAssetReference scriptReference = (ScriptAssetReference)
                    QuotedReferenceFactory.SCRIPT_REFERENCE_FACTORY.
                            createLiteralReference(script);

            // Register the script in the registry for later use by the
            // 'listener' element.
View Full Code Here

        final MarinerPageContext pageContext = getPageContext(context);

        // check the src attribute
        final String src = getAttribute(XDIMEAttribute.SRC, attributes);
        ScriptAssetReference scriptReference = null;
        if (src != null) {
//            Note:ATM script element is in the MCS namespace so there is no use
//            of having a srctype attribute.
//
//            final String srcType =
//                getAttribute(XDIMEAttribute.SRC_TYPE, attributes);
//            if (srcType != null && !srcType.equals("")) {
//                // @to do find out what the srctype should be for mscr files
//                throw new XDIMEException(
//                    "Invalid source type. Found: " + srcType + " expected: ");
//            }
            scriptReference = getScriptAssetReference(src, pageContext);
            if (scriptReference == null) {
                LOGGER.warn("cannot-create-script-asset-reference-for-url",
                    src);
            }
        }

        // set the attributes
        scriptAttributes = new ScriptAttributes();
        final String id = getAttribute(XDIMEAttribute.ID, attributes);
        scriptAttributes.setId(id);
        if (scriptReference == null) {
            // Ensure that type="text/javascript" which is the only value we
            // currently support.
            final String type = attributes.getValue("", "type");
            if (type != null && !"text/javascript".equals(type)) {
                throw new IllegalArgumentException(EXCEPTION_LOCALIZER.format(
                    "script-must-have-text-javascript"));
            }

            scriptAttributes.setType("text/javascript");
        } else {
            scriptAttributes.setScriptReference(scriptReference);
            final ScriptAsset scriptAsset = scriptReference.getScriptAsset();
            scriptAttributes.setCharSet(scriptAsset.getCharacterSet());
            scriptAttributes.setLanguage(scriptAsset.getProgrammingLanguage());
            scriptAttributes.setType(scriptAsset.getMimeType());
        }
View Full Code Here

        final PolicyReferenceFactory factory =
            pageContext.getPolicyReferenceFactory();
        final RuntimePolicyReference reference =
            factory.createLazyNormalizedReference(
                project, baseURL, policyName, PolicyType.SCRIPT);
        final ScriptAssetReference scriptAssetReference =
            new DefaultComponentScriptAssetReference(
                reference, pageContext.getAssetResolver());
        return scriptAssetReference.getScriptAsset() != null ?
            scriptAssetReference : null;
    }
View Full Code Here

        PolicyReferenceResolver resolver =
                pageContext.getPolicyReferenceResolver();

        // Resolve the value event string to a mariner expression
        ScriptAssetReference expression =
                resolver.resolveQuotedScriptExpression(value);
        pattributes.setEvent(eventConstant, expression);
        return pattributes;
    }
View Full Code Here

        // Then we look up the handler to see if it has been defined. If it
        // has not this is an error.
        final MarinerPageContext pageContext = getPageContext(context);
        HandlerScriptRegistry scriptRegistry =
                pageContext.getHandlerScriptRegistry();
        ScriptAssetReference handlerScript =
                scriptRegistry.getScriptById(handlerId);
        if (handlerScript == null) {
            throw new IllegalArgumentException("Handler attribute " +
                    handlerAttribute + "must refer to a defined handler " +
                    "element");
View Full Code Here

    // Javadoc inherited.
    public void updateEventAttributes(EventAttributes eventAttributes) {
        EventAttributes eventAtts = attributes.getEventAttributes(true);
        for (int i=0; i< EventConstants.MAX_EVENTS; i++) {
            ScriptAssetReference event = eventAttributes.getEvent(i);
            // only override if the replacing one is non null.
            if (event != null) {
                eventAtts.setEvent(i, event);
            }
        }
View Full Code Here

                logger.debug("No events found for " + eventName
                             + " at " + eventIndex);
            }
        } else {
            // Get the specific event which has been asked for.
            ScriptAssetReference scriptObject = events.getEvent(eventIndex);
            if (scriptObject == null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("No event found for " + eventName
                                 + " at " + eventIndex);
                }
View Full Code Here

                assetResolverMock, null, expressionParserMock, null);
    }


    public void testResolveLiteralScript() {
        ScriptAssetReference reference =
                resolver.resolveQuotedScriptExpression("script");
        assertEquals("Script literal", "script", reference.getScript());
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.assets.ScriptAssetReference

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.