private void checkNonabstract() { if ( getBeanClass().isInterface() ) { throw new IllegalArgumentException("component class is an interface: " + name); } if ( Modifier.isAbstract( getBeanClass().getModifiers() ) ) { throw new IllegalArgumentException("component class is abstract: " + name); } }
protected Object instantiateEntityBean() throws Exception { Constructor constructor = getBeanClass().getConstructor(new Class[0]); boolean accessible = constructor.isAccessible(); if (Modifier.isProtected(constructor.getModifiers())) { constructor.setAccessible(true); } Object bean = getBeanClass().newInstance(); constructor.setAccessible(accessible); return bean; }
public ClientSideInterceptor(Object bean, Component component) { super(InterceptorType.CLIENT); this.bean = bean; this.beanClass = component.getBeanClass(); init(component); }
private boolean sessionBeanReturnedThis(Object result) { return result==bean || ( result!=null && getComponent().getBeanClass().isAssignableFrom( result.getClass() ) ); }
public JavaBeanInterceptor(Object bean, Component component) { super(InterceptorType.ANY); this.bean = bean; this.beanClass = component.getBeanClass(); init(component); }
public boolean beanClassHasAnnotation(Class annotationType) { return hasAnnotation( getBeanClass(), annotationType ); }
public boolean beanClassHasAnnotation(String annotationName) { return hasAnnotation( getBeanClass(), annotationName ); }
private boolean markDirty(Method method) { return !getComponent().getBeanClass().isAnnotationPresent(ReadOnly.class) && !method.isAnnotationPresent(ReadOnly.class); }
private void checkSerializableForComponentType() { boolean serializableScope = scope==PAGE || scope==SESSION || scope==CONVERSATION; boolean serializableType = type==JAVA_BEAN || type==ENTITY_BEAN; if ( serializableType && serializableScope && !Serializable.class.isAssignableFrom( getBeanClass() ) ) { log.warn("Component class should be serializable: " + name); } }
private boolean componentIsConversational() { return getComponent().getBeanClass().isAnnotationPresent(Conversational.class); }
private void initStartup() { if (startup) { if (scope!=SESSION && scope!=APPLICATION) { throw new IllegalArgumentException("@Startup only supported for SESSION or APPLICATION scoped components: " + name); } Startup annotation = getBeanClass().getAnnotation(Startup.class); if (dependencies.length == 0 && annotation != null) { dependencies = annotation.depends(); } } }
private void initSynchronize() { boolean hasAnnotation = getBeanClass().isAnnotationPresent(Synchronized.class); // Technically, we don't need to synchronize page-scoped components if StateManager#isSavingStateInClient(FacesContext) is true synchronize = ( scope==SESSION || scope==PAGE || hasAnnotation ) && type != ComponentType.STATEFUL_SESSION_BEAN; if (synchronize) { timeout = getBeanClass().isAnnotationPresent(Synchronized.class) ? getBeanClass().getAnnotation(Synchronized.class).timeout() : Synchronized.DEFAULT_TIMEOUT; } if (hasAnnotation && !interceptionEnabled) { log.warn("Interceptors are disabled for @Synchronized component - synchronization will be disabled for: " + name); } if (hasAnnotation && type == ComponentType.STATEFUL_SESSION_BEAN) { log.warn("Seam synchronization interceptor is disabled for @Synchronized @Stateful component - Seam synchronization will be disabled for: " + name); } }
protected Object instantiateJavaBean() throws Exception { Object bean = getBeanClass().newInstance(); if (interceptionEnabled) { JavaBeanInterceptor interceptor = new JavaBeanInterceptor(bean, this); bean = wrap(bean, interceptor); } return bean; }
/** * @return a collection of all component fields injected by Guice (annotated with the @Inject annotation) */ private Collection<Field> getGuiceAnnotatedFields() { final Map<Class,Collection<Field>> fieldsMap = getGuiceComponentFieldsMap(); Collection<Field> annotatedFields = fieldsMap.get(getComponent().getBeanClass()); if (annotatedFields == null) { annotatedFields = Reflections.getFields(getComponent().getBeanClass(), Inject.class); fieldsMap.put(getComponent().getBeanClass(), annotatedFields); } return annotatedFields; }
private void initImports(Context applicationContext) { if (applicationContext!=null) //for unit tests! { Init init = (Init) applicationContext.get( Seam.getComponentName(Init.class) ); if (init!=null) { if ( getBeanClass().isAnnotationPresent(Import.class) ) { addImport( init, getBeanClass().getAnnotation(Import.class) ); } Package pkg = getBeanClass().getPackage(); if ( pkg!=null && pkg.isAnnotationPresent(Import.class) ) { addImport( init, getBeanClass().getPackage().getAnnotation(Import.class) ); } } } }
/** * Get the cached ClassValidator instance. If the argument is an instance of * a session bean Seam component instance, the returned validator will be * aware of constraints defined on the bean class. Therefore this method is * preferred to getValidator(Class) if the argument might be a session bean. * * @param model the object to be validated */ @SuppressWarnings("unchecked") public <T> ClassValidator<T> getValidator(T model) { Class<?> modelClass = model instanceof Instance ? ((Instance) model).getComponent().getBeanClass() : model.getClass(); return getValidator((Class<T>) modelClass); }
@Override protected boolean isNewTransactionRequired(boolean transactionActive) { return isNewTransactionRequired( invocation.getMethod(), getComponent().getBeanClass(), transactionActive ); }
private synchronized Class<ProxyObject> getProxyFactory() { if (factory==null) { factory = createProxyFactory( getType(), getBeanClass(), getBusinessInterfaces() ); } return factory; }
/** * @return a Guice injector for the current component */ private Injector getGuiceInjector() { final String expr; Guice guice = getComponent().getBeanClass().getAnnotation(Guice.class); if (guice != null) { expr = guice.value(); } else { expr = null; } // Optimize lookups for default injector return Strings.isEmpty(expr) ? getCachedDefaultInjector() : getInjectorByName(expr); }
protected void registerSeamComponentResource(Component seamComponent) { log.debug("registering resource as Seam component: {0}", seamComponent.getName()); ResourceFactory factory = new SeamResteasyResourceFactory( seamComponent.getBeanClass(), seamComponent, getDispatcher().getProviderFactory() ); getDispatcher().getRegistry().addResourceFactory(factory); }