-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
262 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Example user template template | ||
### Example user template | ||
|
||
# IntelliJ project files | ||
.idea | ||
*.iml | ||
out | ||
gen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/java/com/landy/singleton/Singleton.java → ...n/java/org/landy/singleton/Singleton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.landy.singleton; | ||
package org.landy.singleton; | ||
|
||
/** | ||
* Created by Landy on 2018/5/12. | ||
|
2 changes: 1 addition & 1 deletion
2
src/main/java/com/landy/singleton/Test.java → src/main/java/org/landy/singleton/Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.landy.singleton; | ||
package org.landy.singleton; | ||
|
||
/** | ||
* Created by Landy on 2018/5/12. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.landy.web.utils; | ||
|
||
import javax.servlet.ServletContext; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
|
||
/** | ||
* 平台类<br> | ||
* 记录平台的配置信息供各个应用使用,并加载并初始化各个应用。 | ||
*/ | ||
public class ApplicationUtil implements ApplicationContextAware { | ||
|
||
private static ApplicationContext applicationContext; | ||
private static ServletContext servletContext; | ||
|
||
public static void init(ServletContext _servletContext) { | ||
servletContext = _servletContext; | ||
} | ||
|
||
public static ServletContext getServletContext() throws Exception { | ||
return servletContext; | ||
} | ||
|
||
/** | ||
* ApplicationContextAware接口的context注入函数. | ||
*/ | ||
public void setApplicationContext(ApplicationContext context) throws BeansException { | ||
applicationContext = context; | ||
} | ||
|
||
public static ApplicationContext getApplicationContext() { | ||
if (applicationContext == null) | ||
throw new IllegalStateException("applicaitonContext未注入,请在applicationContext.xml中定义SpringContextUtil"); | ||
return applicationContext; | ||
} | ||
|
||
public static <T> T getBean(String name) throws BeansException { | ||
return (T) applicationContext.getBean(name); | ||
} | ||
|
||
public static <T> T getBean(Class clazz) throws BeansException { | ||
return (T) applicationContext.getBean(clazz); | ||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration debug="true"> | ||
<!-- 应用名称 --> | ||
<property name="APP_NAME" value="design-patterns" /> | ||
<!--日志文件的保存路径,首先查找系统属性-Dlog.dir,如果存在就使用其;否则,在当前目录下创建名为logs目录做日志存放的目录 --> | ||
<property name="LOG_HOME" value="${log.dir:-logs}/${APP_NAME}" /> | ||
<!-- 日志输出格式 --> | ||
<property name="ENCODER_PATTERN" | ||
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{80} - %msg%n" /> | ||
<contextName>${APP_NAME}</contextName> | ||
|
||
<!-- 控制台日志:输出全部日志到控制台 --> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
<Pattern>${ENCODER_PATTERN}</Pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- 文件日志:输出全部日志到文件 --> | ||
<appender name="FILE" | ||
class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>${LOG_HOME}/output.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>7</maxHistory> | ||
</rollingPolicy> | ||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
<pattern>${ENCODER_PATTERN}</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- 错误日志:用于将错误日志输出到独立文件 --> | ||
<appender name="ERROR_FILE" | ||
class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>${LOG_HOME}/error.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>7</maxHistory> | ||
</rollingPolicy> | ||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
<pattern>${ENCODER_PATTERN}</pattern> | ||
</encoder> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>WARN</level> | ||
</filter> | ||
</appender> | ||
|
||
<!-- 独立输出的同步日志 --> | ||
<appender name="SYNC_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>${LOG_HOME}/sync.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>7</maxHistory> | ||
</rollingPolicy> | ||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | ||
<pattern>${ENCODER_PATTERN}</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<logger name="log.sync" level="DEBUG" addtivity="true"> | ||
<appender-ref ref="SYNC_FILE" /> | ||
</logger> | ||
|
||
<root> | ||
<level value="DEBUG" /> | ||
<appender-ref ref="STDOUT" /> | ||
<appender-ref ref="FILE" /> | ||
<appender-ref ref="ERROR_FILE" /> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" | ||
http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd | ||
http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context-4.1.xsd | ||
http://www.springframework.org/schema/task | ||
http://www.springframework.org/schema/task/spring-task-3.2.xsd" | ||
default-autowire="byName" default-lazy-init="false"> | ||
<!-- 引入属性文件 --> | ||
<context:property-placeholder location="classpath:config.properties" /> | ||
|
||
<!-- 自动扫描(自动注入) --> | ||
<context:component-scan base-package="org.landy" /> | ||
|
||
<!-- task任务扫描注解 --> | ||
<task:annotation-driven/> | ||
<!-- 平台Bean获取工具 --> | ||
<bean id="applicationUtil" class="org.landy.web.utils.ApplicationUtil" /> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters