]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ParameterRef.java
Remove unnecessary check causing failures
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / ParameterRef.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.argeo.slc.core.execution;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.springframework.beans.factory.FactoryBean;
21
22 public class ParameterRef implements FactoryBean {
23 private final static Log log = LogFactory.getLog(ParameterRef.class);
24
25 private InstantiationManager instantiationManager;
26 private String name;
27
28 /** Cached object. */
29 private Object object;
30
31 public ParameterRef() {
32 }
33
34 public ParameterRef(String name) {
35 this.name = name;
36 }
37
38 public Object getObject() throws Exception {
39 if (log.isTraceEnabled())
40 log.debug("Parameter ref called for " + name);
41
42 if (object == null)
43 object = instantiationManager.getInitializingFlowParameter(name);
44 return object;
45 }
46
47 public Class<?> getObjectType() {
48 if (object == null)
49 return instantiationManager.getInitializingFlowParameterClass(name);
50 else
51 return object.getClass();
52 }
53
54 public boolean isSingleton() {
55 return true;
56 }
57
58 public void setInstantiationManager(
59 InstantiationManager instantiationManager) {
60 this.instantiationManager = instantiationManager;
61 }
62
63 public void setName(String name) {
64 this.name = name;
65 }
66
67 }