JBoss schnelles Deployment / Undeployment

Thomas Darimont

Erfahrenes Mitglied
Hallo!

Wie man weis deployed man eine EJB- Anwendung indem man das entsprechende /jar/ear/... in das deploy-Verzeichnis der entsprechenden JBoss Serverkonfiguration kopiert.

Will man nun testweise eine EJB Anwendung deaktivieren (undeployen) so könnte man das jar/ear einfach löschen. JBoss würde das automatisch erkennen und die Anwendung undeployen. Es gibt jedoch noch einen pragmatischeren Weg :)

In der Datei jboss-service.xml (conf Verzeichnis) findet man u.a. folgenden Eintrag für den URLDeploymentScanner:
Code:
<!-- ==================================================================== -->
   <!-- Deployment Scanning                                                  -->
   <!-- ==================================================================== -->

   <!-- An mbean for hot deployment/undeployment of archives.
   -->
   <mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"
      name="jboss.deployment:type=DeploymentScanner,flavor=URL">

      <!-- Uncomment (and comment/remove version below) to enable usage of the
        DeploymentCache
      <depends optional-attribute-name="Deployer">jboss.deployment:type=DeploymentCache</depends>
      -->
      <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>

      <!-- The URLComparator can be used to specify a deployment ordering
           for deployments found in a scanned directory.  The class specified
           must be an implementation of java.util.Comparator, it must be able
           to compare two URL objects, and it must have a no-arg constructor.
           Two deployment comparators are shipped with JBoss:
             - org.jboss.deployment.DeploymentSorter 
               Sorts by file extension, as follows:
                 "sar", "service.xml", "rar", "jar", "war", "wsr", "ear", "zip", 
                 "*"
             - org.jboss.deployment.scanner.PrefixDeploymentSorter
               If the name portion of the url begins with 1 or more digits, those 
               digits are converted to an int (ignoring leading zeroes), and 
               files are deployed in that order.  Files that do not start with 
               any digits will be deployed first, and they will be sorted by
               extension as above with DeploymentSorter.
      -->
      <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>
      <!--
      <attribute name="URLComparator">org.jboss.deployment.scanner.PrefixDeploymentSorter</attribute>
      -->

      <!-- The Filter specifies a java.io.FileFilter for scanned
           directories.  Any file not accepted by this filter will not be
           deployed.  The org.jboss.deployment.scanner.DeploymentFilter 
           rejects the following patterns:
               "#*", "%*", ",*", ".*", "_$*", "*#", "*$", "*%", "*.BAK", 
               "*.old", "*.orig", "*.rej", "*.bak", "*,v", "*~", ".make.state", 
               ".nse_depinfo", "CVS", "CVS.admin", "RCS", "RCSLOG", "SCCS", 
               "TAGS", "core", "tags"
      -->
      <attribute name="Filter">org.jboss.deployment.scanner.DeploymentFilter</attribute>

      <attribute name="ScanPeriod">5000</attribute>

      <!-- URLs are comma separated and resolve relative to the server home URL
         unless the given path is absolute. If the URL ends in "/" it is
         considered a collection and scanned, otherwise it is simply deployed;
         this follows RFC2518 convention and allows discrimination between
         collections and directories that are simply unpacked archives.

         URLs may be local (file:) or remote (http:). Scanning is supported
         for remote URLs but unpacked deployment units are not.

         Example URLs:
            deploy/
                 scans ${jboss.server.url}/deploy/, which is local or remote
                 depending on the URL used to boot the server
            ${jboss.server.home}/deploy/
                 scans ${jboss.server.home)/deploy, which is always local
            file:/var/opt/myapp.ear
                 deploy myapp.ear from a local location
            file:/var/opt/apps/
                 scans the specified directory
            http://www.test.com/netboot/myapp.ear
                 deploys myapp.ear from a remote location
            http://www.test.com/netboot/apps/
                 scans the specified WebDAV location
       -->
      <attribute name="URLs">
         deploy/
      </attribute>

      <!-- Indicates if the scanner should recursively scan directories that
      contain no "." in their names. This can be used to group applications
      and services that must be deployed and that have the same
      logical function in the same directory i.e.
        deploy/JMX/
        deploy/JMS/
        ...
      -->

      <attribute name="RecursiveSearch">True</attribute>

    </mbean>
Wie man dort sehen kann hat kann man über entsprechende Präfixe das Deployment unter JBoss steuern. Setzt man beispielsweise ein '#' als Präfix für das jar einer EJB-Anwendung:
tutorials-ejb-example.jar -> #tutorials-ejb-example.jar
So wird das tutorials-ejb-example.jar beim nächsten JBoss start nicht deployed und falls der Server gerade läuft automatisch undeployed.

Es ist sogar möglich EJB Anwendungen in einer bestimmten Reihenfolge starten zu lassen.

Gruß Tom
 
Hallo,

du schreibst, es ist sogar möglich EJB Anwendungen in einer bestimmten Reihenfolge zu starten: --> ist es auch möglich Abhängigkeiten zwischen verschiedenen Anwendungen zu prüfen, z.B. Starte Anwendung2 nur, wenn Anwendung1 existiert?
Muss ich dafür einen eigenen Deploymentscanner implementieren? Kennt sich hier jemand damit aus oder weiss jemand einen guten Link der mir weiterhelfen könnte?

Grüssle Jens
 
Hallo!

Ja, dass ist möglich. In den JBoss spezifischen Konfigurationsdateien der Anwendung kann man mit dem <depends ...-Element Abhängigkeiten zu anderen Anwendungen/Diensten ausgedrückt werden.

Gruß Tom
 
Danke für deine schnelle Antwort!
Wenn ich das jetzt richtig nachgelesen habe, dann kann ich mit dem depends-Element die Abhängigkeiten zwischen verschiedenen Beans setzen.
In meinem Fall möchte ich zwei ear-Files deployen, wobei die eine Anwendung von der anderen abhängt. Wie kann ich hier die Reihenfolge festlegen?

Grüssle Jens
 
Danke Thomas, dieser Tipp hat mir sehr geholfen. Ich habe bisher die EARs in ein danebenliegendes Verzeichnis kopiert und in das Deploy-Verzeichnis gemoved.
So geht es schneller und besser.

Nun bleibt mir noch die Frage, ob es möglich ist, das Deployen manuell anzustoßen und vom JBoss eine Info zu bekommen, wenn er fertig ist.
Bisher habe ich mich auf den Automatismus verlassen müssen und für den zweiten Teil eine URL im Inneren des zu deployenden EARs gepollt, was zwar funktioniert, mir aber nicht so recht gefällt.

Geht das besser?

Vielen Dank und Shine On, Frank

P.S. Sorry, für die Leichenfledderei, aber es passte ganz gut.
 
Zurück