本文整理了Java中org.nutz.ioc.loader.annotation.Inject.<init>()
方法的一些代码示例,展示了Inject.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inject.<init>()
方法的具体详情如下:
包路径:org.nutz.ioc.loader.annotation.Inject
类名称:Inject
方法名:<init>
暂无
代码示例来源:origin: Rekoe/rk_svnadmin
public abstract class AbstractCrossOriginFilter implements ActionFilter {
@Inject
protected PropertiesProxy conf;
@Override
public View match(ActionContext ac) {
if (on()) {
HttpServletResponse response = ac.getResponse();
addHeader(response);
}
return null;
}
protected abstract boolean on();
protected abstract void addHeader(HttpServletResponse response);
}
代码示例来源:origin: Wizzercn/MqttWk
/**
* Created by wizzer on 2018
*/
@IocBean
@Modules(packages = "cn.wizzer.iot")
public class MainLauncher {
private static final Log log = Logs.get();
@Inject("refer:$ioc")
private Ioc ioc;
@Inject
private PropertiesProxy conf;
@Inject
private RedisService redisService;
@Inject
private BrokerServer brokerServer;
public static void main(String[] args) throws Exception {
NbApp nb = new NbApp().setArgs(args).setPrintProcDoc(true);
nb.setMainPackage("cn.wizzer.iot");
nb.run();
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean
public class DubboStarter implements ServerFace {
@Inject("refer:$ioc")
protected Ioc ioc;
@Override
public void start() throws Exception {
ioc.get(DubboManager.class);
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean
public class ActivitiSetupStarter implements ServerFace {
@Inject("refer:$ioc")
protected Ioc ioc;
public void start() throws Exception {
ioc.get(ProcessEngine.class);
}
}
代码示例来源:origin: org.nutz/nutzboot-starter-dubbo
@IocBean
public class DubboStarter implements ServerFace {
@Inject("refer:$ioc")
protected Ioc ioc;
@Override
public void start() throws Exception {
ioc.get(DubboManager.class);
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean
public class CloudConfigureChangeStarter implements ServerFace {
@Inject
protected AppContext appContext;
public void start() throws Exception {
appContext.getBeans(ConfigureEventHandler.class).forEach((listener)->CloudConfig.addListener(listener));
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean(name = "$views_beetl", create = "init")
public class BeetlViewMakerStarter extends BeetlViewMaker {
private static final Log log = Logs.get();
@Inject
protected AppContext appContext;
public BeetlViewMakerStarter() throws IOException {
super();
}
public void init() throws IOException {
if (appContext == null)
return;
log.debug("beetl init ....");
groupTemplate = appContext.getIoc().get(GroupTemplate.class);
render = new WebRender(groupTemplate);
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean
public class MonitorService {
@Inject
protected NbApp nbApp;
protected List<MonitorObject> objs;
public NutMap getMonitors() {
if (objs == null)
objs = nbApp.getAppContext().getBeans(MonitorObject.class);
NutMap re = new NutMap();
for (MonitorObject mon : objs) {
if (!mon.isMonitorEnable())
continue;
re.put(mon.getMonitorName(), mon.getMonitors());
}
return re;
}
}
代码示例来源:origin: nutzam/nutzboot
/**
*
* @Author wendal
*/
@IocBean
public class TioMvcStarter implements ServerFace {
@Inject
private AppContext appContext;
protected HttpServerStarter httpServerStarter;
public void start() throws Exception {
httpServerStarter = appContext.getIoc().get(HttpServerStarter.class);
httpServerStarter.start();
}
public void stop() throws Exception {
if (httpServerStarter != null)
httpServerStarter.stop();
}
}
代码示例来源:origin: nutzam/nutzboot
/**
* @author 黄川 306955302@qq.com
* @date: 2018/8/14
* 描述此类:
*/
@IocBean(create = "init")
public class PreventDuplicateSubmitStarter {
private static final Log log = Logs.get();
@Inject
protected AppContext appContext;
public void init() {
if (appContext != null) {
log.debug("PreventDuplicateSubmitStarter init ....");
try {
PreventDuplicateSubmitProcessor.redisService = appContext.getIoc().getByType(RedisService.class);
} catch (Exception e) {
log.debug("PreventDuplicateSubmitStarter 没有开启Redis采用,将采用session存储");
//如果没有开启Redis就采用session存储,忽略错误
}
}
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean
public class ShardingJdbcDataSourceStarter {
protected static String PRE = "shardingjdbc.";
@PropDoc(group = "shardingjdbc", value = "配置文件路径", defaultValue = "shardingjdbc.yaml")
public static final String PROP_PATH = PRE + "path";
@Inject
protected PropertiesProxy conf;
@Inject
protected AppContext appContext;
@IocBean
public DataSource getDataSource() throws Exception {
String path = conf.get(PROP_PATH, "shardingjdbc.yaml");
InputStream ins = appContext.getResourceLoader().get(path);
if (ins == null) {
File f = new File(path);
if (f.exists() && f.canRead()) {
ins = new FileInputStream(f);
} else {
throw new RuntimeException("no such shardingjdbc configure file=" + path);
}
}
return ShardingDataSourceFactory.createDataSource(Streams.readBytesAndClose(ins));
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean
public TioServer getAioServer(@Inject ServerGroupContext serverGroupContext) {
return new TioServer(serverGroupContext);
}
代码示例来源:origin: nutzam/nutzboot
@IocBean(name = "shiroLcacheCacheManager")
public CacheManager getShiroLcacheCacheManager(@Inject("refer:shiroEhcacheCacheManager") CacheManager shiroEhcacheCacheManager,
@Inject("refer:shiroRedisCacheManager") CacheManager shiroRedisCacheManager) {
LCacheManager cacheManager = new LCacheManager();
cacheManager.setLevel1(shiroEhcacheCacheManager);
cacheManager.setLevel2(shiroRedisCacheManager);
cacheManager.setJedisAgent(ioc.get(JedisAgent.class));
return cacheManager;
}
代码示例来源:origin: nutzam/nutzboot
@IocBean
@Ok("json:full")
@Fail("http:500")
@At("/monitor")
public class MonitorModule {
@Inject
protected MonitorService monitorService;
@At
public NutMap data() {
return monitorService.getMonitors();
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean(name = "zmodb")
public ZMoDB getZMoDB(@Inject ZMongo zmongo) {
String dbname = conf.get(PROP_DBNAME);
if (Strings.isBlank(dbname))
throw Lang.makeThrow("not config mongo.dbname!");
return zmongo.db(dbname);
}
代码示例来源:origin: nutzam/nutzboot
@IocBean(name = "beetlsqlManager")
public SQLManager creatSQLManager(@Inject("refer:beetlsqlDBStyle") DBStyle dbStyle,
@Inject("beetlsqlConnectionSource") ConnectionSource ds) {
// BeetlSql默认/sql/,但NutzBoot的约定是/sqls/,入乡随俗吧
SQLLoader loader = new ClasspathLoader(conf.get(PROP_PATH, "/sqls/"));
// TODO 支持更多种类的NameConversion
NameConversion nameconv = "default".equals(conf.get(PROP_NAME_CONVERSION, "default"))
? new DefaultNameConversion()
: new UnderlinedNameConversion();
// 是否插入debug拦截器呢? 默认启用好了
if (conf.getBoolean(PROP_DEBUG, true))
return new SQLManager(dbStyle, loader, ds, nameconv, new Interceptor[] { new DebugInterceptor() });
return new SQLManager(dbStyle, loader, ds, nameconv);
}
}
代码示例来源:origin: nutzam/nutzboot
@IocBean(name = "beetlsqlConnectionSource")
public ConnectionSource createConnectionSource(@Inject DataSource dataSource) {
DataSource[] slaves = null;
if (Lang.loadClassQuite("org.nutz.boot.starter.jdbc.DataSourceStarter") != null) {
DataSource slaveDataSource = DataSourceStarter.getSlaveDataSource(ioc, conf, "jdbc.slave.");
if (slaveDataSource != null)
slaves = new DataSource[] {slaveDataSource};
}
if (conf.getBoolean(PROP_TRANS, true)) {
// 默认事务管理,就是没有管理
return new DefaultConnectionSource(dataSource, slaves);
}
// 支持 Trans.exec 或者 @Aop(TransAop.READ_COMMITTED)
return new NutzConnectionSource(dataSource, slaves);
}
代码示例来源:origin: nutzam/nutzboot
@IocBean(name="serverGroupContext")
public ServerGroupContext getServerGroupContext(@Inject ServerAioHandler serverAioHandler,
@Inject ServerAioListener serverAioListener) throws Exception {
ServerGroupContext serverGroupContext = new ServerGroupContext(serverAioHandler, serverAioListener);
serverGroupContext.setName(conf.get(PROP_NAME, "NutzBoot GroupContext"));
serverGroupContext.setHeartbeatTimeout(0);
if ("true".equals(conf.get(PROP_HEARTBEAT))) {
serverGroupContext.setHeartbeatTimeout(conf.getLong(PROP_HEARTBEATTIMEOUT, 120000));
}
if (!Strings.isBlank(conf.get(PROP_SSL_KEYSTORE_PATH))) {
SslConfig ssl = SslConfig.forServer(Files.findFileAsStream(conf.get(PROP_SSL_KEYSTORE_PATH)), null, conf.get(PROP_SSL_KEYSTORE_PASSWORD));
serverGroupContext.setSslConfig(ssl);
}
return serverGroupContext;
}
代码示例来源:origin: nutzam/nutzboot
/**
* 同步阻塞客户端, 然后它不支持通过MqttAsyncClient来构建,真蛋疼
*/
@IocBean(name = "mqttClient", depose = "close")
public MqttClient createMqttClient(@Inject MqttConnectOptions mqttConnectOptions, @Inject MqttClientPersistence mqttClientPersistence) throws MqttException {
String clientId = conf.get(PROP_CLIENT_ID);
if (Strings.isBlank(clientId)) {
clientId = MqttClient.generateClientId();
}
log.info("Client Id = " + clientId);
MqttClient client = new MqttClient(conf.get(PROP_URL, "tcp://127.0.0.1:1883"), clientId, mqttClientPersistence);
if (ioc.has("mqttCallback")) {
client.setCallback(ioc.get(MqttCallback.class, "mqttCallback"));
}
client.setTimeToWait(conf.getLong(PROP_TIME_TO_WAIT, -1));
if (conf.getBoolean(PROP_CONNECT_ON_START, true)) {
IMqttToken token = client.connectWithResult(mqttConnectOptions);
if (token.getException() != null)
throw token.getException();
}
return client;
}
代码示例来源:origin: nutzam/nutzboot
/**
* 异步客户端
*/
@IocBean(name = "mqttAsyncClient", depose = "close")
public MqttAsyncClient createMqttAsyncClient(@Inject MqttConnectOptions mqttConnectOptions, @Inject MqttClientPersistence mqttClientPersistence) throws MqttException {
String clientId = conf.get(PROP_CLIENT_ID);
if (Strings.isBlank(clientId)) {
clientId = MqttClient.generateClientId();
}
log.info("Client Id = " + clientId);
MqttAsyncClient client = new MqttAsyncClient(conf.get(PROP_URL, "tcp://127.0.0.1:1883"), clientId, mqttClientPersistence);
if (ioc.has("mqttCallback")) {
client.setCallback(ioc.get(MqttCallback.class, "mqttCallback"));
}
if (conf.getBoolean(PROP_CONNECT_ON_START, true)) {
IMqttToken token = client.connect(mqttConnectOptions, null, null);
token.waitForCompletion(conf.getLong(PROP_TIME_TO_WAIT, -1));
if (token.getException() != null)
throw token.getException();
}
return client;
}
}
内容来源于网络,如有侵权,请联系作者删除!