Need to call this by reflection for backwards compatibility with Servlet 2.5
970894
static boolean isHttpOnlyReflect(javax.servlet.http.Cookie servletCookie){
        try {
            return (Boolean)servletCookie.getClass().getMethod("isHttpOnly").invoke(servletCookie);
        } catch (Exception e) {
//            Cookie.logger.warn("You are trying to get HttpOnly from a cookie, but it appears you are running on Servlet version before 3.0. Returning false.. which can be false!");
            return false; //return default. Should we be throwing exception here?
        }
    }
1241772
@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		Window window = new Window();
		window.add(new Text("Hello world!"));
		
		Reflector<Component> reflector = new HtmlComponentReflector();
		response.setContentType(reflector.getContentType());
		
		try
		{
			reflector.reflect(window, response.getWriter());
		}
		catch (ReflectorException exception)
		{
			throw new ServletException("Error writing component", exception);
		}
	}
371074
static ObjectMethod objectMethodToOverride(ExecutableElement method) {
    String name = method.getSimpleName().toString();
    switch (method.getParameters().size()) {
      case 0:
        if (name.equals("toString")) {
          return ObjectMethod.TO_STRING;
        } else if (name.equals("hashCode")) {
          return ObjectMethod.HASH_CODE;
        }
        break;
      case 1:
        if (name.equals("equals")) {
          TypeMirror param = getOnlyElement(method.getParameters()).asType();
          if (param.getKind().equals(TypeKind.DECLARED)) {
            TypeElement paramType = MoreTypes.asTypeElement(param);
            if (paramType.getQualifiedName().contentEquals("java.lang.Object")) {
              return ObjectMethod.EQUALS;
            }
          }
        }
        break;
      default:
        // No relevant Object methods have more than one parameter.
    }
    return ObjectMethod.NONE;
  }
862482
@SuppressWarnings({ "rawtypes", "unchecked" })
	public void callMethod(final MethodCallInfo info) {
		try {
			MethodsCaller.logger.info("loading class : ".concat(info.getClassName()));
			final Class clas = getClass().getClassLoader().loadClass(info.getClassName());
			MethodsCaller.logger.info("calling default constructor");
			final Object object = clas.newInstance();
			MethodsCaller.logger.info("calling method : " + info.getMethodName() + " , with params: ".concat(Arrays.toString(info.getParamters())));
			final Method method = clas.getMethod(info.getMethodName(), info.getParamtersTypes());
			final Object result = method.invoke(object, info.getParamters());
			if (!(result instanceof Serializable)) {
				throw new IllegalStateException("object " + result + " from type " + result.getClass().getName() + " is not serialzable");
			}
			info.setResult(result);
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException
				| IllegalArgumentException | InvocationTargetException e) {
			MethodsCaller.logger.severe("calling to method failed : ".concat(info.toString()));
			throw new RemoteReflectionException(e);
		}
	}
