Refine search
@AroundConstruct public Object onConstruct(InvocationContext context) throws Exception { // null before the InvocationContext.proceed() returns Object target = context.getTarget(); isNull(target); // null in case of AroundConstruct Method method = context.getMethod(); isNull(method); // NOT null in case of AroundConstruct Constructor ctor = context.getConstructor(); isNotNull(ctor); // perform the constructor injection Object result = context.proceed(); isNull(result); // NOT null after the InvocationContext.proceed() completes target = context.getTarget(); isNotNull(target); // a constructor should have been called GreetingBean bean = (GreetingBean) target; isBoolean(bean.isConstructed(), true); isBoolean(bean.isInitialized(), false); // constructor injection should have been done isNotNull(bean.getParam()); return null; }
@AroundConstruct public Object aroundConstruct(InvocationContext ctx) throws Exception { aroundConstructInterceptorCalled = true; return ctx.proceed(); }
@AroundConstruct public void aroundConstruct(InvocationContext ctx) { try { setInvoked(); checkConstructor(ctx, Alpha.class); assertNull(ctx.getMethod()); assertNull(ctx.getTarget()); assertEquals(1, ctx.getParameters().length); assertTrue(ctx.getParameters()[0] instanceof BeanManager); assertNull(ctx.proceed()); checkConstructor(ctx, Alpha.class); assertNull(ctx.getMethod()); assertNotNull(ctx.getTarget()); assertTrue(ctx.getTarget() instanceof Alpha); assertEquals(1, ctx.getParameters().length); assertTrue(ctx.getParameters()[0] instanceof BeanManager); } catch (Exception e) { throw new RuntimeException(e); } } }
@AroundConstruct public void intercept(InvocationContext ctx) { if (proceed) { try { ctx.proceed(); Baz instance = (Baz) ctx.getTarget(); instance.accessed = true; } catch (Exception e) { throw new RuntimeException(e); } } }
@AroundConstruct private Object registerMetrics(InvocationContext context) throws Exception { Class<?> bean = context.getConstructor().getDeclaringClass(); registerMetrics(bean, context.getConstructor()); Class<?> type = bean; do { for (Method method : type.getDeclaredMethods()) if (!method.isSynthetic() && !Modifier.isPrivate(method.getModifiers())) { registerMetrics(bean, method); } type = type.getSuperclass(); } while (!Object.class.equals(type)); return context.proceed(); }
@AroundConstruct private Object aroundConstructor(InvocationContext context) throws Exception { return called(context, context.getConstructor()); }
@AroundConstruct public void validateConstructor(InvocationContext context) { System.out.println("MyAroundConstructInterceptor.validateConstructor"); } }
@AroundConstruct public void postConstruct(InvocationContext ctx) throws Exception { aroundConstructCalled = true; ctx.proceed(); }
@AroundConstruct public void aroundConstruct(InvocationContext ctx) { try { setInvoked(); checkConstructor(ctx, Alpha.class); assertNull(ctx.getMethod()); assertNull(ctx.getTarget()); assertEquals(ctx.getParameters().length, 1); assertTrue(ctx.getParameters()[0] instanceof BeanManager); assertNull(ctx.proceed()); checkConstructor(ctx, Alpha.class); assertNull(ctx.getMethod()); assertNotNull(ctx.getTarget()); assertTrue(ctx.getTarget() instanceof Alpha); assertEquals(ctx.getParameters().length, 1); assertTrue(ctx.getParameters()[0] instanceof BeanManager); } catch (Exception e) { throw new RuntimeException(e); } } }
@AroundConstruct public Object onConstructor(final InvocationContext context) throws Exception { findMeter(context.getConstructor()).mark(); return context.proceed(); }
@AroundConstruct public void validateConstructorInvocation(InvocationContext ctx) throws Exception { final boolean isJaxRsConstructor = extension.jaxRsResourceCache.apply(ctx.getConstructor().getDeclaringClass()); if (!isJaxRsConstructor) { interceptor.validateConstructorInvocation(ctx); } } }
@AroundConstruct public Object create(InvocationContext ctx) throws Exception { return doCall(ctx, aroundConstruct); }
@AroundConstruct public void validateConstructorInvocation(InvocationContext ctx) throws Exception { ExecutableValidator executableValidator = validator.forExecutables(); Set<? extends ConstraintViolation<?>> violations = executableValidator.validateConstructorParameters( ctx.getConstructor(), ctx.getParameters() ); getMessage( ctx.getConstructor(), ctx.getParameters(), violations ), violations );
@AroundConstruct public void intercept3(InvocationContext ctx) { try { ctx.proceed(); } catch (Exception e) { throw new RuntimeException(e); } }
@AroundConstruct public void aroundConstruct(InvocationContext ctx) { try { assertNull(ctx.getMethod()); assertNull(ctx.getTarget()); assertEquals(ctx.getParameters().length, 1); assertTrue(ctx.getParameters()[0] instanceof BravoParameter); BravoParameter parameter1 = (BravoParameter) ctx.getParameters()[0];
@AroundConstruct private Object timedConstructor(InvocationContext context) throws Exception { return timedCallable(context, context.getConstructor()); }
@AroundConstruct private Object gaugeBeanConstructor(InvocationContext context) throws Exception { Object target = context.proceed(); Class<?> type = context.getConstructor().getDeclaringClass(); do { for (Method method : type.getDeclaredMethods()) { if(method.isAnnotationPresent(org.eclipse.microprofile.metrics.annotation.Gauge.class)) { Metadata metadata = AnnotationMetadata.buildMetadata(type, method, org.eclipse.microprofile.metrics.annotation.Gauge.class); Gauge gauge = applicationRegistry.getGauges().get(metadata.getName()); if (gauge == null) { applicationRegistry.register(metadata, new ForwardingGauge(method, context.getTarget())); } } } type = type.getSuperclass(); } while (!Object.class.equals(type)); return target; } }
@AroundConstruct public void intercept2(InvocationContext ctx) { try { ctx.proceed(); } catch (Exception e) { throw new RuntimeException(e); } }
@AroundConstruct public void aroundConstruct(InvocationContext ctx) { try { assertNull(ctx.getMethod()); assertNull(ctx.getTarget()); assertEquals(ctx.getParameters().length, 1); assertTrue(ctx.getParameters()[0] instanceof BravoParameter); BravoParameter parameter1 = (BravoParameter) ctx.getParameters()[0];
@AroundConstruct private Object timedConstructor(InvocationContext context) throws Exception { return applyInterceptor(context, context.getConstructor()); }