| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kew.resourceloader; |
| 18 | |
|
| 19 | |
import org.apache.commons.lang.StringUtils; |
| 20 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 21 | |
import org.kuali.rice.core.api.reflect.ObjectDefinition; |
| 22 | |
import org.kuali.rice.core.api.reflect.ObjectDefinition; |
| 23 | |
import org.kuali.rice.core.impl.resourceloader.BaseWrappingResourceLoader; |
| 24 | |
import org.kuali.rice.core.impl.resourceloader.BaseWrappingResourceLoader; |
| 25 | |
import org.kuali.rice.core.api.resourceloader.ServiceLocator; |
| 26 | |
import org.kuali.rice.kew.plugin.PluginRegistry; |
| 27 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 28 | |
import org.kuali.rice.kew.util.KEWConstants; |
| 29 | |
|
| 30 | |
import javax.xml.namespace.QName; |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
public class CoreResourceLoader extends BaseWrappingResourceLoader { |
| 39 | |
|
| 40 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger |
| 41 | |
.getLogger(CoreResourceLoader.class); |
| 42 | |
|
| 43 | 0 | public static final QName NAME = new QName(ConfigContext.getCurrentContextConfig().getServiceNamespace(), "KEW_SPRING+PLUGIN_REGISTRY_CONTAINER_RESOURCE_LOADER"); |
| 44 | |
|
| 45 | |
private final PluginRegistry registry; |
| 46 | |
|
| 47 | |
public CoreResourceLoader(ServiceLocator serviceLocator, PluginRegistry registry) { |
| 48 | 0 | super(CoreResourceLoader.NAME, serviceLocator); |
| 49 | 0 | this.registry = registry; |
| 50 | 0 | } |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public Object getService(QName serviceName) { |
| 56 | 0 | if (isRemoteService(serviceName)) { |
| 57 | 0 | return null; |
| 58 | |
} |
| 59 | 0 | Object service = super.getService(serviceName); |
| 60 | 0 | if (service == null && getRegistry() != null) { |
| 61 | 0 | service = getRegistry().getService(serviceName); |
| 62 | |
} |
| 63 | 0 | return service; |
| 64 | |
} |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
@Override |
| 69 | |
public Object getObject(ObjectDefinition objectDefinition) { |
| 70 | 0 | Object object = super.getObject(objectDefinition); |
| 71 | 0 | if (object == null && getRegistry() != null) { |
| 72 | 0 | object = getRegistry().getObject(objectDefinition); |
| 73 | |
} |
| 74 | 0 | return object; |
| 75 | |
} |
| 76 | |
|
| 77 | |
@Override |
| 78 | |
protected boolean shouldWrapService(QName serviceName, Object service) { |
| 79 | |
|
| 80 | 0 | if (serviceName.getLocalPart().equals("transactionTemplate")) { |
| 81 | 0 | return false; |
| 82 | |
} |
| 83 | 0 | return super.shouldWrapService(serviceName, service); |
| 84 | |
} |
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
@Override |
| 89 | |
public void stop() throws Exception { |
| 90 | 0 | if (getRegistry() != null) { |
| 91 | 0 | registry.stop(); |
| 92 | |
} |
| 93 | 0 | super.stop(); |
| 94 | 0 | } |
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
protected boolean isRemoteService(QName serviceName) { |
| 102 | 0 | return (useRemoteEmailServices() && |
| 103 | |
serviceName.getLocalPart().equals(KEWServiceLocator.IMMEDIATE_EMAIL_REMINDER_SERVICE)); |
| 104 | |
} |
| 105 | |
|
| 106 | |
protected boolean useRemoteEmailServices() { |
| 107 | 0 | String useRemoteEmailServicesValue = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.USE_REMOTE_EMAIL_SERVICES); |
| 108 | 0 | if (!StringUtils.isBlank(useRemoteEmailServicesValue)) { |
| 109 | 0 | return new Boolean(useRemoteEmailServicesValue.trim()); |
| 110 | |
} |
| 111 | 0 | return false; |
| 112 | |
} |
| 113 | |
|
| 114 | |
public PluginRegistry getRegistry() { |
| 115 | 0 | return registry; |
| 116 | |
} |
| 117 | |
|
| 118 | |
} |