30978
@Override
    public Object intercept(MethodInvocationContext<Object, Object> context) {
        AnnotationValue<Client> clientAnnotation = context.findAnnotation(Client.class).orElseThrow(() ->
                new IllegalStateException("Client advice called from type that is not annotated with @Client: " + context)
        );

        HttpClient httpClient = getClient(context, clientAnnotation);

        Class<?> declaringType = context.getDeclaringType();
        if (Closeable.class == declaringType || AutoCloseable.class == declaringType) {
            String clientId = clientAnnotation.getValue(String.class).orElse(null);
            String path = clientAnnotation.get("path", String.class).orElse(null);
            String clientKey = computeClientKey(clientId, path);
            clients.remove(clientKey);
            httpClient.close();
            return null;
        }

        Optional<Class<? extends Annotation>> httpMethodMapping = context.getAnnotationTypeByStereotype(HttpMethodMapping.class);
        if (context.hasStereotype(HttpMethodMapping.class) && httpClient != null) {
            AnnotationValue<HttpMethodMapping> mapping = context.getAnnotation(HttpMethodMapping.class);
            String uri = mapping.getRequiredValue(String.class);
            if (StringUtils.isEmpty(uri)) {
                uri = "/" + context.getMethodName();
            }

            Class<? extends Annotation> annotationType = httpMethodMapping.get();

            HttpMethod httpMethod = HttpMethod.valueOf(annotationType.getSimpleName().toUpperCase());

            ReturnType returnType = context.getReturnType();
            Class<?> javaReturnType = returnType.getType();

            UriMatchTemplate uriTemplate = UriMatchTemplate.of("");
            if (!(uri.length() == 1 && uri.charAt(0) == '/')) {
                uriTemplate = uriTemplate.nest(uri);
            }

            Map<String, Object> paramMap = context.getParameterValueMap();
            Map<String, String> queryParams = new LinkedHashMap<>();
            List<String> uriVariables = uriTemplate.getVariableNames();

            boolean variableSatisfied = uriVariables.isEmpty() || uriVariables.containsAll(paramMap.keySet());
            MutableHttpRequest<Object> request;
            Object body = null;
            Map<String, MutableArgumentValue<?>> parameters = context.getParameters();
            Argument[] arguments = context.getArguments();


            Map<String, String> headers = new LinkedHashMap<>(HEADERS_INITIAL_CAPACITY);

            List<AnnotationValue<Header>> headerAnnotations = context.getAnnotationValuesByType(Header.class);
            for (AnnotationValue<Header> headerAnnotation : headerAnnotations) {
                String headerName = headerAnnotation.get("name", String.class).orElse(null);
                String headerValue = headerAnnotation.getValue(String.class).orElse(null);
                if (StringUtils.isNotEmpty(headerName) && StringUtils.isNotEmpty(headerValue)) {
                    headers.put(headerName, headerValue);
                }
            }

            context.findAnnotation(Version.class)
                    .flatMap(versionAnnotation -> versionAnnotation.getValue(String.class))
                    .filter(StringUtils::isNotEmpty)
                    .ifPresent(version -> {

                        ClientVersioningConfiguration configuration = getVersioningConfiguration(clientAnnotation);

                        configuration.getHeaders()
                                .forEach(header -> headers.put(header, version));

                        configuration.getParameters()
                                .forEach(parameter -> queryParams.put(parameter, version));
                    });
          
            Map<String, Object> attributes = new LinkedHashMap<>(ATTRIBUTES_INITIAL_CAPACITY);

            List<AnnotationValue<RequestAttribute>> attributeAnnotations = context.getAnnotationValuesByType(RequestAttribute.class);
            for (AnnotationValue<RequestAttribute> attributeAnnotation : attributeAnnotations) {
                String attributeName = attributeAnnotation.get("name", String.class).orElse(null);
                Object attributeValue = attributeAnnotation.getValue(Object.class).orElse(null);
                if (StringUtils.isNotEmpty(attributeName) && attributeValue != null) {
                    attributes.put(attributeName, attributeValue);
                }
            }

            List<NettyCookie> cookies = new ArrayList<>();
            List<Argument> bodyArguments = new ArrayList<>();
            ConversionService<?> conversionService = ConversionService.SHARED;
            for (Argument argument : arguments) {
                String argumentName = argument.getName();
                AnnotationMetadata annotationMetadata = argument.getAnnotationMetadata();
                MutableArgumentValue<?> value = parameters.get(argumentName);
                Object definedValue = value.getValue();

                if (paramMap.containsKey(argumentName)) {
                    if (annotationMetadata.hasStereotype(Format.class)) {
                        final Object v = paramMap.get(argumentName);
                        if (v != null) {
                            paramMap.put(argumentName, conversionService.convert(v, ConversionContext.of(String.class).with(argument.getAnnotationMetadata())));
                        }
                    }
                }
                if (definedValue == null) {
                    definedValue = argument.getAnnotationMetadata().getValue(Bindable.class, "defaultValue", String.class).orElse(null);
                }

                if (definedValue == null && !argument.isAnnotationPresent(Nullable.class)) {
                    throw new IllegalArgumentException(
                            String.format("Null values are not allowed to be passed to client methods (%s). Add @javax.validation.Nullable if that is the desired behavior", context.getExecutableMethod().toString())
                    );
                }

                if (argument.isAnnotationPresent(Body.class)) {
                    body = definedValue;
                } else if (annotationMetadata.isAnnotationPresent(Header.class)) {

                    String headerName = annotationMetadata.getValue(Header.class, String.class).orElse(null);
                    if (StringUtils.isEmpty(headerName)) {
                        headerName = NameUtils.hyphenate(argumentName);
                    }
                    String finalHeaderName = headerName;
                    conversionService.convert(definedValue, String.class)
                        .ifPresent(o -> headers.put(finalHeaderName, o));
                } else if (annotationMetadata.isAnnotationPresent(CookieValue.class)) {
                    String cookieName = annotationMetadata.getValue(CookieValue.class, String.class).orElse(null);
                    if (StringUtils.isEmpty(cookieName)) {
                        cookieName = argumentName;
                    }
                    String finalCookieName = cookieName;

                    conversionService.convert(definedValue, String.class)
                        .ifPresent(o -> cookies.add(new NettyCookie(finalCookieName, o)));

                } else if (annotationMetadata.isAnnotationPresent(QueryValue.class)) {
                    String parameterName = annotationMetadata.getValue(QueryValue.class, String.class).orElse(null);
                    conversionService.convert(definedValue, ConversionContext.of(String.class).with(annotationMetadata)).ifPresent(o -> {
                        if (!StringUtils.isEmpty(parameterName)) {
                            paramMap.put(parameterName, o);
                            queryParams.put(parameterName, o);
                        } else {
                            queryParams.put(argumentName, o);
                        }
                    });
                } else if (annotationMetadata.isAnnotationPresent(RequestAttribute.class)) {
                    String attributeName = annotationMetadata.getValue(Annotation.class, String.class).orElse(null);
                    if (StringUtils.isEmpty(attributeName)) {
                        attributeName = NameUtils.hyphenate(argumentName);
                    }
                    String finalAttributeName = attributeName;
                    conversionService.convert(definedValue, Object.class)
                        .ifPresent(o -> attributes.put(finalAttributeName, o));
                } else if (annotationMetadata.isAnnotationPresent(PathVariable.class)) {
                    String parameterName = annotationMetadata.getValue(PathVariable.class, String.class).orElse(null);
                    conversionService.convert(definedValue, ConversionContext.of(String.class).with(annotationMetadata)).ifPresent(o -> {
                        if (!StringUtils.isEmpty(o)) {
                            paramMap.put(parameterName, o);
                        }
                    });
                } else if (!uriVariables.contains(argumentName)) {
                    bodyArguments.add(argument);
                }
            }

            if (HttpMethod.permitsRequestBody(httpMethod)) {
                if (body == null && !bodyArguments.isEmpty()) {
                    Map<String, Object> bodyMap = new LinkedHashMap<>();

                    for (Argument bodyArgument : bodyArguments) {
                        String argumentName = bodyArgument.getName();
                        MutableArgumentValue<?> value = parameters.get(argumentName);
                        bodyMap.put(argumentName, value.getValue());
                    }
                    body = bodyMap;
                }

                if (body != null) {
                    if (!variableSatisfied) {

                        if (body instanceof Map) {
                            paramMap.putAll((Map) body);
                        } else {
                            BeanMap<Object> beanMap = BeanMap.of(body);
                            for (Map.Entry<String, Object> entry : beanMap.entrySet()) {
                                String k = entry.getKey();
                                Object v = entry.getValue();
                                if (v != null) {
                                    paramMap.put(k, v);
                                }
                            }
                        }
                    }
                }
            }

            uri = uriTemplate.expand(paramMap);
            uriVariables.forEach(queryParams::remove);

            request = HttpRequest.create(httpMethod, appendQuery(uri, queryParams));
            if (body != null) {
                request.body(body);

                MediaType[] contentTypes = context.getValue(Produces.class, MediaType[].class).orElse(DEFAULT_ACCEPT_TYPES);
                if (ArrayUtils.isNotEmpty(contentTypes)) {
                    request.contentType(contentTypes[0]);
                }
            }

            // Set the URI template used to make the request for tracing purposes
            request.setAttribute(HttpAttributes.URI_TEMPLATE, resolveTemplate(clientAnnotation, uriTemplate.toString()));
            String serviceId = clientAnnotation.getValue(String.class).orElse(null);
            Argument<?> errorType = clientAnnotation.get("errorType", Class.class).map((Function<Class, Argument>) Argument::of).orElse(HttpClient.DEFAULT_ERROR_TYPE);
            request.setAttribute(HttpAttributes.SERVICE_ID, serviceId);


            if (!headers.isEmpty()) {
                for (Map.Entry<String, String> entry : headers.entrySet()) {
                    request.header(entry.getKey(), entry.getValue());
                }
            }

            cookies.forEach(request::cookie);

            if (!attributes.isEmpty()) {
                for (Map.Entry<String, Object> entry : attributes.entrySet()) {
                    request.setAttribute(entry.getKey(), entry.getValue());
                }
            }

            MediaType[] acceptTypes = context.getValue(Consumes.class, MediaType[].class).orElse(DEFAULT_ACCEPT_TYPES);

            boolean isFuture = CompletableFuture.class.isAssignableFrom(javaReturnType);
            final Class<?> methodDeclaringType = declaringType;
            if (Publishers.isConvertibleToPublisher(javaReturnType) || isFuture) {
                boolean isSingle = Publishers.isSingle(javaReturnType) || isFuture || context.getValue(Consumes.class, "single", Boolean.class).orElse(false);
                Argument<?> publisherArgument = returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT);


                Class<?> argumentType = publisherArgument.getType();

                if (HttpResponse.class.isAssignableFrom(argumentType) || HttpStatus.class.isAssignableFrom(argumentType)) {
                    isSingle = true;
                }

                Publisher<?> publisher;

                if (!isSingle && httpClient instanceof StreamingHttpClient) {
                    StreamingHttpClient streamingHttpClient = (StreamingHttpClient) httpClient;

                    if (!Void.class.isAssignableFrom(argumentType)) {
                        request.accept(acceptTypes);
                    }

                    if (HttpResponse.class.isAssignableFrom(argumentType) ||
                            Void.class.isAssignableFrom(argumentType)) {
                        publisher = streamingHttpClient.exchangeStream(
                                request
                        );
                    } else {
                        boolean isEventStream = Arrays.asList(acceptTypes).contains(MediaType.TEXT_EVENT_STREAM_TYPE);

                        if (isEventStream && streamingHttpClient instanceof SseClient) {
                            SseClient sseClient = (SseClient) streamingHttpClient;
                            if (publisherArgument.getType() == Event.class) {
                                publisher = sseClient.eventStream(
                                        request, publisherArgument.getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT)
                                );
                            } else {
                                publisher = Flowable.fromPublisher(sseClient.eventStream(
                                        request, publisherArgument
                                )).map(Event::getData);
                            }
                        } else {
                            boolean isJson = isJsonParsedMediaType(acceptTypes);
                            if (isJson) {
                                publisher = streamingHttpClient.jsonStream(
                                        request, publisherArgument
                                );
                            } else {
                                Publisher<ByteBuffer<?>> byteBufferPublisher = streamingHttpClient.dataStream(
                                        request
                                );
                                if (argumentType == ByteBuffer.class) {
                                    publisher = byteBufferPublisher;
                                } else {
                                    if (conversionService.canConvert(ByteBuffer.class, argumentType)) {
                                        // It would be nice if we could capture the TypeConverter here
                                        publisher = Flowable.fromPublisher(byteBufferPublisher)
                                                .map(value -> conversionService.convert(value, argumentType).get());
                                    } else {
                                        throw new ConfigurationException("Cannot create the generated HTTP client's " +
                                                "required return type, since no TypeConverter from ByteBuffer to " +
                                                argumentType + " is registered");
                                    }
                                }

                            }
                        }
                    }

                } else {

                    if (Void.class.isAssignableFrom(argumentType)) {
                        publisher = httpClient.exchange(
                                request, null, errorType
                        );
                    } else {
                        request.accept(acceptTypes);
                        if (HttpResponse.class.isAssignableFrom(argumentType)) {
                            publisher = httpClient.exchange(
                                    request, publisherArgument, errorType
                            );
                        } else {
                            publisher = httpClient.retrieve(
                                    request, publisherArgument, errorType
                            );
                        }
                    }
                }

                if (isFuture) {
                    CompletableFuture<Object> future = new CompletableFuture<>();
                    publisher.subscribe(new CompletionAwareSubscriber<Object>() {
                        AtomicReference<Object> reference = new AtomicReference<>();

                        @Override
                        protected void doOnSubscribe(Subscription subscription) {
                            subscription.request(1);
                        }

                        @Override
                        protected void doOnNext(Object message) {
                            if (!Void.class.isAssignableFrom(argumentType)) {
                                reference.set(message);
                            }
                        }

                        @Override
                        protected void doOnError(Throwable t) {
                            if (t instanceof HttpClientResponseException) {
                                HttpClientResponseException e = (HttpClientResponseException) t;
                                if (e.getStatus() == HttpStatus.NOT_FOUND) {
                                    future.complete(null);
                                    return;
                                }
                            }
                            if (LOG.isErrorEnabled()) {
                                LOG.error("Client [" + methodDeclaringType.getName() + "] received HTTP error response: " + t.getMessage(), t);
                            }

                            future.completeExceptionally(t);
                        }

                        @Override
                        protected void doOnComplete() {
                            future.complete(reference.get());
                        }
                    });
                    return future;
                } else {
                    Object finalPublisher = conversionService.convert(publisher, javaReturnType).orElseThrow(() ->
                        new HttpClientException("Cannot convert response publisher to Reactive type (Unsupported Reactive type): " + javaReturnType)
                    );
                    for (ReactiveClientResultTransformer transformer : transformers) {
                        finalPublisher = transformer.transform(finalPublisher);
                    }
                    return finalPublisher;
                }
            } else {
                BlockingHttpClient blockingHttpClient = httpClient.toBlocking();

                if (void.class != javaReturnType) {
                    request.accept(acceptTypes);
                }

                if (HttpResponse.class.isAssignableFrom(javaReturnType)) {
                    return blockingHttpClient.exchange(
                        request, returnType.asArgument().getFirstTypeVariable().orElse(Argument.OBJECT_ARGUMENT), errorType
                    );
                } else if (void.class == javaReturnType) {
                    blockingHttpClient.exchange(request, null, errorType);
                    return null;
                } else {
                    try {
                        return blockingHttpClient.retrieve(
                                request, returnType.asArgument(), errorType
                        );
                    } catch (RuntimeException t) {
                        if (t instanceof HttpClientResponseException && ((HttpClientResponseException) t).getStatus() == HttpStatus.NOT_FOUND) {
                            if (javaReturnType == Optional.class) {
                                return Optional.empty();
                            }
                            return null;
                        } else {
                            throw t;
                        }
                    }
                }
            }
        }
        // try other introduction advice
        return context.proceed();
    }
