Author: indika Date: Tue Jan 6 23:10:50 2009 New Revision: 28188 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=28188
Log: fix for CARBON-1780 Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java?rev=28188&r1=28187&r2=28188&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java Tue Jan 6 23:10:50 2009 @@ -191,21 +191,24 @@ * @return the sequence referenced by the key */ public Mediator getSequence(String key) { - Object o = localRegistry.get(key); + Object o = getEntry(key); if (o != null && o instanceof Mediator) { return (Mediator) o; } - Entry entry; - if (o != null && o instanceof Entry) { - entry = (Entry) o; - } else { - entry = new Entry(key); - entry.setType(Entry.REMOTE_ENTRY); - entry.setMapper(MediatorFactoryFinder.getInstance()); - } + Entry entry; + if (o != null && o instanceof Entry) { + entry = (Entry) o; + if (entry.getMapper() == null) { + entry.setMapper(MediatorFactoryFinder.getInstance()); + } + } else { + entry = new Entry(key); + entry.setType(Entry.REMOTE_ENTRY); + entry.setMapper(MediatorFactoryFinder.getInstance()); + } - if (registry != null) { + if (registry != null) { o = registry.getResource(entry); if (o != null && o instanceof Mediator) { localRegistry.put(key, entry); @@ -464,22 +467,25 @@ * @return the endpoint definition */ public Endpoint getEndpoint(String key) { - - Object o = localRegistry.get(key); + + Object o = getEntry(key); if (o != null && o instanceof Endpoint) { return (Endpoint) o; } - Entry entry; - if (o != null && o instanceof Entry) { - entry = (Entry) o; - } else { - entry = new Entry(key); - entry.setType(Entry.REMOTE_ENTRY); - entry.setMapper(XMLToEndpointMapper.getInstance()); - } + Entry entry; + if (o != null && o instanceof Entry) { + entry = (Entry) o; + if (entry.getMapper() == null) { + entry.setMapper(XMLToEndpointMapper.getInstance()); + } + } else { + entry = new Entry(key); + entry.setType(Entry.REMOTE_ENTRY); + entry.setMapper(XMLToEndpointMapper.getInstance()); + } - if (registry != null) { + if (registry != null) { o = registry.getResource(entry); if (o != null && o instanceof Endpoint) { localRegistry.put(key, entry); Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java?rev=28188&r1=28187&r2=28188&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java Tue Jan 6 23:10:50 2009 @@ -23,6 +23,7 @@ import org.apache.axis2.description.Parameter; import org.apache.synapse.MessageContext; import org.apache.synapse.SynapseConstants; +import org.apache.synapse.config.Entry; import org.apache.synapse.config.SynapseConfiguration; import org.apache.synapse.core.axis2.Axis2MessageContext; @@ -42,9 +43,9 @@ * @param synCtx the message to send */ public void send(MessageContext synCtx) { - if (realEndpoint == null) { - init(((Axis2MessageContext) synCtx).getAxis2MessageContext().getConfigurationContext()); - } + + reLoadAndInitEndpoint(((Axis2MessageContext) synCtx).getAxis2MessageContext().getConfigurationContext()); + if (realEndpoint != null) { realEndpoint.send(synCtx); } else { @@ -96,19 +97,39 @@ /** * Figure out the real endpoint we proxy for, and make sure its initialized */ - public synchronized void init(ConfigurationContext cc) { - Parameter param = cc.getAxisConfiguration().getParameter(SynapseConstants.SYNAPSE_CONFIG); - if (param != null && param.getValue() instanceof SynapseConfiguration) { - SynapseConfiguration synCfg = (SynapseConfiguration) param.getValue(); - realEndpoint = synCfg.getEndpoint(key); - } - if (realEndpoint != null && !realEndpoint.isInitialized()) { - realEndpoint.init(cc); - } + public void init(ConfigurationContext cc) { + reLoadAndInitEndpoint(cc); } @Override public String toString() { return "[Indirect Endpoint [ " + key + "]]"; } + + private synchronized void reLoadAndInitEndpoint(ConfigurationContext cc) { + + Parameter parameter = cc.getAxisConfiguration().getParameter(SynapseConstants.SYNAPSE_CONFIG); + if (parameter != null && parameter.getValue() instanceof SynapseConfiguration) { + SynapseConfiguration synCfg = (SynapseConfiguration) parameter.getValue(); + + boolean reLoad = (realEndpoint == null); + if (!reLoad) { + + Entry entry = synCfg.getEntryDefinition(key); + if (entry != null && entry.isDynamic()) { + + if (!entry.isCached() || entry.isExpired()) { + reLoad = true; + } + } + } + + if (reLoad) { + realEndpoint = synCfg.getEndpoint(key); + if (realEndpoint != null && !realEndpoint.isInitialized()) { + realEndpoint.init(cc); + } + } + } + } } _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
