Hi,

I need to get a web application deployed in carbon. Following is my
approach. Is there any other way that I can optimize the following code.

I have to iterate through 2 for loops. Do we have a way to get an
application by name without iterating the list?

ConfigurationContext configurationContext =
CarbonConfigurationContextFactory.getConfigurationContext();
WebApplicationsHolder defaultApplicationsHolder = ((Map<String,
WebApplicationsHolder>) configurationContext.
        
getProperty(CarbonConstants.WEB_APPLICATIONS_HOLDER_LIST)).get("webapps");
if (defaultApplicationsHolder != null &&
!defaultApplicationsHolder.getStartedWebapps().isEmpty()) {
    defaultApplicationsHolder.getStartedWebapps().forEach((appName,
webApplication) -> {
>
>         if (appName.contains("test-app-wso2")) {

            StandardHost applicationHost = (StandardHost)
webApplication.getContext().getParent();
            StandardEngine applicationEngine = (StandardEngine)
applicationHost.getParent();
            for (Connector connector :
applicationEngine.getService().findConnectors()) {
               String certWebAppPath = connector.getScheme() + "://" +
                        applicationHost.getName() + ":" +
connector.getPort() + webApplication.getContext().getEncodedPath();

            }
        }
    });
}



-- 
*Thanks and Regards,*
Anuruddha Lanka Liyanarachchi
Software Engineer - WSO2
Mobile : +94 (0) 712762611
Tel      : +94 112 145 345
a <[email protected]>[email protected]
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to