211167
protected Object invoke(Bindings bindings, ELContext context, Object base, Method method)
		throws InvocationTargetException, IllegalAccessException {
		Class<?>[] types = method.getParameterTypes();
		Object[] params = null;
		if (types.length > 0) {
			params = new Object[types.length];
			if (varargs && method.isVarArgs()) {
				for (int i = 0; i < params.length - 1; i++) {
					Object param = getParam(i).eval(bindings, context);
					if (param != null || types[i].isPrimitive()) {
						params[i] = bindings.convert(param, types[i]);
					}
				}
				int varargIndex = types.length - 1;
				Class<?> varargType = types[varargIndex].getComponentType();
				int length = getParamCount() - varargIndex;
				Object array = null;
				if (length == 1) { // special: eventually use argument as is
					Object param = getParam(varargIndex).eval(bindings, context);
					if (param != null && param.getClass().isArray()) {
						if (types[varargIndex].isInstance(param)) {
							array = param;
						} else { // coerce array elements
							length = Array.getLength(param);
							array = Array.newInstance(varargType, length);
							for (int i = 0; i < length; i++) {
								Object elem = Array.get(param, i);
								if (elem != null || varargType.isPrimitive()) {
									Array.set(array, i, bindings.convert(elem, varargType));
								}
							}
						}
					} else { // single element array
						array = Array.newInstance(varargType, 1);
						if (param != null || varargType.isPrimitive()) {
							Array.set(array, 0, bindings.convert(param, varargType));
						}
					}
				} else {
					array = Array.newInstance(varargType, length);
					for (int i = 0; i < length; i++) {
						Object param = getParam(varargIndex + i).eval(bindings, context);
						if (param != null || varargType.isPrimitive()) {
							Array.set(array, i, bindings.convert(param, varargType));
						}
					}
				}
				params[varargIndex] = array;
			} else {
				for (int i = 0; i < params.length; i++) {
					Object param = getParam(i).eval(bindings, context);
					if (param != null || types[i].isPrimitive()) {
						params[i] = bindings.convert(param, types[i]);
					}
				}
			}
		}
		return method.invoke(base, params);
	}
