You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/08/18 09:44:12 UTC
svn commit: r432510 [4/5] - in /geronimo/trunk:
applications/console/console-standard/
applications/console/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/
configs/ configs/activemq/ configs/axis-deployer/ configs/client-de...
Modified: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java (original)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java Fri Aug 18 00:44:04 2006
@@ -1,6 +1,6 @@
/**
*
- * Copyright 2003-2005 The Apache Software Foundation
+ * Copyright 2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,174 +17,184 @@
package org.apache.geronimo.deployment.service;
-import java.beans.PropertyEditor;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Collection;
+import java.beans.PropertyEditorManager;
-import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.common.propertyeditor.PropertyEditors;
+import javax.xml.namespace.QName;
+
+import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.deployment.xbeans.PatternType;
+import org.apache.geronimo.deployment.ConfigurationBuilder;
+import org.apache.geronimo.deployment.xbeans.GbeanType;
+import org.apache.geronimo.deployment.xbeans.AttributeType;
+import org.apache.geronimo.deployment.xbeans.XmlAttributeType;
import org.apache.geronimo.deployment.xbeans.ReferenceType;
+import org.apache.geronimo.deployment.xbeans.ReferencesType;
+import org.apache.geronimo.deployment.xbeans.PatternType;
+import org.apache.geronimo.deployment.xbeans.ServiceDocument;
+import org.apache.geronimo.deployment.xbeans.GbeanDocument;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.gbean.GAttributeInfo;
-import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GReferenceInfo;
-import org.apache.geronimo.gbean.ReferencePatterns;
-import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.ReferenceMap;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Repository;
import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.QNameSet;
/**
- * @version $Rev$ $Date$
+ * @version $Rev:$ $Date:$
*/
-public class GBeanBuilder {
- private final GBeanData gbean;
- private final ClassLoader classLoader;
- private final DeploymentContext context;
- private final AbstractName moduleName;
- private final Map xmlAttributeBuilderMap;
- private final Map xmlReferenceBuilderMap;
-
- GBeanBuilder(AbstractName abstractName, GBeanInfo gBeanInfo, ClassLoader classLoader, DeploymentContext context, AbstractName moduleName, Map xmlAttributeBuilderMap, Map xmlReferenceBuilderMap) {
-
- this.classLoader = classLoader;
- this.context = context;
- this.moduleName = moduleName;
- this.gbean = new GBeanData(abstractName, gBeanInfo);
- this.xmlAttributeBuilderMap = xmlAttributeBuilderMap;
- this.xmlReferenceBuilderMap = xmlReferenceBuilderMap;
- }
+public class GBeanBuilder implements NamespaceDrivenBuilder {
+ protected Map attrRefMap;
+ protected Map refRefMap;
+ private static final QName SERVICE_QNAME = ServiceDocument.type.getDocumentElementName();
+ private static final QName GBEAN_QNAME = GbeanDocument.type.getDocumentElementName();
+ private static final QNameSet GBEAN_QNAME_SET = QNameSet.singleton(GBEAN_QNAME);
+
+ public GBeanBuilder(Collection xmlAttributeBuilders, Collection xmlReferenceBuilders) {
+ if (xmlAttributeBuilders != null) {
+ ReferenceMap.Key key = new ReferenceMap.Key() {
- public void setAttribute(String name, String type, String text) throws DeploymentException {
- if (text != null) {
- text = text.trim(); // avoid formatting errors due to extra whitespace in XML configuration file
- }
- try {
- // @todo we should not need all of common just for this
- if (type == null) {
- GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name);
- if (attribute == null) {
- throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName());
+ public Object getKey(Object object) {
+ return ((XmlAttributeBuilder) object).getNamespace();
}
- type = attribute.getType();
- }
-
- PropertyEditor editor = PropertyEditors.findEditor(type, classLoader);
- if (editor == null) {
- throw new DeploymentException("Unable to find PropertyEditor for " + type);
- }
- editor.setAsText(text);
- Object value = editor.getValue();
- gbean.setAttribute(name, value);
- } catch (DeploymentException e) {
- throw e;
- } catch (ClassNotFoundException e) {
- throw new DeploymentException("Unable to find PropertyEditor for " + type, e);
- } catch (Exception e) {
- throw new DeploymentException("Unable to set attribute " + name + " to " + text, e);
+ };
+ attrRefMap = new ReferenceMap(xmlAttributeBuilders, new HashMap(), key);
+ } else {
+ attrRefMap = new HashMap();
}
- }
- public void setXmlAttribute(String name, XmlObject xmlObject) throws DeploymentException {
- String namespace = xmlObject.getDomNode().getNamespaceURI();
- XmlAttributeBuilder builder = (XmlAttributeBuilder) xmlAttributeBuilderMap.get(namespace);
- if (builder == null) {
- throw new DeploymentException("No attribute builder deployed for namespace: " + namespace);
- }
- GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name);
- if (attribute == null) {
- throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName());
- }
- String type = attribute.getType();
- Object value = builder.getValue(xmlObject, type, classLoader);
- gbean.setAttribute(name, value);
- }
+ if (xmlReferenceBuilders != null) {
+ ReferenceMap.Key key = new ReferenceMap.Key() {
- public void setXmlReference(String name, XmlObject xmlObject) throws DeploymentException {
- String namespace = xmlObject.getDomNode().getNamespaceURI();
- XmlReferenceBuilder builder = (XmlReferenceBuilder) xmlReferenceBuilderMap.get(namespace);
- if (builder == null) {
- throw new DeploymentException("No reference builder deployed for namespace: " + namespace);
- }
- ReferencePatterns references = builder.getReferences(xmlObject, context, moduleName, classLoader);
- if (references != null) {
- gbean.setReferencePatterns(name, references);
+ public Object getKey(Object object) {
+ return ((XmlReferenceBuilder) object).getNamespace();
+ }
+ };
+ refRefMap = new ReferenceMap(xmlReferenceBuilders, new HashMap(), key);
}
+ EnvironmentBuilder environmentBuilder = new EnvironmentBuilder();
+ attrRefMap.put(environmentBuilder.getNamespace(), environmentBuilder);
}
- public void setReference(String name, ReferenceType pattern, AbstractName parentName) throws DeploymentException {
- setReference(name, new PatternType[]{pattern}, parentName);
- }
-
- public void setReference(String name, PatternType[] patterns, AbstractName parentName) throws DeploymentException {
- Set patternNames = new HashSet(patterns.length);
- for (int i = 0; i < patterns.length; i++) {
- patternNames.add(buildAbstractNameQuery(name, patterns[i]));
+ public void build(XmlObject container, DeploymentContext applicationContext, DeploymentContext moduleContext) throws DeploymentException {
+ XmlObject[] items = container.selectChildren(GBEAN_QNAME_SET);
+ GbeanType[] gbeans = new GbeanType[items.length];
+ for (int i = 0; i < items.length; i++) {
+ XmlObject any = items[i];
+ gbeans[i] = (GbeanType) any.copy().changeType(GbeanType.type);
+ }
+ for (int i1 = 0; i1 < gbeans.length; i1++) {
+ addGBeanData(gbeans[i1], moduleContext.getModuleName(), moduleContext.getClassLoader(), moduleContext);
}
- gbean.setReferencePatterns(name, patternNames);
}
- public void addDependency(PatternType patternType) throws DeploymentException {
- AbstractNameQuery refInfo = buildAbstractNameQuery(patternType, null);
- gbean.addDependency(refInfo);
+ public String getNamespace() {
+ XmlBeansUtil.registerSubstitutionGroupElements(SERVICE_QNAME, QNameSet.singleton(GBEAN_QNAME));
+ return GBEAN_QNAME.getLocalPart();
}
- private AbstractNameQuery buildAbstractNameQuery(String refName, PatternType pattern) throws DeploymentException {
-// if (refName == null) {
-// throw new DeploymentException("No type specified in dependency pattern " + pattern + " for gbean " + gbean.getName());
-// }
- assert refName != null;
- GReferenceInfo referenceInfo = null;
- Set referenceInfos = gbean.getGBeanInfo().getReferences();
- for (Iterator iterator = referenceInfos.iterator(); iterator.hasNext();) {
- GReferenceInfo testReferenceInfo = (GReferenceInfo) iterator.next();
- String testRefName = testReferenceInfo.getName();
- if (testRefName.equals(refName)) {
- referenceInfo = testReferenceInfo;
+ private AbstractName addGBeanData(GbeanType gbean, AbstractName moduleName, ClassLoader cl, DeploymentContext context) throws DeploymentException {
+ GBeanInfo gBeanInfo = GBeanInfo.getGBeanInfo(gbean.getClass1(), cl);
+ String namePart = gbean.getName();
+ String j2eeType = gBeanInfo.getJ2eeType();
+ AbstractName abstractName = context.getNaming().createChildName(moduleName, namePart, j2eeType);
+ SingleGBeanBuilder builder = new SingleGBeanBuilder(abstractName, gBeanInfo, cl, context, moduleName, attrRefMap , refRefMap);
+
+ // set up attributes
+ AttributeType[] attributeArray = gbean.getAttributeArray();
+ if (attributeArray != null) {
+ for (int j = 0; j < attributeArray.length; j++) {
+ builder.setAttribute(attributeArray[j].getName().trim(), attributeArray[j].getType(), attributeArray[j].getStringValue());
+ }
+ }
+
+ XmlAttributeType[] xmlAttributeArray = gbean.getXmlAttributeArray();
+ if (xmlAttributeArray != null) {
+ for (int i = 0; i < xmlAttributeArray.length; i++) {
+ XmlAttributeType xmlAttributeType = xmlAttributeArray[i];
+ String name = xmlAttributeType.getName().trim();
+ XmlObject[] anys = xmlAttributeType.selectChildren(XmlAttributeType.type.qnameSetForWildcardElements());
+ if (anys.length != 1) {
+ throw new DeploymentException("Unexpected count of xs:any elements in xml-attribute " + anys.length + " qnameset: " + XmlAttributeType.type.qnameSetForWildcardElements());
+ }
+ builder.setXmlAttribute(name, anys[0]);
}
}
- if (referenceInfo == null) {
- throw new DeploymentException("No reference named " + refName + " in gbean " + gbean.getAbstractName());
+
+ // set up all single pattern references
+ ReferenceType[] referenceArray = gbean.getReferenceArray();
+ if (referenceArray != null) {
+ for (int j = 0; j < referenceArray.length; j++) {
+ builder.setReference(referenceArray[j].getName2(), referenceArray[j], moduleName);
+ }
}
- return buildAbstractNameQuery(pattern, referenceInfo);
- }
+ // set up app multi-patterned references
+ ReferencesType[] referencesArray = gbean.getReferencesArray();
+ if (referencesArray != null) {
+ for (int j = 0; j < referencesArray.length; j++) {
+ builder.setReference(referencesArray[j].getName(), referencesArray[j].getPatternArray(), moduleName);
+ }
+ }
- public static AbstractNameQuery buildAbstractNameQuery(PatternType pattern, GReferenceInfo referenceInfo) {
- String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
- String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
- String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null;
- String module = pattern.isSetModule() ? pattern.getModule().trim() : null;
- String type = pattern.isSetType() ? pattern.getType().trim() : null;
- String name = pattern.isSetName() ? pattern.getName().trim() : null;
-
- Artifact artifact = artifactid != null? new Artifact(groupId, artifactid, version, "car"): null;
- //get the type from the gbean info if not supplied explicitly
- if (type == null && referenceInfo != null) {
- type = referenceInfo.getNameTypeName();
- }
- Map nameMap = new HashMap();
- if (name != null) {
- nameMap.put("name", name);
+ XmlAttributeType[] xmlReferenceArray = gbean.getXmlReferenceArray();
+ if (xmlReferenceArray != null) {
+ for (int i = 0; i < xmlReferenceArray.length; i++) {
+ XmlAttributeType xmlAttributeType = xmlReferenceArray[i];
+ String name = xmlAttributeType.getName().trim();
+ XmlObject[] anys = xmlAttributeType.selectChildren(XmlAttributeType.type.qnameSetForWildcardElements());
+ if (anys.length != 1) {
+ throw new DeploymentException("Unexpected count of xs:any elements in xml-attribute " + anys.length + " qnameset: " + XmlAttributeType.type.qnameSetForWildcardElements());
+ }
+ builder.setXmlReference(name, anys[0]);
+ }
}
- if (type != null) {
- nameMap.put("j2eeType", type);
+
+ PatternType[] dependencyArray = gbean.getDependencyArray();
+ if (dependencyArray != null) {
+ for (int i = 0; i < dependencyArray.length; i++) {
+ PatternType patternType = dependencyArray[i];
+ builder.addDependency(patternType);
+ }
}
- if (module != null) {
- nameMap.put("J2EEModule", module);
+
+ GBeanData gbeanData = builder.getGBeanData();
+ try {
+ context.addGBean(gbeanData);
+ } catch (GBeanAlreadyExistsException e) {
+ throw new DeploymentException(e);
}
- Set interfaceTypes = referenceInfo == null? null: Collections.singleton(referenceInfo.getReferenceType());
- return new AbstractNameQuery(artifact, nameMap, interfaceTypes);
+ return abstractName;
+ }
+
+ public static final GBeanInfo GBEAN_INFO;
+
+ static {
+ PropertyEditorManager.registerEditor(Environment.class, EnvironmentBuilder.class);
+
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(GBeanBuilder.class, "ModuleBuilder");
+
+ infoBuilder.addInterface(NamespaceDrivenBuilder.class);
+
+ infoBuilder.addReference("XmlAttributeBuilders", XmlAttributeBuilder.class, "XmlAttributeBuilder");
+ infoBuilder.addReference("XmlReferenceBuilders", XmlReferenceBuilder.class, "XmlReferenceBuilder");
+
+ infoBuilder.setConstructor(new String[]{"XmlAttributeBuilders", "XmlReferenceBuilders"});
+
+ GBEAN_INFO = infoBuilder.getBeanInfo();
}
- public GBeanData getGBeanData() {
- return gbean;
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
}
}
Modified: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Fri Aug 18 00:44:04 2006
@@ -17,17 +17,15 @@
package org.apache.geronimo.deployment.service;
+import java.beans.PropertyEditorManager;
import java.io.File;
-import java.io.IOException;
import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.jar.JarFile;
-import java.beans.PropertyEditorManager;
+import java.io.IOException;
import java.net.URI;
import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.jar.JarFile;
import javax.xml.namespace.QName;
@@ -35,37 +33,29 @@
import org.apache.geronimo.deployment.ConfigurationBuilder;
import org.apache.geronimo.deployment.DeploymentContext;
import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
import org.apache.geronimo.deployment.util.DeploymentUtil;
-import org.apache.geronimo.deployment.xbeans.AttributeType;
+import org.apache.geronimo.deployment.xbeans.ArtifactType;
+import org.apache.geronimo.deployment.xbeans.EnvironmentType;
import org.apache.geronimo.deployment.xbeans.ModuleDocument;
import org.apache.geronimo.deployment.xbeans.ModuleType;
-import org.apache.geronimo.deployment.xbeans.EnvironmentType;
-import org.apache.geronimo.deployment.xbeans.GbeanType;
-import org.apache.geronimo.deployment.xbeans.PatternType;
-import org.apache.geronimo.deployment.xbeans.ReferenceType;
-import org.apache.geronimo.deployment.xbeans.ReferencesType;
-import org.apache.geronimo.deployment.xbeans.XmlAttributeType;
-import org.apache.geronimo.deployment.xbeans.ArtifactType;
import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.ReferenceMap;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.Naming;
import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.Repository;
-import org.apache.geronimo.kernel.repository.ArtifactResolver;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
@@ -77,54 +67,33 @@
private final Environment defaultEnvironment;
private final Collection repositories;
- //TODO this being static is a really good argument that all other builders should have a reference to this gbean, not use static methods on it.
- private static final Map xmlAttributeBuilderMap = new HashMap();
- private static final Map xmlReferenceBuilderMap = new HashMap();
- private Map attrRefMap;
- private Map refRefMap;
- private static final QName SERVICE_QNAME = ModuleDocument.type.getDocumentElementName();
+ private static final QName MODULE_QNAME = ModuleDocument.type.getDocumentElementName();
+ public static final String SERVICE_MODULE = "ServiceModule";
private final Naming naming;
private final ConfigurationManager configurationManager;
+ private final NamespaceDrivenBuilderCollection serviceBuilders;
public ServiceConfigBuilder(Environment defaultEnvironment, Collection repositories, Naming naming) {
- this(defaultEnvironment, repositories, null, null, naming, null);
+ this(defaultEnvironment, repositories, Collections.EMPTY_LIST, naming, null);
}
- public ServiceConfigBuilder(Environment defaultEnvironment, Collection repositories, Collection xmlAttributeBuilders, Collection xmlReferenceBuilders, Kernel kernel) {
- this(defaultEnvironment, repositories, xmlAttributeBuilders, xmlReferenceBuilders, kernel.getNaming(), ConfigurationUtil.getConfigurationManager(kernel));
+ public ServiceConfigBuilder(Environment defaultEnvironment, Collection repositories, Collection serviceBuilders, Kernel kernel) {
+ this(defaultEnvironment, repositories, serviceBuilders, kernel.getNaming(), ConfigurationUtil.getConfigurationManager(kernel));
}
- public ServiceConfigBuilder(Environment defaultEnvironment, Collection repositories, Collection xmlAttributeBuilders, Collection xmlReferenceBuilders, Naming naming) {
- this(defaultEnvironment, repositories, xmlAttributeBuilders, xmlReferenceBuilders, naming, null);
+ public ServiceConfigBuilder(Environment defaultEnvironment, Collection repositories, Collection serviceBuilders, Naming naming) {
+ this(defaultEnvironment, repositories, serviceBuilders, naming, null);
}
- private ServiceConfigBuilder(Environment defaultEnvironment, Collection repositories, Collection xmlAttributeBuilders, Collection xmlReferenceBuilders, Naming naming, ConfigurationManager configurationManager) {
+
+ private ServiceConfigBuilder(Environment defaultEnvironment, Collection repositories, Collection serviceBuilders, Naming naming, ConfigurationManager configurationManager) {
this.naming = naming;
this.configurationManager = configurationManager;
EnvironmentBuilder environmentBuilder = new EnvironmentBuilder();
- xmlAttributeBuilderMap.put(environmentBuilder.getNamespace(), environmentBuilder);
- //cf registering EnvironmentBuilder as a property editor in the static gbeaninfo block.
this.defaultEnvironment = defaultEnvironment;
this.repositories = repositories;
- if (xmlAttributeBuilders != null) {
- ReferenceMap.Key key = new ReferenceMap.Key() {
-
- public Object getKey(Object object) {
- return ((XmlAttributeBuilder) object).getNamespace();
- }
- };
- attrRefMap = new ReferenceMap(xmlAttributeBuilders, xmlAttributeBuilderMap, key);
- }
- if (xmlReferenceBuilders != null) {
- ReferenceMap.Key key = new ReferenceMap.Key() {
-
- public Object getKey(Object object) {
- return ((XmlReferenceBuilder) object).getNamespace();
- }
- };
- refRefMap = new ReferenceMap(xmlReferenceBuilders, xmlReferenceBuilderMap, key);
- }
+ this.serviceBuilders = new NamespaceDrivenBuilderCollection(serviceBuilders);
}
public Object getDeploymentPlan(File planFile, JarFile jarFile, ModuleIDBuilder idBuilder) throws DeploymentException {
@@ -135,11 +104,11 @@
try {
XmlObject xmlObject;
if (planFile != null) {
- xmlObject = XmlBeansUtil.parse(planFile.toURL());
+ xmlObject = XmlBeansUtil.parse(planFile.toURL(), getClass().getClassLoader());
} else {
URL path = DeploymentUtil.createJarURL(jarFile, "META-INF/geronimo-service.xml");
try {
- xmlObject = XmlBeansUtil.parse(path);
+ xmlObject = XmlBeansUtil.parse(path, getClass().getClassLoader());
} catch (FileNotFoundException e) {
// It has a JAR but no plan, and nothing at META-INF/geronimo-service.xml,
// therefore it's not a service deployment
@@ -153,7 +122,7 @@
XmlCursor cursor = xmlObject.newCursor();
try {
cursor.toFirstChild();
- if (!SERVICE_QNAME.equals(cursor.getName())) {
+ if (!MODULE_QNAME.equals(cursor.getName())) {
return null;
}
} finally {
@@ -165,10 +134,7 @@
} else {
moduleDoc = (ModuleDocument) xmlObject.changeType(ModuleDocument.type);
}
- Collection errors = new ArrayList();
- if (!moduleDoc.validate(XmlBeansUtil.createXmlOptions(errors))) {
- throw new DeploymentException("Invalid deployment descriptor: " + errors + "\nDescriptor: " + moduleDoc.toString());
- }
+ XmlBeansUtil.validateDD(moduleDoc);
// If there's no artifact ID and we won't be able to figure one out later, use the plan file name. Bit of a hack.
if(jarFile == null && (moduleDoc.getModule().getEnvironment() == null ||
moduleDoc.getModule().getEnvironment().getModuleId() == null ||
@@ -235,9 +201,11 @@
configurationManager = new SimpleConfigurationManager(configurationStores, artifactResolver, repositories);
}
+ AbstractName moduleName = naming.createRootName(configId, configId.toString(), SERVICE_MODULE);
context = new DeploymentContext(outfile,
inPlaceDeployment && null != jar ? DeploymentUtil.toFile(jar) : null,
environment,
+ moduleName,
ConfigurationModuleType.SERVICE,
naming,
configurationManager,
@@ -247,13 +215,7 @@
context.addIncludeAsPackedJar(URI.create(file.getName()), jar);
}
- ClassLoader cl = context.getClassLoader();
-
-
- AbstractName moduleName = naming.createRootName(configId, configId.toString(), NameFactory.SERVICE_MODULE);
- GbeanType[] gbeans = moduleType.getGbeanArray();
-
- addGBeans(gbeans, cl, moduleName, context);
+ serviceBuilders.build(moduleType, context, context);
return context;
} catch (DeploymentException de) {
cleanupAfterFailedBuild(context, outfile);
@@ -285,107 +247,27 @@
}
}
- public static void addGBeans(GbeanType[] gbeans, ClassLoader cl, AbstractName moduleName, DeploymentContext context) throws DeploymentException {
- for (int i = 0; i < gbeans.length; i++) {
- addGBeanData(gbeans[i], moduleName, cl, context);
- }
- }
-
- public static AbstractName addGBeanData(GbeanType gbean, AbstractName moduleName, ClassLoader cl, DeploymentContext context) throws DeploymentException {
- GBeanInfo gBeanInfo = GBeanInfo.getGBeanInfo(gbean.getClass1(), cl);
- String namePart = gbean.getName();
- String j2eeType = gBeanInfo.getJ2eeType();
- AbstractName abstractName = context.getNaming().createChildName(moduleName, namePart, j2eeType);
- GBeanBuilder builder = new GBeanBuilder(abstractName, gBeanInfo, cl, context, moduleName, xmlAttributeBuilderMap, xmlReferenceBuilderMap);
-
- // set up attributes
- AttributeType[] attributeArray = gbean.getAttributeArray();
- if (attributeArray != null) {
- for (int j = 0; j < attributeArray.length; j++) {
- builder.setAttribute(attributeArray[j].getName().trim(), attributeArray[j].getType(), attributeArray[j].getStringValue());
- }
- }
-
- XmlAttributeType[] xmlAttributeArray = gbean.getXmlAttributeArray();
- if (xmlAttributeArray != null) {
- for (int i = 0; i < xmlAttributeArray.length; i++) {
- XmlAttributeType xmlAttributeType = xmlAttributeArray[i];
- String name = xmlAttributeType.getName().trim();
- XmlObject[] anys = xmlAttributeType.selectChildren(XmlAttributeType.type.qnameSetForWildcardElements());
- if (anys.length != 1) {
- throw new DeploymentException("Unexpected count of xs:any elements in xml-attribute " + anys.length + " qnameset: " + XmlAttributeType.type.qnameSetForWildcardElements());
- }
- builder.setXmlAttribute(name, anys[0]);
- }
- }
-
- // set up all single pattern references
- ReferenceType[] referenceArray = gbean.getReferenceArray();
- if (referenceArray != null) {
- for (int j = 0; j < referenceArray.length; j++) {
- builder.setReference(referenceArray[j].getName2(), referenceArray[j], moduleName);
- }
- }
-
- // set up app multi-patterned references
- ReferencesType[] referencesArray = gbean.getReferencesArray();
- if (referencesArray != null) {
- for (int j = 0; j < referencesArray.length; j++) {
- builder.setReference(referencesArray[j].getName(), referencesArray[j].getPatternArray(), moduleName);
- }
- }
-
- XmlAttributeType[] xmlReferenceArray = gbean.getXmlReferenceArray();
- if (xmlReferenceArray != null) {
- for (int i = 0; i < xmlReferenceArray.length; i++) {
- XmlAttributeType xmlAttributeType = xmlReferenceArray[i];
- String name = xmlAttributeType.getName().trim();
- XmlObject[] anys = xmlAttributeType.selectChildren(XmlAttributeType.type.qnameSetForWildcardElements());
- if (anys.length != 1) {
- throw new DeploymentException("Unexpected count of xs:any elements in xml-attribute " + anys.length + " qnameset: " + XmlAttributeType.type.qnameSetForWildcardElements());
- }
- builder.setXmlReference(name, anys[0]);
- }
- }
-
- PatternType[] dependencyArray = gbean.getDependencyArray();
- if (dependencyArray != null) {
- for (int i = 0; i < dependencyArray.length; i++) {
- PatternType patternType = dependencyArray[i];
- builder.addDependency(patternType);
- }
- }
-
- GBeanData gbeanData = builder.getGBeanData();
- try {
- context.addGBean(gbeanData);
- } catch (GBeanAlreadyExistsException e) {
- throw new DeploymentException(e);
- }
- return abstractName;
- }
-
public static final GBeanInfo GBEAN_INFO;
static {
PropertyEditorManager.registerEditor(Environment.class, EnvironmentBuilder.class);
- GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ServiceConfigBuilder.class, NameFactory.CONFIG_BUILDER);
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(ServiceConfigBuilder.class, CONFIG_BUILDER);
- infoFactory.addInterface(ConfigurationBuilder.class);
+ infoBuilder.addInterface(ConfigurationBuilder.class);
- infoFactory.addAttribute("defaultEnvironment", Environment.class, true);
- infoFactory.addReference("Repository", Repository.class, "Repository");
- infoFactory.addReference("XmlAttributeBuilders", XmlAttributeBuilder.class, "XmlAttributeBuilder");
- infoFactory.addReference("XmlReferenceBuilders", XmlReferenceBuilder.class, "XmlReferenceBuilder");
- infoFactory.addAttribute("kernel", Kernel.class, false, false);
+ infoBuilder.addAttribute("defaultEnvironment", Environment.class, true);
+ infoBuilder.addReference("Repository", Repository.class, "Repository");
+ infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, "ModuleBuilder");
+ infoBuilder.addAttribute("kernel", Kernel.class, false, false);
- infoFactory.setConstructor(new String[]{"defaultEnvironment", "Repository", "XmlAttributeBuilders", "XmlReferenceBuilders", "kernel"});
+ infoBuilder.setConstructor(new String[]{"defaultEnvironment", "Repository", "ServiceBuilders", "kernel"});
- GBEAN_INFO = infoFactory.getBeanInfo();
+ GBEAN_INFO = infoBuilder.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
+
}
Added: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/SingleGBeanBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/SingleGBeanBuilder.java?rev=432510&view=auto
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/SingleGBeanBuilder.java (added)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/SingleGBeanBuilder.java Fri Aug 18 00:44:04 2006
@@ -0,0 +1,190 @@
+/**
+ *
+ * Copyright 2003-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.deployment.service;
+
+import java.beans.PropertyEditor;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.common.propertyeditor.PropertyEditors;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.xbeans.PatternType;
+import org.apache.geronimo.deployment.xbeans.ReferenceType;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SingleGBeanBuilder {
+ private final GBeanData gbean;
+ private final ClassLoader classLoader;
+ private final DeploymentContext context;
+ private final AbstractName moduleName;
+ private final Map xmlAttributeBuilderMap;
+ private final Map xmlReferenceBuilderMap;
+
+ SingleGBeanBuilder(AbstractName abstractName, GBeanInfo gBeanInfo, ClassLoader classLoader, DeploymentContext context, AbstractName moduleName, Map xmlAttributeBuilderMap, Map xmlReferenceBuilderMap) {
+
+ this.classLoader = classLoader;
+ this.context = context;
+ this.moduleName = moduleName;
+ this.gbean = new GBeanData(abstractName, gBeanInfo);
+ this.xmlAttributeBuilderMap = xmlAttributeBuilderMap;
+ this.xmlReferenceBuilderMap = xmlReferenceBuilderMap;
+ }
+
+ public void setAttribute(String name, String type, String text) throws DeploymentException {
+ if (text != null) {
+ text = text.trim(); // avoid formatting errors due to extra whitespace in XML configuration file
+ }
+ try {
+ // @todo we should not need all of common just for this
+ if (type == null) {
+ GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name);
+ if (attribute == null) {
+ throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName());
+ }
+ type = attribute.getType();
+ }
+
+ PropertyEditor editor = PropertyEditors.findEditor(type, classLoader);
+ if (editor == null) {
+ throw new DeploymentException("Unable to find PropertyEditor for " + type);
+ }
+ editor.setAsText(text);
+ Object value = editor.getValue();
+ gbean.setAttribute(name, value);
+ } catch (DeploymentException e) {
+ throw e;
+ } catch (ClassNotFoundException e) {
+ throw new DeploymentException("Unable to find PropertyEditor for " + type, e);
+ } catch (Exception e) {
+ throw new DeploymentException("Unable to set attribute " + name + " to " + text, e);
+ }
+ }
+
+ public void setXmlAttribute(String name, XmlObject xmlObject) throws DeploymentException {
+ String namespace = xmlObject.getDomNode().getNamespaceURI();
+ XmlAttributeBuilder builder = (XmlAttributeBuilder) xmlAttributeBuilderMap.get(namespace);
+ if (builder == null) {
+ throw new DeploymentException("No attribute builder deployed for namespace: " + namespace);
+ }
+ GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name);
+ if (attribute == null) {
+ throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName());
+ }
+ String type = attribute.getType();
+ Object value = builder.getValue(xmlObject, type, classLoader);
+ gbean.setAttribute(name, value);
+ }
+
+ public void setXmlReference(String name, XmlObject xmlObject) throws DeploymentException {
+ String namespace = xmlObject.getDomNode().getNamespaceURI();
+ XmlReferenceBuilder builder = (XmlReferenceBuilder) xmlReferenceBuilderMap.get(namespace);
+ if (builder == null) {
+ throw new DeploymentException("No reference builder deployed for namespace: " + namespace);
+ }
+ ReferencePatterns references = builder.getReferences(xmlObject, context, moduleName, classLoader);
+ if (references != null) {
+ gbean.setReferencePatterns(name, references);
+ }
+ }
+
+ public void setReference(String name, ReferenceType pattern, AbstractName parentName) throws DeploymentException {
+ setReference(name, new PatternType[]{pattern}, parentName);
+ }
+
+ public void setReference(String name, PatternType[] patterns, AbstractName parentName) throws DeploymentException {
+ Set patternNames = new HashSet(patterns.length);
+ for (int i = 0; i < patterns.length; i++) {
+ patternNames.add(buildAbstractNameQuery(name, patterns[i]));
+ }
+ gbean.setReferencePatterns(name, patternNames);
+ }
+
+ public void addDependency(PatternType patternType) throws DeploymentException {
+ AbstractNameQuery refInfo = buildAbstractNameQuery(patternType, null);
+ gbean.addDependency(refInfo);
+ }
+
+ private AbstractNameQuery buildAbstractNameQuery(String refName, PatternType pattern) throws DeploymentException {
+// if (refName == null) {
+// throw new DeploymentException("No type specified in dependency pattern " + pattern + " for gbean " + gbean.getName());
+// }
+ assert refName != null;
+ GReferenceInfo referenceInfo = null;
+ Set referenceInfos = gbean.getGBeanInfo().getReferences();
+ for (Iterator iterator = referenceInfos.iterator(); iterator.hasNext();) {
+ GReferenceInfo testReferenceInfo = (GReferenceInfo) iterator.next();
+ String testRefName = testReferenceInfo.getName();
+ if (testRefName.equals(refName)) {
+ referenceInfo = testReferenceInfo;
+ }
+ }
+ if (referenceInfo == null) {
+ throw new DeploymentException("No reference named " + refName + " in gbean " + gbean.getAbstractName());
+ }
+
+ return buildAbstractNameQuery(pattern, referenceInfo);
+ }
+
+ public static AbstractNameQuery buildAbstractNameQuery(PatternType pattern, GReferenceInfo referenceInfo) {
+ String groupId = pattern.isSetGroupId() ? pattern.getGroupId().trim() : null;
+ String artifactid = pattern.isSetArtifactId() ? pattern.getArtifactId().trim() : null;
+ String version = pattern.isSetVersion() ? pattern.getVersion().trim() : null;
+ String module = pattern.isSetModule() ? pattern.getModule().trim() : null;
+ String type = pattern.isSetType() ? pattern.getType().trim() : null;
+ String name = pattern.isSetName() ? pattern.getName().trim() : null;
+
+ Artifact artifact = artifactid != null? new Artifact(groupId, artifactid, version, "car"): null;
+ //get the type from the gbean info if not supplied explicitly
+ if (type == null && referenceInfo != null) {
+ type = referenceInfo.getNameTypeName();
+ }
+ Map nameMap = new HashMap();
+ if (name != null) {
+ nameMap.put("name", name);
+ }
+ if (type != null) {
+ nameMap.put("j2eeType", type);
+ }
+ if (module != null) {
+ nameMap.put("J2EEModule", module);
+ }
+ Set interfaceTypes = referenceInfo == null? null: Collections.singleton(referenceInfo.getReferenceType());
+ return new AbstractNameQuery(artifact, nameMap, interfaceTypes);
+ }
+
+ public GBeanData getGBeanData() {
+ return gbean;
+ }
+
+}
Propchange: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/SingleGBeanBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/SingleGBeanBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/SingleGBeanBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java (original)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java Fri Aug 18 00:44:04 2006
@@ -20,40 +20,63 @@
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import javax.xml.namespace.QName;
+
import org.w3c.dom.Element;
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.SchemaTypeLoader;
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlValidationError;
/**
* @version $Rev$ $Date$
*/
public class XmlBeansUtil {
private static final Map NAMESPACE_UPDATES = new HashMap();
+ //TODO thread safe? conncurrentReaderMap?
+ private static final Map substitutionGroups = new HashMap();
+ private static final XmlObject[] NO_ELEMENTS = new XmlObject[]{};
static {
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/application-client", "http://geronimo.apache.org/xml/ns/j2ee/application-client-1.1");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/application", "http://geronimo.apache.org/xml/ns/j2ee/application-1.1");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/deployment", "http://geronimo.apache.org/xml/ns/deployment-1.1");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/connector", "http://geronimo.apache.org/xml/ns/j2ee/connector-1.1");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/application-client", "http://geronimo.apache.org/xml/ns/j2ee/application-client-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/application-client-1.1", "http://geronimo.apache.org/xml/ns/j2ee/application-client-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/application", "http://geronimo.apache.org/xml/ns/j2ee/application-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/application-1.1", "http://geronimo.apache.org/xml/ns/j2ee/application-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/deployment", "http://geronimo.apache.org/xml/ns/deployment-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/deployment-1.1", "http://geronimo.apache.org/xml/ns/deployment-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/connector", "http://geronimo.apache.org/xml/ns/j2ee/connector-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/connector-1.1", "http://geronimo.apache.org/xml/ns/j2ee/connector-1.2");
NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/deployment/javabean", "http://geronimo.apache.org/xml/ns/deployment/javabean-1.0");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/loginconfig", "http://geronimo.apache.org/xml/ns/loginconfig-1.0");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/naming", "http://geronimo.apache.org/xml/ns/naming-1.1");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/security", "http://geronimo.apache.org/xml/ns/security-1.1");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web", "http://geronimo.apache.org/xml/ns/j2ee/web-1.1");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web/jetty", "http://geronimo.apache.org/xml/ns/j2ee/web/jetty-1.1");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/loginconfig", "http://geronimo.apache.org/xml/ns/loginconfig-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/loginconfig-1.1", "http://geronimo.apache.org/xml/ns/loginconfig-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/naming", "http://geronimo.apache.org/xml/ns/naming-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/naming-1.1", "http://geronimo.apache.org/xml/ns/naming-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/security", "http://geronimo.apache.org/xml/ns/security-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/security-1.1", "http://geronimo.apache.org/xml/ns/security-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web", "http://geronimo.apache.org/xml/ns/j2ee/web-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/web-1.1", "http://geronimo.apache.org/xml/ns/j2ee/web-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web/jetty", "http://geronimo.apache.org/xml/ns/j2ee/web/jetty-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/web/jetty-1.1", "http://geronimo.apache.org/xml/ns/j2ee/web/jetty-1.2");
NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web/jetty/config", "http://geronimo.apache.org/xml/ns/j2ee/web/jetty/config-1.0");
- NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web/tomcat", "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.1");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web/tomcat", "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2");
+ NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.1", "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2");
NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web/tomcat/config", "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat/config-1.0");
- NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/openejb-jar", "http://www.openejb.org/xml/ns/openejb-jar-2.1");
+ NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/openejb-jar", "http://www.openejb.org/xml/ns/openejb-jar-2.2");
+ NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/openejb-jar-2.1", "http://www.openejb.org/xml/ns/openejb-jar-2.2");
NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/pkgen", "http://www.openejb.org/xml/ns/pkgen-2.0");
NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/corba-css-config_1_0", "http://www.openejb.org/xml/ns/corba-css-config-2.0");
- NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/corba-tss-config_1_0", "http://www.openejb.org/xml/ns/corba-tss-config-2.0");
+ NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/corba-tss-config_1_0", "http://www.openejb.org/xml/ns/corba-tss-config-2.1");
+ NAMESPACE_UPDATES.put("http://www.openejb.org/xml/ns/corba-tss-config-2.0", "http://www.openejb.org/xml/ns/corba-tss-config-2.1");
}
private XmlBeansUtil() {
@@ -69,9 +92,17 @@
return parsed;
}
- public static XmlObject parse(URL url) throws IOException, XmlException {
+ public static XmlObject parse(URL url, ClassLoader cl) throws IOException, XmlException {
ArrayList errors = new ArrayList();
- XmlObject parsed = XmlObject.Factory.parse(url, createXmlOptions(errors));
+ Thread currentThread = Thread.currentThread();
+ ClassLoader oldcl = currentThread.getContextClassLoader();
+ currentThread.setContextClassLoader(cl);
+ XmlObject parsed;
+ try {
+ parsed = XmlObject.Factory.parse(url, createXmlOptions(errors));
+ } finally {
+ currentThread.setContextClassLoader(oldcl);
+ }
if (errors.size() != 0) {
throw new XmlException(errors.toArray().toString());
}
@@ -111,5 +142,68 @@
options.setErrorListener(errors);
options.setLoadSubstituteNamespaces(NAMESPACE_UPDATES);
return options;
+ }
+
+ public static void registerSubstitutionGroupElements(QName substitutionGroup, QNameSet substitutions) {
+ QNameSet oldSubstitutions = (QNameSet) substitutionGroups.get(substitutionGroup);
+ if (oldSubstitutions != null) {
+ substitutions = oldSubstitutions.union(substitutions);
+ }
+ substitutionGroups.put(substitutionGroup, substitutions);
+ }
+
+ public static void unregisterSubstitutionGroupElements(QName substitutionGroup, QNameSet substitutions) {
+ QNameSet oldSubstitutions = (QNameSet) substitutionGroups.get(substitutionGroup);
+ QNameSet difference = oldSubstitutions.intersect(substitutions.inverse());
+ substitutionGroups.put(substitutionGroup, difference);
+ }
+
+ public static QNameSet getQNameSetForSubstitutionGroup(QName substitutionGroup) {
+ return (QNameSet) substitutionGroups.get(substitutionGroup);
+ }
+
+ public static XmlObject[] selectSubstitutionGroupElements(QName substitutionGroup, XmlObject container) {
+ QNameSet substitutionGroupMembers = getQNameSetForSubstitutionGroup(substitutionGroup);
+ if (substitutionGroupMembers == null) {
+ return NO_ELEMENTS;
+ }
+ return container.selectChildren(substitutionGroupMembers);
+ }
+
+ public static void validateDD(XmlObject dd) throws XmlException {
+ XmlOptions xmlOptions = new XmlOptions();
+ xmlOptions.setLoadLineNumbers();
+ Collection errors = new ArrayList();
+ xmlOptions.setErrorListener(errors);
+ try {
+ if (!dd.validate(xmlOptions)) {
+
+ for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
+ Object o = iterator.next();
+ if (o instanceof XmlValidationError) {
+ XmlValidationError validationError = (XmlValidationError) o;
+ List expected = validationError.getExpectedQNames();
+ QName actual = validationError.getOffendingQName();
+ if (expected != null) {
+ for (Iterator iterator1 = expected.iterator(); iterator1.hasNext();) {
+ QName expectedQName = (QName) iterator1.next();
+ QNameSet substitutions = getQNameSetForSubstitutionGroup(expectedQName);
+ if (substitutions != null && substitutions.contains(actual)) {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!errors.isEmpty()) {
+ throw new XmlException("Invalid deployment descriptor: " + errors + "\nDescriptor: " + dd.toString(), null, errors);
+ }
+ }
+ } catch (NullPointerException e) {
+ //ignore
+ }
+// System.out.println("descriptor: " + dd.toString());
}
}
Copied: geronimo/trunk/modules/service-builder/src/schema/geronimo-module-1.2.xsd (from r432067, geronimo/trunk/modules/service-builder/src/schema/geronimo-module-1.1.xsd)
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/schema/geronimo-module-1.2.xsd?p2=geronimo/trunk/modules/service-builder/src/schema/geronimo-module-1.2.xsd&p1=geronimo/trunk/modules/service-builder/src/schema/geronimo-module-1.1.xsd&r1=432067&r2=432510&rev=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/schema/geronimo-module-1.1.xsd (original)
+++ geronimo/trunk/modules/service-builder/src/schema/geronimo-module-1.2.xsd Fri Aug 18 00:44:04 2006
@@ -17,8 +17,8 @@
-->
<xs:schema
- targetNamespace="http://geronimo.apache.org/xml/ns/deployment-1.1"
- xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
+ targetNamespace="http://geronimo.apache.org/xml/ns/deployment-1.2"
+ xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
@@ -28,7 +28,7 @@
Schema for Geronimo Services deployment plans.
Instance documents should begin with the element:
- >gbeans xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1"<
+ >gbeans xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2"<
</xs:documentation>
</xs:annotation>
@@ -37,7 +37,7 @@
<xs:complexType name="moduleType">
<xs:sequence>
<xs:element ref="sys:environment"/>
- <xs:element ref="sys:gbean" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element ref="sys:service" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
@@ -154,6 +154,8 @@
</xs:sequence>
</xs:complexType>
+ <xs:element name="dependencies" type="sys:dependenciesType"/>
+
<xs:complexType name="dependenciesType">
<xs:sequence>
<xs:element name="dependency" type="sys:dependencyType" minOccurs="0" maxOccurs="unbounded">
@@ -171,7 +173,14 @@
<xs:complexType name="emptyType"/>
- <xs:element name="gbean" type="sys:gbeanType">
+ <xs:element name="service" type="sys:abstract-serviceType"/>
+
+ <xs:complexType name="abstract-serviceType" abstract="true">
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="gbean" type="sys:gbeanType" substitutionGroup="sys:service">
<xs:annotation>
<xs:documentation>
Adds a new custom component to the server. The component will be deployed
@@ -270,6 +279,10 @@
</xs:simpleType>
<xs:complexType name="gbeanType">
+ <xs:complexContent>
+ <xs:extension base="sys:abstract-serviceType">
+
+
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="attribute" type="sys:attributeType"/>
<xs:element name="xml-attribute" type="sys:xml-attributeType"/>
@@ -280,6 +293,8 @@
</xs:choice>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="class" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
</xs:complexType>
<xs:complexType name="attributeType">
@@ -329,12 +344,12 @@
</xs:complexContent>
</xs:complexType>
- <xs:element name="service" type="sys:serviceType"/>
+ <!--<xs:element name="service" type="sys:serviceType"/>-->
- <xs:complexType name="serviceType">
- <xs:sequence>
- <xs:element name="dependency" type="sys:artifactType" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
+ <!--<xs:complexType name="serviceType">-->
+ <!--<xs:sequence>-->
+ <!--<xs:element name="dependency" type="sys:artifactType" minOccurs="0" maxOccurs="unbounded"/>-->
+ <!--</xs:sequence>-->
+ <!--</xs:complexType>-->
</xs:schema>
Modified: geronimo/trunk/modules/service-builder/src/schema/xmlconfig.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/schema/xmlconfig.xml?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/schema/xmlconfig.xml (original)
+++ geronimo/trunk/modules/service-builder/src/schema/xmlconfig.xml Fri Aug 18 00:44:04 2006
@@ -5,7 +5,7 @@
<xb:package>org.apache.geronimo.deployment.xbeans</xb:package>
</xb:namespace>
-->
- <xb:namespace uri="http://geronimo.apache.org/xml/ns/deployment-1.1">
+ <xb:namespace uri="http://geronimo.apache.org/xml/ns/deployment-1.2">
<xb:package>org.apache.geronimo.deployment.xbeans</xb:package>
</xb:namespace>
Modified: geronimo/trunk/modules/service-builder/src/test-resources/services/plan1.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/test-resources/services/plan1.xml?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/test-resources/services/plan1.xml (original)
+++ geronimo/trunk/modules/service-builder/src/test-resources/services/plan1.xml Fri Aug 18 00:44:04 2006
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2004 The Apache Software Foundation
+ Copyright 2004-6 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
-->
-<module
- xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1"
- >
+<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
<environment>
<moduleId>
Modified: geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java (original)
+++ geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java Fri Aug 18 00:44:04 2006
@@ -16,40 +16,41 @@
*/
package org.apache.geronimo.deployment.service;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.jar.JarFile;
+
+import javax.management.ObjectName;
+
import junit.framework.TestCase;
import org.apache.geronimo.deployment.DeploymentContext;
import org.apache.geronimo.deployment.FooBarBean;
import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
import org.apache.geronimo.deployment.xbeans.ModuleDocument;
import org.apache.geronimo.deployment.xbeans.ModuleType;
-import org.apache.geronimo.deployment.xbeans.GbeanType;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.ReferenceCollection;
import org.apache.geronimo.gbean.ReferenceCollectionListener;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.Jsr77Naming;
+import org.apache.geronimo.kernel.Naming;
import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
-import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.ListableRepository;
import org.apache.geronimo.kernel.repository.ArtifactManager;
-import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
-import org.apache.geronimo.kernel.Jsr77Naming;
-import org.apache.geronimo.kernel.Naming;
-
-import javax.management.ObjectName;
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.LinkedHashSet;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Collections;
-import java.util.jar.JarFile;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.ListableRepository;
/**
* @version $Rev$ $Date$
@@ -74,7 +75,8 @@
//this is kind of cheating, we rely on the builder to iterate through existing members of the collection.
referenceCollection.add(javaBeanXmlAttributeBuilder);
Naming naming = new Jsr77Naming();
- new ServiceConfigBuilder(parentEnvironment, null, referenceCollection, null, naming);
+ NamespaceDrivenBuilder gbeanBuilder = new GBeanBuilder(referenceCollection, null);
+// ConfigurationBuilder serviceBuilder = new ServiceConfigBuilder(parentEnvironment, null, Collections.singleton(gbeanBuilder), naming);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
final URL plan1 = cl.getResource("services/plan1.xml");
ModuleDocument doc = ModuleDocument.Factory.parse(plan1);
@@ -91,11 +93,10 @@
ArtifactManager artifactManager = new DefaultArtifactManager();
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.singleton(mockRepository), null);
ConfigurationManager configurationManager = new SimpleConfigurationManager(Collections.EMPTY_SET, artifactResolver, Collections.EMPTY_SET);
- DeploymentContext context = new DeploymentContext(outFile, null, environment, ConfigurationModuleType.CAR, naming, configurationManager, Collections.singleton(mockRepository));
- AbstractName j2eeContext = naming.createRootName(environment.getConfigId(), environment.getConfigId().toString(), "Configuration");
+ AbstractName moduleName = naming.createRootName(environment.getConfigId(), "foo", "bar");
+ DeploymentContext context = new DeploymentContext(outFile, null, environment, moduleName, ConfigurationModuleType.CAR, naming, configurationManager, Collections.singleton(mockRepository));
- GbeanType[] gbeans = plan.getGbeanArray();
- ServiceConfigBuilder.addGBeans(gbeans, cl, j2eeContext, context);
+ gbeanBuilder.build(plan, context, context);
Set gbeanNames = context.getGBeanNames();
assertEquals(1, gbeanNames.size());
AbstractName beanName = (AbstractName) gbeanNames.iterator().next();
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java Fri Aug 18 00:44:04 2006
@@ -108,7 +108,7 @@
return location.canRead() && (location.isFile() || new File(location, "META-INF").isDirectory());
}
- private static final String NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.1";
+ private static final String NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.2";
public LinkedHashSet getDependencies(Artifact artifact) {
if(!artifact.isResolved()) {
throw new IllegalArgumentException("Artifact "+artifact+" is not fully resolved");
Modified: geronimo/trunk/modules/tomcat-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/tomcat-builder/pom.xml?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/pom.xml (original)
+++ geronimo/trunk/modules/tomcat-builder/pom.xml Fri Aug 18 00:44:04 2006
@@ -49,23 +49,23 @@
<!-- Module Dependencies -->
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>geronimo-deployment</artifactId>
- <version>${pom.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>geronimo-j2ee</artifactId>
- <version>${pom.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>geronimo-j2ee-schema</artifactId>
- <version>${pom.version}</version>
- </dependency>
+ <!--<dependency>-->
+ <!--<groupId>${pom.groupId}</groupId>-->
+ <!--<artifactId>geronimo-deployment</artifactId>-->
+ <!--<version>${pom.version}</version>-->
+ <!--</dependency>-->
+
+ <!--<dependency>-->
+ <!--<groupId>${pom.groupId}</groupId>-->
+ <!--<artifactId>geronimo-j2ee</artifactId>-->
+ <!--<version>${pom.version}</version>-->
+ <!--</dependency>-->
+
+ <!--<dependency>-->
+ <!--<groupId>${pom.groupId}</groupId>-->
+ <!--<artifactId>geronimo-j2ee-schema</artifactId>-->
+ <!--<version>${pom.version}</version>-->
+ <!--</dependency>-->
<dependency>
<groupId>${pom.groupId}</groupId>
@@ -117,18 +117,18 @@
<!-- Test Dependencies -->
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>geronimo-axis</artifactId>
- <version>${pom.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.4_spec</artifactId>
- <scope>test</scope>
- </dependency>
+ <!--<dependency>-->
+ <!--<groupId>${pom.groupId}</groupId>-->
+ <!--<artifactId>geronimo-axis</artifactId>-->
+ <!--<version>${pom.version}</version>-->
+ <!--<scope>test</scope>-->
+ <!--</dependency>-->
+
+ <!--<dependency>-->
+ <!--<groupId>org.apache.geronimo.specs</groupId>-->
+ <!--<artifactId>geronimo-servlet_2.4_spec</artifactId>-->
+ <!--<scope>test</scope>-->
+ <!--</dependency>-->
<!--WFT??? why is this needed for tests all of a sudden? -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
@@ -155,14 +155,14 @@
</includes>
</resource>
- <resource>
- <directory>src/schema</directory>
- <targetPath>META-INF</targetPath>
- <includes>
- <include>geronimo-tomcat-1.1.xsd</include>
- <include>geronimo-tomcat-config-1.0.xsd</include>
- </includes>
- </resource>
+ <!--<resource>-->
+ <!--<directory>src/schema</directory>-->
+ <!--<targetPath>META-INF</targetPath>-->
+ <!--<includes>-->
+ <!--<include>geronimo-tomcat-1.1.xsd</include>-->
+ <!--<include>geronimo-tomcat-config-1.0.xsd</include>-->
+ <!--</includes>-->
+ <!--</resource>-->
</resources>
<plugins>
@@ -186,7 +186,7 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<configuration>
- <sourceSchemas>geronimo-tomcat-1.1.xsd,geronimo-tomcat-config-1.0.xsd</sourceSchemas>
+ <sourceSchemas>geronimo-tomcat-1.2.xsd,geronimo-tomcat-config-1.0.xsd</sourceSchemas>
</configuration>
</plugin>
Modified: geronimo/trunk/modules/tomcat-builder/project.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/tomcat-builder/project.xml?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/project.xml (original)
+++ geronimo/trunk/modules/tomcat-builder/project.xml Fri Aug 18 00:44:04 2006
@@ -143,6 +143,9 @@
<groupId>geronimo</groupId>
<artifactId>geronimo-j2ee-builder</artifactId>
<version>${pom.currentVersion}</version>
+ <properties>
+ <xmlbeans>true</xmlbeans>
+ </properties>
</dependency>
<dependency>
Modified: geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Fri Aug 18 00:44:04 2006
@@ -25,30 +25,29 @@
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Permissions;
+import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.Collection;
import java.util.jar.JarFile;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
import org.apache.geronimo.deployment.service.EnvironmentBuilder;
-import org.apache.geronimo.deployment.service.ServiceConfigBuilder;
import org.apache.geronimo.deployment.util.DeploymentUtil;
import org.apache.geronimo.deployment.xbeans.EnvironmentType;
-import org.apache.geronimo.deployment.xbeans.GbeanType;
import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
-import org.apache.geronimo.deployment.ModuleIDBuilder;
import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.SingleElementCollection;
import org.apache.geronimo.j2ee.deployment.EARContext;
import org.apache.geronimo.j2ee.deployment.Module;
@@ -64,7 +63,6 @@
import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
import org.apache.geronimo.schema.SchemaConversionUtils;
import org.apache.geronimo.security.deploy.DefaultPrincipal;
-import org.apache.geronimo.security.deployment.SecurityBuilder;
import org.apache.geronimo.security.deployment.SecurityConfiguration;
import org.apache.geronimo.security.jacc.ComponentPermissions;
import org.apache.geronimo.tomcat.ManagerGBean;
@@ -75,6 +73,7 @@
import org.apache.geronimo.tomcat.util.SecurityHolder;
import org.apache.geronimo.web.deployment.AbstractWebModuleBuilder;
import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
+import org.apache.geronimo.webservices.WebServiceContainer;
import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppDocument;
import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
@@ -83,7 +82,6 @@
import org.apache.geronimo.xbeans.j2ee.ServletType;
import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
import org.apache.geronimo.xbeans.j2ee.WebAppType;
-import org.apache.geronimo.webservices.WebServiceContainer;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
@@ -105,8 +103,9 @@
public TomcatModuleBuilder(Environment defaultEnvironment,
AbstractNameQuery tomcatContainerName,
Collection webServiceBuilder,
- Kernel kernel) {
- super(kernel);
+ Collection securityBuilders,
+ Collection serviceBuilders, Kernel kernel) {
+ super(kernel, securityBuilders, serviceBuilders);
this.defaultEnvironment = defaultEnvironment;
this.tomcatContainerName = tomcatContainerName;
@@ -204,15 +203,15 @@
rawPlan = (XmlObject) plan;
} else {
if (plan != null) {
- rawPlan = XmlBeansUtil.parse(((File) plan).toURL());
+ rawPlan = XmlBeansUtil.parse(((File) plan).toURL(), getClass().getClassLoader());
} else {
URL path = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/geronimo-web.xml");
try {
- rawPlan = XmlBeansUtil.parse(path);
+ rawPlan = XmlBeansUtil.parse(path, getClass().getClassLoader());
} catch (FileNotFoundException e) {
path = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/geronimo-tomcat.xml");
try {
- rawPlan = XmlBeansUtil.parse(path);
+ rawPlan = XmlBeansUtil.parse(path, getClass().getClassLoader());
} catch (FileNotFoundException e1) {
log.warn("Web application "+ targetPath + " does not contain a WEB-INF/geronimo-web.xml deployment plan. This may or may not be a problem, depending on whether you have things like resource references that need to be resolved. You can also give the deployer a separate deployment plan file on the command line.");
}
@@ -228,7 +227,7 @@
XmlObject webPlan = new GenericToSpecificPlanConverter(GerTomcatDocument.type.getDocumentElementName().getNamespaceURI(),
TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI(), "tomcat").convertToSpecificPlan(rawPlan);
tomcatWebApp = (TomcatWebAppType) webPlan.changeType(TomcatWebAppType.type);
- SchemaConversionUtils.validateDD(tomcatWebApp);
+ XmlBeansUtil.validateDD(tomcatWebApp);
} else {
String defaultContextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
tomcatWebApp = createDefaultPlan(defaultContextRoot);
@@ -257,13 +256,8 @@
!gerWebApp.isSetSecurityRealmName()) {
throw new DeploymentException("web.xml for web app " + module.getName() + " includes security elements but Geronimo deployment plan is not provided or does not contain <security-realm-name> element necessary to configure security accordingly.");
}
- if (gerWebApp.isSetSecurity()) {
- if (!gerWebApp.isSetSecurityRealmName()) {
- throw new DeploymentException("You have supplied a security configuration for web app " + module.getName() + " but no security-realm-name to allow login");
- }
- SecurityConfiguration securityConfiguration = SecurityBuilder.buildSecurityConfiguration(gerWebApp.getSecurity(), cl);
- earContext.setSecurityConfiguration(securityConfiguration);
- }
+ boolean hasSecurityRealmName = gerWebApp.isSetSecurityRealmName();
+ buildSubstitutionGroups(gerWebApp, hasSecurityRealmName, module, earContext);
}
public void addGBeans(EARContext earContext, Module module, ClassLoader cl, Collection repository) throws DeploymentException {
@@ -275,8 +269,8 @@
WebAppType webApp = (WebAppType) webModule.getSpecDD();
TomcatWebAppType tomcatWebApp = (TomcatWebAppType) webModule.getVendorDD();
- GbeanType[] gbeans = tomcatWebApp.getGbeanArray();
- ServiceConfigBuilder.addGBeans(gbeans, moduleClassLoader, moduleName, moduleContext);
+// GbeanType[] gbeans = tomcatWebApp.getGbeanArray();
+// ServiceConfigBuilder.addGBeans(gbeans, moduleClassLoader, moduleName, moduleContext);
//this may add to the web classpath with enhanced classes.
@@ -411,7 +405,7 @@
}
securityHolder.setChecked(checkedPermissions);
earContext.addSecurityContext(policyContextID, componentPermissions);
- DefaultPrincipal defaultPrincipal = earContext.getSecurityConfiguration().getDefaultPrincipal();
+ DefaultPrincipal defaultPrincipal = ((SecurityConfiguration)earContext.getSecurityConfiguration()).getDefaultPrincipal();
securityHolder.setDefaultPrincipal(defaultPrincipal);
if (defaultPrincipal != null) {
securityHolder.setSecurity(true);
@@ -470,6 +464,8 @@
infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
infoBuilder.addAttribute("tomcatContainerName", AbstractNameQuery.class, true, true);
infoBuilder.addReference("WebServiceBuilder", WebServiceBuilder.class, NameFactory.MODULE_BUILDER);
+ infoBuilder.addReference("SecurityBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
+ infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
infoBuilder.addAttribute("kernel", Kernel.class, false);
infoBuilder.addInterface(ModuleBuilder.class);
@@ -477,6 +473,8 @@
"defaultEnvironment",
"tomcatContainerName",
"WebServiceBuilder",
+ "SecurityBuilders",
+ "ServiceBuilders",
"kernel"});
GBEAN_INFO = infoBuilder.getBeanInfo();
}
Copied: geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat-1.2.xsd (from r432067, geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat-1.1.xsd)
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat-1.2.xsd?p2=geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat-1.2.xsd&p1=geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat-1.1.xsd&r1=432067&r2=432510&rev=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat-1.1.xsd (original)
+++ geronimo/trunk/modules/tomcat-builder/src/schema/geronimo-tomcat-1.2.xsd Fri Aug 18 00:44:04 2006
@@ -17,19 +17,19 @@
-->
<xs:schema
- xmlns:tomcat="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.1"
- targetNamespace="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.1"
- xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
- xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
- xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
+ xmlns:tomcat="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2"
+ targetNamespace="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2"
+ xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
+ xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-1.2"
+ xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.1">
- <xs:import namespace="http://geronimo.apache.org/xml/ns/naming-1.1" schemaLocation="geronimo-naming-1.1.xsd"/>
- <xs:import namespace="http://geronimo.apache.org/xml/ns/security-1.1" schemaLocation="geronimo-security-1.1.xsd"/>
- <xs:import namespace="http://geronimo.apache.org/xml/ns/deployment-1.1" schemaLocation="geronimo-module-1.1.xsd"/>
+ <xs:import namespace="http://geronimo.apache.org/xml/ns/naming-1.2" schemaLocation="geronimo-naming-1.2.xsd"/>
+ <xs:import namespace="http://geronimo.apache.org/xml/ns/j2ee/application-1.2" schemaLocation="geronimo-application-1.2.xsd"/>
+ <xs:import namespace="http://geronimo.apache.org/xml/ns/deployment-1.2" schemaLocation="geronimo-module-1.2.xsd"/>
<xs:element name="web-app" type="tomcat:web-appType"/>
@@ -55,11 +55,11 @@
<xs:element ref="naming:message-destination" minOccurs="0" maxOccurs="unbounded"/>
<xs:sequence minOccurs="0">
- <xs:element name="security-realm-name" type="xs:string"/>
- <xs:element ref="security:security" minOccurs="0"/>
- </xs:sequence>
+ <xs:element name="security-realm-name" type="xs:string"/>
+ <xs:element ref="app:security" minOccurs="0"/>
+ </xs:sequence>
- <xs:element ref="sys:gbean" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element ref="sys:service" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
Modified: geronimo/trunk/modules/tomcat-builder/src/schema/xmlconfig.xml
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/tomcat-builder/src/schema/xmlconfig.xml?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/schema/xmlconfig.xml (original)
+++ geronimo/trunk/modules/tomcat-builder/src/schema/xmlconfig.xml Fri Aug 18 00:44:04 2006
@@ -17,7 +17,7 @@
-->
<!-- @version $Rev$ $Date$ -->
<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config">
- <xb:namespace uri="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.1">
+ <xb:namespace uri="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2">
<xb:package>org.apache.geronimo.xbeans.geronimo.web.tomcat</xb:package>
<xb:prefix>Tomcat</xb:prefix>
</xb:namespace>
Modified: geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java?rev=432510&r1=432509&r2=432510&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java (original)
+++ geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java Fri Aug 18 00:44:04 2006
@@ -7,6 +7,9 @@
import junit.framework.TestCase;
import org.apache.geronimo.deployment.xbeans.ArtifactType;
import org.apache.geronimo.deployment.xbeans.EnvironmentType;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.deployment.service.ServiceConfigBuilder;
+import org.apache.geronimo.deployment.service.GBeanBuilder;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
@@ -15,11 +18,11 @@
import org.apache.geronimo.kernel.Naming;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.schema.SchemaConversionUtils;
import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
import org.apache.geronimo.xbeans.geronimo.web.GerWebAppDocument;
import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
+import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
/**
*/
@@ -35,7 +38,7 @@
private TomcatModuleBuilder builder;
protected void setUp() throws Exception {
- builder = new TomcatModuleBuilder(defaultEnvironment, tomcatContainerObjectName, Collections.singleton(webServiceBuilder), null);
+ builder = new TomcatModuleBuilder(defaultEnvironment, tomcatContainerObjectName, Collections.singleton(webServiceBuilder), Collections.singleton(new GeronimoSecurityBuilderImpl()), Collections.singleton(new GBeanBuilder(null, null)), null);
}
public void testResourceRef() throws Exception {
@@ -57,7 +60,7 @@
ref.setRefName("ref");
ref.setResourceLink("target");
- SchemaConversionUtils.validateDD(tomcatWebAppType);
+ XmlBeansUtil.validateDD(tomcatWebAppType);
}
}