use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.
the class ReferenceConstrainTest method jmxConnectorAuthRealmRefInvalid.
@Test
public void jmxConnectorAuthRealmRefInvalid() throws TransactionFailure {
JmxConnector jmxConnector = habitat.getService(JmxConnector.class, "system");
assertNotNull(jmxConnector);
ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(jmxConnector);
Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("auth-realm-name", "realm-not-exist");
changes.put(serverConfig, configChanges);
try {
ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
cs.apply(changes);
fail("Can not reach this point");
} catch (TransactionFailure tf) {
ConstraintViolationException cv = findConstrViolation(tf);
assertNotNull(cv);
}
}
use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.
the class CreateSsl method addSslToJMXConnector.
private void addSslToJMXConnector(Config config, ActionReport report) {
AdminService adminService = config.getAdminService();
// ensure we have the specified listener
JmxConnector jmxConnector = null;
for (JmxConnector jmxConn : adminService.getJmxConnector()) {
if (jmxConn.getName().equals(listenerId)) {
jmxConnector = jmxConn;
}
}
if (jmxConnector == null) {
report.setMessage(LOCAL_STRINGS.getLocalString("create.ssl.jmx.notfound", "JMX Connector named {0} to which this ssl element is " + "being added does not exist.", listenerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (jmxConnector.getSsl() != null) {
report.setMessage(LOCAL_STRINGS.getLocalString("create.ssl.jmx.alreadyExists", "IIOP Listener named {0} to which this ssl element is " + "being added already has an ssl element.", listenerId));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
ConfigSupport.apply(new SingleConfigCode<JmxConnector>() {
@Override
public Object run(JmxConnector param) throws PropertyVetoException, TransactionFailure {
Ssl newSsl = param.createChild(Ssl.class);
populateSslElement(newSsl);
param.setSsl(newSsl);
return newSsl;
}
}, jmxConnector);
} catch (TransactionFailure e) {
reportError(report, e);
}
reportSuccess(report);
}
use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.
the class ReferenceConstrainTest method jmxConnectorAuthRealmRefValid.
@Test
public void jmxConnectorAuthRealmRefValid() throws TransactionFailure {
JmxConnector jmxConnector = habitat.getService(JmxConnector.class, "system");
assertNotNull(jmxConnector);
ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(jmxConnector);
Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("auth-realm-name", "file");
changes.put(serverConfig, configChanges);
try {
ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
cs.apply(changes);
} catch (TransactionFailure tf) {
fail("Can not reach this point");
}
}
use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.
the class NodeAgentConfigUpgrade method postConstruct.
@Override
public void postConstruct() {
final NodeAgents nodeAgents = domain.getNodeAgents();
if (nodeAgents == null) {
createDefaultNodeList();
return;
}
final List<NodeAgent> agList = nodeAgents.getNodeAgent();
if (agList.isEmpty()) {
createDefaultNodeList();
return;
}
try {
ConfigSupport.apply(new SingleConfigCode<Domain>() {
@Override
public Object run(Domain d) throws PropertyVetoException, TransactionFailure {
Nodes nodes = d.createChild(Nodes.class);
Transaction t = Transaction.getTransaction(d);
if (t == null)
return null;
for (NodeAgent na : agList) {
String host = null;
Node node = nodes.createChild(Node.class);
node.setName(na.getName());
node.setType("CONFIG");
JmxConnector jc = na.getJmxConnector();
if (jc != null) {
// get the properties and see if host name is specified
List<Property> agentProp = jc.getProperty();
for (Property p : agentProp) {
String name = p.getName();
if (name.equals("client-hostname")) {
// create the node with a host name
node.setNodeHost(p.getValue());
node.setInstallDir("${com.sun.aas.productRoot}");
}
}
}
nodes.getNode().add(node);
}
// Now add the builtin localhost node
createDefaultNode(d, nodes);
d.setNodes(nodes);
List<Server> serverList = servers.getServer();
if (serverList.isEmpty())
return null;
for (Server s : serverList) {
s = t.enroll(s);
s.setNodeRef(s.getNodeAgentRef());
s.setNodeAgentRef(null);
}
// remove the node-agent element by setting to null
d.setNodeAgents(null);
return null;
}
}, domain);
} catch (Exception e) {
Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading node-agent from V2 to V3", e);
throw new RuntimeException(e);
}
}
use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.
the class ActiveJmsResourceAdapter method isASRmiRegistryPortAvailable.
private boolean isASRmiRegistryPortAvailable(JmsRaUtil jmsraUtil) {
if (_logger.isLoggable(Level.FINE))
logFine("isASRmiRegistryPortAvailable - JMSService Type:" + jmsraUtil.getJMSServiceType());
// AS RMI Registry. So the check below is not necessary.
if (jmsraUtil.getJMSServiceType().equals(REMOTE) || jmsraUtil.getJMSServiceType().equals(LOCAL)) {
return false;
}
try {
JmxConnector jmxConnector = getJmxConnector();
if (!"true".equals(jmxConnector.getEnabled()))
return false;
if ("true".equals(jmxConnector.getSecurityEnabled()))
return false;
// Attempt to detect JMXStartupService for RMI registry
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Detecting JMXStartupService...");
}
JMXStartupService jmxservice = Globals.get(JMXStartupService.class);
if (jmxservice == null)
return false;
jmxservice.waitUntilJMXConnectorStarted();
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Found JMXStartupService");
}
String name = "rmi://" + getConfiguredRmiRegistryHost() + ":" + getConfiguredRmiRegistryPort() + "/jmxrmi";
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Attempting to list " + name);
}
Naming.list(name);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("List on " + name + " succeeded");
}
// return configured port only if RMI registry is available
return true;
} catch (Exception e) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Failed to detect JMX RMI Registry: " + e.getMessage());
}
return false;
}
}
Aggregations