487860
public static ServletContext wrap(final ServletContext pContext, final Object[] pDelegates, final ClassLoader pLoader) {
        ClassLoader cl = pLoader != null ? pLoader : Thread.currentThread().getContextClassLoader();

        // TODO: Create a "static" mapping between methods in the ServletContext
        // and the corresponding delegate

        // TODO: Resolve super-invokations, to delegate to next delegate in
        // chain, and finally invoke pContext  

        return (ServletContext) Proxy.newProxyInstance(cl, new Class[] {ServletContext.class}, new InvocationHandler() {
            public Object invoke(Object pProxy, Method pMethod, Object[] pArgs) throws Throwable {
                // TODO: Test if any of the delegates should receive, if so invoke

                // Else, invoke on original object
                return pMethod.invoke(pContext, pArgs);
            }
        });
    }
1045703
private void doGetScope() throws PageException {
	String sessionType = AppListenerUtil.toSessionType(config.getSessionType(), "application");
	String localMode = AppListenerUtil.toLocalMode(config.getLocalMode(), "classic");

	Struct sct = new StructImpl();
	pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
	sct.set("allowImplicidQueryCall", Caster.toBoolean(config.allowImplicidQueryCall()));
	sct.set("mergeFormAndUrl", Caster.toBoolean(config.mergeFormAndURL()));

	sct.set("sessiontype", sessionType);
	sct.set("localmode", localMode);
	sct.set("sessionManagement", Caster.toBoolean(config.isSessionManagement()));
	sct.set("clientManagement", Caster.toBoolean(config.isClientManagement()));
	sct.set("domainCookies", Caster.toBoolean(config.isDomainCookies()));
	sct.set("clientCookies", Caster.toBoolean(config.isClientCookies()));
	sct.set("clientStorage", config.getClientStorage());
	sct.set("sessionStorage", config.getSessionStorage());
	sct.set("cgiReadonly", config.getCGIScopeReadonly());

	TimeSpan ts = config.getSessionTimeout();
	sct.set("sessionTimeout", ts);
	sct.set("sessionTimeout_day", Caster.toInteger(ts.getDay()));
	sct.set("sessionTimeout_hour", Caster.toInteger(ts.getHour()));
	sct.set("sessionTimeout_minute", Caster.toInteger(ts.getMinute()));
	sct.set("sessionTimeout_second", Caster.toInteger(ts.getSecond()));

	ts = config.getApplicationTimeout();
	sct.set("applicationTimeout", ts);
	sct.set("applicationTimeout_day", Caster.toInteger(ts.getDay()));
	sct.set("applicationTimeout_hour", Caster.toInteger(ts.getHour()));
	sct.set("applicationTimeout_minute", Caster.toInteger(ts.getMinute()));
	sct.set("applicationTimeout_second", Caster.toInteger(ts.getSecond()));

	ts = config.getClientTimeout();
	sct.set("clientTimeout", ts);
	sct.set("clientTimeout_day", Caster.toInteger(ts.getDay()));
	sct.set("clientTimeout_hour", Caster.toInteger(ts.getHour()));
	sct.set("clientTimeout_minute", Caster.toInteger(ts.getMinute()));
	sct.set("clientTimeout_second", Caster.toInteger(ts.getSecond()));

	// scope cascading type
	if (config.getScopeCascadingType() == Config.SCOPE_STRICT) sct.set("scopeCascadingType", "strict");
	else if (config.getScopeCascadingType() == Config.SCOPE_SMALL) sct.set("scopeCascadingType", "small");
	else if (config.getScopeCascadingType() == Config.SCOPE_STANDARD) sct.set("scopeCascadingType", "standard");
    }
