SeamFramework.orgCommunity Documentation
현재 Web Beans RI는 JBoss AS 5에서만 실행됩니다; RI를 기타 다른 EE 환경 (예를 들어 Glassfish와 같은 다른 애플리케이션 서버)으로 통합, 또는 servlet 컨테이너로 통합 (예: Tomcat), 또는 내장된 EJB3.1 구현과 통합하는 것은 쉽습니다. Appendix에서 필요한 절차에 대해 간략하게 살펴보겠습니다.
SE 환경에서 Web Beans를 실행할 수 있어야 하지만, 자체적 컨텍스트 및 수명 주기 추가와 같은 더 많은 작업을 해야 합니다. 현재 Web Beans RI는 수명 확장 지점을 나타내지 않고 있으므로, Web Beans RI 클래스에 대해 직접 코드화해야 합니다.
Web Beans SPI는 webbeans-ri-spi
모듈에 위치하고 있으며 webbeans-ri-spi.jar
로 패키징되어 있습니다. 일부 SPI는 옵션 사항이며, 기본값 동작을 덮어쓰기해야할 경우, 다른 사항이 필요합니다.
SPI 구현을 시스템 속성으로나 또는 속성 파일 META-INF/web-beans-ri.properties
로 지정할 수 있습니다. 모든 속성 이름은 구현된 인터페이스의 완전 정규화된 클래스 이름입니다; 모드 속성 값은 구현 클래스의 완전 정규화된 클래스 이름입니다.
SPI에 있는 모든 인터페이스는 데코레이터 패턴을 지원하고 Forwarding
클래스를 제공합니다.
public interface WebBeanDiscovery {
/**
* Gets list of all classes in classpath archives with web-beans.xml files
*
* @return An iterable over the classes
*/
public Iterable<Class<?>
> discoverWebBeanClasses();
/**
* Gets a list of all web-beans.xml files in the app classpath
*
* @return An iterable over the web-beans.xml files
*/
public Iterable<URL
> discoverWebBeansXml();
}
Web Bean 클래스 및 web-bean.xml
파일 검색은 쉽게 알 수 있습니다 (알고리즘은 JSR-299 사양 11.1장에 설명되어 있으므로 여기서 다시 설명하지 않습니다).
Web Beans RI는 완전 정규화된 클래스 이름 값과 함께 org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery
속성을 사용하여 WebBeanDiscovery
구현을 불러오기하게 할 수 있습니다. 예:
org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery=org.jboss.webbeans.integration.jbossas.WebBeanDiscoveryImpl
Web Beans RI가 servlet 컨테이너에서 사용될 경우, 이는 생성자 형식을 요청하게 됩니다:
public WebBeanDiscoveryImpl(ServletContext servletContext) {}
servlet 컨텍스트는 WebBeanDiscovery
구현을 허용하기 위해 사용되어 컨테이너와 상호작용할 수 있습니다.
Web Beans RI는 컨테이너로 EJB3 bean 검색을 위임하므로 EJB3 어노테이션을 검색하거나 ejb-jar.xml
을 파싱할 필요가 없습니다. 애플리케이션에 있는 각각의 EJB의 경우 EJBDescriptor를 검색해야 합니다:
public interface EjbDiscovery
{
public static final String PROPERTY_NAME = EjbDiscovery.class.getName();
/**
* Gets a descriptor for each EJB in the application
*
* @return The bean class to descriptor map
*/
public Iterable<EjbDescriptor<?>
> discoverEjbs();
}
public interface EjbDescriptor<T
> {
/**
* Gets the EJB type
*
* @return The EJB Bean class
*/
public Class<T
> getType();
/**
* Gets the local business interfaces of the EJB
*
* @return An iterator over the local business interfaces
*/
public Iterable<BusinessInterfaceDescriptor<?>
> getLocalBusinessInterfaces();
/**
* Gets the remote business interfaces of the EJB
*
* @return An iterator over the remote business interfaces
*/
public Iterable<BusinessInterfaceDescriptor<?>
> getRemoteBusinessInterfaces();
/**
* Get the remove methods of the EJB
*
* @return An iterator over the remove methods
*/
public Iterable<Method
> getRemoveMethods();
/**
* Indicates if the bean is stateless
*
* @return True if stateless, false otherwise
*/
public boolean isStateless();
/**
* Indicates if the bean is a EJB 3.1 Singleton
*
* @return True if the bean is a singleton, false otherwise
*/
public boolean isSingleton();
/**
* Indicates if the EJB is stateful
*
* @return True if the bean is stateful, false otherwise
*/
public boolean isStateful();
/**
* Indicates if the EJB is and MDB
*
* @return True if the bean is an MDB, false otherwise
*/
public boolean isMessageDriven();
/**
* Gets the EJB name
*
* @return The name
*/
public String getEjbName();
}
EjbDescriptor
는 쉽게 알 수 있어야 하며 EJB 사양에 정의되어 있음으로 관련된 메타데이터를 반환해야 합니다. 이러한 두 가지 인터페이스에 더하여, 로컬 비지니스 인터페이스를 나타내는 BusinessInterfaceDescriptor
가 있습니다. (EJB 인스턴스를 검색하는데 사용되는 인터페이스 클래스 및 jndi 이름을 캡슐화)
Web Beans RI는 완전 정규화된 클래스 이름 값과 함께 org.jboss.webbeans.bootstrap.spi.EjbDiscovery
속성을 사용하여 EjbDiscovery
구현을 불러오기하게 할 수 있습니다. 예:
org.jboss.webbeans.bootstrap.spi.EjbDiscovery=org.jboss.webbeans.integration.jbossas.EjbDiscoveryImpl
Web Beans RI가 servlet 컨테이너에서 사용될 경우, 이는 생성자 형식을 요청하게 됩니다:
public EjbDiscoveryImpl(ServletContext servletContext) {}
servlet 컨텍스트는 EjbDiscovery
구현을 허용하기 위해 사용되어 컨테이너와 상호작용할 수 있습니다.
Web Beans RI는 기준에 따라 JNDI 바인딩 및 lookup을 구현하지만, 바인딩 및 lookup을 변경하고자 하실 수 있습니다 (예를 들어 JNDI를 사용할 수 없는 환경에서). 이를 위해 org.jboss.webbeans.spi.resources.NamingContext
를구현합니다:
public interface NamingContext extends Serializable {
/**
* Typed JNDI lookup
*
* @param <T
> The type
* @param name The JNDI name
* @param expectedType The expected type
* @return The object
*/
public <T
> T lookup(String name, Class<? extends T
> expectedType);
/**
* Binds an item to JNDI
*
* @param name The key to bind under
* @param value The item to bind
*/
public void bind(String name, Object value);
}
RI에게 사용할 것을 알립니다:
org.jboss.webbeans.resources.spi.NamingContext=com.acme.MyNamingContext
Web Beans RI가 servlet 컨테이너에서 사용될 경우, 이는 생성자 형식을 요청하게 됩니다:
public MyNamingContext(ServletContext servletContext) {}
servlet 컨텍스트는 NamingContext
구현을 허용하기 위해 사용되어 컨테이너와 상호 작용할 수 있습니다.
Web Beans RI는 여러번 classpath에서 클래스 및 리소스를 불러와야 합니다. 기본값으로 RI를 불러오기 위해 사용되었던 동일한 classloader에서 로딩되지만, 일부 환경에서는 작동하지 않을 수 도 있습니다. 이러한 경우, org.jboss.webbeans.spi.ResourceLoader
를 구현할 수 있습니다:
public interface ResourceLoader {
/**
* Creates a class from a given FQCN
*
* @param name The name of the clsas
* @return The class
*/
public Class<?> classForName(String name);
/**
* Gets a resource as a URL by name
*
* @param name The name of the resource
* @return An URL to the resource
*/
public URL getResource(String name);
/**
* Gets resources as URLs by name
*
* @param name The name of the resource
* @return An iterable reference to the URLS
*/
public Iterable<URL
> getResources(String name);
}
RI에게 사용할 것을 알립니다:
org.jboss.webbeans.resources.spi.ResourceLoader=com.acme.ResourceLoader
Web Beans RI가 servlet 컨테이너에서 사용될 경우, 이는 생성자 형식을 요청하게 됩니다:
public MyResourceLoader(ServletContext servletContext) {}
servlet 컨텍스트는 ResourceLoader
구현을 허용하기 위해 사용되어 컨테이너와 상호작용할 수 있습니다.
API의 외부 구현에서의 올바른 기능을 실행하게 하기 위해 Web Beans RI이 컨테이너에 위치하게 해야 할 여러 요구 사항이 있습니다
Web Beans RI를 다수의 애플리케이션의 운용을 지원하는 환경으로 통합할 경우, 각각의 Web Beans 애플리케이션에 대한 클래스로더 분리를 자동으로 또는 사용자 설정을 통해 반드시 활성화해야 합니다.
Web Beans를 Servlet 환경으로 통합할 경우, Servlet을 사용하는 각각의 Web Beans 애플리케이션에 대해 자동으로 또는 사용자 설정을 통해 org.jboss.webbeans.servlet.WebBeansListener
를 Servlet 청취자로 등록해야 합니다.
Web Beans를 EJB 환경으로 통합하고자 할 경우 엔터프라이즈 beans를 사용하는 각각의 Web Beans 애플리케이션 용으로 모든 EJB 애플리케이션에 대해 EJB 인터셉터로서 org.jboss.webbeans.ejb.SessionBeanInterceptor
를 자동으로 또는 사용자 설정을 통해 등록해야 합니다.
webbeans-ri.jar
Web Beans를 애플리케이션 운용을 지원하는 환경으로 통합하고자 할 경우, webbeans-ri.jar
를 애플리케이션 분리 classloader로 삽입해야 합니다. 이는 공유 classloader에서 불러올 수 없습니다.