use of org.osgi.service.http.runtime.dto.FailedListenerDTO in project felix by apache.
the class HttpServicePlugin method printConfiguration.
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
*/
public void printConfiguration(final PrintWriter pw) {
final RuntimeDTO dto = this.runtime.getRuntimeDTO();
pw.println("HTTP Service Details");
pw.println("====================");
pw.println();
pw.println("Runtime Properties");
pw.println("------------------");
for (final Map.Entry<String, Object> prop : dto.serviceDTO.properties.entrySet()) {
pw.print(prop.getKey());
pw.print(" : ");
pw.println(getValueAsString(prop.getValue()));
}
pw.println();
for (final ServletContextDTO ctxDto : dto.servletContextDTOs) {
pw.print("Servlet Context ");
pw.println(ctxDto.name);
pw.println("-----------------------------------------------");
pw.print("Path : ");
pw.println(getContextPath(ctxDto.contextPath));
printServiceIdAndRanking(pw, this.getServiceReference(ctxDto.serviceId), ctxDto.serviceId);
pw.println();
if (ctxDto.servletDTOs.length > 0) {
pw.println("Servlets");
for (final ServletDTO servlet : ctxDto.servletDTOs) {
pw.print("Patterns : ");
pw.println(getValueAsString(servlet.patterns));
pw.print("Name : ");
pw.println(servlet.name);
final ServiceReference<?> ref = this.getServiceReference(servlet.serviceId);
printServiceIdAndRanking(pw, ref, servlet.serviceId);
pw.print("async : ");
pw.println(String.valueOf(servlet.asyncSupported));
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (ctxDto.filterDTOs.length > 0) {
pw.println("Filters");
for (final FilterDTO filter : ctxDto.filterDTOs) {
final List<String> patterns = new ArrayList<>();
patterns.addAll(Arrays.asList(filter.patterns));
patterns.addAll(Arrays.asList(filter.regexs));
for (final String name : filter.servletNames) {
patterns.add("Servlet : " + name);
}
Collections.sort(patterns);
pw.print("Patterns : ");
pw.println(patterns);
pw.print("Name : ");
pw.println(filter.name);
final ServiceReference<?> ref = this.getServiceReference(filter.serviceId);
printServiceIdAndRanking(pw, ref, filter.serviceId);
pw.print("async : ");
pw.println(String.valueOf(filter.asyncSupported));
pw.print("dispatcher : ");
pw.println(getValueAsString(filter.dispatcher));
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (ctxDto.resourceDTOs.length > 0) {
pw.println("Resources");
for (final ResourceDTO rsrc : ctxDto.resourceDTOs) {
pw.print("Patterns : ");
pw.println(getValueAsString(rsrc.patterns));
pw.print("Prefix : ");
pw.println(rsrc.prefix);
final ServiceReference<?> ref = this.getServiceReference(rsrc.serviceId);
printServiceIdAndRanking(pw, ref, rsrc.serviceId);
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (ctxDto.errorPageDTOs.length > 0) {
pw.println("Error Pages");
for (final ErrorPageDTO ep : ctxDto.errorPageDTOs) {
final List<String> patterns = new ArrayList<>();
for (final long p : ep.errorCodes) {
patterns.add(String.valueOf(p));
}
for (final String p : ep.exceptions) {
patterns.add(p);
}
pw.print("Patterns : ");
pw.println(patterns);
pw.print("Name : ");
pw.println(ep.name);
final ServiceReference<?> ref = this.getServiceReference(ep.serviceId);
printServiceIdAndRanking(pw, ref, ep.serviceId);
pw.print("async : ");
pw.println(String.valueOf(ep.asyncSupported));
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (ctxDto.listenerDTOs.length > 0) {
pw.println("Listeners");
for (final ListenerDTO ep : ctxDto.listenerDTOs) {
pw.print("Types : ");
pw.println(getValueAsString(ep.types));
final ServiceReference<?> ref = this.getServiceReference(ep.serviceId);
printServiceIdAndRanking(pw, ref, ep.serviceId);
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
pw.println();
}
if (dto.failedServletContextDTOs.length > 0) {
for (final FailedServletContextDTO ctxDto : dto.failedServletContextDTOs) {
pw.print("Failed Servlet Context ");
pw.println(ctxDto.name);
pw.println("-----------------------------------------------");
pw.print("Reason : ");
pw.println(getErrorText(ctxDto.failureReason));
pw.print("Path : ");
pw.println(getContextPath(ctxDto.contextPath));
printServiceIdAndRanking(pw, this.getServiceReference(ctxDto.serviceId), ctxDto.serviceId);
pw.println();
}
}
if (dto.failedServletDTOs.length > 0) {
pw.println("Failed Servlets");
for (final FailedServletDTO servlet : dto.failedServletDTOs) {
pw.print("Patterns : ");
pw.println(getValueAsString(servlet.patterns));
pw.print("Reason : ");
pw.println(getErrorText(servlet.failureReason));
pw.print("Name : ");
pw.println(servlet.name);
final ServiceReference<?> ref = this.getServiceReference(servlet.serviceId);
printServiceIdAndRanking(pw, ref, servlet.serviceId);
pw.print("async : ");
pw.println(String.valueOf(servlet.asyncSupported));
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (dto.failedFilterDTOs.length > 0) {
pw.println("Failed Filters");
for (final FailedFilterDTO filter : dto.failedFilterDTOs) {
final List<String> patterns = new ArrayList<>();
patterns.addAll(Arrays.asList(filter.patterns));
patterns.addAll(Arrays.asList(filter.regexs));
for (final String name : filter.servletNames) {
patterns.add("Servlet : " + name);
}
Collections.sort(patterns);
pw.print("Patterns : ");
pw.println(patterns);
pw.print("Reason : ");
pw.println(getErrorText(filter.failureReason));
pw.print("Name : ");
pw.println(filter.name);
final ServiceReference<?> ref = this.getServiceReference(filter.serviceId);
printServiceIdAndRanking(pw, ref, filter.serviceId);
pw.print("async : ");
pw.println(String.valueOf(filter.asyncSupported));
pw.print("dispatcher : ");
pw.println(getValueAsString(filter.dispatcher));
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (dto.failedResourceDTOs.length > 0) {
pw.println("Failed Resources");
for (final FailedResourceDTO rsrc : dto.failedResourceDTOs) {
pw.print("Patterns : ");
pw.println(getValueAsString(rsrc.patterns));
pw.print("Reason : ");
pw.println(getErrorText(rsrc.failureReason));
pw.print("Prefix : ");
pw.println(rsrc.prefix);
final ServiceReference<?> ref = this.getServiceReference(rsrc.serviceId);
printServiceIdAndRanking(pw, ref, rsrc.serviceId);
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (dto.failedErrorPageDTOs.length > 0) {
pw.println("Failed Error Pages");
for (final FailedErrorPageDTO ep : dto.failedErrorPageDTOs) {
final List<String> patterns = new ArrayList<>();
for (final long p : ep.errorCodes) {
patterns.add(String.valueOf(p));
}
for (final String p : ep.exceptions) {
patterns.add(p);
}
pw.print("Patterns : ");
pw.println(patterns);
pw.print("Reason : ");
pw.println(getErrorText(ep.failureReason));
pw.print("Name : ");
pw.println(ep.name);
final ServiceReference<?> ref = this.getServiceReference(ep.serviceId);
printServiceIdAndRanking(pw, ref, ep.serviceId);
pw.print("async : ");
pw.println(String.valueOf(ep.asyncSupported));
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
if (dto.failedListenerDTOs.length > 0) {
pw.println("Listeners");
for (final FailedListenerDTO ep : dto.failedListenerDTOs) {
pw.print("Types : ");
pw.println(getValueAsString(ep.types));
pw.print("Reason : ");
pw.println(getErrorText(ep.failureReason));
final ServiceReference<?> ref = this.getServiceReference(ep.serviceId);
printServiceIdAndRanking(pw, ref, ep.serviceId);
if (ref != null) {
pw.print("Bundle : ");
pw.print(ref.getBundle().getSymbolicName());
pw.print(" <");
pw.print(String.valueOf(ref.getBundle().getBundleId()));
pw.println(">");
}
pw.println();
}
pw.println();
}
pw.println();
}
use of org.osgi.service.http.runtime.dto.FailedListenerDTO in project felix by apache.
the class ListenerMap method getRuntimeInfo.
public void getRuntimeInfo(final List<ListenerDTO> listenerDTOs, final List<FailedListenerDTO> failedListenerDTOs) {
final int length = listenerDTOs.size();
final int failedLength = failedListenerDTOs.size();
final List<ListenerRegistrationStatus<T>> list = this.handlers;
for (final ListenerRegistrationStatus<T> status : list) {
// search for DTO with same service id and failureCode
if (status.getResult() == -1) {
int index = 0;
boolean found = false;
final Iterator<ListenerDTO> i = listenerDTOs.iterator();
while (!found && index < length) {
final ListenerDTO dto = i.next();
if (dto.serviceId == status.getHandler().getListenerInfo().getServiceId()) {
found = true;
}
index++;
}
if (!found) {
listenerDTOs.add(ListenerDTOBuilder.build(status.getHandler(), status.getResult()));
}
} else {
int index = 0;
boolean found = false;
final Iterator<FailedListenerDTO> i = failedListenerDTOs.iterator();
while (!found && index < failedLength) {
final FailedListenerDTO dto = i.next();
if (dto.serviceId == status.getHandler().getListenerInfo().getServiceId() && dto.failureReason == status.getResult()) {
found = true;
}
index++;
}
if (!found) {
failedListenerDTOs.add((FailedListenerDTO) ListenerDTOBuilder.build(status.getHandler(), status.getResult()));
}
}
}
}
use of org.osgi.service.http.runtime.dto.FailedListenerDTO 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.osgi.service.http.runtime.dto.FailedListenerDTO in project felix by apache.
the class ListenerDTOBuilder method build.
public static ListenerDTO build(final ListenerInfo info, final int reason) {
final ListenerDTO dto = (reason == -1 ? new ListenerDTO() : new FailedListenerDTO());
dto.serviceId = info.getServiceId();
dto.types = Arrays.copyOf(info.getListenerTypes(), info.getListenerTypes().length);
if (reason != -1) {
((FailedListenerDTO) dto).failureReason = reason;
}
return dto;
}
use of org.osgi.service.http.runtime.dto.FailedListenerDTO in project felix by apache.
the class RuntimeDTOBuilder method build.
public RuntimeDTO build() {
final RuntimeDTO runtimeDTO = new RuntimeDTO();
runtimeDTO.serviceDTO = createServiceDTO();
runtimeDTO.servletContextDTOs = createContextDTOs();
runtimeDTO.preprocessorDTOs = createPreprocessorDTOs();
runtimeDTO.failedErrorPageDTOs = registry.getFailedDTOHolder().failedErrorPageDTOs.toArray(new FailedErrorPageDTO[registry.getFailedDTOHolder().failedErrorPageDTOs.size()]);
runtimeDTO.failedFilterDTOs = registry.getFailedDTOHolder().failedFilterDTOs.toArray(new FailedFilterDTO[registry.getFailedDTOHolder().failedFilterDTOs.size()]);
runtimeDTO.failedListenerDTOs = registry.getFailedDTOHolder().failedListenerDTOs.toArray(new FailedListenerDTO[registry.getFailedDTOHolder().failedListenerDTOs.size()]);
runtimeDTO.failedResourceDTOs = registry.getFailedDTOHolder().failedResourceDTOs.toArray(new FailedResourceDTO[registry.getFailedDTOHolder().failedResourceDTOs.size()]);
runtimeDTO.failedServletContextDTOs = registry.getFailedDTOHolder().failedServletContextDTOs.toArray(new FailedServletContextDTO[registry.getFailedDTOHolder().failedServletContextDTOs.size()]);
runtimeDTO.failedServletDTOs = registry.getFailedDTOHolder().failedServletDTOs.toArray(new FailedServletDTO[registry.getFailedDTOHolder().failedServletDTOs.size()]);
runtimeDTO.failedPreprocessorDTOs = registry.getFailedDTOHolder().failedPreprocessorDTOs.toArray(new FailedPreprocessorDTO[registry.getFailedDTOHolder().failedPreprocessorDTOs.size()]);
return runtimeDTO;
}
Aggregations