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