use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class ExternalJndiResourceDeployer method toExternalJndiJavaEEResource.
/**
* Returns a new instance of j2ee external jndi resource from the given
* config bean.
* <p/>
* This method gets called from the external resource
* deployer to convert external-jndi-resource config bean into
* external-jndi j2ee resource.
*
* @param rbean external-jndi-resource config bean
* @param resourceInfo
* @return a new instance of j2ee external jndi resource
*/
public static org.glassfish.resources.api.JavaEEResource toExternalJndiJavaEEResource(ExternalJndiResource rbean, ResourceInfo resourceInfo) {
org.glassfish.resources.beans.ExternalJndiResource jr = new org.glassfish.resources.beans.ExternalJndiResource(resourceInfo);
// jr.setDescription( rbean.getDescription() ); // FIXME: getting error
// sets the enable flag
jr.setEnabled(Boolean.valueOf(rbean.getEnabled()));
// sets the jndi look up name
jr.setJndiLookupName(rbean.getJndiLookupName());
// sets the resource type
jr.setResType(rbean.getResType());
// sets the factory class name
jr.setFactoryClass(rbean.getFactoryClass());
// sets the properties
List<Property> properties = rbean.getProperty();
if (properties != null) {
for (Property property : properties) {
ResourceProperty rp = new ResourcePropertyImpl(property.getName(), property.getValue());
jr.addProperty(rp);
}
}
return jr;
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class CustomResourceDeployer method toCustomJavaEEResource.
/**
* Returns a new instance of j2ee custom resource from the given
* config bean.
* <p/>
* This method gets called from the custom resource deployer
* to convert custom-resource config bean into custom j2ee resource.
*
* @param rbean custom-resource config bean
* @param resourceInfo the definition of the resources to create
* @return new instance of j2ee custom resource
*/
public static JavaEEResource toCustomJavaEEResource(CustomResource rbean, ResourceInfo resourceInfo) {
org.glassfish.resources.beans.CustomResource jr = new org.glassfish.resources.beans.CustomResource(resourceInfo);
// jr.setDescription(rbean.getDescription()); // FIXME: getting error
// sets the enable flag
jr.setEnabled(Boolean.valueOf(rbean.getEnabled()));
// sets the resource type
jr.setResType(rbean.getResType());
// sets the factory class name
jr.setFactoryClass(rbean.getFactoryClass());
// sets the properties
List<Property> properties = rbean.getProperty();
if (properties != null) {
for (Property property : properties) {
ResourceProperty rp = new ResourcePropertyImpl(property.getName(), property.getValue());
jr.addProperty(rp);
}
}
return jr;
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class SetHealthCheckServiceConfiguration method execute.
@Override
public void execute(AdminCommandContext context) {
report = context.getActionReport();
if (report.getExtraProperties() == null) {
report.setExtraProperties(new Properties());
}
targetConfig = targetUtil.getConfig(target);
serviceType = parseServiceType(serviceName);
if (serviceType == null) {
String values = Arrays.asList(CheckerType.values()).stream().map(type -> type.name().toLowerCase().replace('_', '-')).collect(Collectors.joining(", "));
report.setMessage("No such service: " + serviceName + ".\nChoose one of: " + values + ".\nThe name can also be given in short form consisting only of the first letters of each word.");
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// update the service to unify the way it is printed later on
serviceName = serviceType.name().toLowerCase().replace('_', '-');
BaseHealthCheck<?, ?> service = getService();
if (service == null) {
report.appendMessage(strings.getLocalString("healthcheck.service.configure.status.error", "Service with name {0} could not be found.", serviceName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
updateServiceConfiguration(service);
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class CreateSecurityService method execute.
/**
* Execute the create-security-service admin command.
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
// Setup the service type and configuration handler
if (AUTHENTICATION.equalsIgnoreCase(serviceType)) {
clazzServiceType = AuthenticationService.class;
serviceConfigHandler = new AuthenticationConfigHandler();
} else {
report.setMessage("Invalid security service type specified: " + serviceType);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// Add service configuration to the security configurations
// TODO - Add validation logic required for base service configuration
SecurityConfiguration config = null;
try {
config = (SecurityConfiguration) ConfigSupport.apply(new SingleConfigCode<SecurityConfigurations>() {
@Override
public Object run(SecurityConfigurations param) throws PropertyVetoException, TransactionFailure {
SecurityConfiguration svcConfig = param.createChild(clazzServiceType);
svcConfig.setName(serviceName);
svcConfig.setDefault(enableDefault.toString());
param.getSecurityServices().add(svcConfig);
return svcConfig;
}
}, secConfigs);
} catch (TransactionFailure transactionFailure) {
report.setMessage("Unable to create security service: " + transactionFailure.getMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(transactionFailure);
return;
}
// TODO - Add validation logic required for specific service configuration
if ((config != null) && (configuration != null) && (!configuration.isEmpty())) {
serviceConfigHandler.setupConfiguration(report, config);
}
}
use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.
the class TemplateRestResource method buildPath.
/**
* This method will build the path string as needed by ConfigModularityUtils.getOwningObject().
* There is a mismatch between what the method expects and the way the REST URIs are constructed.
* For example, for the transaction-service element, the REST URI, stripped of the HTTP and
* server context information, looks like this:
* /domain/configs/config/server-config/transaction-service. The format expected by the
* getOwningObject(), however, looks like this:
* domain/configs/server-config/transaction-service. In the REST URIs, if there is a collection of
* Named items, the type of the collection is inserted into the URI ("config" here) followed by
* the name of the particular instance ("server-config"). In building the path, we must identify
* Named instances and insert the name of the instance rather than the type. We apply this logic
* as we recurse up to the top of the Dom tree to finish building the path desired.
* @param node
* @return
*/
private String buildPath(Dom node) {
final Dom parentNode = node.parent();
String part = node.model.getTagName();
String name = node.attribute("name");
if (name != null) {
part = name;
}
return (parentNode != null) ? (buildPath(parentNode) + "/" + part) : part;
}
Aggregations