use of com.sun.enterprise.config.modularity.ConfigModularityUtils in project Payara by payara.
the class TemplateRestResource method setParentAndTagName.
public void setParentAndTagName(Dom parent, String tagName) {
if (parent == null) {
// prevent https://glassfish.dev.java.net/issues/show_bug.cgi?id=14125
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
this.parent = parent;
this.tagName = tagName;
synchronized (parent) {
entity = parent.nodeElement(tagName);
}
if (entity == null) {
// In some cases, the tagName requested is not found in the DOM tree. This is true,
// for example, for the various ZeroConf elements (e.g., transaction-service). If
// the zero conf element is not in domain.xml, then it won't be in the Dom tree
// returned by HK2. If that's the case, we can use ConfigModularityUtils.getOwningObject()
// to find the ConfigBean matching the path requested, which will add the node to
// the Dom tree. Once that's done, we can return that node and proceed as normal
String location = buildPath(parent) + "/" + tagName;
if (location.startsWith("domain/configs")) {
final ConfigModularityUtils cmu = locatorBridge.getRemoteLocator().<ConfigModularityUtils>getService(ConfigModularityUtils.class);
ConfigBeanProxy cbp = cmu.getOwningObject(location);
if (cbp == null) {
cbp = cmu.getConfigBeanInstanceFor(cmu.getOwningClassForLocation(location));
}
if (cbp != null) {
entity = Dom.unwrap(cbp);
childModel = entity.model;
}
}
// throw new WebApplicationException(new Exception("Trying to create an entity using generic create"),Response.Status.INTERNAL_SERVER_ERROR);
} else {
childModel = entity.model;
}
}
Aggregations