001 package com.hammurapi.config.runtime;
002
003 import java.net.URL;
004
005 import com.hammurapi.config.bootstrap.TokenExpander.TokenSource;
006 import com.hammurapi.util.Context;
007
008
009 /**
010 * Factory parameter class.
011 * @author Pavel Vlasov
012 *
013 */
014 public class FactoryConfig implements Cloneable {
015
016 private URL contextUrl;
017 private ClassLoader classLoader;
018 private TokenSource tokens;
019 private Context context;
020 private String[] profilePath;
021 private ContextFactory contextFactory = new DefaultContextFactory();
022
023 private Object[] objectPath;
024
025 /**
026 * @return Path to the object currently being configured (last element, if already instantiated) from the root object (first element).
027 */
028 public Object[] getObjectPath() {
029 return objectPath;
030 }
031
032 /**
033 * @param objectPath Path to the object currently being configured (last element, if already instantiated) from the root object (first element).
034 */
035 public void setObjectPath(Object[] objectPath) {
036 this.objectPath = objectPath;
037 }
038
039 public void addToObjectPath(Object obj) {
040 if (objectPath==null) {
041 objectPath = new Object[] {obj};
042 } else {
043 Object[] newObjectPath = new Object[objectPath.length+1];
044 System.arraycopy(objectPath, 0, newObjectPath, 0, objectPath.length);
045 newObjectPath[objectPath.length] = obj;
046 objectPath = newObjectPath;
047 }
048 }
049
050 /**
051 * @return Context factory.
052 */
053 public ContextFactory getContextFactory() {
054 return contextFactory;
055 }
056
057 /**
058 * @param contextFactory Context factory.
059 */
060 public void setContextFactory(ContextFactory contextFactory) {
061 this.contextFactory = contextFactory;
062 }
063
064 /**
065 * @return Context URL for classpath entries.
066 */
067 public URL getContextUrl() {
068 return contextUrl;
069 }
070
071 /**
072 * @param contextUrl Context URL for classpath entries.
073 */
074 public void setContextUrl(URL contextUrl) {
075 this.contextUrl = contextUrl;
076 }
077
078 /**
079 * @return Class loader.
080 */
081 public ClassLoader getClassLoader() {
082 return classLoader;
083 }
084
085 /**
086 * @param classLoader Class loader.
087 */
088 public void setClassLoader(ClassLoader classLoader) {
089 this.classLoader = classLoader;
090 }
091
092 /**
093 * @return Expansion tokens.
094 */
095 public TokenSource getTokenSource() {
096 return tokens;
097 }
098
099 /**
100 * @param tokens Expansion tokens.
101 */
102 public void setTokenSource(TokenSource tokens) {
103 this.tokens = tokens;
104 }
105
106 /**
107 * @return Service lookup.
108 */
109 public Context getContext() {
110 return context;
111 }
112
113 /**
114 * @param lookup Service lookup.
115 */
116 public void setContext(Context context) {
117 this.context = context;
118 }
119
120 /**
121 * @return Profile path.
122 */
123 public String[] getProfilePath() {
124 return profilePath;
125 }
126
127 /**
128 * @param profilePath Profile path.
129 */
130 public void setProfilePath(String... profilePath) {
131 this.profilePath = profilePath;
132 }
133
134 @Override
135 public Object clone() throws CloneNotSupportedException {
136 return (FactoryConfig) super.clone();
137 }
138
139 }