Este contenido no está disponible en el idioma seleccionado.

28.10. Deploying custom resources


On start up, Seam scans all JARs containing /seam.properties, /META-INF/components.xml or /META-INF/seam.properties for resources. For example, all classes annotated with @Name are registered on start as Seam components.
You can also use Seam to handle custom resources — that is, Seam can handle specific annotations. First, provide a list of annotation types to handle in the /META-INF/seam-deployment.properties files, like so:
# A colon-separated list of annotation types to handle 
org.jboss.seam.deployment.annotationTypes=com.acme.Foo:com.acme.Bar
Copy to Clipboard Toggle word wrap
Then, collect all classes annotated with @Foo on application start up:
@Name("fooStartup")
@Scope(APPLICATION)
@Startup
public class FooStartup {

   @In("#{deploymentStrategy.annotatedClasses['com.acme.Foo']}")
   private Set<Class<Object>> fooClasses;
   
   @In("#{hotDeploymentStrategy.annotatedClasses['com.acme.Foo']}")
   private Set<Class<Object>> hotFooClasses;

   @Create
   public void create() {
      for (Class clazz: fooClasses) {
         handleClass(clazz);
      }
      for (Class clazz: hotFooClasses) {
         handleClass(clazz);
      }
   }
   
   public void handleClass(Class clazz) {
       // ...
   }

}
Copy to Clipboard Toggle word wrap
You can also set Seam to handle any resource. For example, if you want to process files with the .foo.xml extension, you can write a custom deployment handler:
public class FooDeploymentHandler implements DeploymentHandler { 
  private static DeploymentMetadata FOO_METADATA = new DeploymentMetadata() {

    public String getFileNameSuffix() {
      return ".foo.xml";
    }
  };
  
  public String getName() { 
    return "fooDeploymentHandler"; 
  } 

  public DeploymentMetadata getMetadata() {
    return FOO_METADATA;
  }
}
Copy to Clipboard Toggle word wrap
This provides us with a list of all files with the .foo.xml suffix.
Next, register the deployment handler with Seam in /META-INF/seam-deployment.properties:
# For standard deployment 
# org.jboss.seam.deployment.deploymentHandlers=
#    com.acme.FooDeploymentHandler
 
# For hot deployment 
# org.jboss.seam.deployment.hotDeploymentHandlers=
#    com.acme.FooDeploymentHandler
Copy to Clipboard Toggle word wrap
You can register multiple deployment handlers with a comma-separated list.
Seam uses deployment handlers internally to install components and namespaces, so the handle() is called too early in Seam bootstrap to be useful. You can access the deployment handler easily during the start up of an application-scoped component:
@Name("fooStartup") 
@Scope(APPLICATION) 
@Startup 
public class FooStartup { 
  @In("#{deploymentStrategy.deploymentHandlers['fooDeploymentHandler']}")
  private FooDeploymentHandler myDeploymentHandler;
  @In("#{hotDeploymentStrategy.deploymentHandlers['fooDeploymentHandler']}")
  private FooDeploymentHandler myHotDeploymentHandler;
  @Create public void create() { 
    for (FileDescriptor fd: myDeploymentHandler.getResources()) {
      handleFooXml(fd);
    } 
    for (FileDescriptor f: myHotDeploymentHandler.getResources()) {
      handleFooXml(fd);
    } 
  }
  
  public void handleFooXml(FileDescriptor fd) {
      // ...
  } 
}
Copy to Clipboard Toggle word wrap
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat