Package org.mule.context

Examples of org.mule.context.DefaultMuleContextFactory


                // We need to add this builder before spring so that we can use Mule annotations in Spring or any other builder
                addAnnotationsConfigBuilderIfPresent(builders);

                builders.add(cfgBuilder);

                DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
                if (deploymentListener != null)
                {
                    muleContextFactory.addListener(new MuleContextDeploymentListener(getArtifactName(), deploymentListener));
                }

                ApplicationMuleContextBuilder applicationContextBuilder = new ApplicationMuleContextBuilder(descriptor);
                setMuleContext(muleContextFactory.createMuleContext(builders, applicationContextBuilder));
            }
        }
        catch (Exception e)
        {
            setStatusToFailed();
View Full Code Here


                    // We need to add this builder before spring so that we can use Mule annotations in Spring or any other builder
                    addAnnotationsConfigBuilderIfPresent(builders);

                    builders.add(cfgBuilder);

                    DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
                    if (deploymentListener != null)
                    {
                        muleContextFactory.addListener(new MuleContextDeploymentListener(getArtifactName(), deploymentListener));
                    }
                    DomainMuleContextBuilder domainMuleContextBuilder = new DomainMuleContextBuilder(name);
                    muleContext = muleContextFactory.createMuleContext(builders, domainMuleContextBuilder);
                }
            }
        }
        catch (Exception e)
        {
View Full Code Here

    public synchronized void initialize() throws MuleException {
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
            DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
            if (muleContext != null && muleContext.isStarted()) {
                muleContext.stop();
                muleContext.dispose();
            }
            while (muleContext != null) {
                if (muleContext.isDisposed()) {
                    logger.warning("Mule already disposed!");
                    muleContext = null;
                    break;
                }
                logger.info("Waiting 1s for mule to stop and dispose itself");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    logger.log(Level.SEVERE, e.getMessage(), e);
                }

            }

            DefaultMuleConfiguration muleConfiguration = new
                    PropertiesMuleConfigurationFactory(PropertiesMuleConfigurationFactory.getMuleAppConfiguration(MuleServer.DEFAULT_CONFIGURATION))
                    .createConfiguration();
            muleConfiguration.setId(""+Math.random()*System.currentTimeMillis());
            muleConfiguration.setContainerMode(true);
            muleConfiguration.setShutdownTimeout(3);

            muleConfiguration.setWorkingDirectory(ProcessToolContext.Util.getHomePath() + File.separator + ".mule");

            MuleContextBuilder muleContextBuilder = new DefaultMuleContextBuilder();
            muleContextBuilder.setMuleConfiguration(muleConfiguration);

            List<PluginConfiguration> configurationBuilders = new ArrayList<PluginConfiguration>(configMap.values());
            List<ConfigurationBuilder> builders = new ArrayList<ConfigurationBuilder>();
            List<ConfigResource> resources = new ArrayList<ConfigResource>();
            for (PluginConfiguration c : configurationBuilders) {
                InputStream is = c.getIs();
                try {
                    is.reset();
                    resources.add(new ConfigResource(c.getName(), new ByteArrayInputStream(IOUtils.toByteArray(is))));
                } catch (Exception e) {
                    logger.log(Level.SEVERE, e.getMessage(), e);
                    throw new RuntimeException(e);
                }
            }
            try {
                SpringXmlConfigurationBuilder builder = (SpringXmlConfigurationBuilder)
                                ClassUtils.instanciateClass(SpringXmlConfigurationBuilder.class.getName(),
                                        new Object[]{resources.toArray(new ConfigResource[resources.size()])},
                                        getClass().getClassLoader());
                builders.add(builder);
            } catch (Exception e) {
                logger.log(Level.SEVERE, e.getMessage(), e);
                throw new RuntimeException(e);
            }

            muleContext = muleContextFactory.createMuleContext(builders, muleContextBuilder);
            muleContext.start();
        } finally {
            Thread.currentThread().setContextClassLoader(contextClassLoader);
        }
    }
View Full Code Here

TOP

Related Classes of org.mule.context.DefaultMuleContextFactory

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.