469509
@Override
	public void registerServlet(final String alias, final Servlet servlet,
								@SuppressWarnings("rawtypes") final Dictionary initParams,
								final HttpContext httpContext) throws ServletException,
			NamespaceException {
		synchronized (lock) {
			this.registerServlet(alias, servlet, initParams, null, null,
					httpContext);
		}
	}
89137
@Override
    public void init() throws ServletException {
        super.init();

        // GET
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json, Operation.propertyTypes, new GetPropertyTypes());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json, Operation.primaryTypes, new GetPrimaryTypes());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json, Operation.mixinTypes, new GetMixinTypes());
        operations.setOperation(ServletOperationSet.Method.GET, Extension.json, Operation.typeahead, new JsonTypeahead());
    }
1298538
private void parseMethod()
    throws IOException
  {
    int accessFlags = readShort();
    int nameIndex = readShort();
    int descriptorIndex = readShort();

    JavaMethod method = new JavaMethod(_loader);
    method.setJavaClass(_class);
    method.setName(_cp.getUtf8(nameIndex).getValue());
    method.setDescriptor(_cp.getUtf8(descriptorIndex).getValue());
    method.setAccessFlags(accessFlags);

    int attributesCount = readShort();

    for (int i = 0; i < attributesCount; i++) {
      Attribute attr = parseAttribute();

      method.addAttribute(attr);
      
      if (attr instanceof ExceptionsAttribute) {
        ExceptionsAttribute exn = (ExceptionsAttribute) attr;

        ArrayList<String> exnNames = exn.getExceptionList();

        if (exnNames.size() > 0) {
          JClass []exnClasses = new JClass[exnNames.size()];

          for (int j = 0; j < exnNames.size(); j++) {
            String exnName = exnNames.get(j).replace('/', '.');

            exnClasses[j] = _loader.forName(exnName);
          }

          method.setExceptionTypes(exnClasses);
        }
      }
    }

    _class.addMethod(method);
  }
