use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class RuntimeDelegateImpl method createEndpoint.
@Override
public <T> T createEndpoint(Application app, Class<T> endpointType) throws IllegalArgumentException, UnsupportedOperationException {
if (app == null || (!Server.class.isAssignableFrom(endpointType) && !JAXRSServerFactoryBean.class.isAssignableFrom(endpointType))) {
throw new IllegalArgumentException();
}
JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, false, false, false, null);
if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) {
return endpointType.cast(bean);
}
bean.setStart(false);
Server server = bean.create();
return endpointType.cast(server);
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class CXFNonSpringJaxrsServlet method init.
@Override
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
if (getApplication() != null) {
createServerFromApplication(servletConfig);
return;
}
String applicationClass = servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
if (applicationClass != null) {
createServerFromApplication(applicationClass, servletConfig);
return;
}
String splitChar = getParameterSplitChar(servletConfig);
JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
bean.setBus(getBus());
String address = servletConfig.getInitParameter(SERVICE_ADDRESS_PARAM);
if (address == null) {
address = "/";
}
bean.setAddress(address);
bean.setStaticSubresourceResolution(getStaticSubResolutionValue(servletConfig));
String modelRef = servletConfig.getInitParameter(USER_MODEL_PARAM);
if (modelRef != null) {
bean.setModelRef(modelRef.trim());
}
setDocLocation(bean, servletConfig);
setSchemasLocations(bean, servletConfig);
setAllInterceptors(bean, servletConfig, splitChar);
setInvoker(bean, servletConfig);
Map<Class<?>, Map<String, List<String>>> resourceClasses = getServiceClasses(servletConfig, modelRef != null, splitChar);
Map<Class<?>, ResourceProvider> resourceProviders = getResourceProviders(servletConfig, resourceClasses);
List<?> providers = getProviders(servletConfig, splitChar);
bean.setResourceClasses(new ArrayList<Class<?>>(resourceClasses.keySet()));
bean.setProviders(providers);
for (Map.Entry<Class<?>, ResourceProvider> entry : resourceProviders.entrySet()) {
bean.setResourceProvider(entry.getKey(), entry.getValue());
}
setExtensions(bean, servletConfig);
List<? extends Feature> features = getFeatures(servletConfig, splitChar);
bean.setFeatures(features);
bean.create();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class CXFNonSpringJaxrsServlet method createServerFromApplication.
protected void createServerFromApplication(String applicationNames, ServletConfig servletConfig) throws ServletException {
boolean ignoreApplicationPath = isIgnoreApplicationPath(servletConfig);
String[] classNames = StringUtils.split(applicationNames, getParameterSplitChar(servletConfig));
if (classNames.length > 1 && ignoreApplicationPath) {
throw new ServletException("\"" + IGNORE_APP_PATH_PARAM + "\" parameter must be set to false for multiple Applications be supported");
}
for (String cName : classNames) {
ApplicationInfo providerApp = createApplicationInfo(cName, servletConfig);
Application app = providerApp.getProvider();
JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, ignoreApplicationPath, getStaticSubResolutionValue(servletConfig), isAppResourceLifecycleASingleton(app, servletConfig), getBus());
String splitChar = getParameterSplitChar(servletConfig);
setAllInterceptors(bean, servletConfig, splitChar);
setInvoker(bean, servletConfig);
setExtensions(bean, servletConfig);
setDocLocation(bean, servletConfig);
setSchemasLocations(bean, servletConfig);
bean.setBus(getBus());
bean.setApplicationInfo(providerApp);
bean.create();
}
}
Aggregations