use of org.eclipse.scout.rt.server.admin.inspector.ServiceInspector in project scout.rt by eclipse.
the class ServicesView method renderServiceTables.
private void renderServiceTables(HtmlComponent p) {
// categorize services
TreeMap<CompositeObject, Collection<ServiceInspector>> servicesMap = new TreeMap<CompositeObject, Collection<ServiceInspector>>();
if (m_serviceInspectors != null) {
for (ServiceInspector inspector : m_serviceInspectors) {
String serviceName = inspector.getService().getClass().getSimpleName();
String sectionName = null;
int sectionOrder;
try {
if (serviceName.matches(".*ProcessService")) {
sectionOrder = 1;
sectionName = "Process Services";
} else if (serviceName.matches(".*OutlineService")) {
sectionOrder = 2;
sectionName = "Outline Services";
} else if (serviceName.matches(".*LookupService")) {
sectionOrder = 3;
sectionName = "Lookup Services";
} else {
List<Class<?>> serviceInterfaces = BeanUtility.getInterfacesHierarchy(inspector.getService().getClass(), Object.class);
Class topInterface = (serviceInterfaces.size() > 0 ? serviceInterfaces.get(serviceInterfaces.size() - 1) : null);
if (topInterface != null && topInterface.getPackage() != null && topInterface.getPackage().getName().indexOf(".common.") >= 0) {
sectionOrder = 4;
sectionName = "Common Services";
} else {
sectionOrder = 5;
sectionName = "Other Services";
}
}
CompositeObject key = new CompositeObject(sectionOrder, sectionName);
Collection<ServiceInspector> list = servicesMap.get(key);
if (list == null) {
list = new ArrayList<ServiceInspector>();
servicesMap.put(key, list);
}
list.add(inspector);
} catch (RuntimeException e) {
LOG.warn("Failed inspecting service {}", inspector.getService().getClass(), e);
}
}
}
// tables per section
for (Map.Entry<CompositeObject, Collection<ServiceInspector>> e : servicesMap.entrySet()) {
String sectionName = (String) e.getKey().getComponent(1);
Collection<ServiceInspector> list = e.getValue();
renderServiceTable(p, sectionName, list);
p.p();
}
}
use of org.eclipse.scout.rt.server.admin.inspector.ServiceInspector in project scout.rt by eclipse.
the class ServicesView method renderServiceTable.
private void renderServiceTable(HtmlComponent p, String sectionName, Collection<ServiceInspector> serviceInspectors) {
// sort
TreeMap<String, ServiceInspector> sortMap = new TreeMap<String, ServiceInspector>();
for (ServiceInspector inspector : serviceInspectors) {
String s = inspector.getService().getClass().getName();
sortMap.put(s, inspector);
}
p.p(sectionName);
p.startListBox("listBox", 1, true);
p.listBoxOption(" ", new AbstractHtmlAction("selectService.choose") {
@Override
public void run() {
// do nothing
}
}, false);
for (ServiceInspector serviceInspector : sortMap.values()) {
boolean selected = m_selectedService != null && (m_selectedService.getService() == serviceInspector.getService());
final ServiceInspector finalServiceInspector = serviceInspector;
p.listBoxOption(serviceInspector.getService().getClass().getName(), new AbstractHtmlAction("selectService2." + serviceInspector.getService().getClass().getName()) {
@Override
public void run() {
m_selectedService = finalServiceInspector;
}
}, selected);
}
p.endListBox();
}
use of org.eclipse.scout.rt.server.admin.inspector.ServiceInspector in project scout.rt by eclipse.
the class ServicesView method activated.
@Override
public void activated() {
// read all services
m_serviceInspectors = null;
try {
ArrayList<ServiceInspector> list = new ArrayList<ServiceInspector>();
for (IService service : BEANS.all(IService.class)) {
list.add(new ServiceInspector(service));
}
m_serviceInspectors = list.toArray(new ServiceInspector[list.size()]);
} catch (Exception e) {
// NOSONAR
// nop
}
}
Aggregations