clazzs) throws ClassNotFoundException, IOException {
+ //将报名替换成目录
+ String fileName = packageName.replaceAll("\\.", "/");
+ //通过classloader来获取文件列表
+ File file = new File(Thread.currentThread().getContextClassLoader().getResource(fileName).getFile());
+ File[] files = file.listFiles();
+ for (File f:files) {
+ //如果是目录,这进一个寻找
+ if (f.isDirectory()) {
+ //截取路径最后的文件夹名
+ String currentPathName = f.getAbsolutePath().substring(f.getAbsolutePath().lastIndexOf(File.separator)+1);
+ //进一步寻找
+ findClass(packageName+"."+currentPathName, clazzs);
+ } else {
+ //如果是class文件
+ if (f.getName().endsWith(".class")) {
+ //反射出实例
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(packageName+"."+f.getName().replace(".class",""));
+ clazzs.add(clazz);
+ }
+ }
+ }
+ return clazzs;
+ }
+}
diff --git a/src/main/java/com/pinnet/aware/TestApplicationContextAware.java b/src/main/java/com/pinnet/aware/TestApplicationContextAware.java
new file mode 100644
index 0000000..717d3fa
--- /dev/null
+++ b/src/main/java/com/pinnet/aware/TestApplicationContextAware.java
@@ -0,0 +1,26 @@
+package com.pinnet.aware;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * EmbeddedValueResolverAware/ResourceLoaderAware/ApplicationEventPublisherAware/MessageSourceAware/ApplicationContextAware类似
+ */
+public class TestApplicationContextAware implements ApplicationContextAware {
+
+ private ApplicationContext context;
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.context = applicationContext;
+ }
+
+ public ApplicationContext getContext() {
+ return context;
+ }
+
+ public void setContext(ApplicationContext context) {
+ this.context = context;
+ }
+}
diff --git a/src/main/java/com/pinnet/aware/TestApplicationEventPublisherAware.java b/src/main/java/com/pinnet/aware/TestApplicationEventPublisherAware.java
new file mode 100644
index 0000000..5f24130
--- /dev/null
+++ b/src/main/java/com/pinnet/aware/TestApplicationEventPublisherAware.java
@@ -0,0 +1,40 @@
+package com.pinnet.aware;
+
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.context.ApplicationEventPublisherAware;
+
+import javax.annotation.PostConstruct;
+
+public class TestApplicationEventPublisherAware implements ApplicationEventPublisherAware {
+
+ private ApplicationEventPublisher publisher;
+
+ @Override
+ public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
+ this.publisher = applicationEventPublisher;
+ }
+
+ public ApplicationEventPublisher getPublisher() {
+ return publisher;
+ }
+
+ public class TestEvent extends ApplicationEvent {
+
+ private Object object;
+
+ public TestEvent(Object source, Object object) {
+ super(source);
+ this.object = object;
+ }
+
+ public Object getObject() {
+ return object;
+ }
+ }
+
+ @PostConstruct
+ public void test() {
+ publisher.publishEvent(new TestEvent(this, "test"));
+ }
+}
diff --git a/src/main/java/com/pinnet/aware/TestAware.java b/src/main/java/com/pinnet/aware/TestAware.java
new file mode 100644
index 0000000..40d8874
--- /dev/null
+++ b/src/main/java/com/pinnet/aware/TestAware.java
@@ -0,0 +1,31 @@
+package com.pinnet.aware;
+
+import org.springframework.aop.support.AopUtils;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.*;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.GenericTypeResolver;
+import org.springframework.core.OrderComparator;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.util.Assert;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.*;
+import java.util.concurrent.Executor;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class TestAware {
+
+ public static void main(String[] args) {
+ ApplicationContext context = new ClassPathXmlApplicationContext("spring-aware.xml");
+ }
+
+
+}
diff --git a/src/main/java/com/pinnet/aware/TestBeanAware.java b/src/main/java/com/pinnet/aware/TestBeanAware.java
new file mode 100644
index 0000000..d1b98a4
--- /dev/null
+++ b/src/main/java/com/pinnet/aware/TestBeanAware.java
@@ -0,0 +1,20 @@
+package com.pinnet.aware;
+
+import org.springframework.beans.factory.BeanNameAware;
+
+/**
+ * BeanNameAware/BeanClassLoaderAware/BeanFactoryAware类似
+ */
+public class TestBeanAware implements BeanNameAware{
+
+ private String beanName;
+ @Override
+ public void setBeanName(String beanName) {
+ System.out.println(beanName);
+ this.beanName = beanName;
+ }
+
+ public String getBeanName() {
+ return beanName;
+ }
+}
diff --git a/src/main/java/com/pinnet/aware/TestEmbeddedValueResolverAware.java b/src/main/java/com/pinnet/aware/TestEmbeddedValueResolverAware.java
new file mode 100644
index 0000000..61f5a85
--- /dev/null
+++ b/src/main/java/com/pinnet/aware/TestEmbeddedValueResolverAware.java
@@ -0,0 +1,26 @@
+package com.pinnet.aware;
+
+import org.springframework.context.EmbeddedValueResolverAware;
+import org.springframework.util.StringValueResolver;
+
+import javax.annotation.PostConstruct;
+
+public class TestEmbeddedValueResolverAware implements EmbeddedValueResolverAware {
+
+ private StringValueResolver stringValueResolver;
+
+ @Override
+ public void setEmbeddedValueResolver(StringValueResolver stringValueResolver) {
+ this.stringValueResolver = stringValueResolver;
+ }
+
+ public String getProperties (String name) {
+ String elName = "${"+ name +"}";
+ return stringValueResolver.resolveStringValue(elName);
+ }
+
+ @PostConstruct
+ public void test() {
+ System.out.println(getProperties("name"));
+ }
+}
diff --git a/src/main/java/com/pinnet/aware/TestEvent.java b/src/main/java/com/pinnet/aware/TestEvent.java
new file mode 100644
index 0000000..141c246
--- /dev/null
+++ b/src/main/java/com/pinnet/aware/TestEvent.java
@@ -0,0 +1,23 @@
+package com.pinnet.aware;
+
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * Funtion: TODO.
+ *
+ * Author: lWX559685
+ * Date: 2018/12/11 14:54
+ */
+public class TestEvent extends ApplicationEvent {
+
+ private Object object;
+
+ public TestEvent(Object source, Object object) {
+ super(source);
+ this.object = object;
+ }
+
+ public Object getObject() {
+ return object;
+ }
+}
diff --git a/src/main/java/com/pinnet/aware/TestListener.java b/src/main/java/com/pinnet/aware/TestListener.java
new file mode 100644
index 0000000..bc812a6
--- /dev/null
+++ b/src/main/java/com/pinnet/aware/TestListener.java
@@ -0,0 +1,11 @@
+package com.pinnet.aware;
+
+import org.springframework.context.ApplicationListener;
+
+public class TestListener implements ApplicationListener{
+
+ @Override
+ public void onApplicationEvent(TestApplicationEventPublisherAware.TestEvent testEvent) {
+ System.out.println("TestEvent is Happen" + testEvent.getObject());
+ }
+}
diff --git a/src/main/java/com/pinnet/bean/BeanPostProcessorTest.java b/src/main/java/com/pinnet/bean/BeanPostProcessorTest.java
new file mode 100644
index 0000000..d2f6917
--- /dev/null
+++ b/src/main/java/com/pinnet/bean/BeanPostProcessorTest.java
@@ -0,0 +1,33 @@
+package com.pinnet.bean;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+public class BeanPostProcessorTest implements BeanPostProcessor{
+
+ /**
+ * 在bean加载之前处理
+ * @param bean
+ * @param beanName
+ * @return
+ * @throws BeansException
+ */
+ @Override
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
+ System.out.println("before");
+ return bean;
+ }
+
+ /**
+ * 在bean加载之后处理
+ * @param bean
+ * @param beanName
+ * @return
+ * @throws BeansException
+ */
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ System.out.println("after");
+ return bean;
+ }
+}
diff --git a/src/main/java/com/pinnet/bean/InitTest.java b/src/main/java/com/pinnet/bean/InitTest.java
new file mode 100644
index 0000000..11caaff
--- /dev/null
+++ b/src/main/java/com/pinnet/bean/InitTest.java
@@ -0,0 +1,10 @@
+package com.pinnet.bean;
+
+public class InitTest {
+
+ public void init() {
+ System.out.println("init");
+ }
+
+
+}
diff --git a/src/main/java/com/pinnet/bean/InitializingBeanTest.java b/src/main/java/com/pinnet/bean/InitializingBeanTest.java
new file mode 100644
index 0000000..d3f7dae
--- /dev/null
+++ b/src/main/java/com/pinnet/bean/InitializingBeanTest.java
@@ -0,0 +1,16 @@
+package com.pinnet.bean;
+
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * Funtion: TODO.
+ *
+ * Author: lWX559685
+ * Date: 2018/8/2 19:10
+ */
+public class InitializingBeanTest implements InitializingBean{
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ System.out.println("init");
+ }
+}
diff --git a/src/main/java/com/pinnet/bean/Test.java b/src/main/java/com/pinnet/bean/Test.java
new file mode 100644
index 0000000..8513e1b
--- /dev/null
+++ b/src/main/java/com/pinnet/bean/Test.java
@@ -0,0 +1,14 @@
+package com.pinnet.bean;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Test {
+
+ public static void main(String[] args) {
+ //增强性的bean容器初始化化
+ ApplicationContext context = new ClassPathXmlApplicationContext("spring-bean.xml");
+ InitTest initTest = context.getBean("initTest", InitTest.class);
+ }
+
+}
diff --git a/src/main/java/com/pinnet/customLabel/Test.java b/src/main/java/com/pinnet/customLabel/Test.java
new file mode 100644
index 0000000..4b5b5e5
--- /dev/null
+++ b/src/main/java/com/pinnet/customLabel/Test.java
@@ -0,0 +1,16 @@
+package com.pinnet.customLabel;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Test {
+ public static void main(String[] args) {
+ ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
+ User user1 = (User) context.getBean("user1");
+ User user2 = (User) context.getBean("user2");
+ User user3 = (User) context.getBean("user3");
+ System.out.println(user1);
+ System.out.println(user2);
+ System.out.println(user3);
+ }
+}
diff --git a/src/main/java/com/pinnet/customLabel/User.java b/src/main/java/com/pinnet/customLabel/User.java
new file mode 100644
index 0000000..1c9c66c
--- /dev/null
+++ b/src/main/java/com/pinnet/customLabel/User.java
@@ -0,0 +1,50 @@
+package com.pinnet.customLabel;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+
+public class User implements BeanFactoryPostProcessor{
+
+ private String id;
+ private String name;
+ private String age;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAge() {
+ return age;
+ }
+
+ public void setAge(String age) {
+ this.age = age;
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "id='" + id + '\'' +
+ ", name='" + name + '\'' +
+ ", age='" + age + '\'' +
+ '}';
+ }
+
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
+ System.out.println("test");
+ }
+}
diff --git a/src/main/java/com/pinnet/customLabel/UserBeanDefinitionParser.java b/src/main/java/com/pinnet/customLabel/UserBeanDefinitionParser.java
new file mode 100644
index 0000000..27f7b7c
--- /dev/null
+++ b/src/main/java/com/pinnet/customLabel/UserBeanDefinitionParser.java
@@ -0,0 +1,29 @@
+package com.pinnet.customLabel;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+public class UserBeanDefinitionParser implements BeanDefinitionParser {
+
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ String id = element.getAttribute("id");
+ String name = element.getAttribute("name");
+ String age = element.getAttribute("age");
+ BeanDefinitionRegistry registry = parserContext.getRegistry();
+ BeanDefinition beanDefinition = null;
+ try {
+ beanDefinition = new RootBeanDefinition(User.class);
+ beanDefinition.getPropertyValues().add("id", id);
+ beanDefinition.getPropertyValues().add("name", name);
+ beanDefinition.getPropertyValues().add("age", age);
+ registry.registerBeanDefinition(id, beanDefinition);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return beanDefinition;
+ }
+}
diff --git a/src/main/java/com/pinnet/customLabel/UserNameSpaceHandler.java b/src/main/java/com/pinnet/customLabel/UserNameSpaceHandler.java
new file mode 100644
index 0000000..6dc2881
--- /dev/null
+++ b/src/main/java/com/pinnet/customLabel/UserNameSpaceHandler.java
@@ -0,0 +1,10 @@
+package com.pinnet.customLabel;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+public class UserNameSpaceHandler extends NamespaceHandlerSupport {
+
+ public void init() {
+ registerBeanDefinitionParser("user",new UserBeanDefinitionParser());
+ }
+}
diff --git a/src/main/java/com/pinnet/jdbc/IRoleService.java b/src/main/java/com/pinnet/jdbc/IRoleService.java
new file mode 100644
index 0000000..84fb601
--- /dev/null
+++ b/src/main/java/com/pinnet/jdbc/IRoleService.java
@@ -0,0 +1,15 @@
+package com.pinnet.jdbc;
+
+import java.util.List;
+
+/**
+ * Funtion: TODO.
+ *
+ * Author: lWX559685
+ * Date: 2018/7/4 13:57
+ */
+public interface IRoleService {
+
+ Role save(Role role);
+ List getAll();
+}
diff --git a/src/main/java/com/pinnet/jdbc/Role.java b/src/main/java/com/pinnet/jdbc/Role.java
new file mode 100644
index 0000000..9c76392
--- /dev/null
+++ b/src/main/java/com/pinnet/jdbc/Role.java
@@ -0,0 +1,40 @@
+package com.pinnet.jdbc;
+
+public class Role {
+ private Long id;
+ private String name;
+ private String detail;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDetail() {
+ return detail;
+ }
+
+ public void setDetail(String detail) {
+ this.detail = detail;
+ }
+
+ @Override
+ public String toString() {
+ return "Role{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", detail='" + detail + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/pinnet/jdbc/RoleMapper.java b/src/main/java/com/pinnet/jdbc/RoleMapper.java
new file mode 100644
index 0000000..7b00666
--- /dev/null
+++ b/src/main/java/com/pinnet/jdbc/RoleMapper.java
@@ -0,0 +1,17 @@
+package com.pinnet.jdbc;
+
+import org.springframework.jdbc.core.RowMapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class RoleMapper implements RowMapper {
+
+ public Role mapRow(ResultSet resultSet, int i) throws SQLException {
+ Role role = new Role();
+ role.setId(resultSet.getLong("id"));
+ role.setName(resultSet.getString("name"));
+ role.setDetail(resultSet.getString("detail"));
+ return role;
+ }
+}
diff --git a/src/main/java/com/pinnet/jdbc/RoleTest.java b/src/main/java/com/pinnet/jdbc/RoleTest.java
new file mode 100644
index 0000000..e3112b6
--- /dev/null
+++ b/src/main/java/com/pinnet/jdbc/RoleTest.java
@@ -0,0 +1,21 @@
+package com.pinnet.jdbc;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.List;
+
+public class RoleTest {
+
+ public static void main(String[] args) {
+ ApplicationContext context = new ClassPathXmlApplicationContext("spring-jdbc.xml");
+ IRoleService roleService = (IRoleService) context.getBean("roleService");
+ Role role = new Role();
+ role.setName("test");
+ role.setDetail("detail");
+ roleService.save(role);
+ System.out.println(role);
+ List roles = roleService.getAll();
+ System.out.println(roles);
+ }
+}
diff --git a/src/main/java/com/pinnet/jdbc/impl/RoleServiceImpl.java b/src/main/java/com/pinnet/jdbc/impl/RoleServiceImpl.java
new file mode 100644
index 0000000..efa7d13
--- /dev/null
+++ b/src/main/java/com/pinnet/jdbc/impl/RoleServiceImpl.java
@@ -0,0 +1,34 @@
+package com.pinnet.jdbc.impl;
+
+import com.pinnet.jdbc.IRoleService;
+import com.pinnet.jdbc.Role;
+import com.pinnet.jdbc.RoleMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+import java.util.List;
+
+/**
+ * Funtion: TODO.
+ *
+ * Author: lWX559685
+ * Date: 2018/7/4 13:58
+ */
+public class RoleServiceImpl implements IRoleService {
+
+ private JdbcTemplate jdbcTemplate;
+
+ public void setDataSoure(DataSource dataSoure) {
+ jdbcTemplate = new JdbcTemplate(dataSoure);
+ }
+
+ public Role save(Role role) {
+ jdbcTemplate.update("insert INTO role (name, detail) VALUES (?,?)", new Object[]{ role.getName(), role.getDetail()});
+ return role;
+ }
+
+ public List getAll() {
+ List roles = jdbcTemplate.query("select * from role", new RoleMapper());
+ return roles;
+ }
+}
diff --git a/src/main/java/com/pinnet/jetty/JettyStart.java b/src/main/java/com/pinnet/jetty/JettyStart.java
new file mode 100644
index 0000000..fd693ee
--- /dev/null
+++ b/src/main/java/com/pinnet/jetty/JettyStart.java
@@ -0,0 +1,17 @@
+package com.pinnet.jetty;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+public class JettyStart {
+
+ public static void main(String[] args) throws Exception {
+ Server server = new Server(8090);
+ WebAppContext context = new WebAppContext();
+ context.setContextPath("/");
+ context.setResourceBase("./");
+ context.setDescriptor("./src/main/resources/web.xml");
+ server.setHandler(context);
+ server.start();
+ }
+}
diff --git a/src/main/java/com/pinnet/message/Message.java b/src/main/java/com/pinnet/message/Message.java
new file mode 100644
index 0000000..0c0e6e3
--- /dev/null
+++ b/src/main/java/com/pinnet/message/Message.java
@@ -0,0 +1,32 @@
+package com.pinnet.message;
+
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.HierarchicalMessageSource;
+import org.springframework.context.MessageSource;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.DelegatingMessageSource;
+import org.springframework.context.support.ResourceBundleMessageSource;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class Message {
+
+ public static void main(String[] args) {
+ ApplicationContext context = new ClassPathXmlApplicationContext("spring-message.xml");
+ ResourceBundleMessageSource messageSource = context.getBean("messageSource", ResourceBundleMessageSource.class);
+ String messageZh = messageSource.getMessage("testtest", new Object[]{"数据"}, Locale.CHINESE);
+ String messageEn = messageSource.getMessage("testtest", new Object[]{"data"}, Locale.ENGLISH);
+ System.out.println(messageZh);
+ System.out.println(messageEn);
+
+ ResourceBundle resourceBundle = ResourceBundle.getBundle("message.test", Locale.US);
+ String testest = resourceBundle.getString("testtest");
+ String format = MessageFormat.format(testest, new Object[]{"data"});
+ System.out.println(format);
+ }
+
+
+}
diff --git a/src/main/java/com/pinnet/remote/HttpInvokerTest.java b/src/main/java/com/pinnet/remote/HttpInvokerTest.java
new file mode 100644
index 0000000..187600a
--- /dev/null
+++ b/src/main/java/com/pinnet/remote/HttpInvokerTest.java
@@ -0,0 +1,14 @@
+package com.pinnet.remote;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class HttpInvokerTest {
+
+ public static void main(String[] args) {
+ ApplicationContext client = new ClassPathXmlApplicationContext("spring-httpinvoker-client.xml");
+ IRemoteService remoteService = (IRemoteService) client.getBean("remoteService");
+ String show = remoteService.show();
+ System.out.println(show);
+ }
+}
diff --git a/src/main/java/com/pinnet/remote/IRemoteService.java b/src/main/java/com/pinnet/remote/IRemoteService.java
new file mode 100644
index 0000000..58d3381
--- /dev/null
+++ b/src/main/java/com/pinnet/remote/IRemoteService.java
@@ -0,0 +1,6 @@
+package com.pinnet.remote;
+
+public interface IRemoteService {
+
+ String show();
+}
diff --git a/src/main/java/com/pinnet/remote/RmiTest.java b/src/main/java/com/pinnet/remote/RmiTest.java
new file mode 100644
index 0000000..6fcafd3
--- /dev/null
+++ b/src/main/java/com/pinnet/remote/RmiTest.java
@@ -0,0 +1,13 @@
+package com.pinnet.remote;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class RmiTest {
+ public static void main(String[] args) {
+ ApplicationContext server = new ClassPathXmlApplicationContext("spring-rmi-server.xml");
+ ApplicationContext client = new ClassPathXmlApplicationContext("spring-rmi-client.xml");
+ IRemoteService remoteService = (IRemoteService) client.getBean("remoteService");
+ remoteService.show();
+ }
+}
diff --git a/src/main/java/com/pinnet/remote/impl/RemoteServiecImpl.java b/src/main/java/com/pinnet/remote/impl/RemoteServiecImpl.java
new file mode 100644
index 0000000..958264d
--- /dev/null
+++ b/src/main/java/com/pinnet/remote/impl/RemoteServiecImpl.java
@@ -0,0 +1,11 @@
+package com.pinnet.remote.impl;
+
+import com.pinnet.remote.IRemoteService;
+
+public class RemoteServiecImpl implements IRemoteService {
+
+ public String show() {
+ System.out.println("show");
+ return "show";
+ }
+}
diff --git a/src/main/java/com/pinnet/transaction/ITransactionUserService.java b/src/main/java/com/pinnet/transaction/ITransactionUserService.java
new file mode 100644
index 0000000..87fcabe
--- /dev/null
+++ b/src/main/java/com/pinnet/transaction/ITransactionUserService.java
@@ -0,0 +1,7 @@
+package com.pinnet.transaction;
+
+public interface ITransactionUserService {
+
+ void save(TransactionUser transactionUser);
+ TransactionUser getTransactionUser(Long id);
+}
diff --git a/src/main/java/com/pinnet/transaction/Test.java b/src/main/java/com/pinnet/transaction/Test.java
new file mode 100644
index 0000000..359614d
--- /dev/null
+++ b/src/main/java/com/pinnet/transaction/Test.java
@@ -0,0 +1,16 @@
+package com.pinnet.transaction;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Test {
+
+ public static void main(String[] args) {
+ ApplicationContext context = new ClassPathXmlApplicationContext("spring-transaction.xml");
+ ITransactionUserService transactionUserService = (ITransactionUserService) context.getBean("transactionUserService");
+ TransactionUser transactionUser = new TransactionUser();
+ transactionUser.setName("test");
+ transactionUser.setAge("25");
+ transactionUserService.save(transactionUser);
+ }
+}
diff --git a/src/main/java/com/pinnet/transaction/TransactionUser.java b/src/main/java/com/pinnet/transaction/TransactionUser.java
new file mode 100644
index 0000000..8f7f256
--- /dev/null
+++ b/src/main/java/com/pinnet/transaction/TransactionUser.java
@@ -0,0 +1,41 @@
+package com.pinnet.transaction;
+
+public class TransactionUser {
+
+ private Long id;
+ private String name;
+ private String age;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAge() {
+ return age;
+ }
+
+ public void setAge(String age) {
+ this.age = age;
+ }
+
+ @Override
+ public String toString() {
+ return "TransactionUser{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", age='" + age + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/pinnet/transaction/impl/TransactionUserServiceImpl.java b/src/main/java/com/pinnet/transaction/impl/TransactionUserServiceImpl.java
new file mode 100644
index 0000000..2d7e2ec
--- /dev/null
+++ b/src/main/java/com/pinnet/transaction/impl/TransactionUserServiceImpl.java
@@ -0,0 +1,34 @@
+package com.pinnet.transaction.impl;
+
+import com.pinnet.transaction.ITransactionUserService;
+import com.pinnet.transaction.TransactionUser;
+import com.pinnet.transaction.mapper.TransactionUserMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+public class TransactionUserServiceImpl implements ITransactionUserService {
+
+ private JdbcTemplate jdbcTemplate;
+
+ @Transactional(propagation = Propagation.REQUIRED)
+ public void save(TransactionUser transactionUser) {
+ jdbcTemplate.update("INSERT INTO transaction_user (name, age) VALUES (?,?)",
+ new Object[] {transactionUser.getName(), transactionUser.getAge()});
+ throw new RuntimeException("test");
+ }
+
+ public TransactionUser getTransactionUser(Long id) {
+ TransactionUser transactionUser =
+ jdbcTemplate.queryForObject("select * from transaction_user where id=?", new Object[]{id}, new TransactionUserMapper());
+ return transactionUser;
+ }
+
+ public JdbcTemplate getJdbcTemplate() {
+ return jdbcTemplate;
+ }
+
+ public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
+ this.jdbcTemplate = jdbcTemplate;
+ }
+}
diff --git a/src/main/java/com/pinnet/transaction/mapper/TransactionUserMapper.java b/src/main/java/com/pinnet/transaction/mapper/TransactionUserMapper.java
new file mode 100644
index 0000000..831c76b
--- /dev/null
+++ b/src/main/java/com/pinnet/transaction/mapper/TransactionUserMapper.java
@@ -0,0 +1,18 @@
+package com.pinnet.transaction.mapper;
+
+import com.pinnet.transaction.TransactionUser;
+import org.springframework.jdbc.core.RowMapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class TransactionUserMapper implements RowMapper {
+
+ public TransactionUser mapRow(ResultSet resultSet, int i) throws SQLException {
+ TransactionUser transactionUser = new TransactionUser();
+ transactionUser.setId(resultSet.getLong("id"));
+ transactionUser.setName(resultSet.getString("name"));
+ transactionUser.setAge(resultSet.getString("age"));
+ return transactionUser;
+ }
+}
diff --git a/src/main/java/com/pinnet/util/VolatileUtil.java b/src/main/java/com/pinnet/util/VolatileUtil.java
new file mode 100644
index 0000000..a8dd50c
--- /dev/null
+++ b/src/main/java/com/pinnet/util/VolatileUtil.java
@@ -0,0 +1,40 @@
+package com.pinnet.util;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class VolatileUtil {
+
+
+ public static void main(String[] args) throws InterruptedException {
+ MyRunnable runnable = new MyRunnable();
+ Runnable runnable1 = new Runnable() {
+ @Override
+ public void run() {
+ runnable.run();
+ }
+ };
+ Runnable runnable2 = new Runnable() {
+ @Override
+ public void run() {
+ runnable.stop();
+ }
+ };
+ new Thread(runnable1).start();
+ new Thread(runnable2).start();
+ }
+
+ public static class MyRunnable implements Runnable {
+
+ AtomicBoolean n = new AtomicBoolean(true);
+ @Override
+ public void run() {
+ while (n.get()) {
+ System.out.println(n);
+ }
+
+ }
+ public void stop() {
+ n.set(false);
+ }
+ }
+}
diff --git a/src/main/java/com/pinnet/zip/FileUtils.java b/src/main/java/com/pinnet/zip/FileUtils.java
new file mode 100644
index 0000000..b84de0a
--- /dev/null
+++ b/src/main/java/com/pinnet/zip/FileUtils.java
@@ -0,0 +1,126 @@
+package com.pinnet.zip;
+
+import com.github.junrar.Archive;
+import com.github.junrar.exception.RarException;
+import com.github.junrar.rarfile.FileHeader;
+
+import java.io.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Funtion: 文件操作.
+ *
+ * Author: lWX559685
+ * Date: 2018/8/27 15:31
+ */
+public class FileUtils {
+
+ public static void main(String[] args) throws IOException, RarException {
+ decompressionFile(new File("D:/DevTools/maven-3.0.3.zip"), "/t");
+ }
+
+
+ /**
+ * 提供给用户使用的解压工具
+ * @param inFile
+ * @param outPath
+ * @throws IOException
+ */
+ public static void decompressionFile(File inFile, String outPath) throws IOException, RarException {
+ File out = new File(outPath);
+ if (!out.isDirectory()) {
+ out.mkdirs();
+ }
+ if (!outPath.endsWith(File.separator)) {
+ outPath += File.separator;
+ }
+ //zip读取压缩文件
+ FileInputStream fileInputStream = new FileInputStream(inFile);
+ ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
+ //检测文件类型
+ boolean fileType = checkFile(zipInputStream);
+ //解压文件
+ if (fileType) {
+ unzip(outPath, zipInputStream);
+ } else {
+ unrar(outPath, inFile);
+ }
+ //关闭流
+ zipInputStream.close();
+ }
+
+ /**
+ * ZipInputStream是逐个目录进行读取,所以只需要循环
+ * @param outPath
+ * @param inFile
+ * @throws IOException
+ */
+ private static void unrar(String outPath, File inFile) throws IOException, RarException {
+ Archive archive = new Archive(inFile, null);
+ FileHeader fileHeader = archive.nextFileHeader();
+ while (fileHeader != null) {
+ String name = fileHeader.getFileNameString();
+ File file = new File(outPath+name);
+ file.getParentFile().mkdirs();
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
+ BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
+ archive.extractFile(fileHeader, bufferedOutputStream);
+ //关闭流
+ bufferedOutputStream.close();
+ fileOutputStream.close();
+ //读取下一个目录,作为循环条件
+ fileHeader = archive.nextFileHeader();
+ }
+ }
+
+ /**
+ * @param outPath
+ * @param inputStream
+ * @throws IOException
+ */
+ private static void unzip(String outPath, ZipInputStream inputStream) throws IOException {
+ //读取一个目录
+ ZipEntry nextEntry = inputStream.getNextEntry();
+ //不为空进入循环
+ while (nextEntry != null) {
+ String name = nextEntry.getName();
+ File file = new File(outPath+name);
+ //如果是目录,创建目录
+ if (name.endsWith("/")) {
+ file.mkdir();
+ } else {
+ //文件则写入具体的路径中
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
+ BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
+ int n;
+ byte[] bytes = new byte[1024];
+ while ((n = inputStream.read(bytes)) != -1) {
+ bufferedOutputStream.write(bytes, 0, n);
+ }
+ //关闭流
+ bufferedOutputStream.close();
+ fileOutputStream.close();
+ }
+ //关闭当前布姆
+ inputStream.closeEntry();
+ //读取下一个目录,作为循环条件
+ nextEntry = inputStream.getNextEntry();
+ }
+ }
+
+ /**
+ * 检测文件类型
+ * @param zipInputStream
+ * @return
+ * @throws IOException
+ */
+ private static boolean checkFile(ZipInputStream zipInputStream) throws IOException {
+ if (zipInputStream.getNextEntry() == null) {
+ //rar
+ return false;
+ }
+ //zip
+ return true;
+ }
+}
diff --git a/src/main/java/com/pinnet/zip/ZipIn.java b/src/main/java/com/pinnet/zip/ZipIn.java
new file mode 100644
index 0000000..e2461b6
--- /dev/null
+++ b/src/main/java/com/pinnet/zip/ZipIn.java
@@ -0,0 +1,84 @@
+package com.pinnet.zip;
+
+import java.io.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Funtion: TODO.
+ *
+ * Author: lWX559685
+ * Date: 2018/7/19 16:19
+ */
+public class ZipIn {
+
+ public static void main(String[] args) throws IOException {
+ decompressionFile("D:\\srv.zip", "D:\\test");
+ }
+
+ /**
+ * 提供给用户使用的解压工具
+ * @param srcPath
+ * @param outPath
+ * @throws IOException
+ */
+ public static void decompressionFile(String srcPath, String outPath) throws IOException {
+ //简单判断解压路径是否合法
+ if (!new File(srcPath).isDirectory()) {
+ //判断输出路径是否合法
+ if (new File(outPath).isDirectory()) {
+ if (!outPath.endsWith(File.separator)) {
+ outPath += File.separator;
+ }
+ //zip读取压缩文件
+ FileInputStream fileInputStream = new FileInputStream(srcPath);
+ ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
+ //解压文件
+ decompressionFile(outPath, zipInputStream);
+ //关闭流
+ zipInputStream.close();
+ fileInputStream.close();
+ } else {
+ throw new RuntimeException("输出路径不合法!");
+ }
+ } else {
+ throw new RuntimeException("需要解压的文件不合法!");
+ }
+ }
+
+ /**
+ * ZipInputStream是逐个目录进行读取,所以只需要循环
+ * @param outPath
+ * @param inputStream
+ * @throws IOException
+ */
+ private static void decompressionFile(String outPath, ZipInputStream inputStream) throws IOException {
+ //读取一个目录
+ ZipEntry nextEntry = inputStream.getNextEntry();
+ //不为空进入循环
+ while (nextEntry != null) {
+ String name = nextEntry.getName();
+ File file = new File(outPath+name);
+ //如果是目录,创建目录
+ if (name.endsWith("/")) {
+ file.mkdir();
+ } else {
+ //文件则写入具体的路径中
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
+ BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
+ int n;
+ byte[] bytes = new byte[1024];
+ while ((n = inputStream.read(bytes)) != -1) {
+ bufferedOutputStream.write(bytes, 0, n);
+ }
+ //关闭流
+ bufferedOutputStream.close();
+ fileOutputStream.close();
+ }
+ //关闭当前布姆
+ inputStream.closeEntry();
+ //读取下一个目录,作为循环条件
+ nextEntry = inputStream.getNextEntry();
+ }
+ }
+}
diff --git a/src/main/java/com/pinnet/zip/ZipOut.java b/src/main/java/com/pinnet/zip/ZipOut.java
new file mode 100644
index 0000000..587f13d
--- /dev/null
+++ b/src/main/java/com/pinnet/zip/ZipOut.java
@@ -0,0 +1,86 @@
+package com.pinnet.zip;
+
+import java.io.*;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Funtion: TODO.
+ *
+ * Author: lWX559685
+ * Date: 2018/7/19 10:53
+ */
+public class ZipOut {
+
+ public static void main(String[] args) throws IOException {
+ compressFile("D:\\srv", "D:\\");
+ }
+
+ /**
+ * 提供给用户使用的基本压缩类
+ * @param srcPath
+ * @param outPath
+ * @throws IOException
+ */
+ public static void compressFile(String srcPath, String outPath) throws IOException {
+ //读取源文件
+ File srcFile = new File(srcPath);
+ //判断输出路径是否正确
+ File outFile = new File(outPath);
+ //如果只是路劲加入对应的压缩名称
+ if (outFile.isDirectory()) {
+ //用"/"作文判断标准
+ if (outPath.endsWith(File.separator)) {
+ outPath += srcFile.getName().split("\\.")[0] + ".zip";
+ } else {
+ outPath += File.separator + srcFile.getName().split("\\.")[0] + ".zip";
+ }
+ }
+ //读取文件流
+ FileOutputStream fileOutputStream = new FileOutputStream(outPath);
+ ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
+ //压缩文件
+ compressFile(srcFile, srcFile.getName(),zipOutputStream);
+ //关闭流
+ zipOutputStream.close();
+ fileOutputStream.close();
+ }
+
+ /**
+ * 迭代方式进行文件压缩
+ * @param file
+ * @param fileName
+ * @param outputStream
+ * @throws IOException
+ */
+ private static void compressFile(File file, String fileName, final ZipOutputStream outputStream) throws IOException {
+ //如果是目录
+ if (file.isDirectory()) {
+ //创建文件夹
+ outputStream.putNextEntry(new ZipEntry(fileName+"/"));
+ //迭代判断,并且加入对应文件路径
+ File[] files = file.listFiles();
+ Iterator iterator = Arrays.asList(files).iterator();
+ while (iterator.hasNext()) {
+ File f = iterator.next();
+ compressFile(f, fileName+"/"+f.getName(), outputStream);
+ }
+ } else {
+ //创建文件
+ outputStream.putNextEntry(new ZipEntry(fileName));
+ //读取文件并写出
+ FileInputStream fileInputStream = new FileInputStream(file);
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
+ byte[] bytes = new byte[1024];
+ int n;
+ while ((n = bufferedInputStream.read(bytes)) != -1) {
+ outputStream.write(bytes, 0, n);
+ }
+ //关闭流
+ fileInputStream.close();
+ bufferedInputStream.close();
+ }
+ }
+}
diff --git a/src/main/resources/META-INF/spring.handlers b/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000..d4a01b3
--- /dev/null
+++ b/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.pinnet.com/schema/user=com.pinnet.customLabel.UserNameSpaceHandler
diff --git a/src/main/resources/META-INF/spring.schemas b/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000..f371e9f
--- /dev/null
+++ b/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1,2 @@
+http\://www.pinnet.com/schema/user.xsd=META-INF/user.xsd
+
diff --git a/src/main/resources/META-INF/user.xsd b/src/main/resources/META-INF/user.xsd
new file mode 100644
index 0000000..5353c18
--- /dev/null
+++ b/src/main/resources/META-INF/user.xsd
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/aware.properties b/src/main/resources/aware.properties
new file mode 100644
index 0000000..3299987
--- /dev/null
+++ b/src/main/resources/aware.properties
@@ -0,0 +1,3 @@
+name=test
+age=25
+sex=boy
\ No newline at end of file
diff --git a/src/main/resources/message/test_en.properties b/src/main/resources/message/test_en.properties
new file mode 100644
index 0000000..a963a93
--- /dev/null
+++ b/src/main/resources/message/test_en.properties
@@ -0,0 +1 @@
+testtest=test{0}
\ No newline at end of file
diff --git a/src/main/resources/message/test_zh.properties b/src/main/resources/message/test_zh.properties
new file mode 100644
index 0000000..cee15fe
--- /dev/null
+++ b/src/main/resources/message/test_zh.properties
@@ -0,0 +1 @@
+testtest=\u6d4b\u8bd5{0}
\ No newline at end of file
diff --git a/src/main/resources/spring-aware.xml b/src/main/resources/spring-aware.xml
new file mode 100644
index 0000000..84da593
--- /dev/null
+++ b/src/main/resources/spring-aware.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+ aware.properties
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-bean.xml b/src/main/resources/spring-bean.xml
new file mode 100644
index 0000000..a1a1186
--- /dev/null
+++ b/src/main/resources/spring-bean.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-config.xml b/src/main/resources/spring-config.xml
new file mode 100644
index 0000000..760af12
--- /dev/null
+++ b/src/main/resources/spring-config.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-httpinvoker-client.xml b/src/main/resources/spring-httpinvoker-client.xml
new file mode 100644
index 0000000..a2b591b
--- /dev/null
+++ b/src/main/resources/spring-httpinvoker-client.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-httpinvoker-server.xml b/src/main/resources/spring-httpinvoker-server.xml
new file mode 100644
index 0000000..a19f111
--- /dev/null
+++ b/src/main/resources/spring-httpinvoker-server.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-jdbc.xml b/src/main/resources/spring-jdbc.xml
new file mode 100644
index 0000000..8c21a25
--- /dev/null
+++ b/src/main/resources/spring-jdbc.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-message.xml b/src/main/resources/spring-message.xml
new file mode 100644
index 0000000..4c06e06
--- /dev/null
+++ b/src/main/resources/spring-message.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+ message.test
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-rmi-client.xml b/src/main/resources/spring-rmi-client.xml
new file mode 100644
index 0000000..ff1ff90
--- /dev/null
+++ b/src/main/resources/spring-rmi-client.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-rmi-server.xml b/src/main/resources/spring-rmi-server.xml
new file mode 100644
index 0000000..1ac2805
--- /dev/null
+++ b/src/main/resources/spring-rmi-server.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/spring-transaction.xml b/src/main/resources/spring-transaction.xml
new file mode 100644
index 0000000..ca11917
--- /dev/null
+++ b/src/main/resources/spring-transaction.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/web.xml b/src/main/resources/web.xml
new file mode 100644
index 0000000..abb231c
--- /dev/null
+++ b/src/main/resources/web.xml
@@ -0,0 +1,39 @@
+
+
+ omc-web
+
+ index.html
+
+
+
+ encodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ encoding
+ UTF-8
+
+
+ forceEncoding
+ true
+
+
+
+ encodingFilter
+ /*
+
+
+
+ springMvc
+ org.springframework.web.servlet.DispatcherServlet
+
+ contextConfigLocation
+ classpath:spring-httpinvoker-server.xml
+
+ 1
+
+
+ springMvc
+ /*
+
+
+