org.apache.tomcat.util.bcel.classfile.ElementValuePair Java Examples

The following examples show how to use org.apache.tomcat.util.bcel.classfile.ElementValuePair. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextConfig.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected Map<String,String> processAnnotationWebInitParams(
        ElementValue ev) {
    Map<String, String> result = new HashMap<>();
    if (ev instanceof ArrayElementValue) {
        ElementValue[] arrayValues =
            ((ArrayElementValue) ev).getElementValuesArray();
        for (ElementValue value : arrayValues) {
            if (value instanceof AnnotationElementValue) {
                List<ElementValuePair> evps = ((AnnotationElementValue) value)
                        .getAnnotationEntry().getElementValuePairs();
                String initParamName = null;
                String initParamValue = null;
                for (ElementValuePair evp : evps) {
                    if ("name".equals(evp.getNameString())) {
                        initParamName = evp.getValue().stringifyValue();
                    } else if ("value".equals(evp.getNameString())) {
                        initParamValue = evp.getValue().stringifyValue();
                    } else {
                        // Ignore
                    }
                }
                result.put(initParamName, initParamValue);
            }
        }
    }
    return result;
}
 
Example #2
Source File: ContextConfig.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
protected Map<String,String> processAnnotationWebInitParams(
        ElementValue ev) {
    Map<String, String> result = new HashMap<String,String>();
    if (ev instanceof ArrayElementValue) {
        ElementValue[] arrayValues =
            ((ArrayElementValue) ev).getElementValuesArray();
        for (ElementValue value : arrayValues) {
            if (value instanceof AnnotationElementValue) {
                List<ElementValuePair> evps = ((AnnotationElementValue) value)
                        .getAnnotationEntry().getElementValuePairs();
                String initParamName = null;
                String initParamValue = null;
                for (ElementValuePair evp : evps) {
                    if ("name".equals(evp.getNameString())) {
                        initParamName = evp.getValue().stringifyValue();
                    } else if ("value".equals(evp.getNameString())) {
                        initParamValue = evp.getValue().stringifyValue();
                    } else {
                        // Ignore
                    }
                }
                result.put(initParamName, initParamValue);
            }
        }
    }
    return result;
}
 
Example #3
Source File: OpenEJBContextConfig.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
protected void processAnnotationWebServlet(final String className, final AnnotationEntry ae, final WebXml fragment) {
    try {
        super.processAnnotationWebServlet(className, ae, fragment);
    } catch (final IllegalArgumentException iae) {
        // otherwise TCKs are not passing, hope to be able to let it with next TCK versions

        String[] urlPatterns = null;
        for (final ElementValuePair evp : ae.getElementValuePairs()) {
            final String name = evp.getNameString();
            if ("value".equals(name) || "urlPatterns".equals(name)) {
                urlPatterns = processAnnotationsStringArray(evp.getValue());
                break;
            }
        }

        if (urlPatterns != null) {
            for (final String pattern : urlPatterns) {
                if (fragment.getServletMappings().containsKey(pattern)) {
                    logger.warning(iae.getMessage(), iae);
                    return;
                }
            }
        }

        throw iae;
    }
}