001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.openjpa.meta;
020:
021: import java.io.File;
022: import java.util.Arrays;
023: import java.util.Collection;
024: import java.util.HashSet;
025: import java.util.Map;
026: import java.util.Set;
027:
028: import org.apache.commons.lang.StringUtils;
029: import org.apache.openjpa.conf.OpenJPAConfiguration;
030: import org.apache.openjpa.lib.log.Log;
031: import org.apache.openjpa.lib.meta.ClassArgParser;
032: import serp.util.Strings;
033:
034: /**
035: * Abstract {@link MetaDataFactory} that provides default implementations
036: * of many methods.
037: *
038: * @author Abe White
039: */
040: public abstract class AbstractMetaDataFactory implements
041: MetaDataFactory {
042:
043: protected MetaDataRepository repos = null;
044: protected transient Log log = null;
045: protected File dir = null;
046: protected int store = STORE_DEFAULT;
047: protected boolean strict = false;
048: protected Set types = null;
049:
050: /**
051: * Set of persistent type names supplied by user.
052: */
053: public void setTypes(Set types) {
054: this .types = types;
055: }
056:
057: /**
058: * Set of semicolon-separated persistent type names supplied by user via
059: * auto-configuration.
060: */
061: public void setTypes(String types) {
062: this .types = (StringUtils.isEmpty(types)) ? null : new HashSet(
063: Arrays.asList(Strings.split(types, ";", 0)));
064: }
065:
066: public void setRepository(MetaDataRepository repos) {
067: this .repos = repos;
068: if (repos != null)
069: log = repos.getConfiguration().getLog(
070: OpenJPAConfiguration.LOG_METADATA);
071: }
072:
073: public void setStoreDirectory(File dir) {
074: this .dir = dir;
075: }
076:
077: public void setStoreMode(int store) {
078: this .store = store;
079: }
080:
081: public void setStrict(boolean strict) {
082: this .strict = strict;
083: }
084:
085: public boolean store(ClassMetaData[] metas,
086: QueryMetaData[] queries, SequenceMetaData[] seqs, int mode,
087: Map output) {
088: return false;
089: }
090:
091: public boolean drop(Class[] cls, int mode, ClassLoader envLoader) {
092: return false;
093: }
094:
095: public Set getPersistentTypeNames(boolean devpath,
096: ClassLoader envLoader) {
097: return types;
098: }
099:
100: public Class getQueryScope(String queryName, ClassLoader loader) {
101: return null;
102: }
103:
104: public Class getResultSetMappingScope(String resultSetMappingName,
105: ClassLoader loader) {
106: return null;
107: }
108:
109: public ClassArgParser newClassArgParser() {
110: return new ClassArgParser();
111: }
112:
113: public void clear() {
114: }
115:
116: public void addClassExtensionKeys(Collection exts) {
117: }
118:
119: public void addFieldExtensionKeys(Collection exts) {
120: }
121: }
|