私は多くのWARファイルで構成されたマルチモジュールプロジェクトに取り組んでいます。プロジェクトでは、依存関係を管理するためにSpring 4.0.5を使用し、AOPをサポートするためにロード時間織りでAspectJ 1.8.5を使用します(Spring基本AOPサポートはこのプロジェクトではenoghではありません)。AspectJの読み込み時間EARのデプロイされたクラス内で正常に動作しません
<aspectj>
<aspects>
<!--No need to specify any aspect here-->
</aspects>
<weaver options="-XnoInline -verbose">
<include within="com.myproject..*" />
</weaver>
</aspectj>
AOPは、様々なサービスやDAOにトランザクションの動作と(@Serviceと@Repositoryでanotated)を提供するために主に使用されている(と:また、非常にシンプルな構成でMETA-INFディレクトリ内aop.xmlがあります春の@トランザクションアノテーション)。たとえば:
@Service(value = "alertService")
public class AlertServiceImpl implements IAlertService, Serializable {
...
@Transactional(rollbackFor = Exception.class)
@Override
public Alert createAlert(Alert alert) {
alertDAO.create(alert);
return alert;
}
...
}
または抽象基本DAOそこからアプリケーションのDAOにの残りの部分は
@Repository
public abstract class BaseDAO<E extends IBusinessObject, PK extends Serializable> {
...
@Transactional(readOnly = true)
public <C extends E> C findFirstByFields(Class<C> type, String[] fields, Object[] values, String[] dependencies)
throws ModelException {
List<C> list = findAllByFields(type, fields, values, null, null, 1, null);
if (list.isEmpty()) {
return null;
} else {
C obj = list.get(0);
loadDependencies(obj, dependencies);
return obj;
}
}
...
}
が最後にプロジェクトが建物のためにMavenを使用したJBoss EAP 6.1上で実行されます継承します。
この構成では、WARファイルのビルドとデプロイ時にすべてがうまく動作します。しかし、私が内部にそれらのWARファイルの1つのみで単純なEARファイルを構築すると、読み込み時間はすべてのクラスを作成しますが、1つはBaseDAOです。
私はこれまで何度も苦労してきましたが、アプリケーション起動時には、EAR内でBaseDAOが織り込まれていないことを除けば、両方のケースでほとんど同じになります。なぜ私は理解できません。なぜこれが起きているのか?
PD:
...
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure1'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure3'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure5'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.services.Repository$AjcClosure1'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure1'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure3'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure5'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.model.dao.BaseDAO$AjcClosure7'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.model.dao.LastDocumentNumberDAO$AjcClosure1'
...
しかし、内部のこの戦争とEARの起動時に、BaseDAOクラスが完全に無視されています:AspectJの織りログを有効にすると、WARからアプリケーションを起動するときにこれを示して最後に
...
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure1'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure3'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.commons.services.CommonService$AjcClosure5'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.services.Repository$AjcClosure1'
ServerService Thread Pool -- 227 ? [[email protected]] debug generating class 'com.myproject.subproject.model.dao.LastDocumentNumberDAO$AjcClosure1'
...