Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.jaxrs.servlet;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.ws.rs.core.Application;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.PrimitiveUtils;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.cxf.jaxrs.utils.InjectionUtils;
import org.apache.cxf.jaxrs.utils.ResourceUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
public class CXFNonSpringJaxrsServlet extends CXFNonSpringServlet {
private static final Logger LOG = LogUtils.getL7dLogger(CXFNonSpringJaxrsServlet.class);
private static final String USER_MODEL_PARAM = "user.model";
private static final String SERVICE_ADDRESS_PARAM = "jaxrs.address";
private static final String IGNORE_APP_PATH_PARAM = "jaxrs.application.address.ignore";
private static final String SERVICE_CLASSES_PARAM = "jaxrs.serviceClasses";
private static final String PROVIDERS_PARAM = "jaxrs.providers";
private static final String OUT_INTERCEPTORS_PARAM = "jaxrs.outInterceptors";
private static final String IN_INTERCEPTORS_PARAM = "jaxrs.inInterceptors";
private static final String SERVICE_SCOPE_PARAM = "jaxrs.scope";
private static final String EXTENSIONS_PARAM = "jaxrs.extensions";
private static final String LANGUAGES_PARAM = "jaxrs.languages";
private static final String PROPERTIES_PARAM = "jaxrs.languages";
private static final String SCHEMAS_PARAM = "jaxrs.schemaLocations";
private static final String SERVICE_SCOPE_SINGLETON = "singleton";
private static final String SERVICE_SCOPE_REQUEST = "prototype";
private static final String JAXRS_APPLICATION_PARAM = "javax.ws.rs.Application";
@Override
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
String applicationClass = servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
if (applicationClass != null) {
createServerFromApplication(applicationClass, servletConfig);
return;
}
JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
bean.setBus(getBus());
String address = servletConfig.getInitParameter(SERVICE_ADDRESS_PARAM);
if (address == null) {
address = "/";
}
bean.setAddress(address);
String modelRef = servletConfig.getInitParameter(USER_MODEL_PARAM);
if (modelRef != null) {
bean.setModelRef(modelRef.trim());
}
setSchemasLocations(bean, servletConfig);
setAllInterceptors(bean, servletConfig);
Map> resourceClasses =
getServiceClasses(servletConfig, modelRef != null);
Map resourceProviders =
getResourceProviders(servletConfig, resourceClasses);
List> providers = getProviders(servletConfig);
bean.setResourceClasses(new ArrayList(resourceClasses.keySet()));
bean.setProviders(providers);
for (Map.Entry entry : resourceProviders.entrySet()) {
bean.setResourceProvider(entry.getKey(), entry.getValue());
}
setExtensions(bean, servletConfig);
bean.create();
}
protected void setExtensions(JAXRSServerFactoryBean bean, ServletConfig servletConfig) {
bean.setExtensionMappings(handleMapSequence(servletConfig.getInitParameter(EXTENSIONS_PARAM)));
bean.setLanguageMappings(handleMapSequence(servletConfig.getInitParameter(LANGUAGES_PARAM)));
bean.setProperties(CastUtils.cast(
handleMapSequence(servletConfig.getInitParameter(PROPERTIES_PARAM)),
String.class, Object.class));
}
protected Map