View Javadoc
1   /*
2    * Copyright 2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.context;
17  
18  import java.util.HashSet;
19  import java.util.Set;
20  
21  import javax.xml.namespace.QName;
22  
23  import org.kuali.rice.core.impl.resourceloader.SpringBeanFactoryResourceLoader;
24  
25  /**
26   * A custom {@link org.kuali.rice.kew.plugin.ResourceLoader} which wraps a Spring BeanFactory and delegates certain service lookups to
27   * the BeanFactory.
28   */
29  public class FinancialSystemResourceLoader extends SpringBeanFactoryResourceLoader {
30  
31      private static final String CONVERSIONS_DELIMITER = "|";
32      //private static final String LOOKUPABLE_REGEX = "workflow-.+-Lookupable(.+)";
33  
34      private Set<String> overridableServices = new HashSet<String>();
35  
36      public FinancialSystemResourceLoader() {
37          super(new QName("FinancialSystemResourceLoader"));
38      }
39  
40      @Override
41      public Object getService(QName serviceName) {
42          if (overridableServices.contains(serviceName.getLocalPart())) {
43              return super.getService(serviceName);
44          }
45  //        else if (isKualiLookupable(serviceName)) {
46  //            return fetchKualiLookupable(serviceName);
47  //        }
48          else if (serviceName.getLocalPart().indexOf("Lookupable") > -1) {
49              return super.getService(serviceName);
50          }
51          else if (serviceName.getLocalPart().contains("InactivationBlockingDetectionService")) {
52              return super.getService(serviceName);
53          }
54          return null;
55      }
56  
57  //    protected boolean isKualiLookupable(QName serviceName) {
58  //        return serviceName.getLocalPart().matches(LOOKUPABLE_REGEX);
59  //    }
60  //
61  //    protected Object fetchKualiLookupable(QName serviceName) {
62  //        String lookupableName = serviceName.getLocalPart();
63  //        WorkflowLookupable workflowLookupable = null;
64  //        if (lookupableName.indexOf(".") > 0) {
65  //            String lookupableImplName = lookupableName.substring(0, lookupableName.indexOf("("));
66  //            WorkflowLookupableImpl workflowLookupableImpl = (WorkflowLookupableImpl) getBeanFactory().getBean(lookupableImplName);
67  //            String allConversions = lookupableName.substring(lookupableName.indexOf("(") + 1, lookupableName.indexOf(")"));
68  //            String fieldConversions = null;
69  //            String lookupParameters = null;
70  //            if (allConversions.indexOf(CONVERSIONS_DELIMITER) > 0) {
71  //                fieldConversions = allConversions.substring(0, allConversions.indexOf(CONVERSIONS_DELIMITER));
72  //                lookupParameters = allConversions.substring(allConversions.indexOf(CONVERSIONS_DELIMITER) + 1);
73  //            }
74  //            else {
75  //                fieldConversions = allConversions;
76  //            }
77  //            workflowLookupableImpl.setFieldConversions(fieldConversions);
78  //            workflowLookupableImpl.setLookupParameters(lookupParameters);
79  //            workflowLookupable = (WorkflowLookupable) super.wrap(serviceName, workflowLookupableImpl);
80  //        }
81  //        else {
82  //            workflowLookupable = (WorkflowLookupable) super.getService(serviceName);
83  //        }
84  //        return workflowLookupable;
85  //    }
86  
87      public Set<String> getOverridableServices() {
88          return overridableServices;
89      }
90  
91      public void setOverridableServices(Set<String> overridableServices) {
92          this.overridableServices = overridableServices;
93      }
94  
95  }