class JmxRequestFactory {

    public static <R extends JmxRequest> R createGetRequest(String pPathInfo, ProcessingParameters pProcessingParameters) {
        RequestType type = null;
        try {
            String pathInfo = extractPathInfo(pPathInfo, pProcessingParameters);

            // Get all path elements as a reverse stack
            Stack<String> elements = EscapeUtil.extractElementsFromPath(pathInfo);

            // Use version by default if no type is given
            type = elements.size() != 0 ? RequestType.getTypeByName(elements.pop()) : RequestType.VERSION;

            // Parse request
            return (R) getCreator(type).create(elements, pProcessingParameters);
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException("Invalid object name. " + e.getMessage(),e);
        } catch (EmptyStackException exp) {
            throw new IllegalArgumentException("Invalid arguments in pathinfo " + pPathInfo + (type != null ? " for command " + type : ""),exp);
        }
    }

    private  JmxRequestFactory();

}