001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Rodrigo Westrupp
028: */
029:
030: package com.caucho.amber.cfg;
031:
032: import com.caucho.amber.manager.AmberPersistenceUnit;
033: import com.caucho.amber.type.AbstractEnhancedType;
034: import com.caucho.bytecode.JAnnotation;
035: import com.caucho.bytecode.JClass;
036: import com.caucho.config.ConfigException;
037: import com.caucho.util.L10N;
038:
039: import java.sql.SQLException;
040: import java.util.logging.Logger;
041:
042: /**
043: * Configuration for a mapped superclass type
044: */
045: public class MappedSuperIntrospector extends BaseConfigIntrospector {
046: private static final L10N L = new L10N(
047: MappedSuperIntrospector.class);
048: private static final Logger log = Logger
049: .getLogger(MappedSuperIntrospector.class.getName());
050:
051: // HashMap<String, MappedSuperType> _mappedSuperMap
052: // = new HashMap<String, MappedSuperType>();
053:
054: /**
055: * Creates the introspector.
056: */
057: public MappedSuperIntrospector(AmberPersistenceUnit persistenceUnit) {
058: super (persistenceUnit);
059: }
060:
061: /**
062: * Returns true for mapped superclass type.
063: */
064: public boolean isMappedSuper(JClass type) {
065: getInternalMappedSuperclassConfig(type, _annotationCfg);
066: JAnnotation mappedSuperAnn = _annotationCfg.getAnnotation();
067: MappedSuperclassConfig mappedSuperConfig = _annotationCfg
068: .getMappedSuperclassConfig();
069:
070: return (!_annotationCfg.isNull());
071: }
072:
073: /**
074: * Introspects.
075: */
076: //XXX: public MappedSuperType introspect(JClass type)
077: public AbstractEnhancedType introspect(JClass type)
078: throws ConfigException, SQLException {
079: return null;
080:
081: /* XXX:
082: String typeName = type.getName();
083:
084: MappedSuperType mappedSuperType = _mappedSuperMap.get(typeName);
085:
086: if (mappedSuperType != null)
087: return mappedSuperType;
088:
089: try {
090: mappedSuperType = _persistenceUnit.createMappedSuper(typeName, type);
091: _mappedSuperMap.put(typeName, mappedSuperType);
092:
093: boolean isField = isField(type, mappedSuperConfig);
094:
095: if (isField)
096: mappedSuperType.setFieldAccess(true);
097:
098: mappedSuperType.setInstanceClassName(type.getName() +
099: "__ResinExt");
100: mappedSuperType.setEnhanced(true);
101:
102: if (isField)
103: introspectFields(_persistenceUnit, mappedSuperType, null,
104: type, entityConfig, false);
105: else
106: introspectMethods(_persistenceUnit, mappedSuperType, null,
107: type, entityConfig);
108:
109: } catch (ConfigException e) {
110: mappedSuperType.setConfigException(e);
111:
112: throw e;
113: } catch (SQLException e) {
114: mappedSuperType.setConfigException(e);
115:
116: throw e;
117: } catch (RuntimeException e) {
118: mappedSuperType.setConfigException(e);
119:
120: throw e;
121: }
122:
123: return mappedSuperType;
124: */
125: }
126: }
|