ローカルリポジトリへの追加

忘れるのでメモ。mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging=参考 http://www.techscore.com/tech/Java/ApacheJakarta/Maven/7/

JVMのパラメーター

参考にしたサイト http://blog.ik.am/entry/view/id/85/title/JVM%E3%81%AE%E3%83%92%E3%83%BC%E3%83%97%E3%83%BBGC%E3%83%81%E3%83%A5%E3%83%BC%E3%83%8B%E3%83%B3%E3%82%B0%E3%81%BE%E3%81%A8%E3%82%81/ http://www.whitemark.co.jp/tec/java/javagc.html…

Java reflectionとpermメモリ

http://www.ibm.com/developerworks/jp/java/library/j-nativememory-aix/まとめ ・reflectionは、-Dsun.reflect.inflationThreshold=N(default 15)以上の呼び出しが行われると、クラスが自動生成されて高速なバイトコードアクセスとなる。 それ以前は、低…

JUNITからDataSourceを利用するためには

やることは、 1. 自前でinitialcontextを作成して、JNDIにbindしてあげる。JNDIへのbindingには、TomcatのNamingを利用するので、いつもの通り、pom.xmlに記述して取得する。 DataSourceの取得といったらconnectionの取得なので、ついでにcommons-dbcpを利用…

Google Guiceを利用したJUnit試験用のRunnerとAnnotation 改造

前回作成したTestRunnerに対して、Moduleのクラス名のsafixにTestが付いているものを優先して読み込むように改造した。 #テスト時は、xxxxを利用したいといった場合用です。 public class GuiceJunitRunner extends BlockJUnit4ClassRunner { protected fina…

Google Guiceでservlet

GuiceでServeletを利用するには、guice-servlet.jarが必要になります。 mavenのglobal repositoryにないので、ローカルリポジトリに登録します。 %maven install:install-file -Dfile=guice-servlet-3.0.jar -DgoupdId=com.google.guice -DartifactId=guice-…

Google GuiceのProviderによるInjection

factory系で生成したオブジェクトをDIしましょうという機能らしい。 やり方は2通りで、Providerを実装するか、@Providesインスタンスで指定するか。ただのhogeを返すProvider. public class SampleProvider implements Provider<String> { public String get() { ret</string>…

Google GuiceのInterceptor順序

結論は、bindInterceptor()に登録した順にInterceptorが起動する(っぽい)。Interceptor public class Sample1Intercetpor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { System.out.pr…

LruHashMap

割と使うのでのせとく。この辺の実装はネットであふれている。 S2の実装をベースに改造。 型推論付きのインスタンス生成メソッド付き。 public class LruHashMap<K, V> extends LinkedHashMap<K, V> { private static final long serialVersionUID = 1L; /** * デフォル</k,></k,>…

xyzzyの文字コード関連コマンド

文字コードを変換して保存する C-x C-k f画面の文字コードを変更する C-u M-x: revert-buffer

Propertiesのpopulate

ツールなどの自分が作成した以外のソースの変更ができない場合、Propertiesをpopulateしてあげる。 public class XADataSourceModule extends AbstractModule { @Override protected void configure() { PropertiesLoader propertiesLoader = new Properties…

プロパティファイルの取得の仕方 備忘録

DIの発想にたつと、プロパティの取得をstaticにAbstractModuleに書くのはよくない。 なので、Injectして与えるということになるが・・・。 なんか、複雑やね。 XADatasouceModuleを見ただけでは、生成の仕方が不明で、Conventionもみないといけないし・・・…

Propertiesの内容をInjectする

Propertiesの内容をInjectしてインスタンスを生成するファクトリです。 Injectorは、On-Demandとして利用します。 public class GuiceInstanceFactory { public static <T>T getInstance(Class<T> cls, final Properties properties) { Injector injector = Guice.</t></t>…

DIコンテナにあったら登録したい場合の指定方法

Google GuiceでDIコンテナにあれば登録としたい場合は、次の通り。 @Inject(option=true) String hoge;

Custom Injector SLF4J

Google Guieceにて、SLF4JのCustom Injectorを作成する。 #Google Guice wikiにあったのをコピーしただけ・・pom.xmlにSLFJ4+logbackを追加する。 <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>[1.,)</version> <scope>runtime</scope> </dependency> <dependency> <groupId>ch.qos.logback</groupId> </dependency>

MAVENにて依存関係の排除 s2jdbc-gen, junit4

MAVENにて、s2jdbc-genを依存に加えると、依存関係でjunit3を取り込みます。 junit4を利用したいので、依存関係の排除を記述して対応する。 うーん、s2jdbc-genがjunit3に依存している理由が不明だから、後で調べないと・・。 <repositories> <repository> <id>maven.seasar.org</id> <name>The Seasar</name></repository></repositories>…

Google Guiceを利用したJUnit試験用のRunnerとAnnotation

Google Guiceを利用したJUnit試験用のRunnerとAnnotationのサンプル実装です。Runner public class GuiceJunitRunner extends BlockJUnit4ClassRunner { protected final static Log _log = LogFactory.getLog(GuiceJunitRunner.class); public GuiceJunitRu…

MAVENにてEclipseにソースコードをAttachする方法

EclipseにソースコードをAttachする方法は、pom.xmlに、以下の記述をすることで可能となる。 この設定でmvn実行時に自動でsource.jarもネットからダウンロードしてくれて、Eclipseからソースコードが見れるようになるので、効率が良いです。 org.apache.mave…