List of usage examples for org.springframework.util Assert state
public static void state(boolean expression, Supplier<String> messageSupplier)
From source file:org.cloudfoundry.tools.timeout.TimeoutProtectionFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Assert.state(this.strategy != null, "Please set the TimeoutProtectionStrategy"); TimeoutProtectionHttpRequest timeoutProtectionRequest = TimeoutProtectionHttpRequest.get(request); if (timeoutProtectionRequest == null) { chain.doFilter(request, response); return;//from www .java2s . c om } if (timeoutProtectionRequest.getType() == TimeoutProtectionHttpRequest.Type.POLL) { this.strategy.handlePoll(timeoutProtectionRequest, (HttpServletResponse) response); return; } doFilter(timeoutProtectionRequest, (HttpServletResponse) response, chain); }
From source file:org.openmrs.module.bahmniexports.example.domain.trade.internal.HibernateAwareCustomerCreditItemWriter.java
@Override public void afterPropertiesSet() throws Exception { Assert.state(sessionFactory != null, "Hibernate SessionFactory is required"); Assert.notNull(dao, "Delegate DAO must be set"); }
From source file:com.autentia.wuija.persistence.impl.hibernate.HibernateTestUtils.java
/** * Mtodo pensado para usar en los test, de forma que para la ejecucin tengamos una nica sesin. Sera similar a * clases como <code>penSessionInViewFilter</code>. La idea es invocar este mtodo en un <code>@Before</code>. * <p>// w ww . j ava2s . c o m * Este mtodo se debera invocar una nica vez. * <p> * La sesin se "attacha" al contexto, de forma que est disponible para usar desde las transacciones o desde el * <code>HibernteTemplate</code>. Luego se cerrar con el mtodo {@link #closeSessionFromContext()}. */ public void openSessionAndAttachToContext() { Assert.state(sessionAlreadyOpened == null, "A session is already opened: " + ObjectUtils.identityToString(sessionAlreadyOpened)); sessionAlreadyOpened = SessionFactoryUtils.getSession(sessionFactory, true); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(sessionAlreadyOpened)); if (log.isDebugEnabled()) { log.debug("Opened Session: " + ObjectUtils.identityToString(sessionAlreadyOpened) + ", with SessionFactory: " + ObjectUtils.identityToString(sessionFactory)); } }
From source file:org.opennms.ng.dao.support.ResourceTypeFilteringResourceVisitor.java
/** * <p>afterPropertiesSet</p> * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() *///from w ww .java 2 s . c o m @Override public void afterPropertiesSet() { Assert.state(m_delegatedVisitor != null, "property delegatedVisitor must be set to a non-null value"); Assert.state(m_resourceTypeMatch != null, "property resourceTypeMatch must be set to a non-null value"); }
From source file:org.spring.data.gemfire.app.dao.GemfireRegionCustomerDao.java
protected Region<Long, Customer> customersRegion() { Assert.state(customers != null, "The 'Customers' Region bean was not properly initialized!"); return customers; }
From source file:com.wavemaker.commons.io.local.LocalResourceStore.java
public LocalResourceStore(java.io.File root, JailedResourcePath path) { Assert.notNull(root, "Root must not be null"); Assert.notNull(path, "Path must not be null"); Assert.state(root.exists(), "The root folder '" + root + "' does not exist"); Assert.state(root.isDirectory(), "The root '" + root + "' is not a folder"); this.root = root; this.path = path; this.file = getFileForPath(path); }
From source file:lcn.module.batch.core.item.file.transform.DelimitedLineTokenizer.java
/** * DelimietedLineTokenizer ??//from w w w .jav a2 s . com * Token ? delimiter ? ?? . * * @param delimiter : delimiter ? */ public DelimitedLineTokenizer(String delimiter) { Assert.state(delimiter != DEFAULT_QUOTE_CHARACTER, "[" + DEFAULT_QUOTE_CHARACTER + "] is not allowed as delimiter for tokenizers."); this.delimiter = delimiter; setQuoteCharacter(DEFAULT_QUOTE_CHARACTER); }
From source file:de.langmi.spring.batch.examples.complex.support.CustomMultiResourcePartitioner.java
/** * Assign the filename of each of the injected resources to an * {@link ExecutionContext}./*w ww . ja va2 s . co m*/ * * @see Partitioner#partition(int) */ @Override public Map<String, ExecutionContext> partition(int gridSize) { Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize); int i = 0; for (Resource resource : resources) { ExecutionContext context = new ExecutionContext(); Assert.state(resource.exists(), "Resource does not exist: " + resource); try { context.putString(keyName, resource.getURL().toExternalForm()); context.put("outputFileName", createOutputFilename(i, resource)); } catch (IOException e) { throw new IllegalArgumentException("File could not be located for: " + resource, e); } map.put(PARTITION_KEY + i, context); i++; } return map; }
From source file:com.ai.bss.util.user.DigestUtils.java
/** * Converts the byte array to a string containing its Hex representation. * * @param data the byte array of data/* w w w . j ava 2 s .c o m*/ * @param offset An offset in the array where the encoding should start * @param length Indicates how many bytes should be encoded. * @return the hex representation of the String */ public static String hex(byte[] data, int offset, int length) { Assert.notNull(data); Assert.state(offset >= 0, "The offset must be positive"); Assert.state(offset < data.length, "The offset must be lower than the length of the data"); Assert.state(length >= 0, "The requested length must be positive"); Assert.state(length <= data.length, "The requested length must be equal to or lower than the length of the data"); StringBuilder buf = new StringBuilder(length * 2); for (int i = offset; i < (offset + length); i++) { byte b = data[i]; // look up high nibble char buf.append(HEX_CHARS[(b & 0xf0) >>> 4]); // look up low nibble char buf.append(HEX_CHARS[b & 0x0f]); } return buf.toString(); }
From source file:egovframework.rte.bat.core.item.file.transform.EgovDelimitedLineTokenizer.java
/** * EgovDelimietedLineTokenizer ??// w w w . j av a2 s . c o m * Token ? delimiter ? ?? . * * @param delimiter : delimiter ? */ public EgovDelimitedLineTokenizer(String delimiter) { Assert.state(delimiter != DEFAULT_QUOTE_CHARACTER, "[" + DEFAULT_QUOTE_CHARACTER + "] is not allowed as delimiter for tokenizers."); this.delimiter = delimiter; setQuoteCharacter(DEFAULT_QUOTE_CHARACTER); }