コード例 #1
0
  @Override
  public void transform(
      PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) {
    for (final PlasticMethod method : plasticClass.getMethodsWithAnnotation(CommitAfter.class)) {
      PersistenceContext annotation = method.getAnnotation(PersistenceContext.class);

      MethodAdvice advice =
          annotation == null ? shared : new TransactionalUnitMethodAdvice(manager, annotation);

      method.addAdvice(advice);
    }
  }
コード例 #2
0
  public void transform(
      PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) {

    final ImportJQueryUI annotation = plasticClass.getAnnotation(ImportJQueryUI.class);

    PlasticMethod setupRender =
        plasticClass.introduceMethod(TransformConstants.SETUP_RENDER_DESCRIPTION);

    if (annotation != null) {

      if (annotation.value().length > 0) {

        final Flow<Asset> assetFlow =
            F.flow(annotation.value()).map(expandSimpleName).map(pathToAsset);

        setupRender.addAdvice(
            new MethodAdvice() {

              public void advise(MethodInvocation invocation) {

                assetFlow.each(importLibrary);

                invocation.proceed();
              }
            });
      }
    }

    if (model.isPage()) {
      setupRender.addAdvice(
          new MethodAdvice() {

            public void advise(MethodInvocation invocation) {

              String path =
                  (annotation != null && InternalUtils.isNonBlank(annotation.theme()))
                      ? annotation.theme()
                      : themePath;

              javaScriptSupport.importStylesheet(assetSource.getExpandedAsset(path));

              invocation.proceed();
            }
          });
    }

    model.addRenderPhase(SetupRender.class);
  }