Class WebsphereDeploymentTool

  • All Implemented Interfaces:

    public class WebsphereDeploymentTool
    extends GenericDeploymentTool
    WebSphere deployment tool that augments the ejbjar task. Searches for the WebSphere specific deployment descriptors and adds them to the final ejb jar file. WebSphere has two specific descriptors for session beans:
    • ibm-ejb-jar-bnd.xmi
    • ibm-ejb-jar-ext.xmi
    and another two for container managed entity beans:
    • Map.mapxmi
    • Schema.dbxmi
    In terms of WebSphere, the generation of container code and stubs is called deployment. This step can be performed by the websphere element as part of the jar generation process. If the switch ejbdeploy is on, the ejbdeploy tool from the WebSphere toolset is called for every ejb-jar. Unfortunately, this step only works, if you use the ibm jdk. Otherwise, the rmic (called by ejbdeploy) throws a ClassFormatError. Be sure to switch ejbdeploy off, if run ant with sun jdk.
    • Constructor Detail

      • WebsphereDeploymentTool

        public WebsphereDeploymentTool()
    • Method Detail

      • createWASClasspath

        public Path createWASClasspath()
        Get the classpath to the WebSphere classpaths.
        the WebSphere classpath.
      • setWASClasspath

        public void setWASClasspath​(Path wasClasspath)
        Set the WebSphere classpath.
        wasClasspath - the WebSphere classpath.
      • setDbvendor

        public void setDbvendor​(java.lang.String dbvendor)
        Sets the DB Vendor for the Entity Bean mapping; optional.

        Valid options can be obtained by running the following command: <WAS_HOME>/bin/EJBDeploy.[sh/bat] -help

        This is also used to determine the name of the Map.mapxmi and Schema.dbxmi files, for example Account-DB2UDB_V81-Map.mapxmi and Account-DB2UDB_V81-Schema.dbxmi.

        dbvendor - database vendor type
      • setDbname

        public void setDbname​(java.lang.String dbName)
        Sets the name of the Database to create; optional.
        dbName - name of the database
      • setDbschema

        public void setDbschema​(java.lang.String dbSchema)
        Sets the name of the schema to create; optional.
        dbSchema - name of the schema
      • setCodegen

        public void setCodegen​(boolean codegen)
        Flag, default false, to only generate the deployment code, do not run RMIC or Javac
        codegen - option
      • setQuiet

        public void setQuiet​(boolean quiet)
        Flag, default true, to only output error messages.
        quiet - option
      • setNovalidate

        public void setNovalidate​(boolean novalidate)
        Flag to disable the validation steps; optional, default false.
        novalidate - option
      • setNowarn

        public void setNowarn​(boolean nowarn)
        Flag to disable warning and informational messages; optional, default false.
        nowarn - option
      • setNoinform

        public void setNoinform​(boolean noinform)
        Flag to disable informational messages; optional, default false.
        noinform - if true disables informational messages
      • setTrace

        public void setTrace​(boolean trace)
        Flag to enable internal tracing when set, optional, default false.
        trace - a boolean value.
      • setRmicoptions

        public void setRmicoptions​(java.lang.String options)
        Set the rmic options.
        options - the options to use.
      • setUse35

        public void setUse35​(boolean attr)
        Flag to use the WebSphere 3.5 compatible mapping rules; optional, default false.
        attr - a boolean value.
      • setRebuild

        public void setRebuild​(boolean rebuild)
        Set the rebuild flag to false to only update changes in the jar rather than rerunning ejbdeploy; optional, default true.
        rebuild - a boolean value.
      • setSuffix

        public void setSuffix​(java.lang.String inString)
        String value appended to the basename of the deployment descriptor to create the filename of the WebLogic EJB jar file. Optional, default '.jar'.
        inString - the string to use as the suffix.
      • setKeepgeneric

        public void setKeepgeneric​(boolean inValue)
        This controls whether the generic file used as input to ejbdeploy is retained; optional, default false.
        inValue - either 'true' or 'false'.
      • setEjbdeploy

        public void setEjbdeploy​(boolean ejbdeploy)
        Decide, whether ejbdeploy should be called or not; optional, default true.
        ejbdeploy - a boolean value.
      • setEJBdtd

        public void setEJBdtd​(java.lang.String inString)
        Setter used to store the location of the Sun's Generic EJB DTD. This can be a file on the system or a resource on the classpath.
        inString - the string to use as the DTD location.
      • setOldCMP

        public void setOldCMP​(boolean oldCMP)
        Set the value of the oldCMP scheme. This is an antonym for newCMP
        oldCMP - a boolean value.
      • setNewCMP

        public void setNewCMP​(boolean newCMP)
        Set the value of the newCMP scheme. The old CMP scheme locates the WebSphere CMP descriptor based on the naming convention where the WebSphere CMP file is expected to be named with the bean name as the prefix. Under this scheme the name of the CMP descriptor does not match the name actually used in the main WebSphere EJB descriptor. Also, descriptors which contain multiple CMP references could not be used.
        newCMP - a boolean value.
      • setTempdir

        public void setTempdir​(java.lang.String tempdir)
        The directory, where ejbdeploy will write temporary files; optional, defaults to '_ejbdeploy_temp'.
        tempdir - the directory name to use.
      • getWebsphereDescriptorHandler

        protected DescriptorHandler getWebsphereDescriptorHandler​( srcDir)
        Get a description handler.
        srcDir - the source directory.
        the handler.
      • addVendorFiles

        protected void addVendorFiles​(java.util.Hashtable<java.lang.String,​> ejbFiles,
                                      java.lang.String baseName)
        Add any vendor specific files which should be included in the EJB Jar.
        addVendorFiles in class GenericDeploymentTool
        ejbFiles - a hashtable entryname -> file.
        baseName - a prefix to use.
      • getOptions

        protected java.lang.String getOptions()
        Gets the options for the EJB Deploy operation
      • writeJar

        protected void writeJar​(java.lang.String baseName,
                                java.util.Hashtable<java.lang.String,​> files,
                                java.lang.String publicId)
                         throws BuildException
        Method used to encapsulate the writing of the JAR file. Iterates over the filenames/ in the Hashtable stored on the instance variable ejbFiles..
        writeJar in class GenericDeploymentTool
        baseName - the base name to use.
        jarFile - the jar file to write to.
        files - the files to write to the jar.
        publicId - the id to use.
        BuildException - if there is a problem.
      • isRebuildRequired

        protected boolean isRebuildRequired​( genericJarFile,
        Helper method to check to see if a WebSphere EJB 1.1 jar needs to be rebuilt using ejbdeploy. Called from writeJar it sees if the "Bean" classes are the only thing that needs to be updated and either updates the Jar with the Bean classfile or returns true, saying that the whole WebSphere jar needs to be regenerated with ejbdeploy. This allows faster build times for working developers.

        The way WebSphere ejbdeploy works is it creates wrappers for the publicly defined methods as they are exposed in the remote interface. If the actual bean changes without changing the the method signatures then only the bean classfile needs to be updated and the rest of the WebSphere jar file can remain the same. If the Interfaces, ie. the method signatures change or if the xml deployment descriptors changed, the whole jar needs to be rebuilt with ejbdeploy. This is not strictly true for the xml files. If the JNDI name changes then the jar doesn't have to be rebuild, but if the resources references change then it does. At this point the WebSphere jar gets rebuilt if the xml files change at all.

        genericJarFile - The generic jar file.
        websphereJarFile - The WebSphere jar file to check to see if it needs to be rebuilt.
        true if a rebuild is required.
      • getClassLoaderFromJar

        protected java.lang.ClassLoader getClassLoaderFromJar​( classjar)
        Helper method invoked by isRebuildRequired to get a ClassLoader for a Jar File passed to it.
        classjar - representing jar file to get classes from.
        a classloader for the jar file.
        Throws: - if there is an error.