WrAOP wrapper building library

Simple lib that allows you to easily build wrappers or enable plugins for your app with AspectJ annotations or Spring/AOP alliance advices.

Лицензия

Лицензия

Группа

Группа

im.tym.wraop
Идентификатор

Идентификатор

wraop
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

WrAOP wrapper building library
Simple lib that allows you to easily build wrappers or enable plugins for your app with AspectJ annotations or Spring/AOP alliance advices.
Ссылка на сайт

Ссылка на сайт

https://github.com/tivv/wraop
Система контроля версий

Система контроля версий

https://github.com/tivv/wraop.git

Скачать wraop

Имя Файла Размер
wraop-1.0.pom
wraop-1.0.jar 12 KB
wraop-1.0-sources.jar 9 KB
wraop-1.0-javadoc.jar 79 KB
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/im.tym.wraop/wraop/ -->
<dependency>
    <groupId>im.tym.wraop</groupId>
    <artifactId>wraop</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/im.tym.wraop/wraop/
implementation 'im.tym.wraop:wraop:1.0'
// https://jarcasting.com/artifacts/im.tym.wraop/wraop/
implementation ("im.tym.wraop:wraop:1.0")
'im.tym.wraop:wraop:jar:1.0'
<dependency org="im.tym.wraop" name="wraop" rev="1.0">
  <artifact name="wraop" type="jar" />
</dependency>
@Grapes(
@Grab(group='im.tym.wraop', module='wraop', version='1.0')
)
libraryDependencies += "im.tym.wraop" % "wraop" % "1.0"
[im.tym.wraop/wraop "1.0"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.springframework : spring-aop jar 3.2.3.RELEASE
org.aspectj : aspectjweaver Необязательный jar 1.6.12

test (3)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.9
org.unitils : unitils-easymock jar 3.3
cglib : cglib jar 2.2

Модули Проекта

Данный проект не имеет модулей.

WrAOP wrapper building library

Introduction

How many times have you created a wrapper class that delegates all the methods to it's delegate, while adding some functionality in few places? I've done this many times. This library would allow you to do this easily.

Another option to use it is when you need to provide plugin functionality for your library or application. Now you don't need to create chain of responsibility or "pre" and "post" interfaces simply for extension points. Simply allow your users to register aspects and wrap your objects with the help of this library.

Comparison to other options

  • Spring AOP.

    Actually this library is a wrapper over Spring AOP. If you can use Spring AOP directly, just do it. But not every object is in context. And this library allows to apply your wrapper at much more granular fashion. You directly say which objects you'd like to wrap

  • AspectJ

    AspectJ is much more global thing. It enhances your classes and prefers to do this in compile time. This library creates you proxies, and you can use AspectJ annotations to do the work.

Requirements

  • Java 6
  • Spring AOP

Optional dependencies

  • cglib - to make faster proxies
  • AspectJ weaver - to use AspectJ annotations

Quick start

 new WrapperFactoryBuilder().<TargetClass>build()
    .withAspects(aspect1, aspect2, aspect3).wrapAllInterfaces(target)

That's all. You can reuse the factory with aspects registered to wrap multiple objects. It's thread-safe. It will autodetect aspect types (Spring/AOP alliance/AspectJ). Here is an example aspect from tests:

 @Aspect
 public class ConstantReturningAspect {
     private final Object constant;

     public ConstantReturningAspect(Object constant) {
         this.constant = constant;
     }

     @Around("execution(* im.tym.wraop.data.Transformer.transform(..))")
     Object returnConstant() {
         return constant;
     }
 }

Easy, is not it?

Details

For WrapperFactory, please see it's javadoc. As of aspect types, please refer to Spring AOP documentation: http://docs.spring.io/spring/docs/3.2.3.RELEASE/spring-framework-reference/html/aop.html#aop-introduction

Contacts

Project home page: https://github.com/tivv/wraop You can submit bugs, feature requests or pull requests there.

Author contact: http://blog.vit.tym.im

Версии библиотеки

Версия
1.0