use of com.sun.enterprise.config.serverbeans.AdminService in project Payara by payara.
the class FieldsValidationTest method testNotNullField.
@Test
public void testNotNullField() {
AdminService admin = super.getHabitat().getService(AdminService.class);
Assert.assertNotNull(admin);
try {
ConfigSupport.apply(new SingleConfigCode<AdminService>() {
@Override
public Object run(AdminService wAdmin) throws PropertyVetoException, TransactionFailure {
wAdmin.setDasConfig(null);
return null;
}
}, admin);
Assert.fail("Exception not raised when setting a @NotNull annotated field with null");
} catch (TransactionFailure e) {
if (e.getCause() != null) {
Assert.assertTrue(e.getCause() instanceof ConstraintViolationException);
}
}
}
use of com.sun.enterprise.config.serverbeans.AdminService in project Payara by payara.
the class DirectCreationTest method doTest.
public void doTest() throws TransactionFailure {
AdminService service = habitat.getService(AdminService.class);
ConfigBean serviceBean = (ConfigBean) ConfigBean.unwrap(service);
Class<?>[] subTypes = null;
try {
subTypes = ConfigSupport.getSubElementsTypes(serviceBean);
} catch (ClassNotFoundException e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
throw new RuntimeException(e);
}
ConfigSupport support = getBaseServiceLocator().getService(ConfigSupport.class);
assertNotNull("ConfigSupport not found", support);
for (Class<?> subType : subTypes) {
// TODO: JL force compilation error to mark this probably edit point for grizzly config
if (subType.getName().endsWith("DasConfig")) {
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("dynamic-reload-enabled", "true");
configChanges.put("autodeploy-dir", "funky-dir");
support.createAndSet(serviceBean, (Class<? extends ConfigBeanProxy>) subType, configChanges);
break;
}
}
support.createAndSet(serviceBean, DasConfig.class, (List) null);
List<AttributeChanges> profilerChanges = new ArrayList<AttributeChanges>();
String[] values = { "-Xmx512m", "-RFtrq", "-Xmw24" };
ConfigSupport.MultipleAttributeChanges multipleChanges = new ConfigSupport.MultipleAttributeChanges("jvm-options", values);
String[] values1 = { "profile" };
ConfigSupport.MultipleAttributeChanges multipleChanges1 = new ConfigSupport.MultipleAttributeChanges("name", values1);
profilerChanges.add(multipleChanges);
profilerChanges.add(multipleChanges1);
support.createAndSet((ConfigBean) ConfigBean.unwrap(habitat.<JavaConfig>getService(JavaConfig.class)), Profiler.class, profilerChanges);
}
use of com.sun.enterprise.config.serverbeans.AdminService 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(localStrings.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(localStrings.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.AdminService in project Payara by payara.
the class AdminEndpointDecider method setValues.
private void setValues() {
// can't change
asadminContextRoot = AdminAdapter.PREFIX_URI;
// asadminHosts = Collections.emptyList(); //asadmin is handled completely by the adapter, no VS needed
NetworkListener nl = cfg.getAdminListener();
ThreadPool tp = nl.findThreadPool();
if (tp != null) {
try {
maxThreadPoolSize = Integer.parseInt(tp.getMaxThreadPoolSize());
} catch (NumberFormatException ne) {
}
}
String dvs = nl.findHttpProtocol().getHttp().getDefaultVirtualServer();
guiHosts = Collections.unmodifiableList(Arrays.asList(dvs));
// same for now
asadminHosts = guiHosts;
try {
address = InetAddress.getByName(nl.getAddress());
} catch (UnknownHostException e) {
throw new IllegalStateException(e);
}
if (ServerTags.ADMIN_LISTENER_ID.equals(nl.getName())) {
// at the root context for separate admin-listener
guiContextRoot = "";
try {
port = Integer.parseInt(nl.getPort());
} catch (NumberFormatException ne) {
port = ADMIN_PORT;
}
} else {
try {
port = Integer.parseInt(nl.getPort());
} catch (NumberFormatException ne) {
// this is the last resort
port = 8080;
}
// get the context root from admin-service
AdminService as = cfg.getAdminService();
if (as == null)
guiContextRoot = ServerEnvironmentImpl.DEFAULT_ADMIN_CONSOLE_CONTEXT_ROOT;
else
setGuiContextRootFromAdminService(as);
}
}
Aggregations