Search in sources :

Example 1 with ApplicationResource

use of psiprobe.model.ApplicationResource in project psi-probe by psi-probe.

the class ListAllJdbcResourceGroupsController method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<DataSourceInfoGroup> dataSourceGroups = new ArrayList<>();
    List<DataSourceInfo> dataSources = new ArrayList<>();
    List<ApplicationResource> privateResources = getContainerWrapper().getPrivateDataSources();
    List<ApplicationResource> globalResources = getContainerWrapper().getGlobalDataSources();
    // filter out anything that is not a datasource
    // and use only those datasources that are properly configured
    // as aggregated totals would not make any sense otherwise
    filterValidDataSources(privateResources, dataSources);
    filterValidDataSources(globalResources, dataSources);
    // sort datasources by JDBC URL
    Collections.sort(dataSources, new Comparator<DataSourceInfo>() {

        @Override
        public int compare(DataSourceInfo ds1, DataSourceInfo ds2) {
            String jdbcUrl1 = ds1.getJdbcUrl();
            String jdbcUrl2 = ds2.getJdbcUrl();
            return jdbcUrl1.compareToIgnoreCase(jdbcUrl2);
        }
    });
    // group datasources by JDBC URL and calculate aggregated totals
    DataSourceInfoGroup dsGroup = null;
    for (DataSourceInfo ds : dataSources) {
        if (dsGroup == null || !dsGroup.getJdbcUrl().equalsIgnoreCase(ds.getJdbcUrl())) {
            dsGroup = new DataSourceInfoGroup().builder(ds);
            dataSourceGroups.add(dsGroup);
        } else {
            dsGroup.addDataSourceInfo(ds);
        }
    }
    return new ModelAndView(getViewName(), "dataSourceGroups", dataSourceGroups);
}
Also used : DataSourceInfo(psiprobe.model.DataSourceInfo) ApplicationResource(psiprobe.model.ApplicationResource) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) DataSourceInfoGroup(psiprobe.model.DataSourceInfoGroup)

Example 2 with ApplicationResource

use of psiprobe.model.ApplicationResource in project psi-probe by psi-probe.

the class ListAllJdbcResourcesController method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception {
    boolean supportsGlobal = getContainerWrapper().getResourceResolver().supportsGlobalResources();
    boolean supportsPrivate = getContainerWrapper().getResourceResolver().supportsPrivateResources();
    boolean supportsDataSourceLookup = getContainerWrapper().getResourceResolver().supportsDataSourceLookup();
    List<ApplicationResource> privateResources = getContainerWrapper().getPrivateDataSources();
    List<ApplicationResource> globalResources = getContainerWrapper().getGlobalDataSources();
    return new ModelAndView(getViewName()).addObject("supportsGlobal", supportsGlobal).addObject("supportsPrivate", supportsPrivate).addObject("supportsDSLookup", supportsDataSourceLookup).addObject("privateResources", privateResources).addObject("globalResources", globalResources);
}
Also used : ApplicationResource(psiprobe.model.ApplicationResource) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 3 with ApplicationResource

use of psiprobe.model.ApplicationResource in project psi-probe by psi-probe.

the class Tomcat85ContainerAdapter method addContextResource.

@Override
public void addContextResource(Context context, List<ApplicationResource> resourceList, boolean contextBound) {
    NamingResourcesImpl namingResources = context.getNamingResources();
    for (ContextResource contextResource : namingResources.findResources()) {
        ApplicationResource resource = new ApplicationResource();
        logger.info("reading resource: {}", contextResource.getName());
        resource.setApplicationName(context.getName());
        resource.setName(contextResource.getName());
        resource.setType(contextResource.getType());
        resource.setScope(contextResource.getScope());
        resource.setAuth(contextResource.getAuth());
        resource.setDescription(contextResource.getDescription());
        resourceList.add(resource);
    }
}
Also used : ApplicationResource(psiprobe.model.ApplicationResource) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl) ContextResource(org.apache.tomcat.util.descriptor.web.ContextResource)

Example 4 with ApplicationResource

use of psiprobe.model.ApplicationResource in project psi-probe by psi-probe.

the class Tomcat85ContainerAdapter method addContextResourceLink.

@Override
public void addContextResourceLink(Context context, List<ApplicationResource> resourceList, boolean contextBound) {
    NamingResourcesImpl namingResources = context.getNamingResources();
    for (ContextResourceLink link : namingResources.findResourceLinks()) {
        ApplicationResource resource = new ApplicationResource();
        logger.debug("reading resourceLink: {}", link.getName());
        resource.setApplicationName(context.getName());
        resource.setName(link.getName());
        resource.setType(link.getType());
        resource.setLinkTo(link.getGlobal());
        registerGlobalResourceAccess(link);
        resourceList.add(resource);
    }
}
Also used : ContextResourceLink(org.apache.tomcat.util.descriptor.web.ContextResourceLink) ApplicationResource(psiprobe.model.ApplicationResource) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl)

Example 5 with ApplicationResource

use of psiprobe.model.ApplicationResource in project psi-probe by psi-probe.

the class Tomcat10ContainerAdapter method addContextResource.

@Override
public void addContextResource(Context context, List<ApplicationResource> resourceList, boolean contextBound) {
    NamingResourcesImpl namingResources = context.getNamingResources();
    for (ContextResource contextResource : namingResources.findResources()) {
        ApplicationResource resource = new ApplicationResource();
        logger.info("reading resource: {}", contextResource.getName());
        resource.setApplicationName(context.getName());
        resource.setName(contextResource.getName());
        resource.setType(contextResource.getType());
        resource.setScope(contextResource.getScope());
        resource.setAuth(contextResource.getAuth());
        resource.setDescription(contextResource.getDescription());
        resourceList.add(resource);
    }
}
Also used : ApplicationResource(psiprobe.model.ApplicationResource) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl) ContextResource(org.apache.tomcat.util.descriptor.web.ContextResource)

Aggregations

ApplicationResource (psiprobe.model.ApplicationResource)17 ArrayList (java.util.ArrayList)6 NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)6 NamingException (javax.naming.NamingException)4 DataSourceInfo (psiprobe.model.DataSourceInfo)4 ContextResource (org.apache.tomcat.util.descriptor.web.ContextResource)3 ContextResourceLink (org.apache.tomcat.util.descriptor.web.ContextResourceLink)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 MBeanServer (javax.management.MBeanServer)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 ObjectName (javax.management.ObjectName)2 Context (org.apache.catalina.Context)2 NamingResources (org.apache.catalina.deploy.NamingResources)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 AttributeNotFoundException (javax.management.AttributeNotFoundException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MBeanException (javax.management.MBeanException)1