Results 1 to 3 of 3

Thread: I can't Understanding EntityManager code generated by Spring Roo

Hybrid View

  1. #1
    Join Date
    Aug 2012
    Posts
    2

    Angry I can't Understanding EntityManager code generated by Spring Roo

    @PersistenceContext
    transient EntityManager entityManager;

    public static final EntityManager entityManager() {
    EntityManager em = new Food().entityManager;
    if (em == null)
    throw new IllegalStateException(
    "Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
    return em;
    }

    the code looks very suspicious.

    help me . very very Thanks you . and bless you

  2. #2
    Join Date
    Mar 2007
    Posts
    566

    Default

    Since entityManager() is static it has to create an instance of Food otherwise DI would not work (via AspectJ due to using new and not getBean()). Then it checks if the em exists and returns it.

  3. #3
    Join Date
    Aug 2012
    Posts
    2

    Talking thanks . I decomplier the Food.class I understand

    Quote Originally Posted by spgmx View Post
    Since entityManager() is static it has to create an instance of Food otherwise DI would not work (via AspectJ due to using new and not getBean()). Then it checks if the em exists and returns it.
    thank you replay.

    the Clear reasons

    Code:
    	public Shop() {
    		JoinPoint joinpoint1 = Factory.makeJP(ajc$tjp_11, this, this);
    		JoinPoint joinpoint = Factory.makeJP(ajc$tjp_0, this, this);
    		if (this != null && getClass().isAnnotationPresent(Configurable) && AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable) getClass().getAnnotation(Configurable))) {
    
    			AnnotationBeanConfigurerAspect.aspectOf().ajc$before$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$1$e854fa65(this);
    		}
    
    		if (this != null && getClass().isAnnotationPresent(Configurable) && (this == null || !getClass().isAnnotationPresent(Configurable) || !AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable) getClass().getAnnotation(Configurable))) && AbstractDependencyInjectionAspect.ajc$if$6f1(joinpoint)) {
    			
    			AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
    		}
    		if (!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable) getClass().getAnnotation(Configurable)) && AbstractDependencyInjectionAspect.ajc$if$6f1(joinpoint1)) {
    
    			AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
    		}
    	}
    
    	public static final EntityManager entityManager() {
    		JoinPoint joinpoint = Factory.makeJP(ajc$tjp_1, null, null);
    		if (AnnotationDrivenStaticEntityMockingControl.ajc$cflowCounter$1.isValid() && AnnotationDrivenStaticEntityMockingControl.hasAspect())
    			return (EntityManager) entityManager_aroundBody1$advice(joinpoint, AnnotationDrivenStaticEntityMockingControl.aspectOf(), null, ajc$tjp_1, joinpoint);
    		else
    			return entityManager_aroundBody0(joinpoint);
    	}
    
    	private static final EntityManager entityManager_aroundBody0(JoinPoint joinpoint) {
    		EntityManager em = (new Shop()).entityManager;
    		if (em == null)
    			throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
    		else
    			return em;
    	}
    
    	private static final Object entityManager_aroundBody1$advice(JoinPoint thisJoinPoint, AbstractMethodMockingControl ajc$aspectInstance, AroundClosure ajc$aroundClosure, org.aspectj.lang.JoinPoint.StaticPart thisJoinPointStaticPart, JoinPoint thisJoinPoint) {
    		if (AbstractMethodMockingControl.ajc$inlineAccessFieldGet$org_springframework_mock_staticmock_AbstractMethodMockingControl$org_springframework_mock_staticmock_AbstractMethodMockingControl$recording(ajc$aspectInstance)) {
    			AbstractMethodMockingControl.ajc$inlineAccessFieldGet$org_springframework_mock_staticmock_AbstractMethodMockingControl$org_springframework_mock_staticmock_AbstractMethodMockingControl$expectations(ajc$aspectInstance).expectCall(thisJoinPointStaticPart.toLongString(), thisJoinPoint.getArgs());
    			return null;
    		} else {
    			return AbstractMethodMockingControl.ajc$inlineAccessFieldGet$org_springframework_mock_staticmock_AbstractMethodMockingControl$org_springframework_mock_staticmock_AbstractMethodMockingControl$expectations(ajc$aspectInstance).respond(thisJoinPointStaticPart.toLongString(), thisJoinPoint.getArgs());
    		}
    	}

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •