public void validateDecoratorClasses() { for(Class<?> decoratorClazz : enabledDecorators) { //Validate decorator classes if(!decoratorClazz.isAnnotationPresent(javax.decorator.Decorator.class) && !containsCustomDecoratorClass(decoratorClazz)) { throw new WebBeansDeploymentException("Given class : " + decoratorClazz + " is not a decorator class"); } } }
/** * Those xmls will be scanned by container. * @param xmls beans xmls */ public void deployXMLs(Collection<String> xmls) { if(xmls != null) { for(String url : xmls) { try { addBeanXml(new URL(url)); } catch (MalformedURLException e) { throw new WebBeansDeploymentException("could not convert to URL: " + url, e); } } } }
private <T> void validatePassivationCapableDependency(Bean<T> bean, Bean<?> dependentBean) { if (!isPassivationCapable(dependentBean)) { String type = dependentBean instanceof Interceptor? "Interceptor ": "Decorator "; throw new WebBeansDeploymentException( "Passivation capable beans must satisfy passivation capable dependencies. " + "Bean : " + bean.toString() + " does not satisfy. " + type + dependentBean.toString() + " is not passivation capable"); } validatePassivationCapableDependencies(bean, dependentBean.getInjectionPoints()); }
@Override public void scan() throws WebBeansDeploymentException { logger.info("Using OsgiMetaDataScannerService!"); Bundle mainBundle = BundleUtils.getContextBundle(true); if (mainBundle != null) { ServiceReference reference = mainBundle.getBundleContext().getServiceReference(PackageAdmin.class.getName()); try { PackageAdmin packageAdmin = (PackageAdmin) mainBundle.getBundleContext().getService(reference); // search for all META-INF/beans.xml files findBeansXml(mainBundle, packageAdmin); // search for all classes if (!beanXMLs.isEmpty()) { findBeanClasses(mainBundle, packageAdmin); } } catch(Exception e) { throw new WebBeansDeploymentException("problem while scanning OSGi bundle", e); } finally { mainBundle.getBundleContext().ungetService(reference); } } }
/** * Configure the Web Beans Container with deployment information and fills * annotation database and beans.xml stream database. * * @throws org.apache.webbeans.exception.WebBeansConfigurationException if any run time exception occurs */ @Override public void scan() throws WebBeansDeploymentException { try { configure(); initFinder(); } catch (Exception e) { throw new WebBeansDeploymentException(e); } }
throw new WebBeansDeploymentException("Error while parsing the beans.xml file " + beansXmlLocation, e); throw new WebBeansDeploymentException("Error while closing the input stream!", ioe);
if (methodsDisabledDueToSpecialization.contains(superMethod)) throw new WebBeansDeploymentException("Multiple specializations for the same producer method got detected for type" + producerBean);
throw new WebBeansDeploymentException("found more than WEB-INF/beans.xml file!" + webBeansXml);
if (names.contains(current)) throw new WebBeansDeploymentException("Name '" + name + "' is conflicting with '" + current + "'"); throw new WebBeansDeploymentException("Name '" + name + "' is conflicting");
throw new WebBeansDeploymentException("Final Simple class with name : " + clazz.getName() + " can not define any InterceptorBindings"); throw new WebBeansDeploymentException("Simple web bean class : " + clazz.getName() + " can not define non-static, non-private final methods. " + "Because it is annotated with at least one @InterceptorBinding"); method.getDeclaredAnnotations())) throw new WebBeansDeploymentException("Method : " + method.getName() + "in simple web bean class : " + clazz.getName() + " can not be defined as non-static, non-private and final. "
private void configureDecorators(URL bdaLocation, List<String> decorators) { Set<Class> decoratorsInFile = new HashSet<>(); for (String decorator : decorators) { Class<?> clazz = ClassUtil.getClassFromName(decorator); if (clazz == null) { throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Decorator class : " + decorator + " not found"); } else { if ((scannerService.isBDABeansXmlScanningEnabled() && !scannerService.getBDABeansXmlScanner().addDecorator(clazz, bdaLocation.toExternalForm())) || decoratorsInFile.contains(clazz)) { throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Decorator class : " + decorator + " is already defined"); } decoratorsManager.addEnabledDecorator(clazz); decoratorsInFile.add(clazz); } } }
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { String id = (String) s.readObject(); Bean<T> b = (Bean<T>) WebBeansContext.currentInstance().getBeanManagerImpl().getPassivationCapableBean(id); if (b == null) { throw new WebBeansDeploymentException("cannot deserialize Bean with PassivationCapable id=" + id); } if (b instanceof SerializableBean) { b = ((SerializableBean<T>)b).getBean(); } bean = b; }
throw new WebBeansDeploymentException("Final managed bean class with name : " + clazz.getName() + " can not define any InterceptorBindings"); throw new WebBeansDeploymentException("Managed bean class : " + clazz.getName() + " can not define non-static, non-private final methods. Because it is annotated with at least one @InterceptorBinding"); throw new WebBeansDeploymentException("Method : " + method.getName() + "in managed bean class : " + clazz.getName() + " can not be defined as non-static, non-private and final . Because it is annotated with at least one @InterceptorBinding");
throw new WebBeansDeploymentException("EL name of one bean is of the form x.y, where y is a valid bean EL name, and " + "x is the EL name of the other bean for the bean name : " + beanName);
throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Given alternative : " + alternativeName + " is already added as @Alternative" ); throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Alternative: " + alternativeName + " not found");
private void calculateCdiMethodDecorators(BusinessMethodInterceptorInfo methodInterceptorInfo, List<Decorator<?>> decorators, AnnotatedMethod annotatedMethod, boolean failOnFinal) { if (decorators == null || decorators.isEmpty()) { return; } LinkedHashMap<Decorator<?>, Method> appliedDecorators = new LinkedHashMap<>(); for (Decorator decorator : decorators) { if (!webBeansContext.getDecoratorsManager().isDecoratorEnabled(decorator.getBeanClass())) { continue; } Method decoratingMethod = getDecoratingMethod(decorator, annotatedMethod); if (decoratingMethod != null) { if (isUnproxyable(annotatedMethod, failOnFinal)) { throw new WebBeansDeploymentException(annotatedMethod + " is not proxyable, but an Decorator got defined on it!"); } appliedDecorators.put(decorator, decoratingMethod); } } if (appliedDecorators.size() > 0) { methodInterceptorInfo.setMethodDecorators(appliedDecorators); } }
public void validateInterceptorClasses() { for(Class<?> interceptorClass : configuredInterceptorClasses) { AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(interceptorClass); // Validate decorator classes if(!annotatedType.isAnnotationPresent(javax.interceptor.Interceptor.class) && !containsCustomInterceptorClass(interceptorClass)) { throw new WebBeansDeploymentException("Given class : " + interceptorClass + " is not a interceptor class"); } } }
private <T> void validatePassivationCapableDependencies(Bean<T> bean, Set<InjectionPoint> injectionPoints) { for (InjectionPoint injectionPoint: injectionPoints) { if(!injectionPoint.isTransient()) { if(!webBeansContext.getWebBeansUtil().isPassivationCapableDependency(injectionPoint)) { Annotated annotated = injectionPoint.getAnnotated(); if(annotated.isAnnotationPresent(Disposes.class) || annotated.isAnnotationPresent(TransientReference.class)) { continue; } throw new WebBeansDeploymentException( "Passivation capable beans must satisfy passivation capable dependencies. " + "Bean : " + bean.toString() + " does not satisfy. Details about the Injection-point: " + injectionPoint.toString()); } } } }
public <T> ObserverMethod<T> getObserverMethod() { if (observedType == null) { String extensionName = extension != null ? "(" + extension.toString() + ") ! " : "! "; WebBeansDeploymentException e = new WebBeansDeploymentException("ObserverMethod observedType is missing " + extensionName + toString()); webBeansContext.getBeanManagerImpl().getErrorStack().pushError(e); return null; } if (originalObserverMethod == null && notifyWith == null) { String extensionName = extension != null ? "(" + extension.toString() + ") ! " : "! "; WebBeansDeploymentException e = new WebBeansDeploymentException("ObserverMethod notifyWith is missing " + extensionName + toString()); webBeansContext.getBeanManagerImpl().getErrorStack().pushError(e); return null; } return new ConfiguredObserverMethod(); }
throw new WebBeansDeploymentException("Given alternative class : " + alternativeClass.getName() + " is not annotated wih @Alternative or not an enabled bean");