![JAR search and dependency download from the Maven repository](/logo.png)
com.alibaba.dubbo.monitor.simple.pages.ProvidersPageHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dubbo2-monitor-simple Show documentation
Show all versions of dubbo2-monitor-simple Show documentation
The simple monitor module of dubbo project
The newest version!
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.monitor.simple.pages;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.utils.NetUtils;
import com.alibaba.dubbo.container.page.Page;
import com.alibaba.dubbo.container.page.PageHandler;
import com.alibaba.dubbo.monitor.simple.RegistryContainer;
/**
* ProvidersPageHandler
*
* @author william.liangf
*/
public class ProvidersPageHandler implements PageHandler {
public Page handle(URL url) {
String service = url.getParameter("service");
String host = url.getParameter("host");
String application = url.getParameter("application");
if (service != null && service.length() > 0) {
List> rows = new ArrayList>();
List providers = RegistryContainer.getInstance().getProvidersByService(service);
if (providers != null && providers.size() > 0) {
for (URL u : providers) {
List row = new ArrayList();
String s = u.toFullString();
row.add(s.replace("&", "&"));
row.add("");
rows.add(row);
}
}
return new Page("Services > " + service
+ " > Providers | Consumers | Statistics | Charts", "Providers (" + rows.size() + ")",
new String[] { "Provider URL:", "Unregister" }, rows);
} else if (host != null && host.length() > 0) {
List> rows = new ArrayList>();
List providers = RegistryContainer.getInstance().getProvidersByHost(host);
if (providers != null && providers.size() > 0) {
for (URL u : providers) {
List row = new ArrayList();
String s = u.toFullString();
row.add(s.replace("&", "&"));
row.add("");
rows.add(row);
}
}
return new Page("Hosts > " + NetUtils.getHostName(host) + "/" + host + " > Providers | Consumers", "Providers (" + rows.size() + ")",
new String[] { "Provider URL:", "Unregister" }, rows);
} else if (application != null && application.length() > 0) {
List> rows = new ArrayList>();
List providers = RegistryContainer.getInstance().getProvidersByApplication(application);
if (providers != null && providers.size() > 0) {
for (URL u : providers) {
List row = new ArrayList();
String s = u.toFullString();
row.add(s.replace("&", "&"));
row.add("");
rows.add(row);
}
}
return new Page("Applications > " + application + " > Providers | Consumers | Depends On | Used By", "Providers (" + rows.size() + ")",
new String[] { "Provider URL:", "Unregister" }, rows);
} else {
throw new IllegalArgumentException("Please input service or host or application parameter.");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy