@Override public void handleError(ClientHttpResponse response) throws IOException { String exceptionClazz = null; Map<String, String> map = new HashMap<>(); try { String body = new String(getResponseBody(response)); @SuppressWarnings("unchecked") Map<String, String> parsed = objectMapper.readValue(body, Map.class); map.putAll(parsed); exceptionClazz = map.get("exception"); } catch (Exception e) { // don't want to error here } if (ObjectUtils.nullSafeEquals(exceptionClazz, ReleaseNotFoundException.class.getName())) { handleReleaseNotFoundException(map); } else if (ObjectUtils.nullSafeEquals(exceptionClazz, PackageDeleteException.class.getName())) { handlePackageDeleteException(map); } else if (ObjectUtils.nullSafeEquals(exceptionClazz, SkipperException.class.getName())) { handleSkipperException(map); } super.handleError(response); }
@Override protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) { Class<?> targetType = mbd.getTargetType(); if (targetType == null) { targetType = (mbd.getFactoryMethodName() != null ? getTypeForFactoryMethod(beanName, mbd, typesToMatch) : resolveBeanClass(mbd, beanName, typesToMatch)); if (ObjectUtils.isEmpty(typesToMatch) || getTempClassLoader() == null) { mbd.setTargetType(targetType); } } // Apply SmartInstantiationAwareBeanPostProcessors to predict the // eventual type after a before-instantiation shortcut. if (targetType != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) { for (BeanPostProcessor bp : getBeanPostProcessors()) { if (bp instanceof SmartInstantiationAwareBeanPostProcessor) { SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor) bp; Class<?> predicted = ibp.predictBeanType(targetType, beanName); if (predicted != null && (typesToMatch.length != 1 || !FactoryBean.class.equals(typesToMatch[0]) || FactoryBean.class.isAssignableFrom(predicted))) { return predicted; } } } } return targetType; }
@Bean public MqttPahoClientFactory mqttClientFactory() { DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory(); factory.setServerURIs(mqttProperties.getUrl()); factory.setUserName(mqttProperties.getUsername()); factory.setPassword(mqttProperties.getPassword()); factory.setCleanSession(mqttProperties.isCleanSession()); factory.setConnectionTimeout(mqttProperties.getConnectionTimeout()); factory.setKeepAliveInterval(mqttProperties.getKeepAliveInterval()); if (ObjectUtils.nullSafeEquals(mqttProperties.getPersistence(), "file")) { factory.setPersistence(new MqttDefaultFilePersistence(mqttProperties.getPersistenceDirectory())); } else if (ObjectUtils.nullSafeEquals(mqttProperties.getPersistence(), "memory")) { factory.setPersistence(new MemoryPersistence()); } return factory; }
/** * Set a header. * * @param name Name * @param value Value */ public void setHeader(String name, Object value) { verifyType(name, value); if (value != null) { // Modify header if necessary if (!ObjectUtils.nullSafeEquals(value, getHeader(name))) { this.modified = true; this.headers.put(name, value); } } else { // Remove header if available if (this.headers.containsKey(name)) { this.modified = true; this.headers.remove(name); } } }
/** * Returns the first matching class from the given array, that doens't belong to common libraries such as the JDK or * OSGi API. Useful for filtering OSGi services by type to prevent class cast problems. * * <p/> No sanity checks are done on the given array class. * * @param classes array of classes * @return a 'particular' (non JDK/OSGi) class if one is found. Else the first available entry is returned. */ public static Class<?> getParticularClass(Class<?>[] classes) { boolean hasSecurity = (System.getSecurityManager() != null); for (int i = 0; i < classes.length; i++) { final Class<?> clazz = classes[i]; ClassLoader loader = null; if (hasSecurity) { loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return clazz.getClassLoader(); } }); } else { loader = clazz.getClassLoader(); } // quick boot/system check if (loader != null) { // consider known loaders if (!knownNonOsgiLoadersSet.contains(loader)) { return clazz; } } } return (ObjectUtils.isEmpty(classes) ? null : classes[0]); }
/** * Reads {@code MBeanParameterInfo} from the {@code ManagedOperationParameter} * attributes attached to a method. Returns an empty array of {@code MBeanParameterInfo} * if no attributes are found. */ @Override protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey) { ManagedOperationParameter[] params = this.attributeSource.getManagedOperationParameters(method); if (ObjectUtils.isEmpty(params)) { return super.getOperationParameters(method, beanKey); } MBeanParameterInfo[] parameterInfo = new MBeanParameterInfo[params.length]; Class<?>[] methodParameters = method.getParameterTypes(); for (int i = 0; i < params.length; i++) { ManagedOperationParameter param = params[i]; parameterInfo[i] = new MBeanParameterInfo(param.getName(), methodParameters[i].getName(), param.getDescription()); } return parameterInfo; }
public void testScopes() throws Exception { assertNull(tag); Object a = bf.getBean("a"); System.out.println("got a" + a); assertNotNull(tag); ((Properties) a).put("goo", "foo"); Object b = bf.getBean("b"); System.out.println("request b;got=" + b); System.out.println("b class is" + b.getClass()); b = bf.getBean("b"); System.out.println("request b;got=" + b); System.out.println("b class is" + b.getClass()); Object scopedA = bf.getBean("a"); System.out.println(scopedA.getClass()); System.out.println(a); System.out.println(scopedA); System.out.println(ObjectUtils.nullSafeToString(ClassUtils.getAllInterfaces(scopedA))); }
public String[] getConfigurations(Bundle bundle) { String[] locations = ConfigUtils.getHeaderLocations(bundle.getHeaders()); // if no location is specified in the header, try the defaults if (ObjectUtils.isEmpty(locations)) { // check the default locations if the manifest doesn't provide any info Enumeration defaultConfig = bundle.findEntries(CONTEXT_DIR, CONTEXT_FILES, false); if (defaultConfig != null && defaultConfig.hasMoreElements()) { return new String[] { DEFAULT_CONFIG }; } else { return new String[0]; } } else { return locations; } }
public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(BundleContext bundleContext) throws Exception { Bundle bundle = bundleContext.getBundle(); ApplicationContextConfiguration config = new BlueprintContainerConfig(bundle); String bundleName = OsgiStringUtils.nullSafeNameAndSymName(bundle); if (log.isTraceEnabled()) log.trace("Created configuration " + config + " for bundle " + bundleName); // it's not a spring bundle, ignore it if (!config.isSpringPoweredBundle()) { if (log.isDebugEnabled()) log.debug("No blueprint configuration found in bundle " + bundleName + "; ignoring it..."); return null; } log.info("Discovered configurations " + ObjectUtils.nullSafeToString(config.getConfigurationLocations()) + " in bundle [" + bundleName + "]"); DelegatedExecutionOsgiBundleApplicationContext sdoac = new OsgiBundleXmlApplicationContext(config.getConfigurationLocations()); sdoac.setBundleContext(bundleContext); sdoac.setPublishContextAsService(config.isPublishContextAsService()); return sdoac; }
public static void callListenersUnbind(Object serviceProxy, ServiceReference reference, OsgiServiceLifecycleListener[] listeners) { if (!ObjectUtils.isEmpty(listeners)) { boolean debug = log.isDebugEnabled(); // get a Dictionary implementing a Map Dictionary properties = (reference != null ? OsgiServiceReferenceUtils.getServicePropertiesSnapshot(reference) : null); for (int i = 0; i < listeners.length; i++) { if (debug) log.debug("Calling unbind on " + listeners[i] + " w/ reference " + reference); try { listeners[i].unbind(serviceProxy, (Map) properties); } catch (Exception ex) { log.warn("Unbind method on listener " + listeners[i] + " threw exception ", ex); } if (debug) log.debug("Called unbind on " + listeners[i] + " w/ reference " + reference); } } }
/** * Invoke method with signature <code>bla(ServiceReference ref)</code>. * * @param target * @param method * @param service */ private void invokeCustomServiceReferenceMethod(Object target, Method method, Object service) { if (method != null) { boolean trace = log.isTraceEnabled(); // get the service reference // find the compatible types (accept null service) if (trace) log.trace("invoking listener custom method " + method); ServiceReference ref = (service != null ? ((ImportedOsgiServiceProxy) service).getServiceReference() : null); try { ReflectionUtils.invokeMethod(method, target, new Object[] { ref }); } // make sure to log exceptions and continue with the // rest of the listeners catch (Exception ex) { Exception cause = ReflectionUtils.getInvocationException(ex); log.warn("custom method [" + method + "] threw exception when passing service [" + ObjectUtils.identityToString(service) + "]", cause); } } }
private Class<?> doResolveBeanClass(RootBeanDefinition mbd, Class<?>... typesToMatch) throws ClassNotFoundException { if (!ObjectUtils.isEmpty(typesToMatch)) { ClassLoader tempClassLoader = getTempClassLoader(); if (tempClassLoader != null) { if (tempClassLoader instanceof DecoratingClassLoader) { DecoratingClassLoader dcl = (DecoratingClassLoader) tempClassLoader; for (Class<?> typeToMatch : typesToMatch) { dcl.excludeClass(typeToMatch.getName()); } } String className = mbd.getBeanClassName(); return (className != null ? ClassUtils.forName(className, tempClassLoader) : null); } } return mbd.resolveBeanClass(getBeanClassLoader()); }
@Override protected ExecutorService initializeExecutor( ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) { ScheduledExecutorService executor = createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler); if (executor instanceof ScheduledThreadPoolExecutor && this.removeOnCancelPolicy != null) { ((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(this.removeOnCancelPolicy); } // Register specified ScheduledExecutorTasks, if necessary. if (!ObjectUtils.isEmpty(this.scheduledExecutorTasks)) { registerTasks(this.scheduledExecutorTasks, executor); } // Wrap executor with an unconfigurable decorator. this.exposedExecutor = (this.exposeUnconfigurableExecutor ? Executors.unconfigurableScheduledExecutorService(executor) : executor); return executor; }
private void addSyntheticDependsOn(BeanDefinition definition, String beanName) { if (StringUtils.hasText(beanName)) { String[] dependsOn = definition.getDependsOn(); if (dependsOn != null && dependsOn.length > 0) { for (String dependOn : dependsOn) { if (beanName.equals(dependOn)) { return; } } } // add depends on dependsOn = (String[]) ObjectUtils.addObjectToArray(dependsOn, beanName); definition.setDependsOn(dependsOn); Collection<String> markers = (Collection<String>) definition.getAttribute(SYNTHETIC_DEPENDS_ON); if (markers == null) { markers = new ArrayList<String>(2); definition.setAttribute(SYNTHETIC_DEPENDS_ON, markers); } markers.add(beanName); } }
/** * Based on the given class, properly instructs the ProxyFactory proxies. For additional sanity checks on the passed * classes, check the methods below. * * @see #containsUnrelatedClasses(Class[]) * @see #removeParents(Class[]) * * @param factory * @param classes */ public static void configureFactoryForClass(ProxyFactory factory, Class<?>[] classes) { if (ObjectUtils.isEmpty(classes)) return; for (int i = 0; i < classes.length; i++) { Class<?> clazz = classes[i]; if (clazz.isInterface()) { factory.addInterface(clazz); } else { factory.setTargetClass(clazz); factory.setProxyTargetClass(true); } } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof OpaqueUriComponents)) { return false; } OpaqueUriComponents other = (OpaqueUriComponents) obj; return ObjectUtils.nullSafeEquals(getScheme(), other.getScheme()) && ObjectUtils.nullSafeEquals(this.ssp, other.ssp) && ObjectUtils.nullSafeEquals(getFragment(), other.getFragment()); }
@Bean(name = "sqlSessionFactory") @ConditionalOnMissingBean public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); factory.setDataSource(dataSource); factory.setVfs(SpringBootVFS.class); if (StringUtils.hasText(this.properties.getConfigLocation())) { factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); } org.apache.ibatis.session.Configuration configuration = this.properties.getConfiguration(); if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) { configuration = new org.apache.ibatis.session.Configuration(); } factory.setConfiguration(configuration); if (this.properties.getConfigurationProperties() != null) { factory.setConfigurationProperties(this.properties.getConfigurationProperties()); } if (!ObjectUtils.isEmpty(this.interceptors)) { factory.setPlugins(this.interceptors); } if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) { factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); } if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) { factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage()); } if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) { factory.setMapperLocations(this.properties.resolveMapperLocations()); } return factory.getObject(); }
/** * 根据treeNodeId获取TreeNode对象 * @param treeNodeId * @param allTreeNodeList * @return */ protected T getTreeNodeById(I treeNodeId, List<T> allTreeNodeList) { if(CollectionUtils.isEmpty(allTreeNodeList) || ObjectUtils.isEmpty(treeNodeId)){ return null; } for(T treeNode : allTreeNodeList){ if(treeNode != null && treeNodeId.equals(getTreeNodeId(treeNode))){ return treeNode; } } return null; }
/** * 根据parentTreeNodeId获取直接子节点 * @param parentTreeNodeId * @param allTreeNodeList * @return */ public List<T> getDirectChildNodeList(I parentTreeNodeId, List<T> allTreeNodeList) { List<T> childList = new ArrayList<T>(); if(CollectionUtils.isEmpty(allTreeNodeList) || ObjectUtils.isEmpty(parentTreeNodeId)){ return childList; } for(T treeNode : allTreeNodeList){ if(treeNode != null && parentTreeNodeId.equals(getParentTreeNodeId(treeNode))){ childList.add(treeNode); } } return childList; }
/** * Gets the {@code ModelMBeanInfo} for the bean with the supplied key * and of the supplied type. */ private ModelMBeanInfo getMBeanInfo(Object managedBean, String beanKey) throws JMException { ModelMBeanInfo info = this.assembler.getMBeanInfo(managedBean, beanKey); if (logger.isWarnEnabled() && ObjectUtils.isEmpty(info.getAttributes()) && ObjectUtils.isEmpty(info.getOperations())) { logger.warn("Bean with key '" + beanKey + "' has been registered as an MBean but has no exposed attributes or operations"); } return info; }
@Override public void printStackTrace(PrintStream ps) { if (ObjectUtils.isEmpty(this.messageExceptions)) { super.printStackTrace(ps); } else { ps.println(super.toString() + "; message exception details (" + this.messageExceptions.length + ") are:"); for (int i = 0; i < this.messageExceptions.length; i++) { Exception subEx = this.messageExceptions[i]; ps.println("Failed message " + (i + 1) + ":"); subEx.printStackTrace(ps); } } }
@Override public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) { // Create field error with the exceptions's code, e.g. "typeMismatch". String field = ex.getPropertyName(); String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field); Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field); Object rejectedValue = ex.getValue(); if (rejectedValue != null && rejectedValue.getClass().isArray()) { rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue)); } bindingResult.addError(new FieldError( bindingResult.getObjectName(), field, rejectedValue, true, codes, arguments, ex.getLocalizedMessage())); }
/** * Excludes classes from the given array, which match the given modifier. * * @see Modifier * * @param classes array of classes (can be null) * @param modifier class modifier * @return array of classes (w/o duplicates) which does not have the given modifier */ public static Class<?>[] excludeClassesWithModifier(Class<?>[] classes, int modifier) { if (ObjectUtils.isEmpty(classes)) return new Class[0]; Set<Class<?>> clazzes = new LinkedHashSet<Class<?>>(classes.length); for (int i = 0; i < classes.length; i++) { if ((modifier & classes[i].getModifiers()) == 0) clazzes.add(classes[i]); } return (Class[]) clazzes.toArray(new Class[clazzes.size()]); }
@PostMapping("listUser") @ResponseBody public TableOutput<UserDto> listUser(@RequestBody TableInput<UserDto> tableInput) { TableOutput<UserDto> tableOutput = new TableOutput<>(); List<UserDto> dtos = userService.findByExample(tableInput.getRqObj()); tableOutput.setTotal(ObjectUtils.isEmpty(dtos) ? 0 : dtos.size()); tableOutput.setRows(ObjectUtils.isEmpty(dtos) ? new ArrayList<UserDto>() : dtos); return tableOutput; }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof BeansException)) { return false; } BeansException otherBe = (BeansException) other; return (getMessage().equals(otherBe.getMessage()) && ObjectUtils.nullSafeEquals(getCause(), otherBe.getCause())); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof MatchAlwaysTransactionAttributeSource)) { return false; } MatchAlwaysTransactionAttributeSource otherTas = (MatchAlwaysTransactionAttributeSource) other; return ObjectUtils.nullSafeEquals(this.transactionAttribute, otherTas.transactionAttribute); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof EmptyTargetSource)) { return false; } EmptyTargetSource otherTs = (EmptyTargetSource) other; return (ObjectUtils.nullSafeEquals(this.targetClass, otherTs.targetClass) && this.isStatic == otherTs.isStatic); }
private Object[] extractArgs(Method method, Object[] args) { if (!method.isVarArgs()) { return args; } Object[] varArgs = ObjectUtils.toObjectArray(args[args.length - 1]); Object[] combinedArgs = new Object[args.length - 1 + varArgs.length]; System.arraycopy(args, 0, combinedArgs, 0, args.length - 1); System.arraycopy(varArgs, 0, combinedArgs, args.length - 1, varArgs.length); return combinedArgs; }
private void registerService(ApplicationContext applicationContext) { final Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>(); Bundle bundle = bundleContext.getBundle(); String symName = bundle.getSymbolicName(); serviceProperties.put(Constants.BUNDLE_SYMBOLICNAME, symName); serviceProperties.put(BLUEPRINT_SYMNAME, symName); Version version = OsgiBundleUtils.getBundleVersion(bundle); serviceProperties.put(Constants.BUNDLE_VERSION, version); serviceProperties.put(BLUEPRINT_VERSION, version); log.info("Publishing BlueprintContainer as OSGi service with properties " + serviceProperties); // export just the interface final String[] serviceNames = new String[] { BlueprintContainer.class.getName() }; if (log.isDebugEnabled()) log.debug("Publishing service under classes " + ObjectUtils.nullSafeToString(serviceNames)); AccessControlContext acc = SecurityUtils.getAccFrom(applicationContext); // publish service if (System.getSecurityManager() != null) { registration = AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() { public ServiceRegistration run() { return bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties); } }, acc); } else { registration = bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties); } }
/** * Match the given qualifier annotations against the candidate bean definition. */ protected boolean checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch) { if (ObjectUtils.isEmpty(annotationsToSearch)) { return true; } SimpleTypeConverter typeConverter = new SimpleTypeConverter(); for (Annotation annotation : annotationsToSearch) { Class<? extends Annotation> type = annotation.annotationType(); boolean checkMeta = true; boolean fallbackToMeta = false; if (isQualifier(type)) { if (!checkQualifier(bdHolder, annotation, typeConverter)) { fallbackToMeta = true; } else { checkMeta = false; } } if (checkMeta) { boolean foundMeta = false; for (Annotation metaAnn : type.getAnnotations()) { Class<? extends Annotation> metaType = metaAnn.annotationType(); if (isQualifier(metaType)) { foundMeta = true; // Only accept fallback match if @Qualifier annotation has a value... // Otherwise it is just a marker for a custom qualifier annotation. if ((fallbackToMeta && StringUtils.isEmpty(AnnotationUtils.getValue(metaAnn))) || !checkQualifier(bdHolder, metaAnn, typeConverter)) { return false; } } } if (fallbackToMeta && !foundMeta) { return false; } } } return true; }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof MethodOverride)) { return false; } MethodOverride that = (MethodOverride) other; return (ObjectUtils.nullSafeEquals(this.methodName, that.methodName) && ObjectUtils.nullSafeEquals(this.source, that.source)); }
public void testClassPathFilesOnBundleClassPath() throws Exception { // use org to make sure the bundle class is properly considered (especially for folder based classpath) Resource[] res = patternLoader.getResources("classpath:org/**/*.file"); System.out.println("array count is " + res.length); System.out.println(ObjectUtils.nullSafeToString(res)); printPathWithinContext(res); assertTrue("bundle classpath jar not considered", containsString(res, "jar-folder.file")); }
public void testRootFileOnBundleClassPath() throws Exception { // use org to make sure the bundle class is properly considered (especially for folder based classpath) Resource[] res = patternLoader.getResources("classpath:*.file"); System.out.println("array count is " + res.length); System.out.println(ObjectUtils.nullSafeToString(res)); printPathWithinContext(res); assertTrue("bundle classpath jar not considered", containsString(res, "jar.file")); }
/** * Check whether the named bean declares a qualifier of the given name. * @param qualifier the qualifier to match * @param beanName the name of the candidate bean * @param bf the {@code BeanFactory} from which to retrieve the named bean * @return {@code true} if either the bean definition (in the XML case) * or the bean's factory method (in the {@code @Bean} case) defines a matching * qualifier value (through {@code <qualifier>} or {@code @Qualifier}) */ private static boolean isQualifierMatch(String qualifier, String beanName, ConfigurableListableBeanFactory bf) { if (bf.containsBean(beanName)) { try { BeanDefinition bd = bf.getMergedBeanDefinition(beanName); if (bd instanceof AbstractBeanDefinition) { AbstractBeanDefinition abd = (AbstractBeanDefinition) bd; AutowireCandidateQualifier candidate = abd.getQualifier(Qualifier.class.getName()); if ((candidate != null && qualifier.equals(candidate.getAttribute(AutowireCandidateQualifier.VALUE_KEY))) || qualifier.equals(beanName) || ObjectUtils.containsElement(bf.getAliases(beanName), qualifier)) { return true; } } if (bd instanceof RootBeanDefinition) { Method factoryMethod = ((RootBeanDefinition) bd).getResolvedFactoryMethod(); if (factoryMethod != null) { Qualifier targetAnnotation = factoryMethod.getAnnotation(Qualifier.class); if (targetAnnotation != null && qualifier.equals(targetAnnotation.value())) { return true; } } } } catch (NoSuchBeanDefinitionException ex) { // Ignore - can't compare qualifiers for a manually registered singleton object } } return false; }
public void testResourceAvailableWithPatternOnPathsOnlyInsideFolderClasspath() throws Exception { Resource[] resources = patternLoader.getResources("classpath*:org/eclipse/gemini/blueprint/iandt/**/folder-test.file"); assertNotNull(resources); assertEquals(1, resources.length); assertTrue(resources[0].exists()); System.out.println(ObjectUtils.nullSafeToString((resources))); printPathWithinContext(resources); }
public void testResourceAvailableWithPatternOnlyInsideFolderClasspath() throws Exception { Resource[] resources = patternLoader.getResources("classpath:org/eclipse/gemini/blueprint/iandt/**/folder-test.file"); assertNotNull(resources); assertEquals(1, resources.length); assertTrue(resources[0].exists()); System.out.println(ObjectUtils.nullSafeToString((resources))); printPathWithinContext(resources); }
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) { BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " + "This tag cannot be used nested inside <property>.", ele); return null; } String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isDebugEnabled()) { logger.debug("Using generated bean name [" + id + "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); }
public void testNoRootCpBundleResourceInClassPathFound() throws Exception { ResourcePatternResolver resolver = getNoRootCpBundleResourceResolver(); Resource[] res = resolver.getResources("classpath*:cp.file"); assertFalse("resource should be found since it's on the classpath", ObjectUtils.isEmpty(res)); assertTrue("resource should be found since it's on the classpath", res[0].exists()); System.out.println("classpath*:cp.file resources"); printPathWithinContext(res); }
public void testNoRootCpBundleResourceNestedInClassPathFound() throws Exception { ResourcePatternResolver resolver = getNoRootCpBundleResourceResolver(); Resource[] res = resolver.getResources("classpath*:/some/nested/nested.file"); assertFalse("resource should be found since it's on the classpath", ObjectUtils.isEmpty(res)); assertTrue("resource should be found since it's on the classpath", res[0].exists()); System.out.println("classpath*:/some/nested/nested.file resources"); printPathWithinContext(res); }
@Override public String toString() { StringBuilder sb = new StringBuilder(getClass().getName()); if (this.object != null) { sb.append(": wrapping object [").append(ObjectUtils.identityToString(this.object)).append("]"); } else { sb.append(": no wrapped object set"); } return sb.toString(); }