use of jakarta.annotation.PostConstruct in project starshop by beautautumn.
the class WxConfiguration method init.
@PostConstruct
public void init() {
List<WxMiniAppProperties.Config> configs = this.properties.getConfigs();
if (configs == null) {
throw new RuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!");
}
maServices = configs.stream().map(a -> {
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
config.setAppid(a.getAppid());
config.setSecret(a.getSecret());
config.setToken(a.getToken());
config.setAesKey(a.getAesKey());
config.setMsgDataFormat(a.getMsgDataFormat());
WxMaService service = new WxMaServiceImpl();
service.setWxMaConfig(config);
routers.put(a.getAppid(), this.newRouter(service));
return service;
}).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a));
}
use of jakarta.annotation.PostConstruct in project core by weld.
the class PopulateDatabase method startup.
@PostConstruct
public void startup() {
try {
String fileContent = readFileData(DATA_FILE_NAME);
StringTokenizer st = new StringTokenizer(fileContent, "'");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
while (st.countTokens() > 1) {
CodeFragment c = new CodeFragment();
st.nextToken();
c.setDatetime(formatter.parse(st.nextToken()));
st.nextToken();
c.setLanguage(Language.valueOf(st.nextToken()));
st.nextToken();
st.nextToken();
st.nextToken();
c.setUser(st.nextToken());
st.nextToken();
c.setText(st.nextToken());
// Manual TX control, commit each record independently
entityManager.persist(c);
}
} catch (Exception e) {
log.log(Level.WARNING, "Unable to read all records from " + DATA_FILE_NAME + " file", e);
}
log.info("Successfully imported data!");
}
use of jakarta.annotation.PostConstruct in project myfaces by apache.
the class ClientWindowScopeContextualStorageHolder method init.
@PostConstruct
@Override
public void init() {
super.init();
FacesContext facesContext = FacesContext.getCurrentInstance();
Integer numberOfClientWindowsInSession = MyfacesConfig.getCurrentInstance(facesContext).getNumberOfClientWindows();
clientWindowExpirationStack = new LRULinkedHashMap<>(numberOfClientWindowsInSession, (eldest) -> {
destroyAll(FacesContext.getCurrentInstance(), eldest.getKey());
});
pushClientWindow(facesContext, facesContext.getExternalContext().getClientWindow());
}
use of jakarta.annotation.PostConstruct in project myfaces by apache.
the class AbstractContextualStorageHolder method init.
@PostConstruct
public void init() {
storageMap = new ConcurrentHashMap<>();
FacesContext facesContext = FacesContext.getCurrentInstance();
Object context = facesContext.getExternalContext().getContext();
if (context instanceof ServletContext) {
FacesApplicationArtifactHolder appBean = CDIUtils.get(beanManager, FacesApplicationArtifactHolder.class);
if (appBean.getServletContext() != null) {
appBean.setServletContext((ServletContext) context);
}
}
}
use of jakarta.annotation.PostConstruct in project myfaces by apache.
the class FlowScopeContextualStorageHolder method init.
@PostConstruct
@Override
public void init() {
super.init();
activeFlowMapKeys = new ConcurrentHashMap<>();
FacesContext facesContext = FacesContext.getCurrentInstance();
Integer numberOfClientWindowsInSession = MyfacesConfig.getCurrentInstance(facesContext).getNumberOfClientWindows();
clientWindowExpirationStack = new LRULinkedHashMap<>(numberOfClientWindowsInSession, (eldest) -> {
clearFlowMap(FacesContext.getCurrentInstance(), eldest.getKey());
});
refreshClientWindow(facesContext);
}
Aggregations