ycgwl-jar

1 com.ycgwl:ycgwl-cache:0.0.1.FRAME

缓存实现

分为 服务器缓存以及 redis缓存

需要注册缓存的Service通过继承 CacheSupport 并配置到spring中通过 实例化的时候通过调用 afterPropertiesSet 注册缓存

并且通过base-model中的配置的常亮作为key 存到CacheManager的Map中

那么当调用

CacheManager.getInstance().getCache(BaseCacheConstant.INTERFACE_CATCHE_UUID).get(表的id或者code的时候)如果缓存中没有则 调用该cache实例的doGet从数据库查取实体

具体cache操作Redis 如下

<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
        <property name="maxActive" value="${redis.pool.maxActive}"></property>
        <property name="maxIdle" value="${redis.pool.maxIdle}"></property>
        <property name="maxWait" value="${redis.pool.maxWait}"></property>
        <property name="testOnBorrow" value="${redis.pool.testOnBorrow}"></property>
        <property name="testOnReturn" value="${redis.pool.testOnReturn}"></property>
    </bean>
    
    <bean id="client" class="com.ycgwl.cache.redis.RedisClient">
        <property name="poolConfig" ref="poolConfig"></property>
        <property name="host" value="${redis.host}"></property> 
        <property name="port" value="${redis.port}"></property>
        <!-- <property name="password" value="${redis.password}"></property> -->
    </bean>
    
    <bean id="storage"
        class="com.ycgwl.cache.storage.RedisStorage">
        <property name="client" ref="client"></property>
    </bean>
    
    
    <!-- 产品缓存 -->
    <bean id="baseProductEntityCache" class="com.ycgwl.rosefinch.module.basedev.server.cache.base.BaseProductEntityCache">
        <property name="storage" ref="storage"></property>
        <property name="timeOut" value="${rosefinch.base.BaseProductEntityCache.timeOut}"></property>
    </bean>

2 com.ycgwl:ycgwl-kafka:0.0.1.FRAME
日志收集中心,有具体kafkaConsumer和kafkaProducer的实现

 

3 com.ycgwl:ycgwl-mq:0.0.1.FRAME

该包提供了可缓存的
连接工厂

<task:executor id="taskExecutor" pool-size="4-256" queue-capacity="128" />  
    <bean id="rabbitConnectionFactory" class="com.rabbitmq.client.ConnectionFactory">  
        <property name="host" value="${rabbitmq.host}" />  
        <property name="port" value="${rabbitmq.port}" />  
        <property name="username" value="${rabbitmq.username}" />  
        <property name="password" value="${rabbitmq.password}" />  
        <property name="virtualHost" value="${rabbitmq.vhost}" />  
        <!-- <property name="connectionTimeout" value="${rabbitmq.connection.timeout}" />   -->
    </bean>   
    <bean id="rabbitConnFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">  
        <constructor-arg ref="rabbitConnectionFactory" />  
        <property name="channelCacheSize" value="25" />  
        <property name="executor" ref="taskExecutor" />  
    </bean>  
    <!--通过指定下面的admin信息,当前producer中的exchange和queue会在rabbitmq服务器上自动生成 -->
    <rabbit:admin connection-factory="rabbitConnFactory" />    

 

 以及messageProducer的实现,但是需要一个RabbitTemplate

所以调用方需要配置rabbitTemplate

如下

@Service("messageProducer")
public class MessageProducer implements IMessageProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    private final Logger log = LoggerFactory.getLogger(this.getClass());

    public MessageProducer() {
    }

    public DetailResult sendByQueue(Object message, String queue) {
        this.rabbitTemplate.setRoutingKey(queue);
        String messageJson = JSONObject.toJSONString(message);

        try {
            this.rabbitTemplate.convertAndSend(messageJson);
            this.log.debug("send message " + messageJson, "OTHER");
        } catch (RuntimeException var7) {
            var7.printStackTrace();
            this.log.error("send failed ", "EXCEPTION", var7);

            try {
                this.rabbitTemplate.convertAndSend(message);
            } catch (RuntimeException var6) {
                var6.printStackTrace();
                this.log.error("send failed again", "EXCEPTION", var6);
                return new DetailResult(false, var6.toString());
            }
        }

        return new DetailResult(true, "");
    }
}

调用方

<!-- mq连接工厂 -->
    <import resource="classpath*:rabbitmq-factory.xml" />
        <!-- 创建rabbitTemplate 消息模板类 -->
    <bean id="rabbitTemplate" class="org.springframework.amqp.rabbit.core.RabbitTemplate">
        <constructor-arg ref="rabbitConnFactory"></constructor-arg>
        <property name="exchange" value="${rabbitmq.exchangeBase}" />
    </bean>

 4 com.ycgwl:ycgwl-quartz:0.0.1.FRAME