918865
@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {
        if (constructed)
        {

            String methodName = method.getName();
            int params = args.length;

            if (params == 0)
            {
                if (isUninitialized() && method.equals(getIdentifierMethod))
                {
                    return getIdentifier();
                }

                else if ("getKunderaLazyInitializer".equals(methodName))
                {
                    return this;
                }
            }

            Object target = getImplementation();

            String[] strArr = entityName.split("#");
            String fieldName = strArr[1];

            if (owner != null)
            {
                EntityMetadata m = KunderaMetadataManager.getEntityMetadata(persistenceDelegator.getKunderaMetadata(),
                        owner.getClass());
                Relation r = m.getRelation(fieldName);
                if (r != null)
                {
                    PropertyAccessorHelper.set(owner, r.getProperty(), target);
                }
                if (r.getBiDirectionalField() != null && method.getReturnType().equals(m.getEntityClazz()))
                {
                    PropertyAccessorHelper.set(target, r.getBiDirectionalField(), owner);
                }

            }

            try
            {
                final Object returnValue;
                if (method.isAccessible())
                {
                    if (!method.getDeclaringClass().isInstance(target))
                    {
                        throw new ClassCastException(target.getClass().getName());
                    }
                    returnValue = method.invoke(target, args);
                }
                else
                {
                    if (!method.isAccessible())
                    {
                        method.setAccessible(true);
                    }
                    returnValue = method.invoke(target, args);
                }
                return ((returnValue == target) ? proxy : returnValue);
            }
            catch (InvocationTargetException ite)
            {
                throw new LazyInitializationException(ite);
            }
        }
        else
        {
            // while constructor is running
            throw new LazyInitializationException("unexpected case hit, method=" + method.getName());
        }

    }
