Skip to main content

Posts

Showing posts from June, 2013

Maven中如何配置WAR依赖WAR和JAR的多模块项目结构

先考虑如下实际情况: war项目C和war项目B都依赖war项目A和JAR项目X. 项目A中保存了B和C项目通用的web资源,比如通用的javascript,CSS,jsp等. 项目X中保存了B和C项目中都依赖的一些class 开发人员希望每次都只面对一个项目,即Team A 开发项目A, Team B开发项目B, Team C开发项目C....以此类推 每个Team在开发自己项目时,都希望能直接进行调试,例如war项目A可以直接部署到TOMCAT上运行测试 最后实际交付给客户的却只有2个项目: B和C .也就是说,最后要打包B和C,而在B和C的war包中都要包含A中的web资源和X中的class 在纯Maven中的实现方案 纯MAVEN环境比较简单,经过一段曲折(先是修改maven-war-plguin源码,再是自定义一个插件),最后发现居然有一个现成的插件可以实现这个功能,示范如下:     com.isoftstone.gads     common-web     0.0.1-SNAPSHOT     war     com.isoftstone.gads     common-web     0.0.1-SNAPSHOT     warpath        org.apache.maven.plugins      maven-war-plugin      2.1-beta-1           <! -   必须指定,否则默认会变成在target/war/work 导致被打包进war文件,指定后为target/work   - >       ${project.bu...

Standard MBeans

Standard MBeans This section presents an example of a straightforward, standard MBean. A standard MBean is defined by writing a Java interface called  SomethingMBean  and a Java class called  Something  that implements that interface. Every method in the interface defines either an attribute or an operation in the MBean. By default, every method defines an operation. Attributes and operations are methods that follow certain design patterns. A standard MBean is composed of an MBean interface and a class. The MBean interface lists the methods for all exposed attributes and operations. The class implements this interface and provides the functionality of the instrumented resource. The following sections examine an example of a standard MBean and a simple JMX technology-enabled agent (JMX agent) that manages the MBean. MBean Interface An example of a basic MBean interface,  HelloMBean  , follows: package com.example; public interface HelloMBean {...

ThreadPoolExecutor使用

From 洞玄的博客 http://dongxuan.iteye.com/blog/901689 jdk官方文档(javadoc)是学习的最好,最权威的参考。 文章分上中下。上篇中主要介绍ThreadPoolExecutor接受任务相关的两方面入参的意义和区别,池大小参数 corePoolSize和 maximumPoolSize,BlockingQueue选型( SynchronousQueue, LinkedBlockingQueue, ArrayBlockingQueue );中篇中主要聊聊与 keepAliveTime这个参数相关的话题;下片中介绍一下一些比较少用的该类的API,及他的近亲: ScheduledThreadPoolExecutor 。 如果理解错误,请直接指出。 查看JDK帮助文档,可以发现该类比较简单,继承自AbstractExecutorService,而AbstractExecutorService实现了ExecutorService接口。 ThreadPoolExecutor的完整构造方法的签名是: ThreadPoolExecutor (int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit  unit, BlockingQueue < Runnable > workQueue, ThreadFactory  threadFactory, RejectedExecutionHandler  handler)   先记着,后面慢慢解释。 ===============================神奇分割线================================== 其实对于ThreadPoolExecutor的构造函数网上有N多的解释的,大多讲得都很好,不过我想先换个方式, 从Executors这个类入手 。因为他的几个构造工厂构造方法名字取得令人很容易了解有什么特点。但是其实Executors类的底层实现便是ThreadPoolExecutor! ThreadPoolEx...