use of org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo in project felix by apache.
the class FailedDTOHolder method add.
public void add(final AbstractInfo<?> info, final long contextId, final int failureCode) {
if (info instanceof ServletContextHelperInfo) {
final FailedServletContextDTO dto = (FailedServletContextDTO) ServletContextDTOBuilder.build((ServletContextHelperInfo) info, null, failureCode);
this.failedServletContextDTOs.add(dto);
} else if (info instanceof ServletInfo) {
boolean isError = false;
if (((ServletInfo) info).getErrorPage() != null) {
isError = true;
final FailedErrorPageDTO dto = (FailedErrorPageDTO) ErrorPageDTOBuilder.build((ServletInfo) info, true);
dto.failureReason = failureCode;
final ErrorPageRegistry.ErrorRegistration reg = ErrorPageRegistry.getErrorRegistration((ServletInfo) info);
dto.errorCodes = reg.errorCodes;
dto.exceptions = reg.exceptions;
dto.servletContextId = contextId;
this.failedErrorPageDTOs.add(dto);
}
if (((ServletInfo) info).getPatterns() != null || ((ServletInfo) info).getName() != null || !isError) {
final FailedServletDTO dto = (FailedServletDTO) ServletDTOBuilder.build((ServletInfo) info, failureCode);
if (((ServletInfo) info).getPatterns() != null) {
dto.patterns = ((ServletInfo) info).getPatterns();
} else {
dto.patterns = BuilderConstants.EMPTY_STRING_ARRAY;
}
dto.name = ((ServletInfo) info).getName();
dto.servletContextId = contextId;
this.failedServletDTOs.add(dto);
}
} else if (info instanceof FilterInfo) {
final FailedFilterDTO dto = (FailedFilterDTO) FilterDTOBuilder.build((FilterInfo) info, failureCode);
dto.failureReason = failureCode;
dto.servletContextId = contextId;
this.failedFilterDTOs.add(dto);
} else if (info instanceof ResourceInfo) {
final FailedResourceDTO dto = (FailedResourceDTO) ResourceDTOBuilder.build((ResourceInfo) info, true);
dto.failureReason = failureCode;
dto.servletContextId = contextId;
this.failedResourceDTOs.add(dto);
} else if (info instanceof ListenerInfo) {
final FailedListenerDTO dto = (FailedListenerDTO) ListenerDTOBuilder.build((ListenerInfo) info, failureCode);
dto.servletContextId = contextId;
this.failedListenerDTOs.add(dto);
} else if (info instanceof PreprocessorInfo) {
final FailedPreprocessorDTO dto = (FailedPreprocessorDTO) PreprocessorDTOBuilder.build((PreprocessorInfo) info, failureCode);
this.failedPreprocessorDTOs.add(dto);
} else {
SystemLogger.error("Unsupported info type: " + info.getClass(), null);
}
}
use of org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo in project felix by apache.
the class WhiteboardManager method start.
/**
* Start the whiteboard manager
* @param containerContext The servlet context
*/
public void start(final ServletContext containerContext, @Nonnull final Dictionary<String, Object> httpServiceProps) {
// runtime service gets the same props for now
this.serviceRuntime.setAllAttributes(httpServiceProps);
this.serviceRuntime.setAttribute(HttpServiceRuntimeConstants.HTTP_SERVICE_ID, Collections.singletonList(this.httpServiceFactory.getHttpServiceServiceId()));
this.runtimeServiceReg = this.httpBundleContext.registerService(HttpServiceRuntime.class, serviceRuntime, this.serviceRuntime.getAttributes());
this.serviceRuntime.setServiceReference(this.runtimeServiceReg.getReference());
this.webContext = containerContext;
// add context for http service
final List<WhiteboardContextHandler> list = new ArrayList<>();
final ServletContextHelperInfo info = new ServletContextHelperInfo(Integer.MAX_VALUE, HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID, HttpServiceFactory.HTTP_SERVICE_CONTEXT_NAME, "/", null);
list.add(new HttpServiceContextHandler(info, registry.getRegistry(HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID), httpServiceFactory, webContext, this.httpBundleContext.getBundle()));
this.contextMap.put(HttpServiceFactory.HTTP_SERVICE_CONTEXT_NAME, list);
// add default context
final Dictionary<String, Object> props = new Hashtable<>();
props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME);
props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/");
props.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
this.defaultContextRegistration = httpBundleContext.registerService(ServletContextHelper.class, new ServiceFactory<ServletContextHelper>() {
@Override
public ServletContextHelper getService(final Bundle bundle, final ServiceRegistration<ServletContextHelper> registration) {
return new ServletContextHelper(bundle) {
};
}
@Override
public void ungetService(final Bundle bundle, final ServiceRegistration<ServletContextHelper> registration, final ServletContextHelper service) {
// nothing to do
}
}, props);
addTracker(new FilterTracker(this.httpBundleContext, this));
addTracker(new ListenersTracker(this.httpBundleContext, this));
addTracker(new PreprocessorTracker(this.httpBundleContext, this));
addTracker(new ResourceTracker(this.httpBundleContext, this));
addTracker(new ServletContextHelperTracker(this.httpBundleContext, this));
addTracker(new ServletTracker(this.httpBundleContext, this));
this.plugin.register();
}
Aggregations