1164972
def _call_java(sc, java_obj, name, *args):
    
    m = getattr(java_obj, name)
    java_args = [_py2java(sc, arg) for arg in args]
    return _java2py(sc, m(*java_args))
500757
public int doStartTag()
            throws JspException {
        ServletRequest req = pageContext.getRequest();
        HashMap atts = (HashMap) req.getAttribute(TEMPLATE_ATTRIBUTES);
        try {
            if (atts != null) {
                String val = (String) atts.get(_name);
                if (val != null) {
                    Writer out = pageContext.getOut();
                    out.write(val);
                }
                else {
                    Writer out = pageContext.getOut();
                    if (_defaultValue != null)
                        out.write(_defaultValue);
                    else
                        out.write("");
                }
            }
            else {
                Writer out = pageContext.getOut();
                if (_defaultValue != null)
                    out.write(_defaultValue);
                else
                    out.write("");
            }
        }
        catch (IOException e) {
            localRelease();
            JspException jspException = new JspException("Caught IO Exception:" + e.getMessage(),e);
            // todo: future cleanup
            // The 2.5 Servlet api will set the initCause in the Throwable superclass during construction,
            // this will cause an IllegalStateException on the following call.
            if (jspException.getCause() == null) {
                jspException.initCause(e);
            }
            throw jspException;
        }
        localRelease();
        return EVAL_PAGE;
    }
75071
private void parseControllerMethod(JaxrsApplicationParser.Result result, JaxrsApplicationParser.ResourceContext context, Class<?> controllerClass, Method method) {
        final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
        if (requestMapping != null) {

            // subContext
            context = context.subPath(requestMapping.path().length == 0 ? "" : requestMapping.path()[0]);
            final Map<String, Type> pathParamTypes = new LinkedHashMap<>();
            for (Parameter parameter : method.getParameters()) {
                final PathVariable pathVariableAnnotation = parameter.getAnnotation(PathVariable.class);
                if (pathVariableAnnotation != null) {
                    pathParamTypes.put(pathVariableAnnotation.value(), parameter.getParameterizedType());
                }
            }
            context = context.subPathParamTypes(pathParamTypes);
            final RequestMethod httpMethod = requestMapping.method().length == 0 ? RequestMethod.GET : requestMapping.method()[0];

            // path parameters
            final PathTemplate pathTemplate = PathTemplate.parse(context.path);
            final Map<String, Type> contextPathParamTypes = context.pathParamTypes;
            final List<MethodParameterModel> pathParams = pathTemplate.getParts().stream()
                    .filter(PathTemplate.Parameter.class::isInstance)
                    .map(PathTemplate.Parameter.class::cast)
                    .map(parameter -> {
                        final Type type = contextPathParamTypes.get(parameter.getOriginalName());
                        final Type paramType = type != null ? type : String.class;
                        foundType(result, paramType, controllerClass, method.getName());
                        return new MethodParameterModel(parameter.getValidName(), paramType);
                    })
                    .collect(Collectors.toList());

            // query parameters
            final List<RestQueryParam> queryParams = new ArrayList<>();
            for (Parameter param : method.getParameters()) {
                final RequestParam requestParamAnnotation = param.getAnnotation(RequestParam.class);
                if (requestParamAnnotation != null) {
                    queryParams.add(new RestQueryParam.Single(new MethodParameterModel(requestParamAnnotation.value(), param.getParameterizedType())));
                    foundType(result, param.getParameterizedType(), controllerClass, method.getName());
                }
            }

            // entity parameter
            final MethodParameterModel entityParameter = getEntityParameter(method);
            if (entityParameter != null) {
                foundType(result, entityParameter.getType(), controllerClass, method.getName());
            }

            // return Type
            final Class<?> returnType = method.getReturnType();
            final Type genericReturnType = method.getGenericReturnType();
            final Type modelReturnType;
            if (genericReturnType instanceof ParameterizedType && returnType == ResponseEntity.class) {
                final ParameterizedType parameterizedReturnType = (ParameterizedType) genericReturnType;
                modelReturnType = parameterizedReturnType.getActualTypeArguments()[0];
                foundType(result, modelReturnType, controllerClass, method.getName());
            } else {
                modelReturnType = genericReturnType;
                foundType(result, modelReturnType, controllerClass, method.getName());
            }

            model.getMethods().add(new RestMethodModel(controllerClass, method.getName(), modelReturnType,
                    controllerClass, httpMethod.name(), context.path, pathParams, queryParams, entityParameter, null));
        }
    }
