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

📄 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 页
字号:
                throws SAXException {            /*             * I need to "push" the element onto the String (currentLoc) which             * always represents the current location in the XML document.             */            currentLoc += "\\" + name;            /* A new element has started, so reset the text being captured */            currentText = "";            if (currentLoc.equals("\\ejb-jar")) {                iasDescriptor = false;            } else if (currentLoc.equals("\\ias-ejb-jar")) {                iasDescriptor = true;            }            if ((name.equals("session")) || (name.equals("entity"))) {                ejbType = name;            }        }        /**         * Receive notification that character data has been found in the XML         * document         *         * @param ch Array of characters which have been found in the document.         * @param start Starting index of the data found in the document.         * @param len The number of characters found in the document.         * @throws SAXException If the parser cannot process the document.         */        public void characters(char[] ch, int start, int len)                throws SAXException {            currentText += new String(ch).substring(start, start + len);        }        /**         * Receive notification that the end of an XML element has been found.         *         * @param name String name of the element.         * @throws SAXException If the parser cannot process the document.         */        public void endElement(String name) throws SAXException {            /*             * If this is a standard EJB 1.1 descriptor, we are looking for one             * set of data, while if this is an iAS-specific descriptor, we're             * looking for different set of data.  Hand the processing off to             * the appropriate method.             */            if (iasDescriptor) {                iasCharacters(currentText);            } else {                stdCharacters(currentText);            }            /*             * I need to "pop" the element off the String (currentLoc) which             * always represents my current location in the XML document.             */            int nameLength = name.length() + 1; // Add one for the "\"            int locLength  = currentLoc.length();            currentLoc = currentLoc.substring(0, locLength - nameLength);        }        /**         * Receive notification that character data has been found in a standard         * EJB 1.1 descriptor.  We're interested in retrieving the home         * interface, remote interface, implementation class, the type of bean,         * and if the bean uses CMP.         *         * @param value String data found in the XML document.         */        private void stdCharacters(String value) {            if (currentLoc.equals("\\ejb-jar\\display-name")) {                displayName = value;                return;            }            String base = "\\ejb-jar\\enterprise-beans\\" + ejbType;            if (currentLoc.equals(base + "\\ejb-name")) {                currentEjb = (EjbInfo) ejbs.get(value);                if (currentEjb == null) {                    currentEjb = new EjbInfo(value);                    ejbs.put(value, currentEjb);                }            } else if (currentLoc.equals(base + "\\home")) {                currentEjb.setHome(value);            } else if (currentLoc.equals(base + "\\remote")) {                currentEjb.setRemote(value);            } else if (currentLoc.equals(base + "\\ejb-class")) {                currentEjb.setImplementation(value);            } else if (currentLoc.equals(base + "\\prim-key-class")) {                currentEjb.setPrimaryKey(value);            } else if (currentLoc.equals(base + "\\session-type")) {                currentEjb.setBeantype(value);            } else if (currentLoc.equals(base + "\\persistence-type")) {                currentEjb.setCmp(value);            }        }        /**         * Receive notification that character data has been found in an         * iAS-specific descriptor.  We're interested in retrieving data         * indicating whether the bean must support RMI/IIOP access, whether         * the bean must provide highly available stubs and skeletons (in the         * case of stateful session beans), and if this bean uses additional         * CMP XML descriptors (in the case of entity beans with CMP).         *         * @param value String data found in the XML document.         */        private void iasCharacters(String value) {            String base = "\\ias-ejb-jar\\enterprise-beans\\" + ejbType;            if (currentLoc.equals(base + "\\ejb-name")) {                currentEjb = (EjbInfo) ejbs.get(value);                if (currentEjb == null) {                    currentEjb = new EjbInfo(value);                    ejbs.put(value, currentEjb);                }            } else if (currentLoc.equals(base + "\\iiop")) {                currentEjb.setIiop(value);            } else if (currentLoc.equals(base + "\\failover-required")) {                currentEjb.setHasession(value);            } else if (currentLoc.equals(base + "\\persistence-manager"                                              + "\\properties-file-location")) {                currentEjb.addCmpDescriptor(value);            }        }    }  // End of EjbcHandler inner class    /**     * This inner class represents an EJB that will be compiled using ejbc.     *     */    private class EjbInfo {        private String     name;              // EJB's display name        private Classname  home;              // EJB's home interface name        private Classname  remote;            // EJB's remote interface name        private Classname  implementation;      // EJB's implementation class        private Classname  primaryKey;        // EJB's primary key class        private String  beantype = "entity";  // or "stateful" or "stateless"        private boolean cmp       = false;      // Does this EJB support CMP?        private boolean iiop      = false;      // Does this EJB support IIOP?        private boolean hasession = false;      // Does this EJB require failover?        private List cmpDescriptors = new ArrayList();  // CMP descriptor list        /**         * Construct a new EJBInfo object with the given name.         *         * @param name The display name for the EJB.         */        public EjbInfo(String name) {            this.name = name;        }        /**         * Returns the display name of the EJB.  If a display name has not been         * set, it returns the EJB implementation classname (if the         * implementation class is not set, it returns "[unnamed]").         *         * @return The display name for the EJB.         */        public String getName() {            if (name == null) {                if (implementation == null) {                    return "[unnamed]";                } else {                    return implementation.getClassName();                }            }            return name;        }        /*         * Below are getter's and setter's for each of the instance variables.         * Note that (in addition to supporting setters with the same type as         * the instance variable) a setter is provided with takes a String         * argument -- this are provided so the XML document handler can set         * the EJB values using the Strings it parses.         */        public void setHome(String home) {            setHome(new Classname(home));        }        public void setHome(Classname home) {            this.home = home;        }        public Classname getHome() {            return home;        }        public void setRemote(String remote) {            setRemote(new Classname(remote));        }        public void setRemote(Classname remote) {            this.remote = remote;        }        public Classname getRemote() {            return remote;        }        public void setImplementation(String implementation) {            setImplementation(new Classname(implementation));        }        public void setImplementation(Classname implementation) {            this.implementation = implementation;        }        public Classname getImplementation() {            return implementation;        }        public void setPrimaryKey(String primaryKey) {            setPrimaryKey(new Classname(primaryKey));        }        public void setPrimaryKey(Classname primaryKey) {            this.primaryKey = primaryKey;        }        public Classname getPrimaryKey() {            return primaryKey;        }        public void setBeantype(String beantype) {            this.beantype = beantype.toLowerCase();        }        public String getBeantype() {            return beantype;        }        public void setCmp(boolean cmp) {            this.cmp = cmp;        }        public void setCmp(String cmp) {            setCmp(cmp.equals("Container"));        }        public boolean getCmp() {            return cmp;        }        public void setIiop(boolean iiop) {            this.iiop = iiop;        }        public void setIiop(String iiop) {            setIiop(iiop.equals("true"));        }        public boolean getIiop() {            return iiop;        }        public void setHasession(boolean hasession) {            this.hasession = hasession;        }        public void setHasession(String hasession) {            setHasession(hasession.equals("true"));        }        public boolean getHasession() {            return hasession;        }        public void addCmpDescriptor(String descriptor) {            cmpDescriptors.add(descriptor);        }        public List getCmpDescriptors() {            return cmpDescriptors;        }        /**         * Verifies that the EJB is valid--if it is invalid, an exception is         * thrown         *         *         * @param buildDir The directory where the EJB remote interface, home         *                 interface, and implementation class must be found.         * @throws EjbcException If the EJB is invalid.         */        private void checkConfiguration(File buildDir) throws EjbcException  {            /* Check that the specified instance variables are valid */            if (home == null) {                throw new EjbcException("A home interface was not found "                            + "for the " + name + " EJB.");            }            if (remote == null) {                throw new EjbcException("A remote interface was not found "                            + "for the " + name + " EJB.");            }            if (implementation == null) {                throw new EjbcException("An EJB implementation class was not "                            + "found for the " + name + " EJB.");            }            if ((!beantype.equals(ENTITY_BEAN))                        && (!beantype.equals(STATELESS_SESSION))                        && (!beantype.equals(STATEFUL_SESSION))) {                throw new EjbcException("The beantype found (" + beantype + ") "                            + "isn't valid in the " + name + " EJB.");            }            if (cmp && (!beantype.equals(ENTITY_BEAN))) {                System.out.println("CMP stubs and skeletons may not be generated"                    + " for a Session Bean -- the \"cmp\" attribute will be"                    + " ignoredfor the " + name + " EJB.");            }            if (hasession && (!beantype.equals(STATEFUL_SESSION))) {                System.out.println("Highly available stubs and skeletons may "                    + "only be generated for a Stateful Session Bean -- the "                    + "\"hasession\" attribute will be ignored for the "                    + name + " EJB.");            }            /* Check that the EJB "source" classes all exist */            if (!remote.getClassFile(buildDir).exists()) {                throw new EjbcException("The remote interface "                            + remote.getQualifiedClassName() + " could not be "                            + "found.");            }            if (!home.getClassFile(buildDir).exists()) {                throw new EjbcException("The home interface "                            + home.getQualifiedClassName() + " could not be "                            + "found.");            }            if (!implementation.getClassFile(buildDir).exists()) {                throw new EjbcException("The EJB implementation class "                            + implementation.getQualifiedClassName() + " could "                            + "not be found.");            }        }        /**         * Determines if the ejbc utility needs to be run or not.  If the stubs         * and skeletons can all be found in the destination directory AND all         * of their timestamps are more recent than the EJB source classes         * (home, remote, and implementation classes), the method returns         * <code>false</code>.  Otherwise, the method returns <code>true</code>.         *         * @param destDir The directory where the EJB source classes, stubs and         *                skeletons are located.         * @return A boolean indicating whether or not the ejbc utility needs to         *         be run to bring the stubs and skeletons up to date.         */        public boolean mustBeRecompiled(File destDir) {            long sourceModified = sourceClassesModified(destDir);            long destModified = destClassesModified(destDir);            return (destModified < sourceModified);        }        /**         * Examines each of the EJB source classes (home, remote, and

⌨️ 快捷键说明

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