001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.kfs.context;
017:
018: import java.util.List;
019:
020: import javax.xml.namespace.QName;
021:
022: import org.kuali.core.workflow.KFSResourceLoader;
023: import org.kuali.rice.definition.ObjectDefinition;
024: import org.kuali.rice.resourceloader.BaseResourceLoader;
025: import org.kuali.rice.resourceloader.ResourceLoader;
026:
027: /**
028: * A ResourceLoader for the KFS plugin for KEW. Essentially, this will load the KFS
029: * Spring Context and then delegate calls to the KFSResourceLoader which is loaded
030: * by Spring.
031: *
032: * @author Eric Westfall
033: */
034: public class KFSPluginResourceLoader extends BaseResourceLoader {
035:
036: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
037: .getLogger(KFSPluginResourceLoader.class);
038:
039: private ResourceLoader delegateResourceLoader;
040:
041: public KFSPluginResourceLoader() {
042: super (new QName("KFSPluginResourceLoader"));
043: }
044:
045: @Override
046: public void start() throws Exception {
047: if (isStarted()) {
048: LOG.warn("KFSPluginResourceLoader already started.");
049: return;
050: }
051: SpringContext.initializePluginApplicationContext();
052: ResourceLoader kfsResourceLoader = SpringContext
053: .getBean(KFSResourceLoader.class);
054: if (kfsResourceLoader == null) {
055: throw new RuntimeException(
056: "Could not locate the KFSResourceLoader");
057: }
058: delegateResourceLoader = kfsResourceLoader;
059: super .start();
060: }
061:
062: @Override
063: public void stop() throws Exception {
064: SpringContext.close();
065: delegateResourceLoader = null;
066: super .stop();
067: }
068:
069: public void addResourceLoader(ResourceLoader arg0) {
070: delegateResourceLoader.addResourceLoader(arg0);
071: }
072:
073: public void addResourceLoaderFirst(ResourceLoader arg0) {
074: delegateResourceLoader.addResourceLoaderFirst(arg0);
075: }
076:
077: public String getContents(String arg0, boolean arg1) {
078: return delegateResourceLoader.getContents(arg0, arg1);
079: }
080:
081: public Object getObject(ObjectDefinition arg0) {
082: return delegateResourceLoader.getObject(arg0);
083: }
084:
085: public ResourceLoader getResourceLoader(QName arg0) {
086: return delegateResourceLoader.getResourceLoader(arg0);
087: }
088:
089: public List<QName> getResourceLoaderNames() {
090: return delegateResourceLoader.getResourceLoaderNames();
091: }
092:
093: public List<ResourceLoader> getResourceLoaders() {
094: return delegateResourceLoader.getResourceLoaders();
095: }
096:
097: public Object getService(QName arg0) {
098: if (delegateResourceLoader == null) {
099: return null;
100: }
101: return delegateResourceLoader.getService(arg0);
102: }
103:
104: public void removeResourceLoader(QName arg0) {
105: delegateResourceLoader.removeResourceLoader(arg0);
106: }
107:
108: }
|