通过GridJobLoaderPlugin.start() 读取数据库 循环开启job

 

1:com.ycgwl.framework-base:0.0.1.FRAME(专注于model,service层)

model层:BaseEntity IEnitty,

异常:BusinessException,GeneralException

service层:IService

util相关

IOUtils,JsonUtils,PropertiesHelper,StringUtil

引用了 common json log kafka

 <dependencies>
          <!-- log lib begin -->
      <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <!-- log lib end -->
        
        <dependency>
            <groupId>com.caucho</groupId>
            <artifactId>hessian</artifactId>
        </dependency>
        
        <!-- common lib begin -->    
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
        </dependency>
        <!-- common lib end -->
        
        <!-- json lib begin -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <!-- json lib end -->
        <dependency>
            <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-kafka</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
    </dependencies>
View Code

 

 

2:com.ycgwl.framework-core:0.0.1.FRAME()

context AppContext,RequestContext,SessionContext,

Filter:FrameworkFilter

listener:AppContextListener,ContentLoaderListener

引用 servlet-api,jsp-api,spring,framework-base

 

 <dependencies>
          <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <scope>provided</scope>
        </dependency>
        
        <!-- spring begin -->
        <dependency>
              <groupId>org.springframework</groupId>
              <artifactId>spring-web</artifactId>
          </dependency>
          <dependency>
              <groupId>org.springframework</groupId>
              <artifactId>spring-jdbc</artifactId>
          </dependency>
          
          <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-instrument</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
        </dependency>
        <!-- spring end -->
        
        <!-- inner jar begin -->
        <dependency>
              <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-framework-base</artifactId>
            <version>${ycgwl-version}</version>
          </dependency>
          <!-- inner jar end -->
  </dependencies>
View Code

 

3:com.ycgwl.framework-data:0.0.1.FRAME(专注数据访问层)

拦截器:OffsetLimitInterceptor

引用 mybatis相关,framework-base,spring-context

<dependencies>
      <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
      </dependency>
      <dependency>
        <groupId>org.mybatis.spring</groupId>
        <artifactId>mybatis-spring</artifactId>
      </dependency>
      <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-spring</artifactId>
      </dependency>
      
      <!-- inner jar begin -->
        <dependency>
              <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-framework-base</artifactId>
            <version>${ycgwl-version}</version>
          </dependency>
          <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
        </dependency>
          <!-- inner jar end -->
  </dependencies>
View Code

 

4:com.ycgwl.framework-springmvc:0.0.1.FRAME

拦截器:ModuleInterceptor

主要引用 framework-core

5:com.ycgwl.framework-support:0.0.1.FRAME

excel,id,log,util包

 

1:com.ycgwl.rosefinch:rosefinch-common-base:0.0.1.FRAME

UserContext

Cookie

CommonFilter

主要引用 framework-data,cache

  <dependencies>
          <!-- inner jar begin -->
        <dependency>
            <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-framework-data</artifactId>
            <version>${rosefinch-version}</version>
        </dependency>
        <dependency>
            <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-cache</artifactId>
            <version>${rosefinch-version}</version>
        </dependency>
        <!-- inner jar end -->
          
          <!-- servlet jar begin -->
          <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- servlet jar end -->
  </dependencies>
View Code

 

2: com.ycgwl.rosefinch:rosefinch-common-springmvc:0.0.1.FRAME

annotation,mybatis,util

主要引用 rosefinch-common-base,framework

 <dependencies>
   <!-- jstl begin-->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
    </dependency>
    <!-- jstl end-->
    
           <!-- inner jar begin -->
        <dependency>
            <groupId>com.ycgwl.rosefinch</groupId>
            <artifactId>rosefinch-common-base</artifactId>
            <version>${rosefinch-version}</version>
        </dependency>
        <dependency>
            <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-framework-core</artifactId>
            <version>${ycgwl-version}</version>
        </dependency>
        <dependency>
            <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-framework-springmvc</artifactId>
            <version>${ycgwl-version}</version>
        </dependency>
        <dependency>
            <groupId>com.ycgwl</groupId>
            <artifactId>ycgwl-framework-support</artifactId>
            <version>${ycgwl-version}</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring</groupId>
            <artifactId>mybatis-spring</artifactId>
        </dependency>
        <!-- inner jar end -->
        
        <!-- jackson -->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>${freemarker-version}</version>
        </dependency>
        
        <!-- jackson end -->
        
        <!-- junit lib begin -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- junit lib end -->
   </dependencies>
View Code

 

posted @ 2017-03-25 23:12  zfzf1  阅读(227)  评论(0)    收藏  举报