use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class ResourcesDeployer method deployResourcesFromConfiguration.
public void deployResourcesFromConfiguration(String appName, boolean embedded) throws Exception {
Application application = applications.getApplication(appName);
ApplicationInfo appInfo = appRegistry.get(appName);
if (application != null && appInfo != null) {
Resources appScopedResources = application.getResources();
if (appScopedResources != null) {
deployResources(appName, null, appScopedResources.getResources(), embedded);
}
List<Module> modules = application.getModule();
if (modules != null) {
for (Module module : modules) {
Resources moduleScopedResources = module.getResources();
String moduleName = module.getName();
if (moduleScopedResources != null) {
deployResources(appName, moduleName, moduleScopedResources.getResources(), embedded);
}
}
}
}
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class ConnectorsRecoveryResourceHandler method getAllConnectorResources.
private Collection<ConnectorResource> getAllConnectorResources() {
Collection<ConnectorResource> allResources = new ArrayList<ConnectorResource>();
Collection<ConnectorResource> connectorResources = domain.getResources().getResources(ConnectorResource.class);
allResources.addAll(connectorResources);
for (Application app : applications.getApplications()) {
if (ResourcesUtil.createInstance().isEnabled(app)) {
Resources appScopedResources = app.getResources();
if (appScopedResources != null && appScopedResources.getResources() != null) {
allResources.addAll(appScopedResources.getResources(ConnectorResource.class));
}
List<Module> modules = app.getModule();
if (modules != null) {
for (Module module : modules) {
Resources msr = module.getResources();
if (msr != null && msr.getResources() != null) {
allResources.addAll(msr.getResources(ConnectorResource.class));
}
}
}
}
}
return allResources;
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class RestMonitoringLoader method createAndRegisterApplication.
/**
* Create the system application entry and register the application
* @throws Exception
*/
private void createAndRegisterApplication() throws Exception {
LOGGER.log(Level.FINE, "Registering the Rest Monitoring Application...");
// Create the system application entry and application-ref in the config
ConfigCode code = new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... proxies) throws PropertyVetoException, TransactionFailure {
// Create the system application
SystemApplications systemApplications = (SystemApplications) proxies[0];
Application application = systemApplications.createChild(Application.class);
// Check if the application name is valid, generating a new one if it isn't
checkAndResolveApplicationName(systemApplications);
systemApplications.getModules().add(application);
application.setName(applicationName);
application.setEnabled(Boolean.TRUE.toString());
application.setObjectType("system-admin");
application.setDirectoryDeployed("true");
application.setContextRoot(contextRoot);
try {
application.setLocation("${com.sun.aas.installRootURI}/lib/install/applications/" + RestMonitoringService.DEFAULT_REST_MONITORING_APP_NAME);
} catch (Exception me) {
throw new RuntimeException(me);
}
// Set the engine types
Module singleModule = application.createChild(Module.class);
application.getModule().add(singleModule);
singleModule.setName(applicationName);
Engine webEngine = singleModule.createChild(Engine.class);
webEngine.setSniffer("web");
Engine weldEngine = singleModule.createChild(Engine.class);
weldEngine.setSniffer("cdi");
Engine securityEngine = singleModule.createChild(Engine.class);
securityEngine.setSniffer("security");
singleModule.getEngines().add(webEngine);
singleModule.getEngines().add(weldEngine);
singleModule.getEngines().add(securityEngine);
// Create the application-ref
Server s = (Server) proxies[1];
List<ApplicationRef> arefs = s.getApplicationRef();
ApplicationRef aref = s.createChild(ApplicationRef.class);
aref.setRef(application.getName());
aref.setEnabled(Boolean.TRUE.toString());
aref.setVirtualServers(getVirtualServerListAsString());
arefs.add(aref);
return true;
}
};
Server server = domain.getServerNamed(serverEnv.getInstanceName());
ConfigSupport.apply(code, domain.getSystemApplications(), server);
LOGGER.log(Level.FINE, "Rest Monitoring Application Registered.");
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class ConnectionPoolUtil method isValidModule.
public boolean isValidModule(String applicationName, String moduleName, String poolName, ActionReport report) {
boolean isValid = false;
Application application = applications.getApplication(applicationName);
if (!isValidApplication(applicationName, poolName, report)) {
return false;
}
Module module = application.getModule(moduleName);
if (module != null) {
isValid = true;
} else {
setModuleNotFoundErrorMessage(report, moduleName, applicationName);
}
return isValid;
}
use of com.sun.enterprise.config.serverbeans.Module in project Payara by payara.
the class CreateResourceAdapterConfig method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
HashMap attrList = new HashMap();
attrList.put(RESOURCE_ADAPTER_CONFIG_NAME, raName);
// attrList.put("name", name);
attrList.put(THREAD_POOL_IDS, threadPoolIds);
attrList.put(ServerTags.OBJECT_TYPE, objectType);
ResourceStatus rs;
// TODO ASR : need similar validation while creating app-scoped-resource of resource-adapter-config
String appName = raName;
if (!ConnectorsUtil.isStandAloneRA(raName)) {
appName = ConnectorsUtil.getApplicationNameOfEmbeddedRar(raName);
Application application = applications.getApplication(appName);
if (application != null) {
// embedded RAR
String resourceAdapterName = ConnectorsUtil.getRarNameFromApplication(raName);
Module module = application.getModule(resourceAdapterName);
if (module != null) {
Resources msr = module.getResources();
if (msr != null) {
if (hasDuplicate(msr, report))
return;
}
}
}
} else {
// standalone RAR
Application application = applications.getApplication(appName);
if (application != null) {
Resources appScopedResources = application.getResources();
if (appScopedResources != null) {
if (hasDuplicate(appScopedResources, report))
return;
}
}
}
ResourceAdapterConfigManager resAdapterConfigMgr = new ResourceAdapterConfigManager();
try {
rs = resAdapterConfigMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception ex) {
Logger.getLogger(CreateResourceAdapterConfig.class.getName()).log(Level.SEVERE, "Unable to create resource adapter config for " + raName, ex);
String def = "Resource adapter config: {0} could not be created, reason: {1}";
report.setMessage(localStrings.getLocalString("create.resource.adapter.config.fail", def, raName) + " " + ex.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(ex);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
} else {
report.setMessage(localStrings.getLocalString("create.resource.adapter.config.fail", "Resource adapter config {0} creation failed", raName, ""));
}
if (rs.getException() != null)
report.setFailureCause(rs.getException());
}
report.setActionExitCode(ec);
}
Aggregations