AbstractComponent -> AbstractComponent, AbstractBean

master
mjkhan21 6 months ago
parent 65fe60fe57
commit ea4939df1c

@ -1,68 +1,18 @@
package cokr.xit.foundation;
import java.util.Date;
import java.util.function.Supplier;
import javax.annotation.Resource;
import org.egovframe.rte.fdl.property.EgovPropertyService;
import org.springframework.context.MessageSource;
import cokr.xit.foundation.data.Convert;
/** .
/** .
* <p>AbstractComponent
* <ul><li>{@link Assert}</li>
* <li>{@link #log() } </li>
* <li>{@link #currentAccess() }</li>
* <li>{@link #currentUser() }</li>
* <li>{@link #properties }</li>
* <li>{@link #message(String, String...) }</li>
* <li>{@link Convert}</li>
* </ul>
* .
* <p>AbstractComponent ' ' + 'Bean' .<br />
* , @Component .<br />
* .
* <pre> package cokr.xit.example.business.service.bean;
* {@code @Component("businessBean")}
* public class BusinessBean extends AbstractComponent {
* ...
* }</pre>
* <p> @Resource .
* <pre><code> @Resource(name = "businessBean")
* BusinessBean businessBean;</code></pre>
* @author mjkhan
*/
public class AbstractComponent {
/** 프로퍼티 서비스 */
@Resource(name="propertyService")
protected EgovPropertyService properties;
/** 메시지 소스 */
@Resource(name="messageSource")
protected MessageSource messages;
private String logName;
/** .
* @param logName
*/
public void setLogName(String logName) {
this.logName = logName;
}
/** .
* @param <T>
* @return
*/
protected <T extends UserInfo> T currentUser() {
return UserInfo.current();
}
/** .
* @return
*/
protected static Access currentAccess() {
return Access.current();
}
/**lv rv .
* @param lv
* @param rv
@ -149,27 +99,6 @@ public class AbstractComponent {
return Convert.toBoolean(obj);
}
/** key args .
* @param key key
* @param args
* @return
*/
protected String message(String key, String... args) {
return messages.getMessage(key, ifEmpty(args, () -> null), "", currentAccess().getLocale());
}
/**t t .
* t , NullPointerException , message-common 'valueRequired' .
* @param <T>
* @param t
* @param name assertion
* @return t
*/
protected final <T> T required(T t, String name) {
if (!isEmpty(t)) return t;
throw new NullPointerException(message("valueRequired", name));
}
/**{@link Assert#rootCause(Throwable)}
*/
protected static final Throwable rootCause(Throwable t) {
@ -200,16 +129,7 @@ public class AbstractComponent {
* @return Log
*/
protected Log log() {
return isEmpty(logName) ? log(getClass()) : Log.get(logName);
}
/** Date Date .
* @param date
* @param days
* @return Date
*/
protected static Date dateDiff(Date date, int days) {
return new Date(date.getTime() + (1000L * 60L * 60L * 24L * days));
return log(getClass());
}
/** .

@ -1,3 +1,103 @@
package cokr.xit.foundation.component;
public abstract class AbstractBean extends ManagedComponent {}
import java.util.Date;
import javax.annotation.Resource;
import org.egovframe.rte.fdl.property.EgovPropertyService;
import org.springframework.context.MessageSource;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.Access;
import cokr.xit.foundation.Log;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.util.DateFormats;
/**spring framework .
* <p>AbstractBean
* <ul><li>{@link #currentAccess() }</li>
* <li>{@link #currentUser() }</li>
* <li>{@link #properties }</li>
* <li>{@link #message(String, String...) }</li>
* </ul>
* .
* <p>AbstractBean ' ' + 'Bean' .<br />
* , @Component .<br />
* .
* <pre> package cokr.xit.example.business.service.bean;
* {@code @Component("businessBean")}
* public class BusinessBean extends AbstractBean {
* ...
* }</pre>
* <p> @Resource .
* <pre><code> @Resource(name = "businessBean")
* BusinessBean businessBean;</code></pre>
*/
public abstract class AbstractBean extends AbstractComponent {
/** 프로퍼티 서비스 */
@Resource(name="propertyService")
protected EgovPropertyService properties;
/** 메시지 소스 */
@Resource(name="messageSource")
protected MessageSource messages;
/** 날짜 포맷 모음 */
protected DateFormats dateFormats = new DateFormats();
private String logName;
/** .
* @param logName
*/
public void setLogName(String logName) {
this.logName = logName;
}
/** .
* @param <T>
* @return
*/
protected <T extends UserInfo> T currentUser() {
return UserInfo.current();
}
/** .
* @return
*/
protected static Access currentAccess() {
return Access.current();
}
/** key args .
* @param key key
* @param args
* @return
*/
protected String message(String key, String... args) {
return messages.getMessage(key, ifEmpty(args, () -> null), "", currentAccess().getLocale());
}
/**t t .
* t , NullPointerException , message-common 'valueRequired' .
* @param <T>
* @param t
* @param name assertion
* @return t
*/
protected final <T> T required(T t, String name) {
if (!isEmpty(t)) return t;
throw new NullPointerException(message("valueRequired", name));
}
@Override
protected Log log() {
return isEmpty(logName) ? super.log() : Log.get(logName);
}
/** Date Date .
* @param date
* @param days
* @return Date
*/
protected static Date dateDiff(Date date, int days) {
return new Date(date.getTime() + (1000L * 60L * 60L * 24L * days));
}
}

@ -1,68 +0,0 @@
package cokr.xit.foundation.component;
import javax.annotation.Resource;
import org.egovframe.rte.fdl.property.EgovPropertyService;
import org.springframework.context.MessageSource;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.Access;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.util.DateFormats;
/**spring framework .
* <p>ManagedComponent
* <ul><li>{@link #currentAccess() }</li>
* <li>{@link #currentUser() }</li>
* <li>{@link #properties }</li>
* <li>{@link #message(String, String...) }</li>
* </ul>
* .
* <p>ManagedComponent ' ' + 'Bean' .<br />
* , @Component .<br />
* .
* <pre> package cokr.xit.example.business.service.bean;
* {@code @Component("businessBean")}
* public class BusinessBean extends ManagedComponent {
* ...
* }</pre>
* <p> @Resource .
* <pre><code> @Resource(name = "businessBean")
* BusinessBean businessBean;</code></pre>
*/
public class ManagedComponent extends AbstractComponent {
/** 프로퍼티 서비스 */
@Resource(name="propertyService")
protected EgovPropertyService properties;
/** 메시지 소스 */
@Resource(name="messageSource")
protected MessageSource messages;
/** 날짜 포맷 모음 */
protected DateFormats dateFormats = new DateFormats();
/** .
* @param <T>
* @return
*/
@Override
protected <T extends UserInfo> T currentUser() {
return UserInfo.current();
}
/** .
* @return
*/
protected static Access currentAccess() {
return Access.current();
}
/** key args .
* @param key key
* @param args
* @return
*/
@Override
protected String message(String key, String... args) {
return messages.getMessage(key, ifEmpty(args, () -> null), "", currentAccess().getLocale());
}
}

@ -21,7 +21,7 @@ import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.component.AbstractBean;
/** MyBatis Interceptor
* @author mjkhan
@ -40,7 +40,7 @@ import cokr.xit.foundation.AbstractComponent;
@Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})
})
public class MybatisPlugin extends AbstractComponent implements Interceptor {
public class MybatisPlugin extends AbstractBean implements Interceptor {
protected Properties properties;
@Override

@ -13,10 +13,10 @@ import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.Access;
import cokr.xit.foundation.Assert;
import cokr.xit.foundation.Downloadable;
import cokr.xit.foundation.component.AbstractBean;
import cokr.xit.foundation.component.QueryRequest;
import cokr.xit.foundation.data.paging.BoundedList;
@ -42,7 +42,7 @@ import cokr.xit.foundation.data.paging.BoundedList;
* .
* @author mjkhan
*/
public abstract class AbstractController extends AbstractComponent {
public abstract class AbstractController extends AbstractBean {
@Resource(name="objectMapper")
private ObjectMapper objectMapper;

Loading…
Cancel
Save