1 21 package oracle.toplink.essentials.internal.ejb.cmp3.metadata; 23 24 import java.util.HashMap ; 25 26 import oracle.toplink.essentials.logging.SessionLog; 27 import oracle.toplink.essentials.internal.sessions.AbstractSession; 28 29 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.MetadataAccessor; 30 31 38 public class MetadataLogger { 39 public static final String ALIAS = "metadata_default_alias"; 40 public static final String MAP_KEY_ATTRIBUTE_NAME = "metadata_default_map_key_attribute_name"; 41 public static final String IGNORE_BASIC_FETCH_LAZY = "annotation_warning_ignore_basic_fetch_lazy"; 42 public static final String IGNORE_GET_METHOD = "annotation_warning_ignore_get_method"; 43 public static final String IGNORE_SECONDARY_TABLE = "annotation_warning_ignore_secondary_table"; 44 45 public static final String TABLE_NAME = "metadata_default_table_name"; 46 public static final String TABLE_SCHEMA = "metadata_default_table_schema"; 47 public static final String TABLE_CATALOG = "metadata_default_table_catalog"; 48 49 public static final String JOIN_TABLE_NAME = "metadata_default_join_table_name"; 50 public static final String JOIN_TABLE_SCHEMA = "metadata_default_join_table_schema"; 51 public static final String JOIN_TABLE_CATALOG = "metadata_default_join_table_catalog"; 52 53 public static final String COLUMN = "metadata_default_column"; 54 public static final String PK_COLUMN = "metadata_default_pk_column"; 55 public static final String FK_COLUMN = "metadata_default_fk_column"; 56 public static final String SOURCE_PK_COLUMN = "metadata_default_source_pk_column"; 57 public static final String SOURCE_FK_COLUMN = "metadata_default_source_fk_column"; 58 public static final String TARGET_PK_COLUMN = "metadata_default_target_pk_column"; 59 public static final String TARGET_FK_COLUMN = "metadata_default_target_fk_column"; 60 public static final String DISCRIMINATOR_COLUMN = "metadata_default_discriminator_column"; 61 public static final String INHERITANCE_PK_COLUMN = "metadata_default_inheritance_pk_column"; 62 public static final String INHERITANCE_FK_COLUMN = "metadata_default_inheritance_fk_column"; 63 public static final String SECONDARY_TABLE_PK_COLUMN = "metadata_default_secondary_table_pk_column"; 64 public static final String SECONDARY_TABLE_FK_COLUMN = "metadata_default_secondary_table_fk_column"; 65 66 public static final String ONE_TO_ONE_MAPPING = "metadata_default_one_to_one_mapping"; 67 public static final String ONE_TO_MANY_MAPPING = "metadata_default_one_to_many_mapping"; 68 public static final String ONE_TO_ONE_MAPPING_REFERENCE_CLASS = "metadata_default_one_to_one_reference_class"; 69 public static final String ONE_TO_MANY_MAPPING_REFERENCE_CLASS = "metadata_default_one_to_many_reference_class"; 70 public static final String MANY_TO_ONE_MAPPING_REFERENCE_CLASS = "metadata_default_many_to_one_reference_class"; 71 public static final String MANY_TO_MANY_MAPPING_REFERENCE_CLASS = "metadata_default_many_to_many_reference_class"; 72 73 public static String IGNORE_TABLE; 75 public static String IGNORE_QUERY; 76 public static String IGNORE_MAPPING; 77 public static String IGNORE_ID_CLASS; 78 public static String IGNORE_PRIMARY_KEY; 79 public static String IGNORE_EMBEDDED_ID; 80 public static String IGNORE_INHERITANCE; 81 public static String IGNORE_VERSION_LOCKING; 82 83 protected AbstractSession session; 84 protected HashMap ctxStrings; 85 86 public MetadataLogger(AbstractSession session) { 87 this.session = session; 88 ctxStrings = new HashMap (); 89 initSharedContextStrings(); 90 populateContextStrings(); 91 } 92 93 97 protected String getLoggingContextString(String context) { 98 return (String ) ctxStrings.get(context); 99 } 100 101 105 protected void initSharedContextStrings() { 106 IGNORE_TABLE = "annotation_warning_ignore_table"; 107 IGNORE_QUERY = "annotation_warning_ignore_query"; 108 IGNORE_MAPPING = "annotation_warning_ignore_mapping"; 109 IGNORE_ID_CLASS = "annotation_warning_ignore_id_class"; 110 IGNORE_PRIMARY_KEY = "annotation_warning_ignore_primary_key"; 111 IGNORE_EMBEDDED_ID = "annotation_warning_ignore_embedded_id"; 112 IGNORE_INHERITANCE = "annotation_warning_ignore_inheritance"; 113 IGNORE_VERSION_LOCKING = "annotation_warning_ignore_version_locking"; 114 } 115 116 120 public void log(int level, String ctx, Object [] params) { 121 session.log(level, SessionLog.EJB_ANNOTATION, getLoggingContextString(ctx), params); 122 } 123 124 128 public void logConfigMessage(String ctx, MetadataAccessor accessor, Object param) { 129 log(SessionLog.CONFIG, ctx, new Object [] { accessor.getAnnotatedElement(), param }); 130 } 131 132 136 public void logConfigMessage(String ctx, MetadataDescriptor md, Object param) { 137 log(SessionLog.CONFIG, ctx, new Object [] { md.getJavaClass(), param }); 138 } 139 140 144 public void logConfigMessage(String ctx, Object object) { 145 log(SessionLog.CONFIG, ctx, new Object [] { object }); 146 } 147 148 152 public void logConfigMessage(String ctx, Object param1, Object param2) { 153 log(SessionLog.CONFIG, ctx, new Object [] { param1, param2 }); 154 } 155 156 160 public void logWarningMessage(String ctx, MetadataAccessor accessor) { 161 log(SessionLog.WARNING, ctx, new Object [] { accessor.getJavaClass(), accessor.getAttributeName() }); 162 } 163 164 168 public void logWarningMessage(String ctx, Object param) { 169 log(SessionLog.WARNING, ctx, new Object [] { param }); 170 } 171 172 176 public void logWarningMessage(String ctx, Object param1, Object param2) { 177 log(SessionLog.WARNING, ctx, new Object [] { param1, param2 }); 178 } 179 180 184 public void logWarningMessage(String ctx, Object param1, Object param2, Object param3) { 185 log(SessionLog.WARNING, ctx, new Object [] {param1, param2, param3}); 186 } 187 188 194 protected void populateContextStrings() { 195 ctxStrings.put(ALIAS, ALIAS); 196 ctxStrings.put(MAP_KEY_ATTRIBUTE_NAME, MAP_KEY_ATTRIBUTE_NAME); 197 198 ctxStrings.put(TABLE_NAME, TABLE_NAME); 199 ctxStrings.put(TABLE_SCHEMA, TABLE_SCHEMA); 200 ctxStrings.put(TABLE_CATALOG, TABLE_CATALOG); 201 202 ctxStrings.put(JOIN_TABLE_NAME, JOIN_TABLE_NAME); 203 ctxStrings.put(JOIN_TABLE_SCHEMA, JOIN_TABLE_SCHEMA); 204 ctxStrings.put(JOIN_TABLE_CATALOG, JOIN_TABLE_CATALOG); 205 206 ctxStrings.put(COLUMN, COLUMN); 207 ctxStrings.put(PK_COLUMN, PK_COLUMN); 208 ctxStrings.put(FK_COLUMN, FK_COLUMN); 209 ctxStrings.put(SOURCE_PK_COLUMN, SOURCE_PK_COLUMN); 210 ctxStrings.put(SOURCE_FK_COLUMN, SOURCE_FK_COLUMN); 211 ctxStrings.put(TARGET_PK_COLUMN, TARGET_PK_COLUMN); 212 ctxStrings.put(TARGET_FK_COLUMN, TARGET_FK_COLUMN); 213 ctxStrings.put(DISCRIMINATOR_COLUMN, DISCRIMINATOR_COLUMN); 214 ctxStrings.put(INHERITANCE_PK_COLUMN, INHERITANCE_PK_COLUMN); 215 ctxStrings.put(INHERITANCE_FK_COLUMN, INHERITANCE_FK_COLUMN); 216 ctxStrings.put(SECONDARY_TABLE_PK_COLUMN, SECONDARY_TABLE_PK_COLUMN); 217 ctxStrings.put(SECONDARY_TABLE_FK_COLUMN, SECONDARY_TABLE_FK_COLUMN); 218 219 ctxStrings.put(ONE_TO_ONE_MAPPING, ONE_TO_ONE_MAPPING); 220 ctxStrings.put(ONE_TO_MANY_MAPPING, ONE_TO_MANY_MAPPING); 221 ctxStrings.put(ONE_TO_ONE_MAPPING_REFERENCE_CLASS, ONE_TO_ONE_MAPPING_REFERENCE_CLASS); 222 ctxStrings.put(ONE_TO_MANY_MAPPING_REFERENCE_CLASS, ONE_TO_MANY_MAPPING_REFERENCE_CLASS); 223 ctxStrings.put(MANY_TO_ONE_MAPPING_REFERENCE_CLASS, MANY_TO_ONE_MAPPING_REFERENCE_CLASS); 224 ctxStrings.put(MANY_TO_MANY_MAPPING_REFERENCE_CLASS, MANY_TO_MANY_MAPPING_REFERENCE_CLASS); 225 226 ctxStrings.put(IGNORE_GET_METHOD, IGNORE_GET_METHOD); 227 ctxStrings.put(IGNORE_SECONDARY_TABLE, IGNORE_SECONDARY_TABLE); 228 229 ctxStrings.put(IGNORE_TABLE, IGNORE_TABLE); 230 ctxStrings.put(IGNORE_QUERY, IGNORE_QUERY); 231 ctxStrings.put(IGNORE_MAPPING, IGNORE_MAPPING); 232 ctxStrings.put(IGNORE_ID_CLASS, IGNORE_ID_CLASS); 233 ctxStrings.put(IGNORE_PRIMARY_KEY, IGNORE_PRIMARY_KEY); 234 ctxStrings.put(IGNORE_EMBEDDED_ID, IGNORE_EMBEDDED_ID); 235 ctxStrings.put(IGNORE_INHERITANCE, IGNORE_INHERITANCE); 236 ctxStrings.put(IGNORE_VERSION_LOCKING, IGNORE_VERSION_LOCKING); 237 ctxStrings.put(IGNORE_BASIC_FETCH_LAZY, IGNORE_BASIC_FETCH_LAZY); 238 239 } 240 241 245 public void setSession(AbstractSession session) { 246 this.session = session; 247 } 248 } 249 | Popular Tags |