⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iplanetejbc.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
         * implementation) and returns the modification timestamp for the         * "oldest" class.         *         * @param classpath The classpath to be used to find the source EJB         *                  classes.  If <code>null</code>, the system classpath         *                  is used.         * @return The modification timestamp for the "oldest" EJB source class.         * @throws BuildException If one of the EJB source classes cannot be         *                        found on the classpath.         */        private long sourceClassesModified(File buildDir) {            long latestModified; // The timestamp of the "newest" class            long modified;       // Timestamp for a given class            File remoteFile;     // File for the remote interface class            File homeFile;       // File for the home interface class            File implFile;       // File for the EJB implementation class            File pkFile;         // File for the EJB primary key class            /* Check the timestamp on the remote interface */            remoteFile = remote.getClassFile(buildDir);            modified = remoteFile.lastModified();            if (modified == -1) {                System.out.println("The class "                                + remote.getQualifiedClassName() + " couldn't "                                + "be found on the classpath");                return -1;            }            latestModified = modified;            /* Check the timestamp on the home interface */            homeFile = home.getClassFile(buildDir);            modified = homeFile.lastModified();            if (modified == -1) {                System.out.println("The class "                                + home.getQualifiedClassName() + " couldn't be "                                + "found on the classpath");                return -1;            }            latestModified = Math.max(latestModified, modified);            /* Check the timestamp of the primary key class */            if (primaryKey != null) {                pkFile = primaryKey.getClassFile(buildDir);                modified = pkFile.lastModified();                if (modified == -1) {                    System.out.println("The class "                                    + primaryKey.getQualifiedClassName() + "couldn't be "                                    + "found on the classpath");                    return -1;                }                latestModified = Math.max(latestModified, modified);            } else {                pkFile = null;            }            /* Check the timestamp on the EJB implementation class.             *             * Note that if ONLY the implementation class has changed, it's not             * necessary to rebuild the EJB stubs and skeletons.  For this             * reason, we ensure the file exists (using lastModified above), but             * we DON'T compare it's timestamp with the timestamps of the home             * and remote interfaces (because it's irrelevant in determining if             * ejbc must be run)             */            implFile = implementation.getClassFile(buildDir);            modified = implFile.lastModified();            if (modified == -1) {                System.out.println("The class "                                + implementation.getQualifiedClassName()                                + " couldn't be found on the classpath");                return -1;            }            String pathToFile = remote.getQualifiedClassName();            pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";            ejbFiles.put(pathToFile, remoteFile);            pathToFile = home.getQualifiedClassName();            pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";            ejbFiles.put(pathToFile, homeFile);            pathToFile = implementation.getQualifiedClassName();            pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";            ejbFiles.put(pathToFile, implFile);            if (pkFile != null) {                pathToFile = primaryKey.getQualifiedClassName();                pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";                ejbFiles.put(pathToFile, pkFile);            }            return latestModified;        }        /**         * Examines each of the EJB stubs and skeletons in the destination         * directory and returns the modification timestamp for the "oldest"         * class. If one of the stubs or skeletons cannot be found, <code>-1         * </code> is returned.         *         * @param dest The directory in which the EJB stubs and skeletons are         *             stored.         * @return The modification timestamp for the "oldest" EJB stub or         *         skeleton.  If one of the classes cannot be found, <code>-1         *         </code> is returned.         * @throws BuildException If the canonical path of the destination         *                        directory cannot be found.         */        private long destClassesModified(File destDir) {            String[] classnames = classesToGenerate(); // List of all stubs & skels            long destClassesModified = new Date().getTime(); // Earliest mod time            boolean allClassesFound  = true;           // Has each been found?            /*             * Loop through each stub/skeleton class that must be generated, and             * determine (if all exist) which file has the most recent timestamp             */            for (int i = 0; i < classnames.length; i++) {                String pathToClass =                        classnames[i].replace('.', File.separatorChar) + ".class";                File classFile = new File(destDir, pathToClass);                /*                 * Add each stub/skeleton class to the list of EJB files.  Note                 * that each class is added even if it doesn't exist now.                 */                ejbFiles.put(pathToClass, classFile);                allClassesFound = allClassesFound && classFile.exists();                if (allClassesFound) {                    long fileMod = classFile.lastModified();                    /* Keep track of the oldest modification timestamp */                    destClassesModified = Math.min(destClassesModified, fileMod);                }            }            return (allClassesFound) ? destClassesModified : -1;        }        /**         * Builds an array of class names which represent the stubs and         * skeletons which need to be generated for a given EJB.  The class         * names are fully qualified.  Nine classes are generated for all EJBs         * while an additional six classes are generated for beans requiring         * RMI/IIOP access.         *         * @return An array of Strings representing the fully-qualified class         *         names for the stubs and skeletons to be generated.         */        private String[] classesToGenerate() {            String[] classnames = (iiop)                ? new String[NUM_CLASSES_WITH_IIOP]                : new String[NUM_CLASSES_WITHOUT_IIOP];            final String remotePkg     = remote.getPackageName() + ".";            final String remoteClass   = remote.getClassName();            final String homePkg       = home.getPackageName() + ".";            final String homeClass     = home.getClassName();            final String implPkg       = implementation.getPackageName() + ".";            final String implFullClass = implementation.getQualifiedWithUnderscores();            int index = 0;            classnames[index++] = implPkg + "ejb_fac_" + implFullClass;            classnames[index++] = implPkg + "ejb_home_" + implFullClass;            classnames[index++] = implPkg + "ejb_skel_" + implFullClass;            classnames[index++] = remotePkg + "ejb_kcp_skel_" + remoteClass;            classnames[index++] = homePkg + "ejb_kcp_skel_" + homeClass;            classnames[index++] = remotePkg + "ejb_kcp_stub_" + remoteClass;            classnames[index++] = homePkg + "ejb_kcp_stub_" + homeClass;            classnames[index++] = remotePkg + "ejb_stub_" + remoteClass;            classnames[index++] = homePkg + "ejb_stub_" + homeClass;            if (!iiop) {                return classnames;            }            classnames[index++] = "org.omg.stub." + remotePkg + "_"                                    + remoteClass + "_Stub";            classnames[index++] = "org.omg.stub." + homePkg + "_"                                    + homeClass + "_Stub";            classnames[index++] = "org.omg.stub." + remotePkg                                    + "_ejb_RmiCorbaBridge_"                                    + remoteClass + "_Tie";            classnames[index++] = "org.omg.stub." + homePkg                                    + "_ejb_RmiCorbaBridge_"                                    + homeClass + "_Tie";            classnames[index++] = remotePkg + "ejb_RmiCorbaBridge_"                                                        + remoteClass;            classnames[index++] = homePkg + "ejb_RmiCorbaBridge_" + homeClass;            return classnames;        }        /**         * Convenience method which creates a String representation of all the         * instance variables of an EjbInfo object.         *         * @return A String representing the EjbInfo instance.         */        public String toString() {            String s = "EJB name: " + name                        + "\n\r              home:      " + home                        + "\n\r              remote:    " + remote                        + "\n\r              impl:      " + implementation                        + "\n\r              primaryKey: " + primaryKey                        + "\n\r              beantype:  " + beantype                        + "\n\r              cmp:       " + cmp                        + "\n\r              iiop:      " + iiop                        + "\n\r              hasession: " + hasession;            Iterator i = cmpDescriptors.iterator();            while (i.hasNext()) {                s += "\n\r              CMP Descriptor: " + i.next();            }            return s;        }    } // End of EjbInfo inner class    /**     * Convenience class used to represent the fully qualified name of a Java     * class.  It provides an easy way to retrieve components of the class name     * in a format that is convenient for building iAS stubs and skeletons.     *     */    private static class Classname {        private String qualifiedName;  // Fully qualified name of the Java class        private String packageName;    // Name of the package for this class        private String className;      // Name of the class without the package        /**         * This constructor builds an object which represents the name of a Java         * class.         *         * @param qualifiedName String representing the fully qualified class         *                      name of the Java class.         */        public Classname(String qualifiedName) {            if (qualifiedName == null) {                return;            }            this.qualifiedName = qualifiedName;            int index = qualifiedName.lastIndexOf('.');            if (index == -1) {                className = qualifiedName;                packageName = "";            } else {                packageName = qualifiedName.substring(0, index);                className   = qualifiedName.substring(index + 1);            }        }        /**         * Gets the fully qualified name of the Java class.         *         * @return String representing the fully qualified class name.         */        public String getQualifiedClassName() {            return qualifiedName;        }        /**         * Gets the package name for the Java class.         *         * @return String representing the package name for the class.         */        public String getPackageName() {            return packageName;        }        /**         * Gets the Java class name without the package structure.         *         * @return String representing the name for the class.         */        public String getClassName() {            return className;        }        /**         * Gets the fully qualified name of the Java class with underscores         * separating the components of the class name rather than periods.         * This format is used in naming some of the stub and skeleton classes         * for the iPlanet Application Server.         *         * @return String representing the fully qualified class name using         *         underscores instead of periods.         */        public String getQualifiedWithUnderscores() {            return qualifiedName.replace('.', '_');        }        /**         * Returns a File which references the class relative to the specified         * directory.  Note that the class file may or may not exist.         *         * @param  directory A File referencing the base directory containing         *                   class files.         * @return File referencing this class.         */        public File getClassFile(File directory) {            String pathToFile = qualifiedName.replace('.', File.separatorChar)                                            + ".class";            return new File(directory, pathToFile);        }        /**         * String representation of this class name.  It returns the fully         * qualified class name.         *         * @return String representing the fully qualified class name.         */        public String toString() {            return getQualifiedClassName();        }    }  // End of Classname inner class    /**     * Thread class used to redirect output from an <code>InputStream</code> to     * the JRE standard output.  This class may be used to redirect output from     * an external process to the standard output.     *     */    private static class RedirectOutput extends Thread {        private InputStream stream;  // Stream to read and redirect to standard output        /**         * Constructs a new instance that will redirect output from the         * specified stream to the standard output.         *         * @param stream InputStream which will be read and redirected to the         *               standard output.         */        public RedirectOutput(InputStream stream) {            this.stream = stream;        }        /**         * Reads text from the input stream and redirects it to standard output         * using a separate thread.         */        public void run() {            BufferedReader reader = new BufferedReader(                                            new InputStreamReader(stream));            String text;            try {                while ((text = reader.readLine()) != null) {                    System.out.println(text);                }            } catch (IOException e) {                e.printStackTrace();            } finally {                try {                    reader.close();                } catch (IOException e) {                    // Do nothing                }            }        }    }  // End of RedirectOutput inner class}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -