use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class SecureAdminConfigUpgrade method ensureConfigReady.
// private void prepareNonDASConfigs() throws TransactionFailure, PropertyVetoException {
// for (Config c : configs.getConfig()) {
// if (c.getName().equals(DAS_CONFIG_NAME)) {
// continue;
// }
// ensureConfigReady(c, SecureAdminCommand.PORT_UNIF_PROTOCOL_NAME);
// }
// }
private void ensureConfigReady(final Config c, final String adminListenerProtocol) throws TransactionFailure, PropertyVetoException {
final NetworkConfig nc = c.getNetworkConfig();
final NetworkListener nl = nc.getNetworkListener(SecureAdminCommand.ADMIN_LISTENER_NAME);
if (nl != null) {
return;
}
/*
* Create an admin-listener for this configuration.
*/
final Config config_w = writableConfig(c);
createAdminNetworkListener(transaction(), nc, adminListenerProtocol);
createAdminVirtualServer(transaction(), config_w);
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class SecureAdminUpgradeHelper method ensureConfigReady.
private boolean ensureConfigReady(final Config c) throws TransactionFailure {
/*
* See if this config is already set up for secure admin.
*/
final NetworkConfig nc = c.getNetworkConfig();
if (nc == null) {
/*
* If there is no network config for this configuration then it is
* probably a test configuration of some sort. In any case, there
* is no lower-level network protocols to verify so declare this
* config to be OK.
*/
return true;
}
Protocol secAdminProtocol = nc.getProtocols().findProtocol(SecureAdminCommand.SEC_ADMIN_LISTENER_PROTOCOL_NAME);
if (secAdminProtocol != null) {
return true;
}
final EnableSecureAdminCommand enableCmd = new EnableSecureAdminCommand();
final Config c_w = transaction().enroll(c);
ConfigLevelContext configLevelContext = new ConfigLevelContext(topLevelContext(), c_w);
for (Iterator<Work<ConfigLevelContext>> it = enableCmd.perConfigSteps(); it.hasNext(); ) {
final Work<ConfigLevelContext> step = it.next();
if (!step.run(configLevelContext)) {
rollback();
return false;
}
}
return true;
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class CLIUtil method chooseConfig.
/**
* Selects a config of interest from the domain, based on the target.
* (Eliminates duplicated code formerly in Create, Delete, and ListAuthRealm).
*
* @param domain
* @param target
* @return
*/
static Config chooseConfig(final Domain domain, final String target) {
Config config = null;
Config tmp = null;
try {
tmp = domain.getConfigs().getConfigByName(target);
} catch (Exception ex) {
}
if (tmp != null) {
return tmp;
}
Server targetServer = domain.getServerNamed(target);
if (targetServer != null) {
config = domain.getConfigNamed(targetServer.getConfigRef());
}
com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
config = domain.getConfigNamed(cluster.getConfigRef());
}
return config;
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class UpdateResourceRef method execute.
/**
* Execution method for updating the configuration of a ResourceRef. Will be
* replicated if the target is a cluster.
*
* @param context context for the command.
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
final Logger logger = context.getLogger();
// Make a list of all ResourceRefs that need to change
List<ResourceRef> resourceRefsToChange = new ArrayList<>();
// Add the ResourceRef from a named server if the target is a server
Server server = domain.getServerNamed(target);
// if the target is a server
if (server != null) {
ResourceRef serverResourceRef = server.getResourceRef(name);
// if the ResourceRef doesn't exist
if (serverResourceRef == null) {
report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
return;
}
resourceRefsToChange.add(serverResourceRef);
}
// Add the ResourceRef from a named config if the target is a config
Config config = domain.getConfigNamed(target);
// if the target is a config
if (config != null) {
ResourceRef configResourceRef = config.getResourceRef(name);
// if the ResourceRef doesn't exist
if (configResourceRef == null) {
report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
return;
}
resourceRefsToChange.add(configResourceRef);
}
// Add the ResourceRefs from a named cluster if the target is a cluster
Cluster cluster = domain.getClusterNamed(target);
// if the target is a cluster
if (cluster != null) {
ResourceRef clusterResourceRef = cluster.getResourceRef(name);
// if the ResourceRef doesn't exist
if (clusterResourceRef == null) {
report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
return;
}
resourceRefsToChange.add(clusterResourceRef);
for (Server instance : cluster.getInstances()) {
ResourceRef instanceResourceRef = instance.getResourceRef(name);
// if the server in the cluster contains the ResourceRef
if (instanceResourceRef != null) {
resourceRefsToChange.add(instanceResourceRef);
}
}
}
// Add the ResourceRefs from a named Deployment Group if the target is a Deployment Group
DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
if (dg != null) {
ResourceRef ref = dg.getResourceRef(name);
if (ref == null) {
report.failure(logger, LOCAL_STRINGS.getLocalString("resource.ref.not.exists", "Target {1} does not have a reference to resource {0}.", name, target));
return;
}
resourceRefsToChange.add(ref);
for (Server instance : dg.getInstances()) {
ResourceRef instanceResourceRef = instance.getResourceRef(name);
// if the server in the dg contains the ResourceRef
if (instanceResourceRef != null) {
resourceRefsToChange.add(instanceResourceRef);
}
}
}
// Apply the configuration to the listed ResourceRefs
try {
ConfigSupport.apply(new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... params) throws PropertyVetoException, TransactionFailure {
for (ConfigBeanProxy proxy : params) {
if (proxy instanceof ResourceRef) {
ResourceRef resourceRefProxy = (ResourceRef) proxy;
if (enabled != null) {
resourceRefProxy.setEnabled(enabled.toString());
}
}
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return true;
}
}, resourceRefsToChange.toArray(new ResourceRef[] {}));
} catch (TransactionFailure ex) {
report.failure(logger, ex.getLocalizedMessage());
}
}
use of com.sun.enterprise.config.serverbeans.Config in project Payara by payara.
the class ClusterCommandHelper method getAdminThreadPoolSize.
/**
* Get the size of the admin threadpool
*/
private int getAdminThreadPoolSize(Logger logger) {
final int DEFAULT_POOL_SIZE = 5;
// Get the DAS configuratoin
Config config = domain.getConfigNamed("server-config");
if (config == null)
return DEFAULT_POOL_SIZE;
AdminEndpointDecider aed = new AdminEndpointDecider(config);
return aed.getMaxThreadPoolSize();
}
Aggregations