m_actionFixupList = new ArrayList();
m_persistenceMappingLoadList = new ArrayList();
m_persistenceMappingFixupList = new ArrayList();
m_persistenceMappingGenerationList = new ArrayList();
m_attributeDependencyList = new ArrayList(1);
m_attributeDependencySet = new HashHolder();
m_class2ndPassList = new ArrayList(1);
m_ioFixupList = new ArrayList();
m_environmentFixupList = new ArrayList();
m_privilegeFixupList = new ArrayList();
m_preInheritanceMessageFixupList = new ArrayList();
m_postInheritanceMessageFixupList = new ArrayList();
m_transformationFixupList = new ArrayList();
m_postInheritanceTransformationFixupList = new ArrayList();
m_componentFixupList = new ArrayList();
m_singletonFixupList = new ArrayList();
m_tmpDocument = XMLUtil.parse(new StringReader("<TmpDocument/>"));
m_metadata.setEncrypted((nFlags & ENCRYPTED) != 0);
m_metadata.setEnvironmentOnly(m_bEnvironmentOnly);
if ((nFlags & WARNING) != 0)
{
m_helper.setWarnings(new GenericException(null)
{
private final static long serialVersionUID = -2984934222963813773L;
public void addException(Throwable e)
{
e.setStackTrace(ObjUtil.EMPTY_STACK_TRACE);
super.addException(e);
}
});
}
// Prepare the progress listener
ProgressProxy progressProxy = new ProgressProxy(progress);
if (progress != null)
{
progress = progressProxy;
}
// Load the repository descriptors and process the elements in them
if (progress != null)
{
progress.progress("info.meta.loadingDescriptors", null, 0);
}
Element baseDescElement = m_helper.getDescriptorElement(false);
Element rootDescElement = m_helper.getDescriptorElement(true);
progressProxy.setRange(0.01, 0.02);
m_metadata.setListing(m_helper.getListing(new XMLMetadataHelper.MixinHandler()
{
/**
* Metadata repository information, indexed by namespace.
*/
private Lookup m_metadataMap = new HashTab();
private String getMetadataName(String sNamespace)
{
MetadataInfo info = ((MetadataInfo)m_metadataMap.get(sNamespace));
return (info == null || info.metadata == null) ? sNamespace : info.metadata.getName();
}
public void handleRepository(XMLMixin mixin)
{
String sNamespace = mixin.getNamespace();
XMLMetadataHelper helper = mixin.getHelper();
MetadataInfo info = (MetadataInfo)m_metadataMap.get(sNamespace);
if (info == null)
{
info = new MetadataInfo();
}
// get the metadata instance
if (m_metadataMap.size() == 0)
{
info.metadata = m_metadata;
}
else
{
URL rootURL = helper.getRootURL();
info.metadata = createXMLMetadata(rootURL.getPath(), rootURL, helper.getBaseURL(), helper);
}
// load the version
loadVersion(info.metadata, helper);
m_metadataMap.put(sNamespace, info);
// validate loaded mixin
if (m_metadata != info.metadata)
{
// Adopt the highest coreVersion available from any of the repositories.
if (m_metadata.getCoreVersion() == null || (info.metadata.getCoreVersion() != null &&
StringUtil.compareVersionRanges(m_metadata.getCoreVersion(), info.metadata.getCoreVersion()) < 0))
{
m_metadata.setCoreVersion(info.metadata.getCoreVersion());
}
if (info.ref == null)
{
throw new MetadataValidationException("err.meta.mixinNamespace", new Object[]{info.metadata.getName(), sNamespace});
}
String sVersion = info.ref.getVersion();
String sChecksum = info.ref.getChecksum();
// validate that repository matches mixin declaration
if ((sVersion != null && !sVersion.equals(info.metadata.getVersion()))
|| (sChecksum != null && !sChecksum.equals(info.metadata.getChecksum())))
{
throw new MetadataValidationException("err.meta.mixinLinkVersion", new Object[]{
info.metadata.getName(),
info.metadata.getVersion(),
info.metadata.getChecksum(),
sVersion,
sChecksum,
getMetadataName(info.parentNamespace)
});
}
}
}
public void handleMixinReference(XMLMixin ref, XMLMixin parent)
{
String sParentNamespace = parent.getNamespace();
String sNamespace = ref.getNamespace();
String sVersion = ref.getVersion();
String sChecksum = ref.getChecksum();
MetadataInfo info = (MetadataInfo)m_metadataMap.get(sNamespace);
if (info == null)
{
info = new MetadataInfo();
info.parentNamespace = sParentNamespace;
info.ref = (XMLMixin)ref.clone();
m_metadataMap.put(sNamespace, info);
// mixin declared at top-level is also base
if (sParentNamespace.equals(m_metadata.getNamespace()) && sNamespace.equals(m_metadata.getBaseNamespace()))
{
m_helper.addException(new MetadataValidationException("err.meta.mixinDup",
new Object[] {sNamespace, getMetadataName(sParentNamespace)}));
}
// mixin matches base, but has different version/checksum
if (sNamespace.equals(m_metadata.getBaseNamespace()) &&
(!sVersion.equals(m_metadata.getBaseVersion()) || !sChecksum.equals(m_metadata.getBaseChecksum())))
{
m_helper.addException(new MetadataValidationException("err.meta.mixinBaseVersion",
new Object[]{sNamespace, sVersion, sChecksum, m_metadata.getBaseVersion(), m_metadata.getBaseChecksum()}));
}
}
else if (info.ref != null)
{
if (sParentNamespace.equals(info.parentNamespace))
{
// mixin declared twice in same repository
m_helper.addException(new MetadataValidationException("err.meta.mixinDup",
new Object[] {sNamespace, getMetadataName(sParentNamespace)}));
}
// mixin declared more than once with different version/checksum
if ((info.ref.getVersion() != null && !info.ref.getVersion().equals(sVersion)) ||
(info.ref.getChecksum() != null && !info.ref.getChecksum().equals(sChecksum)))
{
m_helper.addException(new MetadataValidationException("err.meta.mixinVersion", new Object[] {
sNamespace,
sVersion,
sChecksum,
getMetadataName(sParentNamespace),
info.ref.getVersion(),
info.ref.getChecksum(),
getMetadataName(info.parentNamespace)
}));
}
}
}
public void handleMixinOverrideConflict(XMLMixin ref, XMLMixin mixin)
{
throw new MetadataValidationException("err.meta.mixinOverride", new Object[]{ref.getName(), mixin.getName()});
}
public void handleCircularReference(XMLMixin mixin)
{
throw new MetadataValidationException("err.meta.mixinCycle", new Object[]{mixin.getName()});
}
public void handleResourceConflict(XMLResource first, XMLResource second)
{
m_helper.addException(new MetadataValidationException("err.meta.mixinConflict",
new Object[]{
first.getName(),
getMetadataName(first.getNamespace()),
getMetadataName(second.getNamespace())
}));
}
public void handleLinkFailure(XMLMixin ref, Exception e)
{
if (e instanceof MetadataValidationException)
{
m_helper.addException((MetadataValidationException)e);
}
else
{
throw new MetadataException("err.meta.mixin", new Object[]{ref}, e);
}
}
public void handleAlternateResource(XMLResource first, XMLResource second)
{
}
public void handleResourceOverride(XMLResource source, XMLResource overridden)
{
}
final class MetadataInfo
{
/**
* The metadata instance of the repository.
*/
private XMLMetadata metadata;
/**
* The namespace of the repository that linked this repository.
*/
private String parentNamespace;
/**
* The reference that caused this repository to be linked.
*/
private XMLMixin ref;
}
}));
m_helper.setMetadataCoreVersion(
m_metadata.getCoreVersion(), m_metadata.getUpgradeResources());
progressProxy.shiftRange(0.05);
if (!m_bEnvironmentOnly && !bDataSourceOnly)
{
Lookup localeMap = new HashTab();
m_helper.addResources(localeMap, ".locale", "Locale", "locale");
loadStrings(localeMap.iterator());
Lookup stringResMap = new HashTab();
m_helper.addResources(stringResMap, ".strings", "Strings", "strings");
loadStrings(stringResMap.iterator());
if (StringTable.getInstance() == null)
{
StringTable.setInstance(m_metadata.getStringTable(Metadata.DEFAULT_LOCALE));
StringTable.setTimeZone(TZ.UTC);
}
}
progressProxy.shiftRange(0.10);
m_helper.loadEncryptedResourceURL(configURL, "Server", "server", new ResourceHandler()
{
public void handleResource(final Element element, final String sName)
{
if (element.getNodeName().equals("Environment"))
{
String sConnectionsURL = m_properties.getProperty(CONNECTIONS_URL_PROPERTY);
if (StringUtil.isEmpty(sConnectionsURL))
{
m_properties.setProperty(CONNECTIONS_URL_PROPERTY, m_sConfigURL);
}
}
NamedNodeMap attrMap = element.getAttributes();
for (int i = 0; i != attrMap.getLength(); ++i)
{
Node node = attrMap.item(i);
String sOldValue = m_properties.getProperty(node.getNodeName());
if (StringUtil.isEmpty(sOldValue))
{
m_properties.setProperty(node.getNodeName(), node.getNodeValue());
}
}
}
}, m_properties);
m_decryptionDispatcher = new CharacterStreamCipherDispatcher();
m_decryptionDispatcher.init(m_properties);
m_helper.setEncryptionSchemeSet(new HashHolder(4));
loadServer(m_properties);
String sConnectionsURL = m_properties.getProperty(CONNECTIONS_URL_PROPERTY);
URL connectionsURL = null;
if (!StringUtil.isEmpty(sConnectionsURL))
{
connectionsURL = XMLMetadataHelper.getURL(sConnectionsURL, false, handler);
sConnectionsURL = connectionsURL.toString();
if (s_logger.isInfoEnabled())
{
s_logger.info("Connections URL: \"" + sConnectionsURL + "\"");
}
}
m_helper.loadSystemResource("system.dstypes",
"DataSourceTypes", "dataSourceTypes", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
loadDataSourceTypes(element);
}
});
m_helper.loadResources(".dstype", "DataSourceType", "dataSourceType", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
loadDataSourceType(element, sName);
}
}, progress);
m_helper.loadResources(".datasource", "DataSource", "dataSource", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
loadDataSource(element, sName);
}
}, progress);
if (!m_bIntegrationExcluded)
{
m_helper.loadSystemResource("system.chtypes",
"ChannelTypes", "channelTypes", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
loadChannelTypes(element);
}
});
m_helper.loadResources(".chtype", "ChannelType", "channelType", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
loadChannelType(element, sName);
}
}, progress);
// Load the SOA definition XML metadata (which may include definitions of other XML metadata)
m_soaLoader = new XMLSOAMetadataLoader(m_helper);
m_helper.loadResources(".soadef", "SOADefinition", "soadef", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
m_soaLoader.loadDefinition(element, sName);
}
}, progress);
m_soaLoader.resolveReferences();
// dispatcher channel properties loaded from environment.
ChannelType type = m_metadata.getChannelType("ObjectQueue");
m_dispatcherChannel.setType(type);
m_metadata.addChannel(m_dispatcherChannel);
m_helper.loadResources(".channel", "Channel", "channel", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
loadChannel(element, sName);
}
}, progress);
}
final Set componentNameSet = new HashHolder();
m_helper.loadResources(".comp", "Component", "component", new ResourceHandler()
{
public void handleResource(Element element, String sName)
{
if (m_bEnvironmentOnly)
{
XMLMetadataHelper.verifyRootElement(element, "Component");
m_metadata.addComponent(new Component(sName));
}
componentNameSet.add(sName);
}
}, progress);
if (componentNameSet.contains("System.ObjectQueueDispatcher") &&
Boolean.parseBoolean(properties.getProperty("queueing.enabled", "true")))
{
// only enable the dispatcher if the metadata supports it.
m_dispatcherChannel.setSendable(true);
m_dispatcherChannel.setReceivable(true);