1253700
@Override
    public ServletContext getServletContext() {
        try {
            collaborator.preInvoke(componentMetaData);
            return request.getServletContext();
        } finally {
            collaborator.postInvoke();
        }
    }
1281702
void dispatch(ServletRequest servletRequest,
                  ServletResponse servletResponse,
                  int type)
        throws ServletException,IOException
    {
        HttpServletRequest httpServletRequest=(HttpServletRequest)servletRequest;
        HttpServletResponse httpServletResponse=(HttpServletResponse)servletResponse;

        HttpConnection httpConnection=
            _servletHandler.getHttpContext().getHttpConnection();
        ServletHttpRequest servletHttpRequest=
            (ServletHttpRequest)httpConnection.getRequest().getWrapper();
        
        // wrap the request and response
        DispatcherRequest request = new DispatcherRequest(httpServletRequest,
                                                          servletHttpRequest,
                                                          type);
        DispatcherResponse response = new DispatcherResponse(request,
                                                             httpServletResponse);        
        
        if (type==Dispatcher.__FORWARD)
            servletResponse.resetBuffer();
        
        // Merge parameters
        String query=_query;
        MultiMap parameters=null;
        if (query!=null)
        {
            Map old_params = httpServletRequest.getParameterMap();
            
            // Add the parameters
            parameters=new MultiMap();
            UrlEncoded.decodeTo(query,parameters,request.getCharacterEncoding());
            
            if (old_params!=null && old_params.size()>0)
            {
                // Merge old parameters.
                Iterator iter = old_params.entrySet().iterator();
                while (iter.hasNext())
                {
                    Map.Entry entry = (Map.Entry)iter.next();
                    String name=(String)entry.getKey();
                    String[] values=(String[])entry.getValue();
                    for (int i=0;i<values.length;i++)
                        parameters.add(name, values[i]);
                }
            }

            request.setParameters(parameters);
            
            String old_query=httpServletRequest.getQueryString();
            if (old_query!=null)
                request.setQuery(query+"&"+old_query);
            else
                request.setQuery(query);
        }
        
        Object old_scope = null;
        try
        {
            if (request.crossContext())
            {
                // Setup new _context
                old_scope=
                    _servletHandler.getHttpContext()
                    .enterContextScope(httpConnection.getRequest(),httpConnection.getResponse());
            }
        
            if (isNamed())
            {
                // No further modifications required.
                if (_servletHandler instanceof WebApplicationHandler)
                {
                    JSR154Filter filter = ((WebApplicationHandler)_servletHandler).getJsr154Filter();
                    if (filter!=null && filter.isUnwrappedDispatchSupported())
                    {
                        filter.setDispatch(request, response);
                        _servletHandler.dispatch(null,httpServletRequest,httpServletResponse,_holder, type);
                    }
                    else
                        _servletHandler.dispatch(null,request,response,_holder, type);
                }
                else
                	_servletHandler.dispatch(null,request,response,_holder, type);
            }
            else
            {   
                // Adjust servlet paths
                request.setPaths(_servletHandler.getHttpContext().getContextPath(),
                                 PathMap.pathMatch(_pathSpec,_pathInContext),
                                 PathMap.pathInfo(_pathSpec,_pathInContext));
        

                // are we wrap over or wrap under
                if (_servletHandler instanceof WebApplicationHandler)
                {
                    JSR154Filter filter = ((WebApplicationHandler)_servletHandler).getJsr154Filter();
                    if (filter!=null && filter.isUnwrappedDispatchSupported())
                    {
                        filter.setDispatch(request, response);
                        _servletHandler.dispatch(_pathInContext,httpServletRequest,httpServletResponse,_holder, type);
                    }
                    else
                        _servletHandler.dispatch(_pathInContext,request,response,_holder, type);
                }
                else
                    _servletHandler.dispatch(_pathInContext,request,response,_holder, type);
                
                
                if (type!=Dispatcher.__INCLUDE)
                    response.close();
                else if (response.isFlushNeeded())
                    response.flushBuffer();
            }
        }
        finally
        {
            // restore _context
            if (request.crossContext())
                _servletHandler.getHttpContext()
                    .leaveContextScope(httpConnection.getRequest(),
                                       httpConnection.getResponse(),
                                       old_scope);
        }   
    }