001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.clientapp;
018:
019: import javax.naming.Context;
020: import javax.naming.NamingException;
021: import javax.sql.DataSource;
022:
023: import edu.iu.uis.eden.exception.WorkflowException;
024:
025: /**
026: * Used in the ejb days to provide easy access to jndi resources
027: *
028: * @author rkirkend
029: *
030: * @deprecated just don't use this.
031: */
032: public class ResourceLocator {
033: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
034: .getLogger(ResourceLocator.class);
035: private Context ctx;
036: private String env;
037: private String transactional;
038: private String appCode;
039: private String businessClass;
040: private Object postProcessor;
041: private boolean doit;
042:
043: protected ResourceLocator(Context ctx) throws WorkflowException {
044: this .ctx = ctx;
045: this .env = this .getValue("deployEnvironment");
046: this .transactional = this .getValue("transactional");
047: this .appCode = this .getValue("appCode");
048: this .businessClass = this .getValue("busClassLocation");
049: }
050:
051: public ResourceLocator(String env, String transactional,
052: String appCode, String businessClass) {
053: this .env = env;
054: this .transactional = transactional;
055: this .appCode = appCode;
056: this .businessClass = businessClass;
057: }
058:
059: public String getValue(String key) throws WorkflowException {
060: try {
061: return (String) ctx.lookup("java:comp/env/" + key);
062: } catch (NamingException ex) {
063: LOG.error("didn't find value for key (" + key
064: + ") under context java:comp/env/ + key", ex);
065: throw new WorkflowException("didn't find value for key ("
066: + key + ") under context java:comp/env/ + key");
067: }
068: }
069:
070: public DataSource getDataSource(String name)
071: throws WorkflowException {
072: try {
073: return (DataSource) ctx
074: .lookup("java:comp/env/jdbc/" + name);
075: } catch (NamingException ex) {
076: LOG.error("didn't find a DataSource for name (" + name
077: + ") under context java:comp/env/jdbc/ + key", ex);
078: throw new WorkflowException(
079: "didn't find a DataSource for name ("
080: + name
081: + ") under context java:comp/env/jdbc/ + key");
082: }
083: }
084:
085: public String getEnv() {
086: return env;
087: }
088:
089: public String getTransactional() {
090: return transactional;
091: }
092:
093: public String getAppCode() {
094: return appCode;
095: }
096:
097: public String getBusinessClass() {
098: return businessClass;
099: }
100:
101: public boolean isDoit() {
102: return doit;
103: }
104:
105: public void setDoit(boolean doit) {
106: this .doit = doit;
107: }
108:
109: public Object getPostProcessor() {
110: return postProcessor;
111: }
112:
113: public void setPostProcessor(Object postProcessor) {
114: this.postProcessor = postProcessor;
115: }
116: }
|