User: salborini
Date: 00/09/08 19:46:22
Modified: src/main/org/jboss/metadata ApplicationMetaData.java
BeanMetaData.java EntityMetaData.java
XmlFileLoader.java
Log:
Modifications to allow plugin data in metadata. (currently only used by jaws)
Added Wolfgang Werner's patch to prevent access to sun's website during deployment.
Revision Changes Path
1.7 +11 -2 jboss/src/main/org/jboss/metadata/ApplicationMetaData.java
Index: ApplicationMetaData.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/metadata/ApplicationMetaData.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ApplicationMetaData.java 2000/09/08 05:25:42 1.6
+++ ApplicationMetaData.java 2000/09/09 02:46:21 1.7
@@ -25,7 +25,7 @@
*
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class ApplicationMetaData extends MetaData {
// Constants -----------------------------------------------------
@@ -37,6 +37,7 @@
private ArrayList securityRoles = new ArrayList();
private ArrayList configurations = new ArrayList();
private HashMap resources = new HashMap();
+ private HashMap plugins = new HashMap();
// Static --------------------------------------------------------
@@ -87,7 +88,15 @@
return (String)resources.get(name);
}
-
+
+ public void addPluginData(String pluginName, Object pluginData) {
+ plugins.put(pluginName, pluginData);
+ }
+
+ public Object getPluginData(String pluginName) {
+ return plugins.get(pluginName);
+ }
+
public void importEjbJarXml (Element element) throws DeploymentException {
// find the beans
1.9 +6 -2 jboss/src/main/org/jboss/metadata/BeanMetaData.java
Index: BeanMetaData.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/metadata/BeanMetaData.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BeanMetaData.java 2000/08/26 20:10:41 1.8
+++ BeanMetaData.java 2000/09/09 02:46:21 1.9
@@ -21,7 +21,7 @@
*
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public abstract class BeanMetaData extends MetaData {
// Constants -----------------------------------------------------
@@ -72,6 +72,10 @@
public Iterator getEjbReferences() { return ejbReferences.values().iterator();
}
+ public EjbRefMetaData getEjbRefByName(String name) {
+ return (EjbRefMetaData)ejbReferences.get(name);
+ }
+
public Iterator getEnvironmentEntries() { return
environmentEntries.iterator(); }
public Iterator getSecurityRoleReferences() { return
securityRoleReferences.iterator(); }
@@ -229,7 +233,7 @@
while (iterator.hasNext()) {
Element ejbRef = (Element)iterator.next();
String ejbRefName = getElementContent(getUniqueChild(ejbRef,
"ejb-ref-name"));
- EjbRefMetaData ejbRefMetaData =
(EjbRefMetaData)ejbReferences.get(ejbRefName);
+ EjbRefMetaData ejbRefMetaData = getEjbRefByName(ejbRefName);
if (ejbRefMetaData == null) {
throw new DeploymentException("ejb-ref " + ejbRefName
+ " found in jboss.xml but not in ejb-jar.xml");
}
1.4 +2 -2 jboss/src/main/org/jboss/metadata/EntityMetaData.java
Index: EntityMetaData.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/metadata/EntityMetaData.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EntityMetaData.java 2000/08/25 20:19:18 1.3
+++ EntityMetaData.java 2000/09/09 02:46:21 1.4
@@ -17,7 +17,7 @@
*
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class EntityMetaData extends BeanMetaData {
// Constants -----------------------------------------------------
@@ -42,7 +42,7 @@
public boolean isBMP() { return !cmp; }
public boolean isReentrant() { return reentrant; }
public String getPrimaryKeyClass() { return primaryKeyClass; }
- public String[] getCMPFields() { return (String[]) cmpFields.toArray(); }
+ public Iterator getCMPFields() { return cmpFields.iterator(); }
public String getPrimKeyField() { return primKeyField; }
public String getDefaultConfigurationName() {
1.4 +50 -11 jboss/src/main/org/jboss/metadata/XmlFileLoader.java
Index: XmlFileLoader.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/metadata/XmlFileLoader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XmlFileLoader.java 2000/08/18 03:21:06 1.3
+++ XmlFileLoader.java 2000/09/09 02:46:22 1.4
@@ -10,6 +10,8 @@
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.util.Hashtable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -17,6 +19,7 @@
import org.xml.sax.Parser;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.EntityResolver;
import org.jboss.ejb.DeploymentException;
import org.jboss.logging.Logger;
@@ -26,7 +29,8 @@
*
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
- * @version $Revision: 1.3 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Wolfgang Werner</a>
+ * @version $Revision: 1.4 $
*/
public class XmlFileLoader {
// Constants -----------------------------------------------------
@@ -116,22 +120,57 @@
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
- protected Document getDocument(URL url) throws IOException {
- Reader in = new InputStreamReader(url.openStream());
- com.sun.xml.tree.XmlDocumentBuilder xdb = new
com.sun.xml.tree.XmlDocumentBuilder();
- Parser parser = new com.sun.xml.parser.Parser();
- xdb.setParser(parser);
-
+ public static Document getDocument(URL url) throws DeploymentException {
try {
- parser.parse(new InputSource(in));
+ Reader in = new InputStreamReader(url.openStream());
+ com.sun.xml.tree.XmlDocumentBuilder xdb = new
com.sun.xml.tree.XmlDocumentBuilder();
+
+ Parser parser = new com.sun.xml.parser.Parser();
+
+ // Use a local entity resolver to get rid of the DTD loading
via internet
+ EntityResolver er = new LocalResolver();
+ parser.setEntityResolver(er);
+ xdb.setParser(parser);
+
+ parser.parse(new InputSource(in));
return xdb.getDocument();
- }
- catch (SAXException se) {
- throw new IOException(se.getMessage());
+ } catch (Exception e) {
+ throw new DeploymentException(e.getMessage());
}
}
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
+ /**
+ * Local entity resolver to handle EJB 1.1 DTD. With this a http connection
+ * to sun is not needed during deployment.
+ * @author <a href="mailto:[EMAIL PROTECTED]">Wolfgang Werner</a>
+ **/
+ private static class LocalResolver implements EntityResolver {
+ private Hashtable dtds = new Hashtable();
+
+ public LocalResolver() {
+ registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN", "ejb-jar.dtd");
+ }
+
+ public void registerDTD(String publicId, String dtdFileName) {
+ dtds.put(publicId, dtdFileName);
+ }
+
+ public InputSource resolveEntity (String publicId, String systemId) {
+ String dtd = (String)dtds.get(publicId);
+
+ if (dtd != null) {
+ try {
+ InputStream dtdStream =
getClass().getResourceAsStream(dtd);
+ return new InputSource(dtdStream);
+ } catch( Exception ex ) {
+ // ignore
+ }
+ }
+ return null;
+ }
+ }
+
}