diff --git a/.classpath b/.classpath
deleted file mode 100644
index cf81d48..0000000
--- a/.classpath
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
index 7ed7b1c..a0ab1af 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
-/bin/
-<<<<<<< HEAD
-/target/
-=======
-/target
->>>>>>> 4d33b120c4e9b0cc0e23dd32b7e352b99d17350c
+**/target/*
+.idea
+**/*.iml
+*.iml
+/jdk-study/*.iml
diff --git a/.gitignore.BASE.gitignore b/.gitignore.BASE.gitignore
deleted file mode 100644
index ae3c172..0000000
--- a/.gitignore.BASE.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/bin/
diff --git a/.gitignore.LOCAL.gitignore b/.gitignore.LOCAL.gitignore
deleted file mode 100644
index 09e3bc9..0000000
--- a/.gitignore.LOCAL.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin/
-/target/
diff --git a/.gitignore.REMOTE.gitignore b/.gitignore.REMOTE.gitignore
deleted file mode 100644
index e0e1cc4..0000000
--- a/.gitignore.REMOTE.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin/
-/target
diff --git a/.idea/libraries/Maven__com_google_guava_guava_18_0.xml b/.idea/libraries/Maven__com_google_guava_guava_18_0.xml
deleted file mode 100644
index 967a097..0000000
--- a/.idea/libraries/Maven__com_google_guava_guava_18_0.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml b/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml
deleted file mode 100644
index 0e57856..0000000
--- a/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_10.xml b/.idea/libraries/Maven__junit_junit_4_10.xml
deleted file mode 100644
index 58342e5..0000000
--- a/.idea/libraries/Maven__junit_junit_4_10.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__log4j_log4j_1_2_17.xml b/.idea/libraries/Maven__log4j_log4j_1_2_17.xml
deleted file mode 100644
index 354599b..0000000
--- a/.idea/libraries/Maven__log4j_log4j_1_2_17.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_0.xml b/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_0.xml
deleted file mode 100644
index 6656636..0000000
--- a/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_0.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_1.xml b/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_1.xml
deleted file mode 100644
index 4ccc14b..0000000
--- a/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_1.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml
deleted file mode 100644
index 57da5a5..0000000
--- a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jboss_weld_se_weld_se_2_2_6_Final.xml b/.idea/libraries/Maven__org_jboss_weld_se_weld_se_2_2_6_Final.xml
deleted file mode 100644
index 9755096..0000000
--- a/.idea/libraries/Maven__org_jboss_weld_se_weld_se_2_2_6_Final.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mozilla_rhino_1_7R4.xml b/.idea/libraries/Maven__org_mozilla_rhino_1_7R4.xml
deleted file mode 100644
index 4cff9ad..0000000
--- a/.idea/libraries/Maven__org_mozilla_rhino_1_7R4.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.project b/.project
deleted file mode 100644
index 23bd0d0..0000000
--- a/.project
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
- study_java_8
-
-
-
-
-
- org.eclipse.wst.common.project.facet.core.builder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
-
- org.eclipse.m2e.core.maven2Nature
- org.eclipse.jdt.core.javanature
- org.eclipse.wst.common.project.facet.core.nature
-
-
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 13b3428..0000000
--- a/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,13 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
deleted file mode 100644
index f897a7f..0000000
--- a/.settings/org.eclipse.m2e.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
deleted file mode 100644
index ab295be..0000000
--- a/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/java-ee-study/pom.xml b/java-ee-study/pom.xml
new file mode 100644
index 0000000..f2bc113
--- /dev/null
+++ b/java-ee-study/pom.xml
@@ -0,0 +1,40 @@
+
+
+
+ java-study
+ java-study
+ 0.1.2
+
+ 4.0.0
+
+ java-ee-study
+ 0.1.2
+
+
+
+ javax.enterprise
+ cdi-api
+ 2.0.SP1
+
+
+
+ org.jboss.weld.se
+ weld-se-core
+ 3.1.2.Final
+
+
+ java-study
+ jdk-study
+ 0.1.2
+ test
+
+
+
+ javax.validation
+ validation-api
+ LATEST
+
+
+
\ No newline at end of file
diff --git a/java-ee-study/src/test/java/study/commons/MiscUtils.java b/java-ee-study/src/test/java/study/commons/MiscUtils.java
new file mode 100644
index 0000000..0369721
--- /dev/null
+++ b/java-ee-study/src/test/java/study/commons/MiscUtils.java
@@ -0,0 +1,468 @@
+package study.commons;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.collections4.iterators.ObjectArrayIterator;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.CharUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import java.io.*;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.MathContext;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.file.StandardOpenOption;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.*;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+public class MiscUtils {
+ public static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors();
+
+ public static long getPropertyNumber(String name, long defaultValue) {
+ String str = System.getProperty(name);
+ if (StringUtils.isNumeric(str)) {
+ return Long.parseLong(str);
+ }
+ return defaultValue;
+ }
+
+ public static String invocationInfo() {
+ StackTraceElement[] ste = Thread.currentThread().getStackTrace();
+ int i = 2;
+ return String.format("%s\t%s.%s", ste[i].getFileName(), ste[i].getClassName(), ste[i].getMethodName());
+ }
+
+ public static String invocInfo() {
+ StackTraceElement[] ste = Thread.currentThread().getStackTrace();
+ int i = 2;
+ return String.format("%s\t%s.%s", ste[i].getFileName(), StringUtils.substringAfterLast(ste[i].getClassName(), "."), ste[i].getMethodName());
+ }
+
+ public static String invocationInfo(final int i) {
+ StackTraceElement[] ste = Thread.currentThread().getStackTrace();
+ return String.format("%s\t%s.%s", ste[i].getFileName(), ste[i].getClassName(), ste[i].getMethodName());
+ }
+
+ public static String byteCountToDisplaySize(long size) {
+ if (size > 1073741824L) return String.valueOf(size / 1073741824L) + " GB";
+ if (size > 1048576L) return String.valueOf(size / 1048576L) + " MB";
+ if (size > 1024L) return String.valueOf(size / 1024L) + " KB";
+ return String.valueOf(size) + " bytes";
+ }
+
+ public static List pi2Longs(Integer n) {
+ return pi(n).toString().substring(0, n).chars().filter(i -> CharUtils.isAsciiNumeric((char) i)).map(i -> i - 48).mapToObj(Long::valueOf).collect(Collectors.toList());
+ }
+
+ public static List pi2Longs(Integer n, int range) {
+ List nums = pi2Longs(n);
+ List _nums = new ArrayList<>();
+ Random rand = new Random();
+ for (ListIterator it = nums.listIterator(); it.hasNext(); ) {
+ Long num = it.next();
+ for (int i = 0, step = rand.nextInt(range); i < step && it.hasNext(); i++) {
+ num = num * 10 + it.next();
+ }
+// System.out.println(step + "\t" + num);
+ _nums.add(num);
+ }
+ return _nums;
+ }
+
+ public static BigDecimal pi(Integer n) {
+ if (n == null) {
+ n = 0;
+ }
+
+ if (n == 0)
+ return null;
+ if (n == 1)
+ return new BigDecimal(3);
+ if (n == 2)
+ return new BigDecimal(3.1);
+ if (n == 3)
+ return new BigDecimal(3.14);
+
+ MathContext mc = new MathContext(n);
+ BigDecimal pi = new BigDecimal(BigInteger.ZERO, n, mc);
+ BigDecimal one = new BigDecimal(BigInteger.ONE, n, mc);
+ BigDecimal two = new BigDecimal(new BigInteger("2"), n, mc);
+ BigDecimal four = new BigDecimal(new BigInteger("4"), n, mc);
+ for (int k = 0; k < n; k++) {
+ BigDecimal tmp1 = one.divide(new BigDecimal(16).pow(k, mc), mc);
+
+ BigDecimal tmp2_1 = four.divide(new BigDecimal(8 * k + 1, mc), mc);
+ BigDecimal tmp2_2 = two.divide(new BigDecimal(8 * k + 4, mc), mc);
+ BigDecimal tmp2_3 = one.divide(new BigDecimal(8 * k + 5, mc), mc);
+ BigDecimal tmp2_4 = one.divide(new BigDecimal(8 * k + 6, mc), mc);
+
+ BigDecimal tmp2 = tmp2_1.subtract(tmp2_2, mc).subtract(tmp2_3, mc).subtract(tmp2_4, mc);
+ pi = pi.add(tmp1.multiply(tmp2, mc));
+ }
+
+ // pi.setScale(n, BigDecimal.ROUND_UP);
+ pi.scaleByPowerOfTen(n);
+
+ return pi;
+ }
+
+ public static long getProcessId() {
+ // Note: may fail in some JVM implementations
+ // therefore fallback has to be provided
+
+ // something like '@', at least in SUN / Oracle JVMs
+ final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
+ final int index = jvmName.indexOf('@');
+ String pidStr = jvmName.substring(0, index);
+
+ if (index < 1 || !NumberUtils.isNumber(pidStr)) {
+ // part before '@' empty (index = 0) / '@' not found (index = -1)
+ return 0;
+ }
+
+ return Long.parseLong(pidStr);
+ }
+
+ public static void easySleep(long i) {
+ try {
+ Thread.sleep(i);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ public static String stackInfo() {
+ final StringBuilder sb = new StringBuilder();
+ final StackTraceElement[] stes = Thread.currentThread().getStackTrace();
+ ArrayUtils.reverse(stes);
+ Stream.of(stes).forEach(ste -> sb.append(String.format("%s\t%s.%s\n", ste.getFileName(), ste.getClassName(), ste.getMethodName())));
+ return sb.toString();
+ }
+
+ public static String now() {
+ return DateFormatUtils.format(Calendar.getInstance(), "yy-MM-dd hh:mm:ss");
+ }
+
+ public static String toBinStr(final byte _b) {
+ final StringBuilder sb = new StringBuilder();
+ for (byte i = 7; i >= 0; i--) {
+ sb.append((_b & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(final int _i) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(_i < 0 ? 1 : 0);
+ for (byte i = 31; i >= 0; i--) {
+ sb.append((_i & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(final short _s) {
+ final StringBuilder sb = new StringBuilder();
+ for (byte i = 16; i >= 0; i--) {
+ sb.append((_s & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(long _l) {
+ final StringBuilder sb = new StringBuilder();
+ for (byte i = 64; i >= 0; i--) {
+ sb.append((_l & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static class LoopingArrayIterator extends ObjectArrayIterator {
+ @SafeVarargs
+ public LoopingArrayIterator(final E... array) {
+ super(array, 0, array.length);
+ }
+
+ public LoopingArrayIterator(final E array[], final int start) {
+ super(array, start, array.length);
+ }
+
+ public E loop() {
+ final E[] array = this.getArray();
+ loopIdx.compareAndSet(array.length, 0);
+ return array[loopIdx.getAndIncrement() % array.length];
+ }
+
+ private AtomicInteger loopIdx = new AtomicInteger();
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static Map map(Object... keyAndVals) {
+ return MapUtils.putAll(new HashMap(), keyAndVals);
+ }
+
+ public static long HOST_HASH = System.currentTimeMillis();
+
+ static {
+ try {
+ HOST_HASH = InetAddress.getLocalHost().getHostAddress().hashCode();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static long uniqueLong() {
+ return Math.abs(UUID.randomUUID().hashCode());
+ }
+
+ public static ThreadFactory namedThreadFactory(final String name) {
+ return new BasicThreadFactory.Builder().namingPattern(name + "_%d").build();
+ }
+
+ public static String lineNumber(final String str) {
+ if (str == null) {
+ return null;
+ }
+
+ final StringReader sr = new StringReader(str);
+ final BufferedReader br = new BufferedReader(sr);
+
+ final StringBuilder sb = new StringBuilder(0);
+ AtomicLong lineNumber = new AtomicLong(0);
+ br.lines().forEach(line -> sb.append(lineNumber.incrementAndGet()).append("\t").append(line).append('\n'));
+
+ return sb.toString();
+ }
+
+ private static final Logger log = LoggerFactory.getLogger(MiscUtils.class);
+
+ public static String mapToJson(Map paramMap) {
+ if (MapUtils.isEmpty(paramMap)) {
+ return "{}";
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(paramMap);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ return paramMap.toString();
+ }
+ }
+
+ public static String toXML(final Object bean) {
+ final StringWriter sw = new StringWriter();
+
+ try {
+ JAXBContext jc = JAXBContext.newInstance(bean.getClass());
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FRAGMENT, true);
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.marshal(bean, sw);
+ } catch (Exception e) {
+ log.error(String.valueOf(bean), e);
+ }
+ return sw.toString();
+ }
+
+ public static T toObj(final String xmlStr, final Class cls) {
+ if (StringUtils.isBlank(xmlStr) || cls == null) {
+ return null;
+ }
+
+ try {
+ JAXBContext jc = JAXBContext.newInstance(cls);
+ Unmarshaller um = jc.createUnmarshaller();
+ return um.unmarshal(new StreamSource(new StringReader(xmlStr)), cls).getValue();
+ } catch (JAXBException e) {
+ log.error(xmlStr, e);
+ }
+
+ return null;
+ }
+
+// public static Map extractParams(MultivaluedMap params) {
+// Map paramsMap = new HashMap();
+// params.keySet().forEach(key -> paramsMap.put(key, params.getFirst(key)));
+// return paramsMap;
+// }
+//
+// public static Map toParamMap(MultivaluedMap params) {
+// Map paramsMap = new HashMap();
+// params.keySet().forEach(key -> paramsMap.put(key, params.get(key).toArray(new String[0])));
+// return paramsMap;
+// }
+
+ public static Map extractParams(Map params) {
+ Map paramsMap = new HashMap();
+ params.keySet().forEach(key -> {
+ final String[] vals = params.get(key);
+ paramsMap.put(key, ArrayUtils.isEmpty(vals) ? null : vals[0]);
+ });
+ return paramsMap;
+ }
+
+ public static String generate(final String text) {
+ final StringBuffer sb = new StringBuffer();
+ try {
+ final byte[] intext = text.getBytes();
+ final MessageDigest md5 = MessageDigest.getInstance("MD5");
+ final byte[] md5rslt = md5.digest(intext);
+ for (int i = 0; i < md5rslt.length; i++) {
+ final int val = 0xff & md5rslt[i];
+ if (val < 16) {
+ sb.append("0");
+ }
+ sb.append(Integer.toHexString(val));
+ }
+ } catch (final Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ return sb.toString();
+ }
+
+ public static String loadResAsString(final Class> cls, final String fileName) {
+ if (cls == null || StringUtils.isBlank(fileName)) {
+ return StringUtils.EMPTY;
+ }
+
+ try {
+ return IOUtils.toString(cls.getClassLoader().getResourceAsStream(fileName));
+ } catch (IOException e) {
+ log.error("", e);
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static String getEncodedText(String plainText) {
+ String encodedPassword = null;
+ try {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(plainText.getBytes());
+ encodedPassword = new String(Hex.encodeHex(md.digest()));
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ return encodedPassword;
+ }
+
+ public static void writeToMappedFile(File file, byte[] data) throws IOException {
+ try (FileChannel fc = FileChannel.open(file.toPath(), StandardOpenOption.WRITE, StandardOpenOption.READ)) {
+ MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, data.length);
+ mbb.put(data);
+ mbb.force();
+ }
+ }
+
+ public static byte[] readFromMappedFile(File file) throws IOException {
+ try (FileChannel fc = FileChannel.open(file.toPath(), StandardOpenOption.READ)) {
+ long length = file.length();
+ MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, length);
+ if (!mbb.load().isLoaded()) {
+ throw new IllegalStateException(String.format("%s can not be loaded", file.getAbsolutePath()));
+ }
+
+ byte[] data = new byte[(int) length];
+ mbb.get(data);
+ return data;
+ }
+ }
+
+ public static Class[] getParameterizedClzz(Type type) {
+ if (type == null) return null;
+ if (type instanceof Class) {
+ Class aClass = (Class) type;
+ return new Class[]{aClass};
+ }
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
+ return Stream.of(pt.getActualTypeArguments()).filter(_type -> _type instanceof Class).toArray(Class[]::new);
+ }
+ return null;
+ }
+
+ public static HttpResponse easyGet(String urlStr, String... params) {
+ if (StringUtils.isBlank(urlStr)) {
+ return null;
+ }
+
+ try (CloseableHttpClient hc = HttpClients.createDefault()) {
+ URIBuilder ub = new URIBuilder(urlStr);
+ if (!ArrayUtils.isEmpty(params)) {
+ IntStream.range(0, params.length).filter(i -> i % 2 == 1).forEach(i -> ub.addParameter(params[i - 1], params[i]));
+ }
+
+ HttpGet hg = new HttpGet(ub.build());
+ try (CloseableHttpResponse hr = hc.execute(hg)) {
+ BasicHttpResponse bhr = new BasicHttpResponse(hr.getStatusLine());
+ bhr.setEntity(new InputStreamEntity(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity()))));
+ return bhr;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static HttpResponse easyPost(String urlStr, String... params) {
+ if (StringUtils.isBlank(urlStr)) {
+ return null;
+ }
+
+ try (CloseableHttpClient hc = HttpClients.createDefault()) {
+ URIBuilder ub = new URIBuilder(urlStr);
+ HttpPost hp = new HttpPost(ub.build());
+ List nvps = new ArrayList();
+ if (!ArrayUtils.isEmpty(params)) {
+ IntStream.range(0, params.length).filter(i -> i % 2 == 1).forEach(i -> nvps.add(new BasicNameValuePair(params[i - 1], params[i])));
+ }
+ hp.setEntity(new UrlEncodedFormEntity(nvps));
+
+ try (CloseableHttpResponse hr = hc.execute(hp)) {
+ BasicHttpResponse bhr = new BasicHttpResponse(hr.getStatusLine());
+ bhr.setEntity(new InputStreamEntity(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity()))));
+ return bhr;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/java-ee-study/src/test/java/study/javax/cdi/weld/WeldTests.java b/java-ee-study/src/test/java/study/javax/cdi/weld/WeldTests.java
new file mode 100644
index 0000000..67b0e49
--- /dev/null
+++ b/java-ee-study/src/test/java/study/javax/cdi/weld/WeldTests.java
@@ -0,0 +1,60 @@
+package study.javax.cdi.weld;
+
+import org.jboss.weld.context.RequestContext;
+import org.jboss.weld.context.unbound.UnboundLiteral;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
+import org.junit.jupiter.api.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import study.javax.cdi.weld.beans.AppBean;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.CDI;
+
+public class WeldTests {
+ static final Logger log = LoggerFactory.getLogger(WeldTests.class);
+
+ public static Weld weld;
+ public static WeldContainer container;
+ public static BeanManager bm;
+ @SuppressWarnings("rawtypes")
+ public static CDI _CDI;
+
+ @BeforeAll
+ public static void setUp() {
+ try {
+ weld = new Weld();
+ container = weld.initialize();
+ bm = container.getBeanManager();
+ _CDI = CDI.current();
+ } catch (final Exception e) {
+ log.error("failed to initiate...", e);
+ System.exit(-1);
+ }
+ }
+
+ @AfterAll
+ public static void tearDown() {
+ if (weld != null)
+ weld.shutdown();
+ }
+
+ @BeforeEach
+ public void activateCtx() {
+ RequestContext reqCtx = (RequestContext) _CDI.select(RequestContext.class, UnboundLiteral.INSTANCE).get();
+ reqCtx.activate();
+ }
+
+ public static T getBean(Class cls) {
+ return CDI.current().select(cls).get();
+ }
+
+ @Test
+ public void testCDI() {
+ AppBean app = getBean(AppBean.class);
+ Assertions.assertNotNull(app);
+ log.info("AppBean:\t{}", app);
+ }
+
+}
diff --git a/java-ee-study/src/test/java/study/javax/cdi/weld/beans/AppBean.java b/java-ee-study/src/test/java/study/javax/cdi/weld/beans/AppBean.java
new file mode 100644
index 0000000..9eb345d
--- /dev/null
+++ b/java-ee-study/src/test/java/study/javax/cdi/weld/beans/AppBean.java
@@ -0,0 +1,8 @@
+package study.javax.cdi.weld.beans;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class AppBean extends BaseBean {
+
+}
diff --git a/java-ee-study/src/test/java/study/javax/cdi/weld/beans/BaseBean.java b/java-ee-study/src/test/java/study/javax/cdi/weld/beans/BaseBean.java
new file mode 100644
index 0000000..e7043ea
--- /dev/null
+++ b/java-ee-study/src/test/java/study/javax/cdi/weld/beans/BaseBean.java
@@ -0,0 +1,67 @@
+package study.javax.cdi.weld.beans;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import study.commons.MiscUtils;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.Dependent;
+import javax.inject.Inject;
+import java.util.Objects;
+
+@Dependent
+public class BaseBean {
+ static final Logger log = LoggerFactory.getLogger(BaseBean.class);
+ protected Long createdTime = System.currentTimeMillis();
+ @Inject
+ protected Long id;
+
+ protected String name;
+
+ public Long getCreatedTime() {
+ return createdTime;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @PostConstruct
+ public void postConstruct() {
+ log.info(MiscUtils.invocationInfo() + "\n\t" + this);
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ log.info(MiscUtils.invocationInfo() + "\n\t" + this);
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof BaseBean)) return false;
+ BaseBean baseBean = (BaseBean) o;
+ return Objects.equals(getId(), baseBean.getId());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getId());
+ }
+
+}
diff --git a/java-ee-study/src/test/java/study/javax/cdi/weld/beans/SeqGenerator.java b/java-ee-study/src/test/java/study/javax/cdi/weld/beans/SeqGenerator.java
new file mode 100644
index 0000000..743e360
--- /dev/null
+++ b/java-ee-study/src/test/java/study/javax/cdi/weld/beans/SeqGenerator.java
@@ -0,0 +1,43 @@
+package study.javax.cdi.weld.beans;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import study.commons.MiscUtils;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicLong;
+
+@ApplicationScoped
+public class SeqGenerator {
+ private static Logger log = LoggerFactory.getLogger(SeqGenerator.class);
+ private AtomicLong seq;
+
+ @Produces
+ public Long getSeq() {
+ final long newId = seq.incrementAndGet();
+ log.info("{} \t-> \t{newId: {}}", MiscUtils.invocationInfo(), newId);
+ return newId;
+ }
+
+ @Produces
+ public Date getTimeStamp() {
+ return Calendar.getInstance().getTime();
+ }
+
+ @PostConstruct
+ public void postConstruct() {
+ log.info(MiscUtils.invocationInfo());
+ seq = new AtomicLong();
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ log.info(MiscUtils.invocationInfo());
+ log.info("last id: {}", seq.get());
+ }
+}
diff --git a/java-ee-study/src/test/resources/META-INF/beans.xml b/java-ee-study/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..df1e633
--- /dev/null
+++ b/java-ee-study/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/java-ee-study/src/test/resources/log4j2.xml b/java-ee-study/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..739f19f
--- /dev/null
+++ b/java-ee-study/src/test/resources/log4j2.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jdk-study/pom.xml b/jdk-study/pom.xml
new file mode 100644
index 0000000..ccface1
--- /dev/null
+++ b/jdk-study/pom.xml
@@ -0,0 +1,14 @@
+
+ 4.0.0
+ java-study
+ jdk-study
+ 0.1.2
+
+
+ java-study
+ java-study
+ 0.1.2
+
+
+
\ No newline at end of file
diff --git a/jdk-study/src/test/java/study/JdkStudyUtils.java b/jdk-study/src/test/java/study/JdkStudyUtils.java
new file mode 100644
index 0000000..bae2bff
--- /dev/null
+++ b/jdk-study/src/test/java/study/JdkStudyUtils.java
@@ -0,0 +1,62 @@
+package study;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sun.misc.Unsafe;
+
+import java.lang.reflect.Field;
+
+public class JdkStudyUtils {
+ static final Logger log = LoggerFactory.getLogger(JdkStudyUtils.class);
+
+ public static String toBinStr(final byte _b) {
+ final StringBuilder sb = new StringBuilder(Byte.SIZE);
+ for (byte i = Byte.SIZE - 1; i >= 0; i--) {
+ sb.append((_b & (1 << i)) != 0 ? '1' : '0');
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(final int _i) {
+ final StringBuilder sb = new StringBuilder(Integer.SIZE);
+ sb.append(_i < 0 ? '1' : '0');
+ for (byte i = Integer.SIZE - 2; i >= 0; i--) {
+ sb.append((_i & (1 << i)) != 0 ? '1' : '0');
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(final short _s) {
+ final StringBuilder sb = new StringBuilder(Short.SIZE);
+ for (byte i = Short.SIZE - 1; i >= 0; i--) {
+ sb.append((_s & (1 << i)) != 0 ? '1' : '0');
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(long _l) {
+ final StringBuilder sb = new StringBuilder(Long.SIZE);
+ for (byte i = Long.SIZE; i >= 0; i--) {
+ sb.append((_l & (1 << i)) != 0 ? '1' : '0');
+ }
+ return sb.toString();
+ }
+
+ public static Unsafe getUnsafe() {
+ try {
+ Field f = Unsafe.class.getDeclaredField("theUnsafe");
+ f.setAccessible(true);
+ return (Unsafe) f.get(null);
+ } catch (Exception e) {
+ log.error("failed to get Unsafe", e);
+ return null;
+ }
+ }
+
+ public static void easySleep(long i) {
+ try {
+ Thread.sleep(i);
+ } catch (InterruptedException e) {
+ }
+ }
+}
diff --git a/jdk-study/src/test/java/study/commons/MiscUtils.java b/jdk-study/src/test/java/study/commons/MiscUtils.java
new file mode 100644
index 0000000..b202372
--- /dev/null
+++ b/jdk-study/src/test/java/study/commons/MiscUtils.java
@@ -0,0 +1,471 @@
+package study.commons;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.collections4.iterators.ObjectArrayIterator;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.CharUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import java.io.*;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.MathContext;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.file.StandardOpenOption;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.*;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+public class MiscUtils {
+ public static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors();
+
+ public static long getPropertyNumber(String name, long defaultValue) {
+ String str = System.getProperty(name);
+ if (StringUtils.isNumeric(str)) {
+ return Long.parseLong(str);
+ }
+ return defaultValue;
+ }
+
+ public static String invocationInfo() {
+ StackTraceElement[] ste = Thread.currentThread().getStackTrace();
+ int i = 2;
+ return String.format("%s\t%s.%s", ste[i].getFileName(), ste[i].getClassName(), ste[i].getMethodName());
+ }
+
+ public static String invocInfo() {
+ StackTraceElement[] ste = Thread.currentThread().getStackTrace();
+ int i = 2;
+ return String.format("%s\t%s.%s", ste[i].getFileName(), StringUtils.substringAfterLast(ste[i].getClassName(), "."), ste[i].getMethodName());
+ }
+
+ public static String invocationInfo(final int i) {
+ StackTraceElement[] ste = Thread.currentThread().getStackTrace();
+ ste = ArrayUtils.subarray(ste, 0, i);
+ return Stream.of(ste)
+ .map(st -> String.format("%s\t%s.%s", st.getFileName(), st.getClassName(), st.getMethodName()))
+ .collect(Collectors.joining("\n"));
+ }
+
+ public static String byteCountToDisplaySize(long size) {
+ if (size > 1073741824L) return String.valueOf(size / 1073741824L) + " GB";
+ if (size > 1048576L) return String.valueOf(size / 1048576L) + " MB";
+ if (size > 1024L) return String.valueOf(size / 1024L) + " KB";
+ return String.valueOf(size) + " bytes";
+ }
+
+ public static List pi2Longs(Integer n) {
+ return pi(n).toString().substring(0, n).chars().filter(i -> CharUtils.isAsciiNumeric((char) i)).map(i -> i - 48).mapToObj(Long::valueOf).collect(Collectors.toList());
+ }
+
+ public static List pi2Longs(Integer n, int range) {
+ List nums = pi2Longs(n);
+ List _nums = new ArrayList<>();
+ Random rand = new Random();
+ for (ListIterator it = nums.listIterator(); it.hasNext(); ) {
+ Long num = it.next();
+ for (int i = 0, step = rand.nextInt(range); i < step && it.hasNext(); i++) {
+ num = num * 10 + it.next();
+ }
+// System.out.println(step + "\t" + num);
+ _nums.add(num);
+ }
+ return _nums;
+ }
+
+ public static BigDecimal pi(Integer n) {
+ if (n == null) {
+ n = 0;
+ }
+
+ if (n == 0)
+ return null;
+ if (n == 1)
+ return new BigDecimal(3);
+ if (n == 2)
+ return new BigDecimal(3.1);
+ if (n == 3)
+ return new BigDecimal(3.14);
+
+ MathContext mc = new MathContext(n);
+ BigDecimal pi = new BigDecimal(BigInteger.ZERO, n, mc);
+ BigDecimal one = new BigDecimal(BigInteger.ONE, n, mc);
+ BigDecimal two = new BigDecimal(new BigInteger("2"), n, mc);
+ BigDecimal four = new BigDecimal(new BigInteger("4"), n, mc);
+ for (int k = 0; k < n; k++) {
+ BigDecimal tmp1 = one.divide(new BigDecimal(16).pow(k, mc), mc);
+
+ BigDecimal tmp2_1 = four.divide(new BigDecimal(8 * k + 1, mc), mc);
+ BigDecimal tmp2_2 = two.divide(new BigDecimal(8 * k + 4, mc), mc);
+ BigDecimal tmp2_3 = one.divide(new BigDecimal(8 * k + 5, mc), mc);
+ BigDecimal tmp2_4 = one.divide(new BigDecimal(8 * k + 6, mc), mc);
+
+ BigDecimal tmp2 = tmp2_1.subtract(tmp2_2, mc).subtract(tmp2_3, mc).subtract(tmp2_4, mc);
+ pi = pi.add(tmp1.multiply(tmp2, mc));
+ }
+
+ // pi.setScale(n, BigDecimal.ROUND_UP);
+ pi.scaleByPowerOfTen(n);
+
+ return pi;
+ }
+
+ public static long getProcessId() {
+ // Note: may fail in some JVM implementations
+ // therefore fallback has to be provided
+
+ // something like '@', at least in SUN / Oracle JVMs
+ final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
+ final int index = jvmName.indexOf('@');
+ String pidStr = jvmName.substring(0, index);
+
+ if (index < 1 || !NumberUtils.isNumber(pidStr)) {
+ // part before '@' empty (index = 0) / '@' not found (index = -1)
+ return 0;
+ }
+
+ return Long.parseLong(pidStr);
+ }
+
+ public static void easySleep(long i) {
+ try {
+ Thread.sleep(i);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ public static String stackInfo() {
+ final StringBuilder sb = new StringBuilder();
+ final StackTraceElement[] stes = Thread.currentThread().getStackTrace();
+ ArrayUtils.reverse(stes);
+ Stream.of(stes).forEach(ste -> sb.append(String.format("%s\t%s.%s\n", ste.getFileName(), ste.getClassName(), ste.getMethodName())));
+ return sb.toString();
+ }
+
+ public static String now() {
+ return DateFormatUtils.format(Calendar.getInstance(), "yy-MM-dd hh:mm:ss");
+ }
+
+ public static String toBinStr(final byte _b) {
+ final StringBuilder sb = new StringBuilder();
+ for (byte i = 7; i >= 0; i--) {
+ sb.append((_b & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(final int _i) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(_i < 0 ? 1 : 0);
+ for (byte i = 31; i >= 0; i--) {
+ sb.append((_i & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(final short _s) {
+ final StringBuilder sb = new StringBuilder();
+ for (byte i = 16; i >= 0; i--) {
+ sb.append((_s & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static String toBinStr(long _l) {
+ final StringBuilder sb = new StringBuilder();
+ for (byte i = 64; i >= 0; i--) {
+ sb.append((_l & (1 << i)) != 0 ? 1 : 0);
+ }
+ return sb.toString();
+ }
+
+ public static class LoopingArrayIterator extends ObjectArrayIterator {
+ @SafeVarargs
+ public LoopingArrayIterator(final E... array) {
+ super(array, 0, array.length);
+ }
+
+ public LoopingArrayIterator(final E array[], final int start) {
+ super(array, start, array.length);
+ }
+
+ public E loop() {
+ final E[] array = this.getArray();
+ loopIdx.compareAndSet(array.length, 0);
+ return array[loopIdx.getAndIncrement() % array.length];
+ }
+
+ private AtomicInteger loopIdx = new AtomicInteger();
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static Map map(Object... keyAndVals) {
+ return MapUtils.putAll(new HashMap(), keyAndVals);
+ }
+
+ public static long HOST_HASH = System.currentTimeMillis();
+
+ static {
+ try {
+ HOST_HASH = InetAddress.getLocalHost().getHostAddress().hashCode();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static long uniqueLong() {
+ return Math.abs(UUID.randomUUID().hashCode());
+ }
+
+ public static ThreadFactory namedThreadFactory(final String name) {
+ return new BasicThreadFactory.Builder().namingPattern(name + "_%d").build();
+ }
+
+ public static String lineNumber(final String str) {
+ if (str == null) {
+ return null;
+ }
+
+ final StringReader sr = new StringReader(str);
+ final BufferedReader br = new BufferedReader(sr);
+
+ final StringBuilder sb = new StringBuilder(0);
+ AtomicLong lineNumber = new AtomicLong(0);
+ br.lines().forEach(line -> sb.append(lineNumber.incrementAndGet()).append("\t").append(line).append('\n'));
+
+ return sb.toString();
+ }
+
+ private static final Logger log = LoggerFactory.getLogger(MiscUtils.class);
+
+ public static String mapToJson(Map paramMap) {
+ if (MapUtils.isEmpty(paramMap)) {
+ return "{}";
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(paramMap);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ return paramMap.toString();
+ }
+ }
+
+ public static String toXML(final Object bean) {
+ final StringWriter sw = new StringWriter();
+
+ try {
+ JAXBContext jc = JAXBContext.newInstance(bean.getClass());
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FRAGMENT, true);
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.marshal(bean, sw);
+ } catch (Exception e) {
+ log.error(String.valueOf(bean), e);
+ }
+ return sw.toString();
+ }
+
+ public static T toObj(final String xmlStr, final Class cls) {
+ if (StringUtils.isBlank(xmlStr) || cls == null) {
+ return null;
+ }
+
+ try {
+ JAXBContext jc = JAXBContext.newInstance(cls);
+ Unmarshaller um = jc.createUnmarshaller();
+ return um.unmarshal(new StreamSource(new StringReader(xmlStr)), cls).getValue();
+ } catch (JAXBException e) {
+ log.error(xmlStr, e);
+ }
+
+ return null;
+ }
+
+// public static Map extractParams(MultivaluedMap params) {
+// Map paramsMap = new HashMap();
+// params.keySet().forEach(key -> paramsMap.put(key, params.getFirst(key)));
+// return paramsMap;
+// }
+//
+// public static Map toParamMap(MultivaluedMap params) {
+// Map paramsMap = new HashMap();
+// params.keySet().forEach(key -> paramsMap.put(key, params.get(key).toArray(new String[0])));
+// return paramsMap;
+// }
+
+ public static Map extractParams(Map params) {
+ Map paramsMap = new HashMap();
+ params.keySet().forEach(key -> {
+ final String[] vals = params.get(key);
+ paramsMap.put(key, ArrayUtils.isEmpty(vals) ? null : vals[0]);
+ });
+ return paramsMap;
+ }
+
+ public static String generate(final String text) {
+ final StringBuffer sb = new StringBuffer();
+ try {
+ final byte[] intext = text.getBytes();
+ final MessageDigest md5 = MessageDigest.getInstance("MD5");
+ final byte[] md5rslt = md5.digest(intext);
+ for (int i = 0; i < md5rslt.length; i++) {
+ final int val = 0xff & md5rslt[i];
+ if (val < 16) {
+ sb.append("0");
+ }
+ sb.append(Integer.toHexString(val));
+ }
+ } catch (final Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ return sb.toString();
+ }
+
+ public static String loadResAsString(final Class> cls, final String fileName) {
+ if (cls == null || StringUtils.isBlank(fileName)) {
+ return StringUtils.EMPTY;
+ }
+
+ try {
+ return IOUtils.toString(cls.getClassLoader().getResourceAsStream(fileName));
+ } catch (IOException e) {
+ log.error("", e);
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static String getEncodedText(String plainText) {
+ String encodedPassword = null;
+ try {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(plainText.getBytes());
+ encodedPassword = new String(Hex.encodeHex(md.digest()));
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ return encodedPassword;
+ }
+
+ public static void writeToMappedFile(File file, byte[] data) throws IOException {
+ try (FileChannel fc = FileChannel.open(file.toPath(), StandardOpenOption.WRITE, StandardOpenOption.READ)) {
+ MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, data.length);
+ mbb.put(data);
+ mbb.force();
+ }
+ }
+
+ public static byte[] readFromMappedFile(File file) throws IOException {
+ try (FileChannel fc = FileChannel.open(file.toPath(), StandardOpenOption.READ)) {
+ long length = file.length();
+ MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, length);
+ if (!mbb.load().isLoaded()) {
+ throw new IllegalStateException(String.format("%s can not be loaded", file.getAbsolutePath()));
+ }
+
+ byte[] data = new byte[(int) length];
+ mbb.get(data);
+ return data;
+ }
+ }
+
+ public static Class[] getParameterizedClzz(Type type) {
+ if (type == null) return null;
+ if (type instanceof Class) {
+ Class aClass = (Class) type;
+ return new Class[]{aClass};
+ }
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
+ return Stream.of(pt.getActualTypeArguments()).filter(_type -> _type instanceof Class).toArray(Class[]::new);
+ }
+ return null;
+ }
+
+ public static HttpResponse easyGet(String urlStr, String... params) {
+ if (StringUtils.isBlank(urlStr)) {
+ return null;
+ }
+
+ try (CloseableHttpClient hc = HttpClients.createDefault()) {
+ URIBuilder ub = new URIBuilder(urlStr);
+ if (!ArrayUtils.isEmpty(params)) {
+ IntStream.range(0, params.length).filter(i -> i % 2 == 1).forEach(i -> ub.addParameter(params[i - 1], params[i]));
+ }
+
+ HttpGet hg = new HttpGet(ub.build());
+ try (CloseableHttpResponse hr = hc.execute(hg)) {
+ BasicHttpResponse bhr = new BasicHttpResponse(hr.getStatusLine());
+ bhr.setEntity(new InputStreamEntity(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity()))));
+ return bhr;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static HttpResponse easyPost(String urlStr, String... params) {
+ if (StringUtils.isBlank(urlStr)) {
+ return null;
+ }
+
+ try (CloseableHttpClient hc = HttpClients.createDefault()) {
+ URIBuilder ub = new URIBuilder(urlStr);
+ HttpPost hp = new HttpPost(ub.build());
+ List nvps = new ArrayList();
+ if (!ArrayUtils.isEmpty(params)) {
+ IntStream.range(0, params.length).filter(i -> i % 2 == 1).forEach(i -> nvps.add(new BasicNameValuePair(params[i - 1], params[i])));
+ }
+ hp.setEntity(new UrlEncodedFormEntity(nvps));
+
+ try (CloseableHttpResponse hr = hc.execute(hp)) {
+ BasicHttpResponse bhr = new BasicHttpResponse(hr.getStatusLine());
+ bhr.setEntity(new InputStreamEntity(new ByteArrayInputStream(EntityUtils.toByteArray(hr.getEntity()))));
+ return bhr;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/jdk-study/src/test/java/study/env/EnvTests.java b/jdk-study/src/test/java/study/env/EnvTests.java
new file mode 100644
index 0000000..80d11b0
--- /dev/null
+++ b/jdk-study/src/test/java/study/env/EnvTests.java
@@ -0,0 +1,121 @@
+package study.env;
+
+
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.DynamicTest.dynamicTest;
+
+/**
+ * This class is meant to test logging settings
+ * as well as some new feature of JUnit5
+ */
+public class EnvTests {
+ static final Logger log = LoggerFactory.getLogger(EnvTests.class);
+
+ int testCount = 0;
+
+ @TestFactory
+ Collection dynamicTestsFromCollection() {
+ return Arrays.asList(
+ dynamicTest("1st dynamic test", () -> assertTrue(true)),
+ dynamicTest("2nd dynamic test", () -> assertEquals(4, 2 * 2))
+ );
+ }
+
+ /**
+ *
+ * Denotes that the annotated method should be executed before all
+ * @Test, @RepeatedTest, @ParameterizedTest, and @TestFactory methods in the current class;
+ * analogous to JUnit 4’s @BeforeClass. Such methods are inherited (unless they are hidden or overridden)
+ * and must be static (unless the "per-class" test instance lifecycle is used).
+ *
+ */
+ @BeforeAll
+ public static void beforeAll() {
+ log.info("this is run before all test cases");
+ }
+
+ @BeforeEach
+ public void beforeEach() {
+ log.info("this is run before each test case: {}", testCount++);
+ }
+
+ @AfterEach
+ public void afterEach() {
+ log.info("this is run after each test case: {}", testCount);
+ }
+
+ /**
+ *
+ * Denotes that a method is a test method. Unlike JUnit 4’s @Test annotation,
+ * this annotation does not declare any attributes,
+ * since test extensions in JUnit Jupiter operate based on their own dedicated annotations.
+ * Such methods are inherited unless they are overridden.
+ *
+ */
+ @Test
+ public void testCase1() {
+ log.info("this is a test run for junit @Test");
+ }
+
+ @Test
+ public void testCase2() {
+ log.info("this is a test run for junit @Test");
+ }
+
+ @Test
+ @Disabled
+ public void testAbort() {
+ log.info("this test aborts the junit");
+ System.exit(1);
+ }
+
+ @RepeatedTest(3)
+ public void testRepeated() {
+ log.info("I am not sure how many times I am repeated");
+ }
+
+ @RepeatedTest(3)
+ public void testRepeated1(RepetitionInfo rpi) {
+ log.info("I am being repeated the {}-th time out of {} times", rpi.getCurrentRepetition(), rpi.getTotalRepetitions());
+ }
+
+ @RepeatedTest(value = 3)
+ public void testRepeated2(RepetitionInfo rpi) {
+ log.info("I am being repeated the {}-th time out of {} times", rpi.getCurrentRepetition(), rpi.getTotalRepetitions());
+ if (rpi.getCurrentRepetition() == 2) {
+ throw new RuntimeException("enough! stop!");
+ }
+ }
+
+ @Test
+ public void testWhatInfo(TestInfo ti) {
+ log.info("what is in the TestInfo:\n\t{}", ti);
+ }
+
+ @ParameterizedTest
+ @ValueSource(ints = {1, 2, 3, 4})
+ public void testParamsFromValueSrc(int arg) {
+ log.info("what parameter is it? \n\t{}", arg);
+ }
+
+// @ParameterizedTest
+// @ValueSource(ints = {1, 2, 3, 4})
+// public void testParamsFromValueSrcExt(int arg, ParameterContext aa) {
+// log.info("what parameter is it? \n\t{}\n\t among {}", arg, aa);
+// }
+
+ @AfterAll
+ public static void afterAll() {
+ log.info("this is run after all test cases");
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/lang/base/ArithmeticTests.java b/jdk-study/src/test/java/study/java/lang/base/ArithmeticTests.java
new file mode 100644
index 0000000..f4df07c
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/lang/base/ArithmeticTests.java
@@ -0,0 +1,64 @@
+package study.java.lang.base;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ArithmeticTests {
+ static final Logger log = LoggerFactory.getLogger(ArithmeticTests.class);
+
+ @Test
+ public void testAdd() {
+ {
+ log.info("add different types of numbers to integer");
+ int _i = Integer.MAX_VALUE;
+ log.info("1 + {} = {}", _i, 1 + _i);
+ long _l = Long.MAX_VALUE;
+ log.info("1 + {} = {}", _l, 1 + _l);
+ short _s = Short.MAX_VALUE;
+ log.info("1 + {} = {}", _s, 1 + _s);
+ byte _b = Byte.MAX_VALUE;
+ log.info("1 + {} = {}", _b, 1 + _b);
+ double _f = Float.MAX_VALUE;
+ log.info("1 + {} = {}", _f, 1 + _f);
+ double _d = Double.MAX_VALUE;
+ log.info("1 + {} = {}", _d, 1 + _d);
+ }
+ }
+
+ @Test
+ public void testMod() {
+ {
+ log.info("-3 % 2 = {}", -3 % 2);
+ log.info("3 % -2 = {}", 3 % -2);
+
+ int _i = Integer.MAX_VALUE;
+ long _l = Long.MAX_VALUE;
+ log.info("{} % {} = {}", _l, (_l - _i), _l % (_l - _i));
+ }
+
+ {
+ log.info("5 % 4 = {}", 5 % 4);
+ log.info("5 % 2 + 2 = {}", 5 % 2 + 2);
+ log.info("5 % 2 * 2 = {}", 5 % 2 * 2);
+ log.info("2 + 5 % 2 = {}", 2 + 5 % 2);
+ log.info("2 * 5 % 2 = {}", 2 * 5 % 2);
+ }
+
+ {
+ log.info("0.75 % 0.5 = {}", 0.75 % 0.5);
+ log.info("0.75 % 1.5 = {}", 0.75 % 1.5);
+ log.info("(2/3) % (5/7) = {}", (2 / 3.0) % (5 / 7.0));
+ log.info("(5/3) % (5/7) = {} \t 5 / 21.0 = {}", (5 / 3.0) % (5 / 7.0), 5 / 21.0);
+ log.info("(4/3) % (5/7) = {} \t 5 / 21.0 = {}", (4 / 3.0) % (5 / 7.0), 13 / 21.0);
+ }
+
+ try {
+ log.info("3 % 0 = {}", 3 % 0);
+ Assertions.fail("should be ArithmeticException");
+ } catch (Exception e) {
+ log.error("can not mod by 0, {}", e.getMessage());
+ }
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/lang/base/IntTests.java b/jdk-study/src/test/java/study/java/lang/base/IntTests.java
new file mode 100644
index 0000000..61fa671
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/lang/base/IntTests.java
@@ -0,0 +1,115 @@
+package study.java.lang.base;
+
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import study.JdkStudyUtils;
+import sun.misc.Unsafe;
+
+import java.lang.reflect.Field;
+import java.nio.ByteOrder;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static study.JdkStudyUtils.toBinStr;
+
+public class IntTests {
+ static final Logger log = LoggerFactory.getLogger(IntTests.class);
+ static final Unsafe us = JdkStudyUtils.getUnsafe();
+
+ int b;
+ int intValue = 0xAA << 24 | 0xCC << 16 | 0xEE << 8 | 0xFF;
+
+ @Test
+ public void testUnsafeOper() throws Exception {
+
+ Field f = IntTests.class.getDeclaredField("intValue");
+ long offset = us.objectFieldOffset(f);
+ byte b1 = us.getByte(this, offset);
+ byte b2 = us.getByte(this, offset + 1);
+ byte b3 = us.getByte(this, offset + 2);
+ byte b4 = us.getByte(this, offset + 3);
+
+ log.info("{}\t{}", intValue, toBinStr(intValue));
+ log.info("{}\t{}\t{}\t{}", toBinStr(b1), toBinStr(b2), toBinStr(b3), toBinStr(b4));
+ log.info(ByteOrder.nativeOrder().toString());
+ }
+
+ @Test
+ public void testIntDef() {
+ int a = 0;
+ assertEquals(a, 0);
+ a = 1;
+ assertEquals(a, 1);
+// int b, c = 5; //compile error, b is not initialized
+ assertEquals(b, 0);
+// int d=e=4; //e is not defined
+ int d = 0, e = 0;
+ d = e = 3;
+ assertEquals(d, e);
+ }
+
+ @Test
+ public void testValueRange() {
+ assertEquals(32, Integer.SIZE);
+ assertEquals(4, Integer.BYTES);
+
+ log.info("Integer.MAX_VALUE ={}\t{}", Integer.MAX_VALUE, toBinStr(Integer.MAX_VALUE));
+ log.info("Integer.MIN_VALUE = {}\t{}", Integer.MIN_VALUE, toBinStr(Integer.MIN_VALUE));
+
+ {
+ int i = Integer.MAX_VALUE + 1;
+ log.info("Integer.MAX_VALUE + 1 = {}\t{}", i, toBinStr(i));
+ i = Integer.MAX_VALUE + 2;
+ log.info("Integer.MAX_VALUE + 2 = {}\t{}", i, toBinStr(i));
+ }
+
+ {
+ int i = Integer.MIN_VALUE - 1;
+ log.info("Integer.MIN_VALUE - 1 = {}\t{}", i, toBinStr(i));
+ i = Integer.MIN_VALUE - 2;
+ log.info("Integer.MIN_VALUE - 2 = {}\t{}", i, toBinStr(i));
+ }
+
+ {
+ int i = Integer.MAX_VALUE + Integer.MAX_VALUE;
+ log.info("Integer.MAX_VALUE + Integer.MAX_VALUE = {}\t{}", i, toBinStr(i));
+ i = Integer.MAX_VALUE + Integer.MIN_VALUE;
+ log.info("Integer.MAX_VALUE + Integer.MIN_VALUE = {}\t{}", i, toBinStr(i));
+ i = Integer.MIN_VALUE + Integer.MIN_VALUE;
+ log.info("Integer.MIN_VALUE + Integer.MIN_VALUE = {}\t{}", i, toBinStr(i));
+ }
+
+ {
+ int i = Integer.MAX_VALUE - Integer.MAX_VALUE;
+ log.info("Integer.MAX_VALUE - Integer.MAX_VALUE = {}\t{}", i, toBinStr(i));
+ i = Integer.MAX_VALUE - Integer.MIN_VALUE;
+ log.info("Integer.MAX_VALUE - Integer.MIN_VALUE = {}\t{}", i, toBinStr(i));
+ i = Integer.MIN_VALUE - Integer.MIN_VALUE;
+ log.info("Integer.MIN_VALUE - Integer.MIN_VALUE = {}\t{}", i, toBinStr(i));
+ }
+ }
+
+ @Test
+ public void testCasting() {
+ int i = Integer.MAX_VALUE;
+ {
+ short s = (short) i;
+ log.info("int {}|{} to short {}|{}", i, toBinStr(i), s, toBinStr(s));
+ int j = s;
+ log.info("short {}|{} to int {}|{}", s, toBinStr(s), j, toBinStr(j));
+ }
+ {
+ byte b = (byte) i;
+ log.info("int {}|{} to byte {}|{}", i, toBinStr(i), b, toBinStr(b));
+ int j = b;
+ log.info("byte {}|{} to int {}|{}", b, toBinStr(b), j, toBinStr(j));
+ }
+ }
+
+ @Test
+ public void testComplement() {
+ log.info("{}\t{}", 4, toBinStr(4));
+ log.info("{}\t{}", ~4, toBinStr(~4));
+ log.info("{}\t{}", -4, toBinStr(-4));
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/lang/base/Java12FeatureTests.java b/jdk-study/src/test/java/study/java/lang/base/Java12FeatureTests.java
new file mode 100644
index 0000000..e0574fa
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/lang/base/Java12FeatureTests.java
@@ -0,0 +1,25 @@
+package study.java.lang.base;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.DayOfWeek;
+
+public class Java12FeatureTests {
+
+ static final Logger log = LoggerFactory.getLogger(Java12FeatureTests.class);
+
+ @ParameterizedTest
+ @EnumSource(value = DayOfWeek.class, names = {"MONDAY", "SUNDAY"})
+ public void switchExp(DayOfWeek d) {
+// log.info("{} is {}",
+// d,
+// switch (d) {
+// case MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY -> "weekday";
+// case SATURDAY, SUNDAY -> "weekend";
+// default -> throw new IllegalArgumentException("what is " + d);
+// });
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/lang/base/KeywordAndGrammaTests.java b/jdk-study/src/test/java/study/java/lang/base/KeywordAndGrammaTests.java
new file mode 100644
index 0000000..41383b7
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/lang/base/KeywordAndGrammaTests.java
@@ -0,0 +1,134 @@
+package study.java.lang.base;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Comparator;
+import java.util.Random;
+import java.util.concurrent.Callable;
+
+public class KeywordAndGrammaTests {
+ static final Logger log = LoggerFactory.getLogger(KeywordAndGrammaTests.class);
+
+ public static final String[] KEY_WORDS = {"abstract", // checked
+ "assert", // checked
+ "boolean", "break", // checked
+ "byte", "case", // checked
+ "catch", "char", "class", "const", // checked
+ "continue", "default", // checked
+ "do", "double", "else", // checked
+ "enum", "extends", "final", "finally", "float", "for", "goto", "if", // checked
+ "implements", "import", // checked
+ "instanceof", "int", "interface", "long", "native", "new", "package", // checked
+ "private", "protected", "public", "return", "short", "static", "strictfp", "super", "switch", // checked
+ "synchronized", "this", "throw", "throws", "transient", "try", "void", "volatile", "while"};
+
+ static int cmp(C cmp1, C cmp2, String mark) {
+ log.info("comparing {} to {} with mark:\t{}", cmp1, cmp2, mark);
+ return Comparator.nullsFirst(Comparator.naturalOrder()).compare(cmp1, cmp2);
+ }
+
+ @Test
+ public void testIfAndElse() {
+ if (true) log.info("if (true)");
+ if (false) log.info("if (false)");
+
+ if (false) ;
+ else log.info("no true");
+
+ int i = 5;
+
+ if (cmp(i, 0, "i == 0") == 0) {
+ log.info("i:{} == 0", i);
+ } else if (cmp(i, 0, "i > 0") > 0) {
+ log.info("i:{} > 0", i);
+ } else {
+ log.info("i:{} < 0", i);
+ }
+
+ int j = 0;
+ Random rand = new Random();
+ if ((j = rand.nextInt()) > 10) {
+ log.info("j: {} > 10", j);
+ }
+ Assertions.assertNotEquals(0, j);
+ log.info("j: {} changed", j);
+
+ //invalid
+// if ((int k = rand.nextInt()) >10){
+// log.info("k: {} > 10", k);
+// }
+// log.info("k: {} changed", k);
+ }
+
+ @Test
+ public void testAssert() throws Exception {
+ assert true;
+ log.info("assert true");
+// assert false; // run java with "-ea", this throws AssertError
+// log.info("assert false");
+
+ Assertions.assertThrows(AssertionError.class, () -> {
+ assert cmp(1, 2, "false") > 0 : "1 is not greater than 2";
+ }, "got you, AssertionError");
+
+ //invalid
+// assert null;
+
+ Assertions.assertThrows(NullPointerException.class, () -> {
+ Boolean nullBoolean = null;
+ assert nullBoolean;
+ }, "got you, NullPointerException");
+
+ Assertions.assertThrows(RuntimeException.class, () -> {
+ Callable foo = () -> {
+ throw new RuntimeException("Boom");
+ };
+ assert false : foo.call();
+ }, "got you, RuntimeException");
+ }
+
+ @Test
+ public void testBreak() {
+ // break; break can't be used outside of loop or switch
+ for (int i = 0; i < 1; i++) {
+ break;
+ }
+ do {
+ break;
+ } while (true);
+
+ while (true) {
+ break;
+ }
+
+ switch (1) {
+ case 1:
+ break;
+ default:
+ break;
+ }
+
+ _outer:
+ for (int i = 0; i < 3; i++) {
+ log.info("outer begins: " + i);
+ _inner: for (int j = 0; j < i; j++) {
+ log.info("\t" + j);
+ break _inner; // jump out of outer loop too
+ }
+ log.info("outer ends: " + i);
+ }
+
+ _outer:
+ for (int i = 0; i < 3; i++) {
+ log.info("outer begins: " + i);
+ _inner: for (int j = 0; j < i; j++) {
+ log.info("\t" + j);
+ break _outer; // jump out of outer loop too
+ }
+ log.info("outer ends: " + i);
+ }
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/lang/base/ThreadLocalTests.java b/jdk-study/src/test/java/study/java/lang/base/ThreadLocalTests.java
new file mode 100644
index 0000000..8d3a722
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/lang/base/ThreadLocalTests.java
@@ -0,0 +1,58 @@
+package study.java.lang.base;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import study.commons.MiscUtils;
+
+import java.lang.ref.Cleaner;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public class ThreadLocalTests {
+ static final Logger log = LoggerFactory.getLogger(ThreadLocalTests.class);
+ static ThreadLocal tl = null;
+
+ static final Cleaner cleaner = Cleaner.create();
+
+ static class DummyEntry {
+ Cleaner.Cleanable c = null;
+
+ public DummyEntry() {
+// log.info(MiscUtils.invocInfo());
+ c = cleaner.register(this, this::getCleaned);
+ }
+
+ public void getCleaned() {
+ log.info(MiscUtils.invocationInfo(5));
+ }
+ }
+
+ @BeforeClass
+ public static void initThreadLocal() {
+ tl = ThreadLocal.withInitial(DummyEntry::new);
+ }
+
+ @Test
+ public void testLocalValueFinalization() throws InterruptedException {
+ tl.get();
+ tl.remove();
+ tl.get();
+ tl.get();
+ tl.get();
+
+ {
+ ExecutorService es = Executors.newCachedThreadPool(); //.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
+ for (int i = 0; i < 1000; i++) {
+ es.submit(() -> {
+ tl.get();
+ });
+ }
+ es.shutdownNow();
+ while (!es.isTerminated())
+ es.awaitTermination(2, TimeUnit.SECONDS);
+ }
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/lang/base/ThreadTests.java b/jdk-study/src/test/java/study/java/lang/base/ThreadTests.java
new file mode 100644
index 0000000..b20e5d9
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/lang/base/ThreadTests.java
@@ -0,0 +1,240 @@
+package study.java.lang.base;
+
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static study.commons.MiscUtils.easySleep;
+
+public class ThreadTests {
+ static final Logger log = LoggerFactory.getLogger(ThreadTests.class);
+
+ public static class DaemonThreadTest {
+ static {
+ log.info("first in static {}", Thread.currentThread());
+ Thread.currentThread().setDaemon(true);
+ }
+
+ public static void main(String[] args) {
+ log.info("first in main");
+ try {
+ new ThreadTests().testDaemon();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Test
+ public void testDaemon() throws Exception {
+ log.info("starting Daemon thread");
+
+ Thread thread = new Thread(() -> {
+ log.info("thread started");
+ try {
+ Thread.sleep(1000);
+ log.info("sleep 1");
+ Thread.sleep(1000);
+ log.info("sleep 2");
+ Thread.sleep(1000);
+ log.info("sleep 3");
+ } catch (Exception e) {
+ log.error("?", e);
+ }
+ log.info("thread stopped");
+ });
+
+ thread.setDaemon(false);
+ thread.start();
+ Thread.sleep(10);
+// thread.join();
+ log.info("exit");
+ }
+
+ @Test
+ public void testDaemonInfiniteLoop() throws Exception {
+ log.info("starting Daemon thread");
+
+ Thread thread = new Thread(() -> {
+ log.info("thread started");
+ try {
+ while (true) {
+ Thread.sleep(1000);
+ log.info("sleep 1");
+ Thread.sleep(1000);
+ log.info("sleep 2");
+ Thread.sleep(1000);
+ log.info("sleep 3");
+ }
+ } catch (Exception e) {
+ log.error("?", e);
+ }
+ log.info("thread stopped");
+ });
+
+ Thread waitForThread = new Thread(() -> {
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ log.error("?", e);
+ }
+ });
+
+// thread.setDaemon(true);
+ thread.start();
+ waitForThread.start();
+ Thread.sleep(1010);
+ }
+
+ @Test
+ public void testThreadHoldingMain() throws Exception {
+ log.info("starting test");
+ Thread thread = new Thread(() -> {
+ jam(2000);
+ });
+ thread.start();
+ Thread.sleep(1000);
+ thread.join();
+ log.info("I go first");
+ }
+
+ private static void jam(int millisec) {
+ log.info("start jamming");
+ long now = System.currentTimeMillis();
+ while (System.currentTimeMillis() - now < millisec) {
+ double d = Math.pow(Math.PI, Math.E);
+ }
+ log.info("stop jamming");
+ }
+
+ @Test
+ public void testInterrupt() {
+ Thread th = new Thread(() -> {
+ try {
+ for (int i = 0; i < 5; i++) {
+// Thread.sleep(1000);
+ jam(1000);
+ log.info("am I interrupted? {}", Thread.currentThread().isInterrupted());
+ }
+ } catch (Exception e) {
+ log.error("I am interrupted by {}", e);
+ }
+ });
+ th.start();
+ try {
+ Thread.sleep(3500);
+ th.interrupt();
+ th.join();
+ } catch (InterruptedException e) {
+ log.error("I am interrupted by {}", e);
+ }
+ }
+
+ @Test
+ public void testDeadLock() {
+ String a = "a";
+ String b = "b";
+
+ Thread th1 = new Thread(() -> {
+ log.info("going to get a");
+ try {
+ synchronized (a) {
+ easySleep(1000);
+ log.info("I have a, going to get b");
+ synchronized (b) {
+ log.info("I have both a and b");
+ }
+ log.info("what happened?");
+ }
+ } catch (Exception e) {
+ log.error("what happened? \n{}", e);
+ }
+ });
+
+ Thread th2 = new Thread(() -> {
+ log.info("going to get b");
+ try {
+ synchronized (b) {
+ easySleep(1000);
+ log.info("I have b, going to get a");
+ synchronized (a) {
+ log.info("I have both a and b");
+ }
+ }
+ } catch (Exception e) {
+ log.error("what happened? \n{}", e);
+ }
+ });
+
+ th1.start();
+ th2.start();
+ try {
+ th1.join(3000);
+ log.info("state of th1 {}", th1.getState());
+ th2.join(3000);
+ log.info("state of th2 {}", th1.getState());
+ th1.interrupt();
+ easySleep(1000);
+ log.info("state of th1 {} after interruption", th1.getState());
+ } catch (InterruptedException e) {
+ log.error("I am interrupted by {}", e);
+ }
+ log.info("I go first");
+ }
+
+ @Test
+ public void testAvertDeadLock() {
+ String a = "a";
+ String b = "b";
+
+ Thread th1 = new Thread(() -> {
+ log.info("going to get a");
+ try {
+ synchronized (a) {
+ easySleep(1000);
+ log.info("I had a, give up a now, going to get b");
+ a.wait();
+ synchronized (b) {
+ log.info("I have both a and b");
+ }
+ log.info("what happened?");
+ }
+ } catch (Exception e) {
+ log.error("what happened? \n{}", e, e);
+ }
+ });
+
+ Thread th2 = new Thread(() -> {
+ log.info("going to get b");
+ try {
+ synchronized (b) {
+ easySleep(1000);
+ log.info("I had b, going to get a");
+ synchronized (a) {
+ log.info("I have both a and b");
+ a.notifyAll();
+ }
+ log.info("now you can take b");
+ b.wait();
+ }
+ } catch (Exception e) {
+ log.error("what happened? \n{}", e);
+ }
+ });
+
+ th1.start();
+ th2.start();
+ try {
+ th1.join(3000);
+ log.info("state of th1 {}", th1.getState());
+ th2.join(3000);
+ log.info("state of th2 {}", th1.getState());
+ th1.interrupt();
+ easySleep(1000);
+ log.info("state of th1 {} after interruption", th1.getState());
+ } catch (InterruptedException e) {
+ log.error("I am interrupted by {}", e);
+ }
+ log.info("I go first");
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/lang/base/VarScopeTests.java b/jdk-study/src/test/java/study/java/lang/base/VarScopeTests.java
new file mode 100644
index 0000000..aa4ab1d
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/lang/base/VarScopeTests.java
@@ -0,0 +1,77 @@
+package study.java.lang.base;
+
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+public class VarScopeTests {
+ static final Logger log = LoggerFactory.getLogger(VarScopeTests.class);
+
+ static int i = 0;
+
+ // int i = 1; //conflict with static i
+ {
+ log.info("what is i before initial block? \n\t{}", i);
+ int i = 2;
+ log.info("what is i after initial block? \n\t{}\n\t or VarScopeTests.i: {}", i, VarScopeTests.i);
+ }
+
+ @Test
+ public void testScope() {
+ int i = 3;
+ log.info("i inside testScope() is \n\t{}", i);
+ {
+// int i = 4;//i is already defined in outer scope
+ int j = 4;
+ log.info("j inside { } inside testScope() is \n\t{}", j);
+ }
+ int j = 5;
+ log.info("j inside testScope() is \n\t{}", j);
+
+ Runnable r = () -> {
+ log.info("check j from inside Runnable inside testScope() is \n\t{}", j);
+// int j = 6; //conflict with j in outer scope
+ };
+ r.run();
+
+ stub(() -> {
+ int k = 8;
+ log.info("check k from inside Runnable inside testScope() is \n\t{}", k);
+ });
+
+// Function f = (Runnable r)->{ /* r is already defined at line 338*/};
+ Function f = (Runnable _r) -> {
+ int k = 9;
+ _r.run();
+ log.info("check k from inside lambda f() is \n\t{}", k);
+ return null;
+ };
+
+ f.apply(() -> {
+ int k = 10;
+ log.info("check k from inside Runnable passed to f inside testScope() is \n\t{}", k);
+ });
+
+ Supplier> s = () -> {
+ Integer l = 11;
+ return () -> l;
+ };
+ int l = 12;
+
+ for (int a = 0; a < 1; a++) {
+ log.info("check a from for loop: {}", a);
+ }
+// log.info("check a after for loop: {}", a);
+ int a = -1;
+ log.info("check new a after for loop: {}", a);
+ }
+
+ void stub(Runnable r) {
+ int k = 7;
+ r.run();
+ log.info("check k from inside stub() is \n\t{}", k);
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/util/LinkedHashMapTests.java b/jdk-study/src/test/java/study/java/util/LinkedHashMapTests.java
new file mode 100644
index 0000000..00e4b67
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/util/LinkedHashMapTests.java
@@ -0,0 +1,34 @@
+package study.java.util;
+
+import org.apache.commons.collections4.IteratorUtils;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.LinkedHashMap;
+
+public class LinkedHashMapTests {
+ static final Logger log = LoggerFactory.getLogger(LinkedHashMapTests.class);
+
+ @Test
+ public void testOrder1() {
+ LinkedHashMap lhm = new LinkedHashMap<>(16,0.75f,true);
+ lhm.put("banana", "yellow");
+ lhm.put("apple", "red");
+ lhm.put("watermelon", "green");
+ lhm.put("plum", "purple");
+
+ log.info("Order: \n\tkeys:\t{}\n\tvalues:\t{}\n\tentries:\t{}",
+ lhm.keySet(),
+ lhm.values(),
+ IteratorUtils.toString(lhm.entrySet().iterator()));
+
+ lhm.get("banana");
+ lhm.get("watermelon");
+
+ log.info("Order: \n\tkeys:\t{}\n\tvalues:\t{}\n\tentries:\t{}",
+ lhm.keySet(),
+ lhm.values(),
+ IteratorUtils.toString(lhm.entrySet().iterator()));
+ }
+}
diff --git a/jdk-study/src/test/java/study/java/util/ListTests.java b/jdk-study/src/test/java/study/java/util/ListTests.java
new file mode 100644
index 0000000..ad7dba9
--- /dev/null
+++ b/jdk-study/src/test/java/study/java/util/ListTests.java
@@ -0,0 +1,27 @@
+package study.java.util;
+
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ListTests {
+ static final Logger log = LoggerFactory.getLogger(ListTests.class);
+
+ @Test
+ public void testRemoveInForeach() {
+ List list = new ArrayList<>();
+ list.add("1");
+ list.add("2");
+
+ for (String str : list) {
+ if ("2".equals(str)) {
+ list.remove(str);
+ }
+ }
+ log.info("list is {}", list);
+ }
+
+}
diff --git a/jdk-study/src/test/resources/log4j2.xml b/jdk-study/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..739f19f
--- /dev/null
+++ b/jdk-study/src/test/resources/log4j2.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4623b77..08ff401 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,151 +1,161 @@
-
- 4.0.0
- study_java_8
- study_java_8
- 0.0.1-SNAPSHOT
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
- 2.5.0-rc1
-
-
- junit
- junit
- 4.10
-
-
- org.apache.commons
- commons-lang3
- 3.1
-
-
- org.apache.commons
- commons-collections4
- 4.0
-
-
- org.apache.commons
- commons-io
- 1.3.2
-
-
-
- org.jboss
- jandex
- 1.2.0.Final
-
-
-
-
-
- org.jboss.weld.se
- weld-se
- 2.2.6.Final
-
-
-
-
-
- com.google.guava
- guava
- 18.0
-
-
- log4j
- log4j
- 1.2.17
-
-
-
-
-
-
-
- org.mozilla
- rhino
- 1.7R4
-
-
-
-
-
-
-
-
- org.hibernate.javax.persistence
- hibernate-jpa-2.1-api
- 1.0.0.Final
-
-
-
- org.hibernate
- hibernate-entitymanager
- 4.3.7.Final
-
-
-
-
- org.glassfish.hk2
- class-model
- 2.4.0-b07
-
-
-
- org.apache.xbean
- xbean-classloader
- 4.1
-
-
-
- org.python
- jython
- 2.7-b1
-
-
-
- org.apache.lucene
- lucene-queries
- 4.10.3
-
-
-
- org.hsqldb
- hsqldb
- 2.3.2
-
-
-
-
- src/main/java
- src/main/java
-
-
-
- maven-compiler-plugin
- 3.1
-
- 1.8
- 1.8
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.18.1
-
- -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m
-
-
-
- always
-
-
-
-
-
+
+ 4.0.0
+ java-study
+ java-study
+ 0.1.2
+ pom
+
+
+ 5.5.1
+
+
+
+ jdk-study
+ java-ee-study
+ testing-study
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.jupiter.version}
+ test
+
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ ${junit.jupiter.version}
+
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.12.1
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.9
+
+
+
+ org.apache.commons
+ commons-collections4
+ 4.4
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.10.0.pr2
+
+
+
+ org.apache.commons
+ commons-io
+ 1.3.2
+
+
+ commons-io
+ commons-io
+
+
+
+
+
+ org.apache.commons
+ commons-compress
+ 1.4.1
+
+
+
+ commons-codec
+ commons-codec
+ LATEST
+
+
+
+ org.apache.httpcomponents
+ fluent-hc
+ LATEST
+
+
+
+ javax.xml.bind
+ jaxb-api
+ LATEST
+
+
+ com.sun.xml.bind
+ jaxb-core
+ LATEST
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ LATEST
+
+
+
+
+
+
+ maven-compiler-plugin
+ 3.8.1
+
+ 12
+ 12
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M4
+
+
+ false
+ 3.0
+ false
+ true
+ true
+ true
+
+
+ false
+ UTF-8
+ false
+
+
+ false
+ false
+ true
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.8.2
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+ 3.0.0-M4
+
+
+
diff --git a/src/main/java/cf/study/java8/javax/cdi/weld/WeldTest.java b/src/main/java/cf/study/java8/javax/cdi/weld/WeldTest.java
deleted file mode 100644
index 4d23796..0000000
--- a/src/main/java/cf/study/java8/javax/cdi/weld/WeldTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package cf.study.java8.javax.cdi.weld;
-
-import java.util.Set;
-import java.util.function.Consumer;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.CDI;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.jboss.weld.context.RequestContext;
-import org.jboss.weld.context.unbound.UnboundLiteral;
-import org.jboss.weld.environment.se.Weld;
-import org.jboss.weld.environment.se.WeldContainer;
-import org.jboss.weld.literal.AnyLiteral;
-import org.jboss.weld.literal.NamedLiteral;
-import org.jboss.weld.literal.NormalScopeLiteral;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import cf.study.java8.javax.cdi.weld.beans.AppBean;
-import cf.study.java8.javax.cdi.weld.beans.BizRequest;
-
-public class WeldTest {
-
- static Weld weld;
- static WeldContainer container;
- static BeanManager bm;
- static CDI cdi;
-
- // @Inject
-
- @BeforeClass
- public static void setUp() {
- try {
- weld = new Weld();
- container = weld.initialize();
- bm = container.getBeanManager();
- cdi = CDI.current();
- } catch (final Exception e) {
- e.printStackTrace();
- System.exit(-1);
- }
- }
-
- @Test
- public void testAppBean() throws Exception {
- System.out.println(bm.getBeans("appBean"));
- Set> appBeans = bm.getBeans(AppBean.class);
- System.out.println(appBeans);
- appBeans.forEach((bean) -> {
- System.out.println(ToStringBuilder.reflectionToString(bean, ToStringStyle.MULTI_LINE_STYLE));
- System.out.println(bm.getReference(bean, AppBean.class, bm.createCreationalContext(bean)));
- });
- }
-
- @Test
- public void testBizReq() throws Exception {
- /**
- * In this case Weld is using unbound RequestContext that is associated with a thread (RequestContext).
- * You need to manually initialize new RequestContext in a thread that You're creating
- */
- RequestContext reqCtx = (RequestContext) cdi.select(RequestContext.class, UnboundLiteral.INSTANCE).get();
- reqCtx.activate();
-
- System.out.println(bm.getBeans("bizRequest"));
- Set> bizReqs = bm.getBeans(BizRequest.class);
- System.out.println(bizReqs);
- bizReqs.forEach((bean) -> {
- System.out.println(ToStringBuilder.reflectionToString(bean, ToStringStyle.MULTI_LINE_STYLE));
- System.out.println(bm.getReference(bean, BizRequest.class, bm.createCreationalContext(bean)));
- });
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testSelectClzzByScope() {
- Consumer printer = (i) -> {
- try {
- System.out.println(ToStringBuilder.reflectionToString(i, ToStringStyle.MULTI_LINE_STYLE));
- } catch (Exception e) {
- e.printStackTrace();
- }
- };
-
-// cdi.forEach(printer);
-
- bm.getBeans(Object.class, AnyLiteral.INSTANCE).forEach(printer);
- }
-
- @AfterClass
- public static void tearDown() {
-
- if (weld != null)
- weld.shutdown();
- }
-}
diff --git a/src/main/java/cf/study/java8/javax/cdi/weld/beans/AppBean.java b/src/main/java/cf/study/java8/javax/cdi/weld/beans/AppBean.java
deleted file mode 100644
index c816c99..0000000
--- a/src/main/java/cf/study/java8/javax/cdi/weld/beans/AppBean.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package cf.study.java8.javax.cdi.weld.beans;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.ApplicationScoped;
-
-import misc.MiscUtils;
-
-import org.apache.log4j.Logger;
-
-@ApplicationScoped
-public class AppBean extends BasicBean {
-
- private static Logger log = Logger.getLogger(AppBean.class);
-
- @PostConstruct
- public void postConstruct() {
- log.info(MiscUtils.invocationInfo() + "\n\t" + this);
- }
-
- @PreDestroy
- public void preDestroy() {
- log.info(MiscUtils.invocationInfo() + "\n\t" + this);
- }
-
-
-}
diff --git a/src/main/java/cf/study/java8/javax/cdi/weld/beans/BasicBean.java b/src/main/java/cf/study/java8/javax/cdi/weld/beans/BasicBean.java
deleted file mode 100644
index 16f9a6e..0000000
--- a/src/main/java/cf/study/java8/javax/cdi/weld/beans/BasicBean.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package cf.study.java8.javax.cdi.weld.beans;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.Dependent;
-import javax.inject.Inject;
-
-import misc.MiscUtils;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.log4j.Logger;
-
-@Dependent
-public class BasicBean {
-
- private static Logger log = Logger.getLogger(BasicBean.class);
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Long getCreatedTime() {
- return createdTime;
- }
-
- @Inject
- protected Long id;
- protected Long createdTime = System.currentTimeMillis();
- protected String name;
-
- public Long getId() {
- return id;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof BasicBean))
- return false;
- BasicBean other = (BasicBean) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-
- public BasicBean() {
- //log.info(MiscUtils.invocationInfo() + "\n\t" + this);
- }
-
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-
- @PostConstruct
- public void postConstruct() {
- log.info(MiscUtils.invocationInfo() + "\n\t" + this);
- }
-
- @PreDestroy
- public void preDestroy() {
- log.info(MiscUtils.invocationInfo() + "\n\t" + this);
- }
-
-
-}
diff --git a/src/main/java/cf/study/java8/javax/cdi/weld/beans/BizRequest.java b/src/main/java/cf/study/java8/javax/cdi/weld/beans/BizRequest.java
deleted file mode 100644
index 48ca72b..0000000
--- a/src/main/java/cf/study/java8/javax/cdi/weld/beans/BizRequest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package cf.study.java8.javax.cdi.weld.beans;
-
-import javax.enterprise.context.RequestScoped;
-
-import org.apache.log4j.Logger;
-
-@RequestScoped
-public class BizRequest extends BasicBean {
-
- private static Logger log = Logger.getLogger(BizRequest.class);
-
- private Object param;
-
- public Object getParam() {
- return param;
- }
-
- public void setParam(Object param) {
- this.param = param;
- }
-}
diff --git a/src/main/java/cf/study/java8/javax/cdi/weld/beans/IBizProcessor.java b/src/main/java/cf/study/java8/javax/cdi/weld/beans/IBizProcessor.java
deleted file mode 100644
index e2ae03d..0000000
--- a/src/main/java/cf/study/java8/javax/cdi/weld/beans/IBizProcessor.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package cf.study.java8.javax.cdi.weld.beans;
-
-import javax.inject.Named;
-
-@Named
-public interface IBizProcessor