Hi Anuruddha,
Can you try out the below code segment?
Map<String, WebApplicationsHolder> webApplicationsHolderMap =
WebAppUtils.getAllWebappHolders(getConfigContext());
for (WebApplicationsHolder webApplicationsHolder :
webApplicationsHolderMap.values()) {
WebApplication webApplication =
webApplicationsHolder.getStartedWebapps().get(webappFileName);
[1] -
https://github.com/wso2/carbon-deployment/blob/4.7.x/components/webapp-mgt/org.wso2.carbon.webapp.mgt/src/main/java/org/wso2/carbon/webapp/mgt/WebappAdmin.java#L149
On Thu, Jun 29, 2017 at 7:14 PM, Anuruddha Liyanarachchi <
[email protected]> wrote:
> 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]
>
--
Thusitha Dayaratne
WSO2 Inc. - lean . enterprise . middleware | wso2.com
Mobile +94712756809
Blog alokayasoya.blogspot.com
About http://about.me/thusithathilina
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev