| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.ksb.messaging; |
| 18 | |
|
| 19 | |
import org.apache.commons.lang.StringUtils; |
| 20 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 21 | |
import org.springframework.beans.factory.BeanInitializationException; |
| 22 | |
|
| 23 | |
import java.util.ArrayList; |
| 24 | |
import java.util.List; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | 0 | public class PropertyConditionalKSBExporter extends KSBExporter { |
| 33 | |
|
| 34 | 0 | private List<String> exportIf = new ArrayList<String>(); |
| 35 | 0 | private List<String> exportUnless = new ArrayList<String>(); |
| 36 | 0 | private boolean exportIfPropertyNotSet = true; |
| 37 | |
|
| 38 | |
public void afterPropertiesSet() throws Exception { |
| 39 | 0 | if (shouldRemoteThisService()) { |
| 40 | 0 | super.afterPropertiesSet(); |
| 41 | |
} |
| 42 | 0 | } |
| 43 | |
|
| 44 | |
protected boolean shouldRemoteThisService() throws Exception { |
| 45 | 0 | if (exportIf.isEmpty() && exportUnless.isEmpty()) { |
| 46 | 0 | return true; |
| 47 | |
} |
| 48 | 0 | boolean remoteThisService = false; |
| 49 | 0 | String serviceValue = null; |
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | 0 | for (String expIf : exportIf) { |
| 55 | 0 | serviceValue = ConfigContext.getCurrentContextConfig().getProperty(expIf); |
| 56 | |
|
| 57 | 0 | if (!StringUtils.isBlank(serviceValue)) { |
| 58 | 0 | remoteThisService = new Boolean(serviceValue); |
| 59 | 0 | if (remoteThisService) { |
| 60 | 0 | break; |
| 61 | |
} |
| 62 | 0 | } else if (exportIfPropertyNotSet) { |
| 63 | 0 | remoteThisService = true; |
| 64 | 0 | break; |
| 65 | |
} |
| 66 | |
} |
| 67 | |
|
| 68 | 0 | for (String expUnless : exportUnless) { |
| 69 | 0 | serviceValue = ConfigContext.getCurrentContextConfig() |
| 70 | |
.getProperty(expUnless); |
| 71 | |
|
| 72 | 0 | if (!StringUtils.isBlank(serviceValue)) { |
| 73 | 0 | remoteThisService = new Boolean(serviceValue); |
| 74 | 0 | if (remoteThisService) { |
| 75 | 0 | remoteThisService = new Boolean("false"); |
| 76 | 0 | break; |
| 77 | |
} |
| 78 | |
} |
| 79 | |
} |
| 80 | 0 | return remoteThisService; |
| 81 | |
} |
| 82 | |
|
| 83 | |
public List getExportIf() { |
| 84 | 0 | return this.exportIf; |
| 85 | |
} |
| 86 | |
|
| 87 | |
public void setExportIf(List exportIf) throws BeanInitializationException { |
| 88 | 0 | this.exportIf = exportIf; |
| 89 | 0 | } |
| 90 | |
|
| 91 | |
public List getExportUnless() { |
| 92 | 0 | return this.exportUnless; |
| 93 | |
} |
| 94 | |
|
| 95 | |
public void setExportUnless(List exportUnless) |
| 96 | |
throws BeanInitializationException { |
| 97 | 0 | this.exportUnless = exportUnless; |
| 98 | 0 | } |
| 99 | |
|
| 100 | |
public boolean isExportIfPropertyNotSet() { |
| 101 | 0 | return this.exportIfPropertyNotSet; |
| 102 | |
} |
| 103 | |
|
| 104 | |
public void setExportIfPropertyNotSet(boolean exportIfPropertyNotSet) { |
| 105 | 0 | this.exportIfPropertyNotSet = exportIfPropertyNotSet; |
| 106 | 0 | } |
| 107 | |
|
| 108 | |
} |