private void safeCloseClient() { try { getManagementClient().close(); } catch (final Exception e) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Caught exception closing ModelControllerClient", e); } } }
@Override public final void stop() throws LifecycleException { try { stopInternal(null); } finally { safeCloseClient(); } }
/** * Checks to see if the attribute is a valid attribute for the operation. This is useful to determine if the running * container supports an attribute for the version running. * * <p> * This is the same as executing {@link #isOperationAttributeSupported(ModelNode, String, String) isOperationAttriubuteSupported(null, operationName, attributeName)} * </p> * * @param operationName the operation name * @param attributeName the attribute name * * @return {@code true} if the attribute is supported or {@code false} if the attribute was not found on the * operation description * * @throws IOException if an error occurs while attempting to execute the operation * @throws IllegalStateException if the operation fails */ protected boolean isOperationAttributeSupported(final String operationName, final String attributeName) throws IOException { return isOperationAttributeSupported(null, operationName, attributeName); }
startInternal(); } catch (LifecycleException e) { safeCloseClient(); throw e;
@Override public void setup(final EmbeddedContainerConfiguration config) { super.setup(config); server = EmbeddedServerFactory.create(config.getJbossHome(), config.getModulePath(), config.getBundlePath()); }
final ModelControllerClient client = getModelControllerClient(); final ModelNode op; if (address == null) { msg = String.format("Failed to determine if attribute %s is supported for operation %s. %s", attributeName, operationName, Operations.getFailureDescription(result)); } else { msg = String.format("Failed to determine if attribute %s is supported for operation %s:%s. %s", attributeName, addressToCliString(address), operationName, Operations.getFailureDescription(result));
@Override public void perform(Container container) throws Exception { event.fire(new BeforeStop(container.getDeployableContainer())); try { if (container.getState().equals(Container.State.STARTED)) { CommonDeployableContainer c = (CommonDeployableContainer) container.getDeployableContainer(); c.stop(stopEvent.getTimeout()); } container.setState(Container.State.STOPPED); } catch (LifecycleException e) { container.setState(Container.State.STOPPED_FAILED); throw e; } event.fire(new AfterStop(container.getDeployableContainer())); } });
startInternal(); } catch (LifecycleException e) { safeCloseClient(); throw e;
@Override public void setup(final EmbeddedContainerConfiguration config) { super.setup(config); if (config.getCleanServerBaseDir() != null) { SecurityActions.setSystemProperty(EmbeddedStandAloneServerFactory.JBOSS_EMBEDDED_ROOT, config.getCleanServerBaseDir()); } server = EmbeddedServerFactory.create(config.getJbossHome(), config.getModulePath(), config.getBundlePath()); }
final ModelControllerClient client = getModelControllerClient(); final ModelNode op; if (address == null) { msg = String.format("Failed to determine if attribute %s is supported for operation %s. %s", attributeName, operationName, Operations.getFailureDescription(result)); } else { msg = String.format("Failed to determine if attribute %s is supported for operation %s:%s. %s", attributeName, addressToCliString(address), operationName, Operations.getFailureDescription(result));
@Override public void perform(Container container) throws Exception { event.fire(new BeforeStop(container.getDeployableContainer())); try { if (container.getState().equals(Container.State.STARTED)) { CommonDeployableContainer c = (CommonDeployableContainer) container.getDeployableContainer(); c.stop(stopEvent.getTimeout()); } container.setState(Container.State.STOPPED); } catch (LifecycleException e) { container.setState(Container.State.STOPPED_FAILED); throw e; } event.fire(new AfterStop(container.getDeployableContainer())); } });
@Override public final void stop() throws LifecycleException { try { stopInternal(); } finally { safeCloseClient(); } }
@Override public final void start() throws LifecycleException { // Create a client configuration builder from the container configuration final ModelControllerClientConfiguration.Builder clientConfigBuilder = new ModelControllerClientConfiguration.Builder() .setProtocol(containerConfig.getManagementProtocol()) .setHostName(containerConfig.getManagementAddress()) .setPort(containerConfig.getManagementPort()) .setAuthenticationConfigUri(authenticationConfig); // Check for username and password authentication if(containerConfig.getUsername() != null) { Authentication.username = containerConfig.getUsername(); Authentication.password = containerConfig.getPassword(); clientConfigBuilder.setHandler(getCallbackHandler()); } mccProvider.setDelegate(ModelControllerClient.Factory.create(clientConfigBuilder.build())); try { final Properties jndiProps = new Properties(); jndiProps.setProperty(Context.URL_PKG_PREFIXES, JBOSS_URL_PKG_PREFIX); jndiContext.set(new InitialContext(jndiProps)); } catch (final NamingException ne) { throw new LifecycleException("Could not set JNDI Naming Context", ne); } try { startInternal(); } catch (LifecycleException e) { safeCloseClient(); throw e; } }
private void safeCloseClient() { try { IoUtils.safeClose(getManagementClient()); } catch (final Exception e) { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Caught exception closing ModelControllerClient", e); } } }
@Override public void setup(final EmbeddedContainerConfiguration config) { super.setup(config); if (config.getCleanServerBaseDir() != null) { SecurityActions.setSystemProperty(EmbeddedStandaloneServerFactory.JBOSS_EMBEDDED_ROOT, config.getCleanServerBaseDir()); } final String[] cmdArgs = getCommandArgs(config); server = EmbeddedProcessFactory.createStandaloneServer(config.getJbossHome(), config.getModulePath(), config.getSystemPackagesArray(), cmdArgs); }
/** * Checks to see if the attribute is a valid attribute for the operation. This is useful to determine if the running * container supports an attribute for the version running. * * <p> * This is the same as executing {@link #isOperationAttributeSupported(ModelNode, String, String) isOperationAttriubuteSupported(null, operationName, attributeName)} * </p> * * @param operationName the operation name * @param attributeName the attribute name * * @return {@code true} if the attribute is supported or {@code false} if the attribute was not found on the * operation description * * @throws IOException if an error occurs while attempting to execute the operation * @throws IllegalStateException if the operation fails */ protected boolean isOperationAttributeSupported(final String operationName, final String attributeName) throws IOException { return isOperationAttributeSupported(null, operationName, attributeName); }
public final void stop(Integer timeout) throws LifecycleException { try { stopInternal(timeout); } finally { safeCloseClient(); } }
@Override public final void start() throws LifecycleException { // Create a client configuration builder from the container configuration final ModelControllerClientConfiguration.Builder clientConfigBuilder = new ModelControllerClientConfiguration.Builder() .setProtocol(containerConfig.getManagementProtocol()) .setHostName(containerConfig.getManagementAddress()) .setPort(containerConfig.getManagementPort()) .setAuthenticationConfigUri(authenticationConfig); // Check for username and password authentication if(containerConfig.getUsername() != null) { Authentication.username = containerConfig.getUsername(); Authentication.password = containerConfig.getPassword(); clientConfigBuilder.setHandler(getCallbackHandler()); } mccProvider.setDelegate(ModelControllerClient.Factory.create(clientConfigBuilder.build())); try { final Properties jndiProps = new Properties(); jndiProps.setProperty(Context.URL_PKG_PREFIXES, JBOSS_URL_PKG_PREFIX); jndiContext.set(new InitialContext(jndiProps)); } catch (final NamingException ne) { throw new LifecycleException("Could not set JNDI Naming Context", ne); } try { startInternal(); } catch (LifecycleException e) { safeCloseClient(); throw e; } }
protected ModelControllerClient getModelControllerClient() { return getManagementClient().getControllerClient(); }
@Override public final void stop() throws LifecycleException { try { stopInternal(null); } finally { safeCloseClient(); } }