Example usage for org.springframework.util Assert state

List of usage examples for org.springframework.util Assert state

Introduction

In this page you can find the example usage for org.springframework.util Assert state.

Prototype

public static void state(boolean expression, Supplier<String> messageSupplier) 

Source Link

Document

Assert a boolean expression, throwing an IllegalStateException if the expression evaluates to false .

Usage

From source file:org.cloudfoundry.identity.uaa.oauth.token.TokenKeyEndpoint.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.state(this.signerProvider != null, "A SignerProvider must be provided");
}

From source file:org.opennms.ng.dao.support.BottomNAttributeStatisticVisitor.java

/**
 * <p>afterPropertiesSet</p>
 *
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 *//*w w w  . j a  v a 2  s . c  om*/
@Override
public void afterPropertiesSet() {
    Assert.state(m_count != null, "property count must be set to a non-null value");
}

From source file:com.autentia.wuija.view.ApplicationBreadcrumb.java

/**
 * El parmetro de entrada de este mtodo tiene que ser el devuelto por
 * {@link ApplicationBreadcrumb#getViewToFordwardTo(Class)}.
 * <p>//  w ww.  ja  va 2  s .c o  m
 * Este mtodo es necesario porque a veces para mostrar una vista hay que hacer antes ciertas tareas de
 * inicilizacin. De esta forma se puede pedir la instancia de la siguiente vista, hacer la inicializcin y luego
 * llamar a este mtodo. De forma que cuando se lance el evento {@link ViewActivatedEvent} la vista est
 * inicializada correctamente.
 * <p>
 * Siempre que sea posible se debera usar el mtodo {@link ApplicationBreadcrumb#forward(Class)} que es ms
 * sencillo.
 * 
 * @param <T> el tipo de la vista.
 * @param nextView La instancia de la vista a la que queremos saltar. Debe ser la instancia que nos devolvi
 *            {@link ApplicationBreadcrumb#getViewToFordwardTo(Class)}.
 */
public void forward(View nextView) {
    Assert.state(returnedView == nextView,
            "The parameter 'nextView' have to be the return of getViewInstance()");

    final View currentView = viewsStack.peekFirst();

    nextView.setVisible(true);
    viewsStack.addFirst(nextView);

    if (currentView != null) {
        // Si estamos en la primera vista no hay nada que esconder. Somos los primeros !!!
        currentView.setVisible(false);
    }
}

From source file:org.spring.data.gemfire.app.service.GemstoneService.java

protected GemstoneDao getGemFireGemsDao() {
    Assert.state(gemfireGemstoneDao != null,
            "A reference to the 'GemFire' GemsDao was not properly configured!");
    return gemfireGemstoneDao;
}

From source file:org.spring.data.gemfire.app.dao.provider.JpaUserDao.java

@PostConstruct
public void init() {
    Assert.state(entityManager != null, "A reference to the JPA EntityManager was not properly configured!");
    System.out.printf("%1$s%n", entityManager.getEntityManagerFactory().getProperties());
    System.out.printf("%1$s initialized!%n", getClass().getSimpleName());
}

From source file:com.redblackit.web.server.DefaultEmbeddedJettyServer.java

/**
 * Constructor taking key- and trust-store info
 * /*w w w  .ja v  a 2 s  .c om*/
 * We've suppressed deprecation warnings given that setPort etc have been
 * deprecated without corresponding update to Javadoc.
 * 
 * @param keyStore
 * @param keyStorePassword
 * @param trustStore
 * @param trustStorePassword
 *            for private key (defaults to keyStorePassword)
 */
@SuppressWarnings("deprecation")
public DefaultEmbeddedJettyServer(final int httpPort, final int httpsPort, final String keyStore,
        final String keyStorePassword, final String trustStore, final String trustStorePassword) {

    final String pmsg = ":httpPort=" + httpPort + ":httpsPort=" + httpsPort + ":keyStore=" + keyStore
            + ":keyStorePassword=" + trustStorePassword + ":trustStore=" + trustStore + ":trustStorePassword="
            + trustStorePassword;

    Assert.state(httpPort > 0 || httpsPort > 0, "one of httpPort, httpsPort must be gt 0" + pmsg);

    if (httpsPort > 0) {
        Assert.state(httpPort != httpsPort, "httpPort equals httpsPort=" + httpsPort + pmsg);
        Assert.notNull(keyStore, "keyStore" + pmsg);
        Assert.notNull(keyStorePassword, "keyStorePassword" + pmsg);
        Assert.notNull(trustStore, "trustStore" + pmsg);
        Assert.notNull(trustStorePassword, "trustStorePassword" + pmsg);

        Assert.state(
                !keyStore.equals(trustStore)
                        || (keyStore.equals(trustStore) && keyStorePassword.equals(trustStorePassword)),
                "keyStore = trustStore but keyStorePassword != trustStorePassword" + pmsg);
    } else {
        if (keyStore != null || keyStorePassword != null || trustStore != null || trustStorePassword != null) {
            logger.warn("httpsPort=" + httpsPort + " <= 0, but keyInfo supplied" + pmsg);
        }
    }

    setServer(new Server());

    if (httpPort > 0) {
        Connector connector = new SelectChannelConnector();
        connector.setPort(httpPort);
        getServer().addConnector(connector);
    }

    if (httpsPort > 0) {
        SslConnector sslConnector = new SslSelectChannelConnector();
        sslConnector.setPort(httpsPort);
        sslConnector.setKeystore(keyStore);
        sslConnector.setPassword(keyStorePassword);
        sslConnector.setKeyPassword(keyStorePassword);
        sslConnector.setTruststore(trustStore);
        sslConnector.setTrustPassword(trustStorePassword);
        sslConnector.setWantClientAuth(true);
        getServer().addConnector(sslConnector);
    }
}

From source file:org.appverse.web.framework.backend.security.oauth2.resourceserver.handlers.OAuth2LogoutHandler.java

public OAuth2LogoutHandler tokenStore(TokenStore tokenStore) {
    Assert.state(tokenStore != null, "TokenStore cannot be null in OAuth2LogoutHandler");
    this.tokenStore = tokenStore;
    return this;
}

From source file:org.esco.portlet.changeetab.dao.impl.LdapUserDao.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.notNull(this.ldapTemplate, "No LdapTemplate configured !");
    Assert.hasText(this.userDn, "No user dn configured !");
    Assert.hasText(this.userIdTemplate, "No user Id template configured !");
    Assert.hasText(this.currentEtabIdLdapKey, "No current etab Id Ldap key configured !");

    Assert.state(this.userDn.contains(this.userIdTemplate), "User dn doesn't contain the user Id template !");
}

From source file:fr.mby.portal.coreimpl.message.BasicMessageDispatcher.java

@Override
public void dispatch(final IMessage message, final IReply reply) {
    final Iterable<IPortalApp> portalApps = this.portalAppResolver.resolve(message.getUserAction());

    boolean disptached = false;

    if (portalApps != null) {
        for (final IPortalApp portalApp : portalApps) {
            disptached = this.dispatchToPortalApp(portalApp, message, reply) || disptached;
        }// w  w  w. ja  v  a 2 s  .co m
    }

    final Iterable<IEventApp> eventApps = this.eventAppResolver.resolve(message.getUserAction());

    if (eventApps != null) {
        for (final IEventApp eventApp : eventApps) {
            disptached = this.dispatchToEventApp(eventApp, message, reply) || disptached;
        }
    }

    Assert.state(disptached, "Fail to dispatch IMessage to IPortalApp.");
}