use of org.apache.catalina.util.ContextName in project tomcat by apache.
the class MBeanUtils method createObjectName.
/**
* Create an <code>ObjectName</code> for this
* <code>Loader</code> object.
*
* @param domain Domain in which this name is to be created
* @param loader The Loader to be named
* @return a new object name
* @exception MalformedObjectNameException if a name cannot be created
*/
static ObjectName createObjectName(String domain, Loader loader) throws MalformedObjectNameException {
ObjectName name = null;
Context context = loader.getContext();
ContextName cn = new ContextName(context.getName(), false);
Container host = context.getParent();
name = new ObjectName(domain + ":type=Loader,host=" + host.getName() + ",context=" + cn.getDisplayName());
return name;
}
use of org.apache.catalina.util.ContextName in project tomcat by apache.
the class MBeanUtils method createObjectName.
/**
* Create an <code>ObjectName</code> for this
* <code>Service</code> object.
*
* @param domain Domain in which this name is to be created
* @param environment The ContextEnvironment to be named
* @return a new object name
* @exception MalformedObjectNameException if a name cannot be created
*/
public static ObjectName createObjectName(String domain, ContextEnvironment environment) throws MalformedObjectNameException {
ObjectName name = null;
Object container = environment.getNamingResources().getContainer();
if (container instanceof Server) {
name = new ObjectName(domain + ":type=Environment" + ",resourcetype=Global,name=" + environment.getName());
} else if (container instanceof Context) {
Context context = ((Context) container);
ContextName cn = new ContextName(context.getName(), false);
Container host = context.getParent();
name = new ObjectName(domain + ":type=Environment" + ",resourcetype=Context,host=" + host.getName() + ",context=" + cn.getDisplayName() + ",name=" + environment.getName());
}
return (name);
}
use of org.apache.catalina.util.ContextName in project tomcat by apache.
the class HTMLManagerServlet method doPost.
/**
* Process a POST request for the specified resource.
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet-specified error occurs
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
StringManager smClient = StringManager.getManager(Constants.Package, request.getLocales());
// Identify the request parameters that we need
// By obtaining the command from the pathInfo, per-command security can
// be configured in web.xml
String command = request.getPathInfo();
String path = request.getParameter("path");
ContextName cn = null;
if (path != null) {
cn = new ContextName(path, request.getParameter("version"));
}
String deployPath = request.getParameter("deployPath");
ContextName deployCn = null;
if (deployPath != null) {
deployCn = new ContextName(deployPath, request.getParameter("deployVersion"));
}
String deployConfig = request.getParameter("deployConfig");
String deployWar = request.getParameter("deployWar");
// Prepare our output writer to generate the response message
response.setContentType("text/html; charset=" + Constants.CHARSET);
String message = "";
if (command == null || command.length() == 0) {
// No command == list
// List always displayed -> do nothing
} else if (command.equals("/upload")) {
message = upload(request, smClient);
} else if (command.equals("/deploy")) {
message = deployInternal(deployConfig, deployCn, deployWar, smClient);
} else if (command.equals("/reload")) {
message = reload(cn, smClient);
} else if (command.equals("/undeploy")) {
message = undeploy(cn, smClient);
} else if (command.equals("/expire")) {
message = expireSessions(cn, request, smClient);
} else if (command.equals("/start")) {
message = start(cn, smClient);
} else if (command.equals("/stop")) {
message = stop(cn, smClient);
} else if (command.equals("/findleaks")) {
message = findleaks(smClient);
} else {
// Try GET
doGet(request, response);
return;
}
list(request, response, message, smClient);
}
use of org.apache.catalina.util.ContextName in project tomcat by apache.
the class ManagerServlet method doGet.
/**
* Process a GET request for the specified resource.
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet-specified error occurs
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
StringManager smClient = StringManager.getManager(Constants.Package, request.getLocales());
// Identify the request parameters that we need
String command = request.getPathInfo();
if (command == null)
command = request.getServletPath();
String config = request.getParameter("config");
String path = request.getParameter("path");
ContextName cn = null;
if (path != null) {
cn = new ContextName(path, request.getParameter("version"));
}
String type = request.getParameter("type");
String war = request.getParameter("war");
String tag = request.getParameter("tag");
boolean update = false;
if ((request.getParameter("update") != null) && (request.getParameter("update").equals("true"))) {
update = true;
}
boolean statusLine = false;
if ("true".equals(request.getParameter("statusLine"))) {
statusLine = true;
}
// Prepare our output writer to generate the response message
response.setContentType("text/plain; charset=" + Constants.CHARSET);
PrintWriter writer = response.getWriter();
// Process the requested command
if (command == null) {
writer.println(smClient.getString("managerServlet.noCommand"));
} else if (command.equals("/deploy")) {
if (war != null || config != null) {
deploy(writer, config, cn, war, update, smClient);
} else if (tag != null) {
deploy(writer, cn, tag, smClient);
} else {
writer.println(smClient.getString("managerServlet.invalidCommand", command));
}
} else if (command.equals("/list")) {
list(writer, smClient);
} else if (command.equals("/reload")) {
reload(writer, cn, smClient);
} else if (command.equals("/resources")) {
resources(writer, type, smClient);
} else if (command.equals("/save")) {
save(writer, path, smClient);
} else if (command.equals("/serverinfo")) {
serverinfo(writer, smClient);
} else if (command.equals("/sessions")) {
expireSessions(writer, cn, request, smClient);
} else if (command.equals("/expire")) {
expireSessions(writer, cn, request, smClient);
} else if (command.equals("/start")) {
start(writer, cn, smClient);
} else if (command.equals("/stop")) {
stop(writer, cn, smClient);
} else if (command.equals("/undeploy")) {
undeploy(writer, cn, smClient);
} else if (command.equals("/findleaks")) {
findleaks(statusLine, writer, smClient);
} else if (command.equals("/vminfo")) {
vmInfo(writer, smClient, request.getLocales());
} else if (command.equals("/threaddump")) {
threadDump(writer, smClient, request.getLocales());
} else if (command.equals("/sslConnectorCiphers")) {
sslConnectorCiphers(writer, smClient);
} else {
writer.println(smClient.getString("managerServlet.unknownCommand", command));
}
// Finish up the response
writer.flush();
writer.close();
}
use of org.apache.catalina.util.ContextName in project tomcat by apache.
the class HTMLManagerServlet method doGet.
// --------------------------------------------------------- Public Methods
/**
* Process a GET request for the specified resource.
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet-specified error occurs
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
StringManager smClient = StringManager.getManager(Constants.Package, request.getLocales());
// Identify the request parameters that we need
// By obtaining the command from the pathInfo, per-command security can
// be configured in web.xml
String command = request.getPathInfo();
String path = request.getParameter("path");
ContextName cn = null;
if (path != null) {
cn = new ContextName(path, request.getParameter("version"));
}
// Prepare our output writer to generate the response message
response.setContentType("text/html; charset=" + Constants.CHARSET);
String message = "";
// Process the requested command
if (command == null || command.equals("/")) {
// No command == list
} else if (command.equals("/list")) {
// List always displayed - nothing to do here
} else if (command.equals("/sessions")) {
try {
doSessions(cn, request, response, smClient);
return;
} catch (Exception e) {
log("HTMLManagerServlet.sessions[" + cn + "]", e);
message = smClient.getString("managerServlet.exception", e.toString());
}
} else if (command.equals("/sslConnectorCiphers")) {
sslConnectorCiphers(request, response);
} else if (command.equals("/upload") || command.equals("/deploy") || command.equals("/reload") || command.equals("/undeploy") || command.equals("/expire") || command.equals("/start") || command.equals("/stop")) {
message = smClient.getString("managerServlet.postCommand", command);
} else {
message = smClient.getString("managerServlet.unknownCommand", command);
}
list(request, response, message, smClient);
}
Aggregations