Package org.andromda.core.common

Examples of org.andromda.core.common.XmlObjectFactory


                    NamespaceProperties.PROFILE_MAPPINGS_URI,
                    false);
            final String mappingsUriValue = mappingsUri != null ? mappingsUri.getValue() : null;
            if (mappingsUriValue != null)
            {
                final XmlObjectFactory factory = XmlObjectFactory.getInstance(Profile.class);
                final Profile profile = (Profile)factory.getObject(new URL(mappingsUriValue.trim()));
                this.elements.putAll(profile.elements);
            }
        }
        catch (final Throwable throwable)
        {
View Full Code Here


     */
    public static final NamespaceComponents instance()
    {
        if (instance == null)
        {
            final XmlObjectFactory factory = XmlObjectFactory.getInstance(NamespaceComponents.class);
            instance = (NamespaceComponents)factory.getObject(ResourceUtils.getResource(CONFIGURATION_URI));
        }
        return instance;
    }
View Full Code Here

     */
    public void discover()
    {
        AndroMDALogger.info("- discovering namespaces -");

        final XmlObjectFactory registryFactory = XmlObjectFactory.getInstance(NamespaceRegistry.class);
        final ComponentContainer container = ComponentContainer.instance();

        // - discover all registries and sort them by name
        final Map registryMap = this.discoverAllRegistries();
        final List registries = new ArrayList(registryMap.keySet());
        Collections.sort(
            registries,
            new NamespaceRegistryComparator());
        for (final Iterator iterator = registries.iterator(); iterator.hasNext();)
        {
            NamespaceRegistry registry = (NamespaceRegistry)iterator.next();
            final URL resource = (URL)registryMap.get(registry);
            final String registryName = registry.getName();

            // - only register if we haven't yet registered the namespace resource
            if (!this.registeredNamespaceResources.contains(resource))
            {
                final Namespaces namespaces = Namespaces.instance();
                final String namespace = registry.isShared() ? Namespaces.DEFAULT : registry.getName();

                // - first merge on the namespace registry descriptor (if needed)
                final Merger merger = Merger.instance();
                boolean requiresMerge = merger.requiresMerge(namespace);
                if (requiresMerge)
                {
                    registry =
                        (NamespaceRegistry)registryFactory.getObject(
                            merger.getMergedString(
                                ResourceUtils.getContents(resource),
                                namespace), resource);
                }

                // - add the resource root
                registry.addResourceRoot(this.getNamespaceResourceRoot(resource));
               
                // - only log the fact we've found the namespace registry, if we haven't done it yet
                if (!this.registeredRegistries.contains(registryName))
                {
                    AndroMDALogger.info("found namespace --> '" + registryName + "'");
                    this.registeredRegistries.add(registryName);
                }

                final NamespaceRegistry existingRegistry = namespaces.getRegistry(registryName);
                if (existingRegistry != null)
                {
                    // - if we already have an existing registry with the same name, copy
                    //   over any resources.
                    registry.copy(existingRegistry);
                }

                // - add the registry to the namespaces instance
                namespaces.addRegistry(registry);
                final String[] components = registry.getRegisteredComponents();
                final int componentNumber = components.length;
                for (int componentCtr = 0; componentCtr < componentNumber; componentCtr++)
                {
                    final String componentName = components[componentCtr];
                    final Component component = this.getComponent(componentName);
                    if (component == null)
                    {
                        throw new NamespaceComponentsException("'" + componentName +
                            "' is not a valid namespace component");
                    }

                    // - add any paths defined within the registry
                    component.addPaths(registry.getPaths(component.getName()));
                    if (!container.isRegisteredByNamespace(
                            registryName,
                            component.getType()))
                    {
                        AndroMDALogger.info("  +  registering component '" + componentName + "'");
                        final XmlObjectFactory componentFactory = XmlObjectFactory.getInstance(component.getType());
                        final URL componentResource =
                            this.getNamespaceResource(
                                registry.getResourceRoots(),
                                component.getPaths());
                        if (componentResource == null)
                        {
                            throw new NamespaceComponentsException("'" + componentName +
                                "' is not a valid component within namespace '" + namespace + "' (the " +
                                componentName + "'s descriptor can not be found)");
                        }
                        NamespaceComponent namespaceComponent =
                            (NamespaceComponent)componentFactory.getObject(componentResource);

                        // - now perform a merge of the descriptor (if we require one)
                        if (requiresMerge)
                        {
                            namespaceComponent =
                                (NamespaceComponent)componentFactory.getObject(
                                    merger.getMergedString(
                                        ResourceUtils.getContents(componentResource),
                                        namespace));
                        }

View Full Code Here

     */
    private Map discoverAllRegistries()
    {
        final Map registries = new HashMap();
        final URL[] resources = ResourceFinder.findResources(this.getPath());
        final XmlObjectFactory registryFactory = XmlObjectFactory.getInstance(NamespaceRegistry.class);
        if (resources != null && resources.length > 0)
        {
            final int numberOfResources = resources.length;
            for (int ctr = 0; ctr < numberOfResources; ctr++)
            {
                final URL resource = resources[ctr];
                final NamespaceRegistry registry = (NamespaceRegistry)registryFactory.getObject(resource);
                registries.put(
                    registry,
                    resource);
            }
        }
View Full Code Here

                    final String uri = (String)iterator.next();
                    if (uri.replaceAll(
                            ".*(\\\\+|/)",
                            "").equals(DESCRIPTOR))
                    {
                        final XmlObjectFactory factory = XmlObjectFactory.getInstance(AndroMDApp.class);
                        final URL descriptorUri = ResourceUtils.toURL(uri);
                        final AndroMDAppType andromdapp = (AndroMDAppType)factory.getObject(descriptorUri);
                        andromdapp.setResource(descriptorUri);
                        final String type = andromdapp.getType();
                        AndroMDALogger.info("discovered andromdapp type --> '" + type + "'");
                        this.types.put(
                            type,
View Full Code Here

     */
    public void addConfigurationUri(final String configurationUri)
    {
        if (configurationUri != null && configurationUri.trim().length() > 0)
        {
            final XmlObjectFactory factory = XmlObjectFactory.getInstance(Configuration.class);
            final URL configurationUrl = ResourceUtils.toURL(configurationUri);
            if (configurationUrl == null)
            {
                throw new AndroMDAppException("configuriationUri is invalid --> '" + configurationUri + "'");
            }
            this.configurations.add(factory.getObject(ResourceUtils.toURL(configurationUri)));
        }
    }
View Full Code Here

     */
    public void addConfiguration(final String configuration)
    {
        if (configuration != null && configuration.trim().length() > 0)
        {
            final XmlObjectFactory factory = XmlObjectFactory.getInstance(Configuration.class);
            this.configurations.add(factory.getObject(configuration));
        }
    }
View Full Code Here

        andromdapp.setConfigurations(this.configurations);
        andromdapp.initialize();

        final Map templateContext = andromdapp.getTemplateContext();

        final XmlObjectFactory factory = XmlObjectFactory.getInstance(AndroMDApp.class);
        final String contents = andromdapp.promptUser();
        // - evaluate all properties in the descriptor and recreate the AndroMDAppType
        andromdapp = (AndroMDAppType)factory.getObject(contents);
        andromdapp.setConfigurations(this.configurations);
        andromdapp.addToTemplateContext(templateContext);
        return andromdapp.processResources(write);
    }
View Full Code Here

TOP

Related Classes of org.andromda.core.common.XmlObjectFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.