use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ConnectorMessageBeanClient method getActivationName.
/**
* {@inheritDoc}
* @Override
*/
public String getActivationName() {
if (activationName == null) {
String appName = descriptor_.getApplication().getName();
String moduleID = descriptor_.getEjbBundleDescriptor().getModuleID();
int pound = moduleID.indexOf('#');
if (pound >= 0) {
// the module ID is in the format: appName#ejbName.jar
// remove the appName part since it is duplicated
moduleID = moduleID.substring(pound + 1);
}
String mdbClassName = descriptor_.getEjbClassName();
ServerEnvironmentImpl env = Globals.get(ServerEnvironmentImpl.class);
String instanceName = env.getInstanceName();
Domain domain = Globals.get(Domain.class);
String domainName = domain.getName();
Cluster cluster = domain.getServerNamed(instanceName).getCluster();
String clusterName = null;
if (cluster != null) {
// this application is deployed in a cluster
clusterName = cluster.getName();
}
if (clusterName != null) {
// this application is deployed in a cluster
activationName = combineString(domainName, clusterName, appName, moduleID, mdbClassName);
} else {
// this application is deployed in a stand-alone server instance.
activationName = combineString(domainName, instanceName, appName, moduleID, mdbClassName);
}
}
return activationName;
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ManagedConnectionImpl method getJdbcConnectionPool.
private static JdbcConnectionPool getJdbcConnectionPool(javax.resource.spi.ManagedConnectionFactory mcf) {
if (Globals.getDefaultHabitat().getService(ProcessEnvironment.class).getProcessType() != ProcessEnvironment.ProcessType.Server) {
// otherwise we bave no domain to draw upon
return null;
}
ManagedConnectionFactoryImpl spiMCF = (ManagedConnectionFactoryImpl) mcf;
Resources resources = Globals.getDefaultHabitat().getService(Domain.class).getResources();
ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, spiMCF.getPoolName());
if (pool instanceof JdbcConnectionPool) {
return (JdbcConnectionPool) pool;
}
return null;
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ListJndiResourcesTest method setUp.
@Before
public void setUp() {
habitat = getHabitat();
cr = habitat.getService(CommandRunner.class);
context = new AdminCommandContextImpl(LogDomains.getLogger(ListJndiResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
parameters = new ParameterMap();
Resources resources = habitat.<Domain>getService(Domain.class).getResources();
for (Resource resource : resources.getResources()) {
if (resource instanceof org.glassfish.resources.config.ExternalJndiResource) {
origNum = origNum + 1;
}
}
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class SecurityConfigUpgradeService method postConstruct.
@Override
public void postConstruct() {
if (domain.getExtensionByType(SecurityConfigurations.class) != null) {
/*
* The domain already contains a security-configurations setting,
* so for now that's sufficient to conclude we don't need to upgrade.
*/
logger.log(Level.INFO, "SecurityConfigUpgradeService bypassing - security-configurations already present");
return;
}
Transaction t = null;
try {
t = new Transaction();
final Domain domain_w = t.enroll(domain);
/*
* Create the security configurations element and add it to the domain.
*/
final SecurityConfigurations sc_w = domain_w.createChild(SecurityConfigurations.class);
domain_w.getExtensions().add(sc_w);
/*
* Create and add the authentication service.
*/
final AuthenticationService as_w = addAuthenticationService(sc_w);
/*
* Next, add the two providers and their children.
*/
addAdmRealmProvider(as_w);
addFileRealmProvider(as_w);
/**
* Next add the authorization service
*/
final AuthorizationService authorizationService = addAuthorizationService(sc_w);
/**
* Next add the authorization service provider
*/
addSimpleAuthorizationProvider(authorizationService);
t.commit();
logger.log(Level.INFO, "SecurityConfigUpgradeService successfully completed the upgrade");
} catch (Exception ex) {
if (t != null) {
t.rollback();
}
logger.log(Level.SEVERE, null, ex);
}
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class DeleteModuleConfigCommand method deleteTopLevelExtensionByType.
private void deleteTopLevelExtensionByType(Config config, final String className, Class configBeanType) {
if (ConfigExtension.class.isAssignableFrom(configBeanType)) {
if (config.checkIfExtensionExists(configBeanType)) {
try {
ConfigSupport.apply(new SingleConfigCode<Config>() {
@Override
public Object run(Config param) throws PropertyVetoException, TransactionFailure {
List<ConfigExtension> configExtensions;
configExtensions = param.getExtensions();
for (ConfigExtension ext : configExtensions) {
String configExtensionClass = GlassFishConfigBean.unwrap(ext).getProxyType().getSimpleName();
if (configExtensionClass.equals(className)) {
configExtensions.remove(ext);
break;
}
}
return configExtensions;
}
}, config);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (TransactionFailure e) {
String actual = e.getMessage();
String msg = localStrings.getLocalString("delete.module.config.failed.to.delete.config", DEFAULT_FORMAT, serviceName, actual);
report.setMessage(msg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
} else {
report.setMessage(localStrings.getLocalString("delete.module.config.no.configuration", "No customized configuration exist for this service nor the default configuration has been added to the domain.xml."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
} else if (DomainExtension.class.isAssignableFrom(configBeanType)) {
if (domain.checkIfExtensionExists(configBeanType)) {
try {
ConfigSupport.apply(new SingleConfigCode<Domain>() {
@Override
public Object run(Domain param) throws PropertyVetoException, TransactionFailure {
List<DomainExtension> domainExtensions;
domainExtensions = param.getExtensions();
for (DomainExtension ext : domainExtensions) {
String configExtensionClass = GlassFishConfigBean.unwrap(ext).getProxyType().getSimpleName();
if (configExtensionClass.equals(className)) {
domainExtensions.remove(ext);
break;
}
}
return domainExtensions;
}
}, domain);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (TransactionFailure e) {
String actual = e.getMessage();
String msg = localStrings.getLocalString("delete.module.config.failed.to.delete.config", DEFAULT_FORMAT, serviceName, actual);
report.setMessage(msg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
} else {
report.setMessage(localStrings.getLocalString("delete.module.config.no.configuration", "No customized configuration exist for this service nor the default configuration has been added to the domain.xml."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
}
}
Aggregations