/** * DOC qian class global comment. A global service register provides the service registration and acquirement. <br/> * * $Id: talend-code-templates.xml 1 2006-09-29 17:06:40 +0000 (星期五, 29 九月 2006) nrousseau $ * */ publicclass GlobalServiceRegister {
// The shared instance privatestatic GlobalServiceRegister instance =new GlobalServiceRegister();
/** * DOC qian Comment method "getService".Gets the specific IService. * * @param klass the Service type you want to get * @return IService IService */ public IService getService(Class klass) { IService service = services.get(klass); if (service ==null) { service = findService(klass); if (service ==null) { thrownew RuntimeException("The service "+ klass.getName() +" has not been registered."); } services.put(klass, service); } return service; }
/** * DOC qian Comment method "findService".Finds the specific service from the list. * * @param klass the interface type want to find. * @return IService */ private IService findService(Class klass) { String key = klass.getName(); for (int i =0; i < configurationElements.length; i++) { IConfigurationElement element = configurationElements[i]; String id = element.getAttribute("serviceId");
if (!key.endsWith(id)) { continue; } try{ Object service = element.createExecutableExtension("class"); if (klass.isInstance(service)) { return (IService) service; } }catch (CoreException e) { ExceptionHandler.process(e); } } returnnull; } }
/** * DOC get a implement of IRepositoryService. * * @return a implement of IRepositoryService */ public IRepositoryService getRepositoryService() { IService service = GlobalServiceRegister.getDefault().getService(IRepositoryService.class); return (IRepositoryService) service; }
本篇文章重点说明什么是函数柯里化,这个语法现象的背后动机是什么,有什么样的应用场景,以及与部分应用函数(Partial Applied Function)之间的联系 1. 什么是柯里化函数
A way to write functions with multiple parameter lists. For instance
def f(x: Int)(y: Int) is a
ApplicationContext能读取多个Bean定义文件,方法是:
ApplicationContext appContext = new ClassPathXmlApplicationContext(
new String[]{“bean-config1.xml”,“bean-config2.xml”,“bean-config3.xml”,“bean-config4.xml
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information re
参考了
http://zhedahht.blog.163.com/blog/static/25411174201142733927831/
但是用java来实现有一个问题。
由于Java无法像C那样“传递参数的地址,函数返回时能得到参数的值”,唯有新建一个辅助类:AuxClass
import ljn.help.*;
public class BalancedBTree {
BeanUtils.copyProperties VS PropertyUtils.copyProperties
作为两个bean属性copy的工具类,他们被广泛使用,同时也很容易误用,给人造成困然;比如:昨天发现同事在使用BeanUtils.copyProperties copy有integer类型属性的bean时,没有考虑到会将null转换为0,而后面的业