use of org.glassfish.web.valve.GlassFishValve in project Payara by payara.
the class ValveBase method createObjectName.
public ObjectName createObjectName(String domain, ObjectName parent) throws MalformedObjectNameException {
Container container = this.getContainer();
if (container == null || !(container instanceof ContainerBase))
return null;
ContainerBase containerBase = (ContainerBase) container;
Pipeline pipe = containerBase.getPipeline();
GlassFishValve[] valves = pipe.getValves();
/* Compute the "parent name" part */
String parentName = "";
if (container instanceof Engine) {
} else if (container instanceof Host) {
parentName = ",host=" + container.getName();
} else if (container instanceof Context) {
String path = ((Context) container).getPath();
if (path.length() < 1) {
path = "/";
}
Host host = (Host) container.getParent();
parentName = ",path=" + path + ",host=" + host.getName();
} else if (container instanceof Wrapper) {
Context ctx = (Context) container.getParent();
String path = ctx.getPath();
if (path.length() < 1) {
path = "/";
}
Host host = (Host) ctx.getParent();
parentName = ",servlet=" + container.getName() + ",path=" + path + ",host=" + host.getName();
}
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "valve parent=" + parentName + " " + parent);
}
String className = this.getClass().getName();
int period = className.lastIndexOf('.');
if (period >= 0)
className = className.substring(period + 1);
int seq = 0;
for (int i = 0; i < valves.length; i++) {
// Find other valves with the same name
if (valves[i] == this) {
break;
}
if (valves[i] != null && valves[i].getClass() == this.getClass()) {
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Duplicate " + valves[i] + " " + this + " " + container);
}
seq++;
}
}
String ext = "";
if (seq > 0) {
ext = ",seq=" + seq;
}
ObjectName objectName = new ObjectName(domain + ":type=Valve,name=" + className + ext + parentName);
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "valve objectname = " + objectName);
}
return objectName;
}
Aggregations