synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Upul Godage" <upulg....@gmail.com>
Subject Re: svn commit: r645420 - /synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/spring/SpringMediator.java
Date Tue, 08 Apr 2008 04:46:13 GMT
Yes, I will use the existing code for both. Thanks.

Upul

On Tue, Apr 8, 2008 at 4:20 AM, Andreas Veithen <andreas.veithen@skynet.be>
wrote:

> Upul,
>
> Is there a reason why the init method doesn't reuse the existing
> buildAppContext method?
>
> Andreas
>
>
> On 07 Apr 2008, at 11:17, upul@apache.org wrote:
>
> > Author: upul
> > Date: Mon Apr  7 02:17:32 2008
> > New Revision: 645420
> >
> > URL: http://svn.apache.org/viewvc?rev=645420&view=rev
> > Log:
> > create spring appcontext in mediator init
> >
> > Modified:
> >
> > synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/spring/SpringMediator.java
> >
> > Modified:
> > synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/spring/SpringMediator.java
> > URL:
> > http://svn.apache.org/viewvc/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/spring/SpringMediator.java?rev=645420&r1=645419&r2=645420&view=diff
> >
> > ==============================================================================
> > ---
> > synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/spring/SpringMediator.java
> > (original)
> > +++
> > synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/spring/SpringMediator.java
> > Mon Apr  7 02:17:32 2008
> > @@ -21,6 +21,9 @@
> >
> > import org.apache.synapse.MessageContext;
> > import org.apache.synapse.Mediator;
> > +import org.apache.synapse.ManagedLifecycle;
> > +import org.apache.synapse.SynapseException;
> > +import org.apache.synapse.core.SynapseEnvironment;
> > import org.apache.synapse.mediators.AbstractMediator;
> > import org.apache.synapse.config.SynapseConfigUtils;
> > import org.apache.synapse.config.Entry;
> > @@ -37,7 +40,7 @@
> >  * refers to a Spring bean name, and also either a Spring configuration
> > defined to Synapse
> >  * or an inlined Spring configuration.
> >  */
> > -public class SpringMediator extends AbstractMediator {
> > +public class SpringMediator extends AbstractMediator implements
> > ManagedLifecycle {
> >
> >    /**
> >     * The Spring bean ref to be used
> > @@ -152,4 +155,35 @@
> >    public String getType() {
> >        return "SpringMediator";
> >    }
> > +
> > +
> > +  public void init(SynapseEnvironment se) {
> > +        if (log.isDebugEnabled()) {
> > +            log.debug("Creating Spring ApplicationContext from key : "
> > + configKey);
> > +        }
> > +
> > +        MessageContext synCtx = se.createMessageContext();
> > +        GenericApplicationContext appContext = new
> > GenericApplicationContext();
> > +        XmlBeanDefinitionReader xbdr = new
> > XmlBeanDefinitionReader(appContext);
> > +        xbdr.setValidating(false);
> > +
> > +        Object springConfig = synCtx.getEntry(configKey);
> > +        if(springConfig == null) {
> > +          String errorMessage = "Cannot look up Spring configuration "
> > + configKey;
> > +          log.error(errorMessage);
> > +          throw new SynapseException(errorMessage);
> > +        }
> > +
> > +        xbdr.loadBeanDefinitions(
> > +            new InputStreamResource(
> > +
> >  SynapseConfigUtils.getStreamSource(springConfig).getInputStream()));
> > +        appContext.refresh();
> > +        if (log.isDebugEnabled()) {
> > +            log.debug("Spring ApplicationContext from key : " +
> > configKey + " created");
> > +        }
> > +        this.appContext = appContext;
> > +  }
> > +
> > +  public void destroy() {
> > +  }
> > }
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
> For additional commands, e-mail: dev-help@synapse.apache.org
>
>

Mime
View raw message