List of usage examples for org.springframework.util ObjectUtils nullSafeToString
public static String nullSafeToString(@Nullable short[] array)
From source file:com.productone.spring.ServerOsgiBundleXmlWebApplicationContext.java
/** * Creates a// w ww. j a v a2s . c o m * <code>ServerOsgiBundleXmlWebApplicationContext</code> with the supplied * config locations. * * @param configLocations the config locations. */ public ServerOsgiBundleXmlWebApplicationContext(String[] configLocations) { super(configLocations); setDisplayName("Root ServerOsgiBundleXmlWebApplicationContext"); logger.debug("Creating an ServerOsgiBundleXmlWebApplicationContext with locations [{}].", ObjectUtils.nullSafeToString(configLocations)); }
From source file:com.productone.spring.ServerOsgiBundleXmlWebApplicationContext.java
/** * Creates a/* w w w. j a va2s . co m*/ * <code>ServerOsgiBundleXmlWebApplicationContext</code> with the supplied * parent and config locations. * * @param configLocations the config locations. * @param parent the parent {@link ApplicationContext}. */ public ServerOsgiBundleXmlWebApplicationContext(String[] configLocations, ApplicationContext parent) { super(configLocations, parent); setDisplayName("Root ServerOsgiBundleXmlWebApplicationContext"); logger.debug("Creating an ServerOsgiBundleXmlWebApplicationContext with locations [{}] and parent [{}].", ObjectUtils.nullSafeToString(configLocations), parent); }
From source file:org.eclipse.gemini.blueprint.test.AbstractDependencyManagerTests.java
/** * Returns the bundles that have to be installed as part of the test setup. * This method is preferred as the bundles are by their names rather then as * {@link Resource}s. It allows for a <em>declarative</em> approach for * specifying bundles as opposed to {@link #getTestBundles()} which provides * a programmatic one.//from w ww. j a v a 2s.c o m * * <p/>This implementation reads a predefined properties file to determine * the bundles needed. If the configuration needs to be changed, consider * changing the configuration location. * * @return an array of testing framework bundle identifiers * @see #getTestingFrameworkBundlesConfiguration() * @see #locateBundle(String) * */ protected String[] getTestFrameworkBundlesNames() { // load properties file Properties props = PropertiesUtil.loadAndExpand(getTestingFrameworkBundlesConfiguration()); if (props == null) throw new IllegalArgumentException( "cannot load default configuration from " + getTestingFrameworkBundlesConfiguration()); boolean trace = logger.isTraceEnabled(); if (trace) logger.trace("Loaded properties " + props); // pass properties to test instance running inside OSGi space System.getProperties().put(GEMINI_BLUEPRINT_VERSION_PROP_KEY, props.get(GEMINI_BLUEPRINT_VERSION_PROP_KEY)); System.getProperties().put(SPRING_VERSION_PROP_KEY, props.get(SPRING_VERSION_PROP_KEY)); Properties excluded = PropertiesUtil.filterKeysStartingWith(props, IGNORE); if (trace) { logger.trace("Excluded ignored properties " + excluded); } String[] bundles = props.keySet().toArray(new String[props.size()]); // sort the array (as the Properties file doesn't respect the order) //bundles = StringUtils.sortStringArray(bundles); if (logger.isDebugEnabled()) logger.debug("Default framework bundles :" + ObjectUtils.nullSafeToString(bundles)); return bundles; }
From source file:com.geodevv.testing.irmina.IrminaContextLoader.java
protected void loadBeanDefinitions(IrminaApplicationContext context, MergedContextConfiguration mergedConfig) { Class<?>[] configClasses = mergedConfig.getClasses(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Registering configuration classes: " + ObjectUtils.nullSafeToString(configClasses)); }// ww w . j av a2 s . co m new AnnotatedBeanDefinitionReader(context).register(configClasses); }
From source file:org.carewebframework.security.spring.AbstractSecurityService.java
/** * Checks the current SecurityContext for the specified authorities. * /*from w w w. ja v a 2s . c o m*/ * @param grantedAuthorities Comma-delimited string of granted authorities * @param checkAllRoles boolean true-specified roles must be found in security context * authorities, false-security context must contain at least 1 specified authority * @return True if Authentication is granted authorities */ @Override public boolean isGranted(String grantedAuthorities, boolean checkAllRoles) { Authentication authentication = getAuthentication(); if (authentication == null) { log.info("Authentication context was null during check for granted authorities '" + ObjectUtils.nullSafeToString(grantedAuthorities) + "'."); return false; } if (grantedAuthorities == null) { return false; } for (String desiredAuthority : grantedAuthorities.split(",")) { if (!desiredAuthority.isEmpty()) { if (isGranted(desiredAuthority, authentication) != checkAllRoles) { return !checkAllRoles; } } } return checkAllRoles; }
From source file:org.eclipse.gemini.blueprint.test.AbstractOnTheFlyBundleCreatorTests.java
private void addImportPackage(Manifest manifest) { String[] rawImports = determineImports(); boolean trace = logger.isTraceEnabled(); if (trace)/*w ww . ja va2 s .c om*/ logger.trace("Discovered raw imports " + ObjectUtils.nullSafeToString(rawImports)); Collection specialImportsOut = eliminateSpecialPackages(rawImports); Collection imports = eliminatePackagesAvailableInTheJar(specialImportsOut); if (trace) logger.trace("Filtered imports are " + imports); manifest.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, StringUtils.collectionToCommaDelimitedString(imports)); }
From source file:spring.osgi.io.OsgiBundleResourcePatternResolver.java
/** * Applies synthetic class-path analysis. That is, search the bundle space * and the bundle class-path for entries matching the given path. * * @param bundle bundle/*w ww . j a v a 2s. c o m*/ * @param path path * @param foundPaths foundPaths * @throws java.io.IOException */ private void findSyntheticClassPathMatchingResource(Bundle bundle, String path, Collection<String> foundPaths) throws IOException { // 1. bundle space lookup OsgiBundleResourcePatternResolver localPatternResolver = new OsgiBundleResourcePatternResolver(bundle, getClassLoader()); Resource[] foundResources = localPatternResolver.findResources(path); boolean trace = logger.isTraceEnabled(); if (trace) logger.trace("Found synthetic cp resources " + ObjectUtils.nullSafeToString(foundResources)); for (Resource foundResource : foundResources) { // assemble only the OSGi paths foundPaths.add(foundResource.getURL().getPath()); } // 2. Bundle-Classpath lookup (on the path stripped of the prefix) Collection<String> cpMatchingPaths = findBundleClassPathMatchingPaths(bundle, path); if (trace) logger.trace("Found Bundle-ClassPath matches " + cpMatchingPaths); foundPaths.addAll(cpMatchingPaths); // 3. Required-Bundle is considered already by the dependency resolver }
From source file:spring.osgi.io.OsgiBundleResourcePatternResolver.java
/** * Searches the bundle classpath (Bundle-Classpath) entries for the given * pattern./*from www. j a va2s .c om*/ * * @param bundle bundle * @param pattern pattern * @return paths * @throws java.io.IOException */ private Collection<String> findBundleClassPathMatchingPaths(Bundle bundle, String pattern) throws IOException { // list of strings pointing to the matching resources List<String> list = new ArrayList<>(4); boolean trace = logger.isTraceEnabled(); if (trace) logger.trace("Analyzing " + Constants.BUNDLE_CLASSPATH + " entries for bundle [" + bundle.getBundleId() + "|" + bundle.getSymbolicName() + "]"); // see if there is a bundle class-path defined String[] entries = OsgiHeaderUtils.getBundleClassPath(bundle); if (trace) logger.trace( "Found " + Constants.BUNDLE_CLASSPATH + " entries " + ObjectUtils.nullSafeToString(entries)); // 1. if so, look at the entries for (String entry : entries) { // make sure to exclude the default entry if (!entry.equals(BUNDLE_DEFAULT_CP)) { // 2. locate resource first from the bundle space (since it might not exist) OsgiBundleResource entryResource = new OsgiBundleResource(bundle, entry); // call the internal method to avoid catching an exception URL url = null; ContextResource res = entryResource.getResourceFromBundleSpace(entry); if (res != null) { url = res.getURL(); } if (trace) logger.trace("Classpath entry [" + entry + "] resolves to [" + url + "]"); // we've got a valid entry so let's parse it if (url != null) { String cpEntryPath = url.getPath(); // is it a jar ? if (entry.endsWith(JAR_EXTENSION)) findBundleClassPathMatchingJarEntries(list, url, pattern); // no, so it must be a folder else findBundleClassPathMatchingFolders(list, bundle, cpEntryPath, pattern); } } } return list; }
From source file:spring.osgi.io.OsgiBundleResourcePatternResolver.java
/** * Replace the super class implementation to pass in the searchType * parameter./* w w w. j a va2 s. co m*/ * * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver#findPathMatchingResources(String) */ private Resource[] findPathMatchingResources(String locationPattern, int searchType) throws IOException { String rootDirPath = determineRootDir(locationPattern); String subPattern = locationPattern.substring(rootDirPath.length()); Resource[] rootDirResources = getResources(rootDirPath); boolean trace = logger.isTraceEnabled(); if (trace) logger.trace("Found root resources for [" + rootDirPath + "] :" + ObjectUtils.nullSafeToString(rootDirResources)); Set<Resource> result = new LinkedHashSet<>(); for (Resource rootDirResource : rootDirResources) { if (isJarResource(rootDirResource)) { result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern)); } else { result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern, searchType)); } } if (logger.isTraceEnabled()) { logger.trace("Resolved location pattern [" + locationPattern + "] to resources " + result); } return result.toArray(new Resource[result.size()]); }
From source file:com.gohighedu.platform.framework.utils.common.StringUtils.java
/** * Convenience method to return a String array as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * @param arr the array to display/* w ww.ja va 2 s.com*/ * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String arrayToDelimitedString(Object[] arr, String delim) { if (ObjectUtils.isEmpty(arr)) { return ""; } if (arr.length == 1) { return ObjectUtils.nullSafeToString(arr[0]); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { if (i > 0) { sb.append(delim); } sb.append(arr[i]); } return sb.toString(); }