org.nutz.ioc.impl.PropertiesProxy Java Examples

The following examples show how to use org.nutz.ioc.impl.PropertiesProxy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WxContext.java    From nutzwx with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setPath(String path) {
	PropertiesProxy pp = new PropertiesProxy(path);
	Map<String, Object> map = new LinkedHashMap(pp.toMap());
	if (pp.get("openid") != null) {
		String appid = pp.get("openid");
		WxMaster def = Lang.map2Object(map, WxMaster.class);
		masters.put(appid, def);
		apis.put(appid, new WxApiImpl(def));
		handlers.put(appid, new BasicWxHandler(def.getToken()));
	}
	for (Entry<String, Object> en : map.entrySet()) {
		String key = en.getKey();
		if (key.endsWith(".openid")) {
			key = key.substring(0, key.indexOf('.'));
			Map<String, Object> tmp = filter(map, key + ".", null, null, null);
			String openid = tmp.get("openid").toString();
			WxMaster one = Lang.map2Object(tmp, WxMaster.class);
			masters.put(openid, one);
			apis.put(openid, new WxApiImpl(one));
			handlers.put(openid, new BasicWxHandler(one.getToken()));
		}
	}
}
 
Example #2
Source File: WxsTest.java    From nutzwx with Apache License 2.0 6 votes vote down vote up
@Test
public void test_ioc_load() throws ClassNotFoundException {
    // 仿真一个配置文件
       PropertiesProxy conf = new PropertiesProxy();
       conf.put("weixin.atstore", "jedis"); // 测试jedisAgent存储AccessToken
       conf.put("weixin.token", "1234567890");
       conf.put("weixin.appid", "wx10927e35a365fe1c");
       conf.put("weixin.appsecret", "c29accd1784e636d6478eac9b6b3aYYY"); // YYY是假的
       conf.put("weixin.openid", "XXX");
       
       // 沙箱测试
    // http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
    NutIoc ioc = new NutIoc(new ComboIocLoader("*weixin", "*jedis"));
    ioc.getIocContext().save("app", "conf", new ObjectProxy(conf));
    
    WxApi2 wxApi2 = ioc.get(WxApi2.class);
    for (int i = 0; i < 6; i++) {
        wxApi2.get_industry();
       }
    ioc.depose();
}
 
Example #3
Source File: NutzSetup.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(NutConfig cfg) {

	// registry jobhandler
	XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler());
	XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler());
	XxlJobExecutor.registJobHandler("httpJobHandler", new HttpJobHandler());
	XxlJobExecutor.registJobHandler("commandJobHandler", new CommandJobHandler());

	// load executor prop
	PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties");

	// init executor
	xxlJobExecutor = new XxlJobExecutor();
	xxlJobExecutor.setAdminAddresses(xxlJobProp.get("xxl.job.admin.addresses"));
	xxlJobExecutor.setAccessToken(xxlJobProp.get("xxl.job.accessToken"));
	xxlJobExecutor.setAppname(xxlJobProp.get("xxl.job.executor.appname"));
	xxlJobExecutor.setAddress(xxlJobProp.get("xxl.job.executor.address"));
	xxlJobExecutor.setIp(xxlJobProp.get("xxl.job.executor.ip"));
	xxlJobExecutor.setPort(xxlJobProp.getInt("xxl.job.executor.port"));
	xxlJobExecutor.setLogPath(xxlJobProp.get("xxl.job.executor.logpath"));
	xxlJobExecutor.setLogRetentionDays(xxlJobProp.getInt("xxl.job.executor.logretentiondays"));

	// start executor
	try {
		xxlJobExecutor.start();
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
}
 
Example #4
Source File: WxLoginImpl.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public WxLoginImpl configure(PropertiesProxy conf, String prefix) {
    prefix = Strings.sBlank(prefix);
    appid = conf.get(prefix + "appid");
    appsecret = conf.get(prefix + "appsecret");
    host = conf.get(prefix + "host");
    return this;
}
 
Example #5
Source File: BasicWxHandler.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public BasicWxHandler configure(PropertiesProxy conf, String prefix){
    prefix = Strings.sBlank(prefix);
    token = conf.check(prefix+"token");
    aeskey = conf.get(prefix+"aes");
    appid = conf.get(prefix+"appid");
    return this;
}
 
Example #6
Source File: AbstractWxApi2.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public WxApi2 configure(PropertiesProxy conf, String prefix) {
    prefix = Strings.sBlank(prefix);
    token = conf.check(prefix + "token");
    appid = conf.get(prefix + "appid");
    appsecret = conf.get(prefix + "appsecret");
    openid = conf.get(prefix + "openid");
    encodingAesKey = conf.get(prefix + "aes");
    return this;
}
 
Example #7
Source File: AbstractRpcRefProxy.java    From nutzcloud with Apache License 2.0 4 votes vote down vote up
public void setConf(PropertiesProxy conf) {
	this.conf = conf;
}