use of org.jvnet.hk2.config.ConfigModel in project Payara by payara.
the class DefaultConfigParser method parseContainerConfig.
@Override
public <T extends Container> T parseContainerConfig(ServiceLocator habitat, final URL configuration, Class<T> configType) throws IOException {
// I don't use the GlassFish document here as I don't need persistence
final DomDocument doc = new DomDocument<GlassFishConfigBean>(habitat) {
@Override
public Dom make(final ServiceLocator habitat, XMLStreamReader xmlStreamReader, GlassFishConfigBean dom, ConfigModel configModel) {
// by default, people get the translated view.
return new GlassFishConfigBean(habitat, this, dom, configModel, xmlStreamReader);
}
};
// add the new container configuration to the server config
final T container = doc.getRoot().createProxy(configType);
try {
ConfigSupport.apply(new SingleConfigCode<Config>() {
@Override
public Object run(Config config) throws PropertyVetoException, TransactionFailure {
config.getContainers().add(container);
return null;
}
}, config);
} catch (TransactionFailure e) {
logger.log(Level.SEVERE, KernelLoggerInfo.exceptionAddContainer, e);
}
return container;
}
use of org.jvnet.hk2.config.ConfigModel in project Payara by payara.
the class ResourcesGeneratorBase method processNonLeafChildElement.
private void processNonLeafChildElement(String elementName, ConfigModel.Property childElement, DomDocument domDocument, ClassWriter classWriter) {
ConfigModel.Node node = (ConfigModel.Node) childElement;
ConfigModel childModel = node.getModel();
String beanName = ResourceUtil.getUnqualifiedTypeName(childModel.targetTypeName);
if (beanName.equals("Property")) {
classWriter.createGetChildResource("property", "PropertiesBagResource");
} else if (beanName.equals("MonitoredAttribute")) {
classWriter.createGetChildResource("monitored-attribute", "MonitoredAttributeBagResource");
} else {
String childResourceClassName = getClassName(beanName);
if (childElement.isCollection()) {
childResourceClassName = "List" + childResourceClassName;
}
classWriter.createGetChildResource(/*
* childModel.getTagName()
*/
elementName, childResourceClassName);
}
if (childElement.isCollection()) {
generateList(childModel, domDocument);
} else {
generateSingle(childModel, domDocument);
}
}
use of org.jvnet.hk2.config.ConfigModel in project Payara by payara.
the class ClientGenerator method generateClasses.
public void generateClasses() {
Domain entity = getBaseServiceLocator().getService(Domain.class);
Dom dom = Dom.unwrap(entity);
document = dom.document;
ConfigModel rootModel = dom.document.getRoot().model;
alreadyGenerated.clear();
generateSingle(rootModel);
}
use of org.jvnet.hk2.config.ConfigModel in project Payara by payara.
the class ClientGenerator method processNonLeafChildElement.
private void processNonLeafChildElement(ClientClassWriter writer, String elementName, ConfigModel.Property childElement) {
ConfigModel.Node node = (ConfigModel.Node) childElement;
ConfigModel childModel = node.getModel();
String beanName = ResourceUtil.getUnqualifiedTypeName(childModel.targetTypeName);
writer.createGetChildResource(childModel, Util.upperCaseFirstLetter(Util.eleminateHypen(elementName)), beanName);
if (childElement.isCollection()) {
generateList(writer, childModel);
} else {
generateSingle(childModel);
}
}
Aggregations