public Class<?> loadBeanClass(final String className) { try { return (Class<?>) AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { return Class.forName(className, true, getClassLoader(this.getClass())); } }); } catch (PrivilegedActionException pae) { throw BeanLogger.LOG.cannotLoadClass(className, pae.getException()); } }
private static void checkContainerState(Container container) { ContainerState state = container.getState(); if (state.equals(ContainerState.STOPPED) || state.equals(ContainerState.SHUTDOWN)) { throw BeanManagerLogger.LOG.beanManagerNotAvailable(); } }
protected static void validateResourceInjectionPointType(Class<?> resourceType, InjectionPoint injectionPoint) { Class<?> injectionPointRawType = Reflections.getRawType(injectionPoint.getType()); HierarchyDiscovery discovery = new HierarchyDiscovery(resourceType); for (Type type : discovery.getTypeClosure()) { if (Reflections.getRawType(type).equals(injectionPointRawType)) { return; } } // type autoboxing if (resourceType.isPrimitive() && BOXED_TYPES.get(resourceType).equals(injectionPointRawType)) { return; } else if (injectionPointRawType.isPrimitive() && BOXED_TYPES.get(injectionPointRawType).equals(resourceType)) { return; } throw BeanLogger.LOG.invalidResourceProducerType(injectionPoint.getAnnotated(), resourceType.getName()); }
private void checkDecoratedMethods(EnhancedAnnotatedType<T> type, List<Decorator<?>> decorators) { if (type.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithDecoratorsNotAllowed(this); } checkNoArgsConstructor(type); for (Decorator<?> decorator : decorators) { EnhancedAnnotatedType<?> decoratorClass; if (decorator instanceof DecoratorImpl<?>) { DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator; decoratorClass = decoratorBean.getBeanManager().getServices().get(ClassTransformer.class) .getEnhancedAnnotatedType(decoratorBean.getAnnotated()); } else if (decorator instanceof CustomDecoratorWrapper<?>) { decoratorClass = ((CustomDecoratorWrapper<?>) decorator).getEnhancedAnnotated(); } else { throw BeanLogger.LOG.nonContainerDecorator(decorator); } for (EnhancedAnnotatedMethod<?, ?> decoratorMethod : decoratorClass.getEnhancedMethods()) { EnhancedAnnotatedMethod<?, ?> method = type.getEnhancedMethod(decoratorMethod.getSignature()); if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithInterceptorsNotAllowed(this); } } } }
private void checkNoArgsConstructor(EnhancedAnnotatedType<T> type) { if (!beanManager.getServices().get(ProxyInstantiator.class).isUsingConstructor()) { return; } EnhancedAnnotatedConstructor<T> constructor = type.getNoArgsEnhancedConstructor(); if (constructor == null) { throw BeanLogger.LOG.decoratedHasNoNoargsConstructor(this); } else if (constructor.isPrivate()) { throw BeanLogger.LOG .decoratedNoargsConstructorIsPrivate(this, Formats.formatAsStackTraceElement(constructor.getJavaMember())); } }
private void checkInitializationNotAlreadyEnded() { if (weldStartup == null) { throw BootstrapLogger.LOG.callingBootstrapMethodAfterContainerHasBeenInitialized(); } } }
/** * Checks that this event is currently being delivered to an extension. Otherwise, {@link IllegalStateException} is thrown. This guarantees that methods of * container lifecycle events are not called outside of extension observer method invocations. * * @throws IllegalStateException if this method is not called within extension observer method invocation */ protected void checkWithinObserverNotification() { if (receiver == null) { throw BootstrapLogger.LOG.containerLifecycleEventMethodInvokedOutsideObserver(); } } }
/** * Gets the name of the parameter * * @throws IllegalArgumentException (not supported) * @see org.jboss.weld.annotated.enhanced.EnhancedAnnotated#getName() */ public String getName() { throw ReflectionLogger.LOG.unableToGetParameterName(); }
private static void checkNotNull(Object expression, String methodName, Object target) { if (expression == null) { throw MetadataLogger.LOG.metadataSourceReturnedNull(methodName, target); } }
@Override protected EnhancedAnnotatedMethod<?, ? super T> processLevelResult(EnhancedAnnotatedMethod<?, ? super T> method) { BeanLogger.LOG.foundOnePostConstructMethod(method, type); return method; } });
@Override protected EnhancedAnnotatedMethod<?, ? super T> processLevelResult(EnhancedAnnotatedMethod<?, ? super T> method) { BeanLogger.LOG.foundOnePreDestroyMethod(method, type); return method; } });
/** * Callback that allows to override the behavior when CDI.current() is not called from within a bean archive. */ protected BeanManagerImpl unsatisfiedBeanManager(String callerClassName) { throw BeanManagerLogger.LOG.unsatisfiedBeanManager(callerClassName); }
public InterceptorBindingsAdapter(InterceptionModel interceptionModel) { if (interceptionModel == null) { throw BeanLogger.LOG.interceptionModelNull(); } this.interceptionModel = interceptionModel; }
/** * Throws {@link IllegalArgumentException} if the reference is null. This method should only be used for methods with single argument. * * @param reference the reference to be checked */ public static void checkArgumentNotNull(Object reference) { if (reference == null) { throw ValidatorLogger.LOG.argumentNull(); } }
public WeldExpressionFactory(ExpressionFactory expressionFactory) { if (expressionFactory == null) { throw ElLogger.LOG.nullExpressionFactory(); } this.delegate = expressionFactory; }
@Override public DeploymentException construct(Object... params) { return ValidatorLogger.LOG.alternativeClassSpecifiedMultipleTimes(params[0], params[1], params[2]); } };
@Override public DeploymentException construct(Object... params) { return ValidatorLogger.LOG.interceptorSpecifiedTwice(params[0], params[1], params[2]); } };
@Override public void log(Object... params) { ValidatorLogger.LOG.interceptorEnabledForApplicationAndBeanArchive(params[0], params[1]); } };
private void checkInitializationNotAlreadyEnded() { if (weldStartup == null) { throw BootstrapLogger.LOG.callingBootstrapMethodAfterContainerHasBeenInitialized(); } } }
/** * Checks that this event is currently being delivered to an extension. Otherwise, {@link IllegalStateException} is thrown. This guarantees that methods of * container lifecycle events are not called outside of extension observer method invocations. * * @throws IllegalStateException if this method is not called within extension observer method invocation */ protected void checkWithinObserverNotification() { if (receiver == null) { throw BootstrapLogger.LOG.containerLifecycleEventMethodInvokedOutsideObserver(); } } }