public static HibernatePersistenceProvider instance() { return (HibernatePersistenceProvider) Component.getInstance(HibernatePersistenceProvider.class, ScopeType.STATELESS); } }
this.startup = startup; this.dependencies = dependencies; type = Seam.getComponentType( getBeanClass() ); interceptionEnabled = Seam.isInterceptionEnabled( getBeanClass() ); perNestedConversation = hasAnnotation(getBeanClass(), PerNestedConversation.class); checkName(); checkNonabstract(); initNamespace(componentName, applicationContext); initImports(applicationContext); initSynchronize(); initStartup(); initSecurity(); checkScopeForComponentType(); checkSynchronizedForComponentType(); checkSerializableForComponentType(); getJndiName(applicationContext) : componentJndiName; "Component: " + getName() + ", scope: " + getScope() + ", type: " + getType() + ", class: " + getBeanClass().getName() + ( jndiName==null ? "" : ", JNDI: " + jndiName ) ); initMembers( getBeanClass(), applicationContext );
public static FacesMessages instance() { Component component = Component.forName(StatusMessages.COMPONENT_NAME); if(component != null && !component.getScope().isContextActive()) { throw new IllegalStateException("No active "+component.getScope().name()+" context"); } //Attempting to get the instance anyway for backwards compatibility with some potential hack situations. return (FacesMessages) Component.getInstance(StatusMessages.COMPONENT_NAME); } }
private synchronized Class<ProxyObject> getProxyFactory() { if (factory==null) { factory = createProxyFactory( getType(), getBeanClass(), getBusinessInterfaces() ); } return factory; }
protected void init(Component component) { isSeamComponent = true; componentName = component.getName(); userInterceptors = component.createUserInterceptors(type); this.component = component; }
public boolean businessInterfaceHasAnnotation(Class annotationType) { for (Class businessInterface: getBusinessInterfaces() ) { if ( hasAnnotation(businessInterface, annotationType) ) { return true; } } return false; }
Component component = Component.forName(serviceIntfName); Class clz = null; if (component.getType().isSessionBean() && component.getBusinessInterfaces().size() > 0) { for (Class c : component.getBusinessInterfaces()) { if (c.isAnnotationPresent(EJB.LOCAL)) { clz = c; clz = component.getBeanClass();
protected void registerSeamComponentProvider(Component seamComponent) { log.debug("registering provider as Seam component: {0}", seamComponent.getName()); getDispatcher().getProviderFactory().registerProviderInstance( Component.getInstance(seamComponent.getName()) ); }
if (seamComponent.getBeanClass().equals(ResourceHome.class) || seamComponent.getBeanClass().equals(ResourceQuery.class)) switch (seamComponent.getType()) && !seamComponent.getBeanClass().isAnnotationPresent(javax.ws.rs.Path.class)) switch (seamComponent.getScope()) else if (seamComponent.getBeanClass().isAnnotationPresent(javax.ws.rs.Path.class)) default: throw new RuntimeException( "Resource Seam component '" + seamComponent.getName() + "' must be scoped either " + "EVENT, APPLICATION, STATELESS, or SESSION" ); handledResources.add(seamComponent.getBeanClass()); handledResources.addAll(seamComponent.getBusinessInterfaces());
/** * Startup a component and all its dependencies */ static void startup(Component component) { if ( component.isStartup() ) { for ( String dependency: component.getDependencies() ) { Component dependentComponent = Component.forName(dependency); if (dependentComponent!=null) { startup(dependentComponent); } } } if ( !component.getScope().getContext().isSet( component.getName() ) ) { log.debug( "starting up: " + component.getName() ); component.newInstance(); } }
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 static synchronized List<SeamComponentInfo> listNuxeoComponents() { if (components == null) { components = new ArrayList<>(); for (String cName : listAllComponentsNames()) { SeamComponentInfoImpl desc = new SeamComponentInfoImpl(); Component comp = Component.forName(cName); String className = comp.getBeanClass().getName(); // if (className.startsWith("org.nuxeo")) { if (!className.startsWith("org.jboss")) { desc.setName(cName); desc.setScope(comp.getScope().toString()); desc.setClassName(className); @SuppressWarnings("rawtypes") Set<Class> ifaces = comp.getBusinessInterfaces(); if (ifaces != null && ifaces.size() > 0) { for (Class<?> iface : ifaces) { desc.addInterfaceName(iface.getName()); } } desc.addInterfaceName(comp.getBeanClass().getName()); components.add(desc); } } Collections.sort(components); } return components; } }
private static Object getInstance(String name, boolean create, boolean allowAutoCreation, Object result, ScopeType scope) { Component component = Component.forName(name); result = getInstanceFromFactory(name, scope); if (result==null) else if ( component.getScope().isContextActive() ) result = component.newInstance(); log.warn("Cannot create Seam component, scope is not active: " + name + "(" + component.getScope().name() + ")"); if ( !component.isInstance(result) ) if ( component.hasUnwrapMethod() ) return result; ///best way??? throw new IllegalArgumentException( "value of context variable is not an instance of the component bound to the context variable: " + name + ". If you are using hot deploy, you may have attempted to hot deploy a session or " + "application-scoped component definition while using an old instance in the session."); result = component.unwrap(result);
public void setComponent(Component component) { componentName = component.getName(); this.component = component; }
protected void registerHomeQueryResources(Component seamComponent) { // We can always instantiate this safely here because it can't have dependencies! AbstractResource instance = (AbstractResource) seamComponent.newInstance(); String path = instance.getPath(); if (path != null) { if (!path.startsWith("/")) { path = "/" + path; } log.debug( "registering resource, configured ResourceHome/Query on path {1}, as Seam component: {0}", seamComponent.getName(), path ); ResourceFactory factory = new SeamResteasyResourceFactory( seamComponent.getBeanClass(), seamComponent, getDispatcher().getProviderFactory() ); getDispatcher().getRegistry().addResourceFactory(factory, path); } else { log.error("Unable to register {0} resource on null path, check components.xml", seamComponent.getName()); } }
public List<Class> getSeamInterfaces() { List<Class> interfaces = new ArrayList<Class>(); Component component = getComponent(); // Attempt to piece together all of the possible interfaces to apply // to our proxy. if ( component != null && component.isInterceptionEnabled() ) { if (component.getType().isSessionBean()) { interfaces.addAll(component.getBusinessInterfaces()); } else { interfaces.add(HttpSessionActivationListener.class); interfaces.add(Mutable.class); } interfaces.add(Proxy.class); } return interfaces; }
ProxyObject proxy = Component.createProxyFactory( ComponentType.JAVA_BEAN, beanClass, Component.getBusinessInterfaces(beanClass) ).newInstance(); proxy.setHandler(this); return comp.wrap(bean, this);
getAttributeMessage(name) ); if ( out.scope()==UNSPECIFIED ) component = Component.forName(name); if (value!=null && component!=null) if ( !component.isInstance(value) ) getAttributeMessage(name) ); getAttributeMessage(name) ); getOutScope( out.scope(), this ) : component.getScope();
private void initInterceptors() { initDefaultInterceptors(); for ( Annotation annotation: getBeanClass().getAnnotations() ) { if ( annotation.annotationType().isAnnotationPresent(INTERCEPTORS) ) { Class[] classes = value( annotation.annotationType().getAnnotation(INTERCEPTORS) ); addInterceptor( new Interceptor(classes, annotation, this) ); } if ( annotation.annotationType().isAnnotationPresent(Interceptors.class) ) { Class[] classes = annotation.annotationType().getAnnotation(Interceptors.class).value(); addInterceptor( new Interceptor(classes, annotation, this) ); } } newSort(interceptors); newSort(clientSideInterceptors); if ( log.isDebugEnabled() ) log.debug("interceptor stack: " + interceptors); }
protected static void runTasks() { Component component = Component.forName(StatusMessages.COMPONENT_NAME); if( component != null && !component.getScope().isContextActive() ) { return; } //Attempting to get the instance anyway for backwards compatibility with some potential hack situations. StatusMessages statusMessages = instance(); if ( statusMessages != null ) { statusMessages.doRunTasks(); } }