001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.compass.core.config;
018:
019: /**
020: * Compass environment settings constants class. Additional environemnt setting
021: * can be found at: {@link org.compass.core.lucene.LuceneEnvironment}.
022: *
023: * @author kimchy
024: */
025: public class CompassEnvironment {
026:
027: /**
028: * Determines the connection string (like file path)
029: */
030: public static final String CONNECTION = "compass.engine.connection";
031:
032: /**
033: * Expert. The sub context of the connection.
034: */
035: public static final String CONNECTION_SUB_CONTEXT = "compass.engine.connection.subContext";
036:
037: /**
038: * The name of the compass instance. If Jndi is enabled, will also be the name
039: * under which compass will register.
040: */
041: public static final String NAME = "compass.name";
042:
043: public static final String MAPPING_PREFIX = "compass.mapping";
044:
045: /**
046: * Settings for global rregistration and handling of property accessors.
047: * <p/>
048: * This is a group settings, you can set more than one property accessor setting.
049: */
050: public abstract class PropertyAccessor {
051:
052: /**
053: * The prefix for property accessor group settings
054: */
055: public static final String PREFIX = "compass.propertyAccessor";
056:
057: /**
058: * The fully qualified class name of the {@link PropertyAccessor}.
059: */
060: public static final String TYPE = "type";
061:
062: /**
063: * The group name of the default group. It will be used when no
064: * accessor is defined.
065: */
066: public static final String DEFAULT_GROUP = "default";
067: }
068:
069: /**
070: * Converter settings
071: */
072: public abstract class Converter {
073:
074: /**
075: * The prefix used for converter groups.
076: */
077: public static final String PREFIX = "compass.converter";
078:
079: /**
080: * The fully qualified class name of the {@link Converter} implementation.
081: */
082: public static final String TYPE = "type";
083:
084: /**
085: * The class that the converter will be registered under, ADVANCE USAGE.
086: */
087: public static final String REGISTER_CLASS = "registerClass";
088:
089: /**
090: * Default compass short hand types. It means that instead of defining a converter of
091: * type <code>org.compass.converter.basic.DateConverter</code>, you can use the
092: * shorthand name.
093: */
094: public abstract class DefaultTypes {
095:
096: public abstract class Simple {
097:
098: public static final String DATE = "date";
099:
100: public static final String CALENDAR = "calendar";
101:
102: public static final String LONG = "long";
103:
104: public static final String BOOLEAN = "boolean";
105:
106: public static final String BYTE = "byte";
107:
108: public static final String CHAR = "char";
109:
110: public static final String DOUBLE = "double";
111:
112: public static final String FLOAT = "float";
113:
114: public static final String INTEGER = "int";
115:
116: public static final String SHORT = "short";
117:
118: public static final String STRING = "string";
119:
120: public static final String STRINGBUFFER = "stringbuffer";
121:
122: public static final String URL = "url";
123:
124: public static final String BIGDECIMAL = "bigdecimal";
125:
126: public static final String BIGINTEGER = "biginteger";
127:
128: public static final String ENUM = "enum";
129:
130: public static final String STRINGBUILDER = "stringbuilder";
131: }
132:
133: public abstract class Extendend {
134:
135: public static final String FILE = "file";
136:
137: public static final String SQL_DATE = "sqldate";
138:
139: public static final String SQL_TIME = "sqltime";
140:
141: public static final String SQL_TIMESTAMP = "sqltimestamp";
142:
143: public static final String READER = "reader";
144:
145: public static final String PRIMITIVE_BYTE_ARRAY = "primitivebytearray";
146:
147: public static final String OBJECT_BYTE_ARRAY = "objectbytearray";
148:
149: public static final String INPUT_STREAM = "binary";
150:
151: public static final String LOCALE = "locale";
152: }
153:
154: }
155:
156: /**
157: * The default name types that compass default converters will be registered under.
158: */
159: public abstract class DefaultTypeNames {
160:
161: public abstract class Simple {
162:
163: public static final String DATE = "date";
164:
165: public static final String CALENDAR = "calendar";
166:
167: public static final String LONG = "long";
168:
169: public static final String BOOLEAN = "boolean";
170:
171: public static final String BYTE = "byte";
172:
173: public static final String CHAR = "char";
174:
175: public static final String DOUBLE = "double";
176:
177: public static final String FLOAT = "float";
178:
179: public static final String INTEGER = "int";
180:
181: public static final String SHORT = "short";
182:
183: public static final String STRING = "string";
184:
185: public static final String STRINGBUFFER = "stringbuffer";
186:
187: public static final String STRINGBUILDER = "stringbuilder";
188:
189: public static final String ENUM = "enum";
190:
191: public static final String URL = "url";
192:
193: public static final String URI = "uri";
194:
195: public static final String BIGDECIMAL = "bigdecimal";
196:
197: public static final String BIGINTEGER = "biginteger";
198: }
199:
200: public abstract class Extendend {
201:
202: public static final String FILE = "file";
203:
204: public static final String SQL_DATE = "sqldate";
205:
206: public static final String SQL_TIME = "sqltime";
207:
208: public static final String SQL_TIMESTAMP = "sqltimestamp";
209:
210: public static final String READER = "reader";
211:
212: public static final String PRIMITIVE_BYTE_ARRAY = "primitivebytearray";
213:
214: public static final String OBJECT_BYTE_ARRAY = "objectbytearray";
215:
216: public static final String INPUT_STREAM = "binary";
217:
218: public static final String LOCALE = "locale";
219: }
220:
221: public abstract class Mapping {
222:
223: public static final String RAW_RESOURCE_MAPPING = "rawResourceMapping";
224:
225: public static final String XML_OBJECT_MAPPING = "xmlObjectMapping";
226:
227: public static final String XML_PROPERTY_MAPPING = "xmlPropertyMapping";
228:
229: public static final String XML_ID_MAPPING = "xmlIdMapping";
230:
231: public static final String XML_CONTENT_MAPPING = "xmlContentMapping";
232:
233: public static final String CLASS_MAPPING = "classMapping";
234:
235: public static final String CLASS_PROPERTY_MAPPING = "classPropertyMapping";
236:
237: public static final String CLASS_ID_PROPERTY_MAPPING = "classIdPropertyMapping";
238:
239: public static final String COMPONENT_MAPPING = "component";
240:
241: public static final String REFERENCE_MAPPING = "referenceMapping";
242:
243: public static final String COLLECTION_MAPPING = "collectionMapping";
244:
245: public static final String ARRAY_MAPPING = "arrayMapping";
246:
247: public static final String CONSTANT_MAPPING = "constantMapping";
248:
249: public static final String PARENT_MAPPING = "parentMapping";
250:
251: public static final String CASCADE_MAPPING = "cascadeMapping";
252: }
253:
254: public abstract class Dynamic {
255:
256: public static final String JEXL = "jexl";
257:
258: public static final String VELOCITY = "velocity";
259:
260: public static final String JAKARTA_EL = "el";
261:
262: public static final String OGNL = "ognl";
263:
264: public static final String GROOVY = "groovy";
265: }
266: }
267:
268: /**
269: * Settings applicable to xml content mapping converters
270: */
271: public abstract class XmlContent {
272:
273: public static final String TYPE = "xmlContentConverter.type";
274:
275: public static final String WRAPPER = "xmlContentConverter.wrapper";
276:
277: public static final String WRAPPER_SINGLETON = "singleton";
278: public static final String WRAPPER_POOL = "pool";
279: public static final String WRAPPER_PROTOTYPE = "prototype";
280:
281: /**
282: * The minimum pool size. Applies to pooled xml content converters.
283: */
284: public static final String MIN_POOL_SIZE = "xmlContentConverter.minPoolSize";
285:
286: /**
287: * The maximum pool size. Applies to pooled xml content converters.
288: */
289: public static final String MAX_POOL_SIZE = "xmlContentConverter.maxPoolSize";
290: }
291:
292: /**
293: * Formatted settings that apply to all the default date and number types.
294: */
295: public abstract class Format {
296:
297: /**
298: * The format itself. For data format structure, please see
299: * {@link java.text.SimpleDateFormat}. For number formats
300: * please see {@link java.text.DecimalFormat}.
301: */
302: public static final String FORMAT = "format";
303:
304: /**
305: * The locale used with the formatters.
306: */
307: public static final String LOCALE = "format.locale";
308:
309: /**
310: * The minimum pool size. Formatters are pooled for better
311: * performance.
312: */
313: public static final String MIN_POOL_SIZE = "format.minPoolSize";
314:
315: /**
316: * The maximum pool size. Formatters are pooled for better
317: * performance.
318: */
319: public static final String MAX_POOL_SIZE = "format.maxPoolSize";
320: }
321: }
322:
323: /* JNDI Settings */
324: public abstract class Jndi {
325:
326: /**
327: * If jndi registration is enabled
328: */
329: public static final String ENABLE = "compass.jndi.enable";
330:
331: /**
332: * JNDI initial context class, <code>Context.INITIAL_CONTEXT_FACTORY</code>
333: */
334: public static final String CLASS = "compass.jndi.class";
335:
336: /**
337: * JNDI provider URL, <code>Context.PROVIDER_URL</code>
338: */
339: public static final String URL = "compass.jndi.url";
340:
341: /**
342: * prefix for arbitrary JNDI <code>InitialContext</code> properties
343: */
344: public static final String PREFIX = "compass.jndi";
345:
346: }
347:
348: /* Transaction Settings */
349: public abstract class Transaction {
350:
351: /**
352: * Sets the transaction factory to be used (<code>LocalTransactionFactory</code>
353: * for example).
354: */
355: public static final String FACTORY = "compass.transaction.factory";
356:
357: /**
358: * For transaction factories that uses synchronization, commits the transaction in the
359: * <code>beforeCompletion</code> stage. Relevant transaction factories are JTA and Spring.
360: * <p/>
361: * Can have <code>true</code> or <code>false</code> values, defaults to <code>false</code>.
362: * <p/>
363: * <b>Must</b> be set when using a jdbc based index, and <b>must not</b> be used in other cases!.
364: */
365: public static final String COMMIT_BEFORE_COMPLETION = "compass.transaction.commitBeforeCompletion";
366:
367: /**
368: * <code>TransactionManagerLookup</code> implementor to use for obtaining
369: * the <code>TransactionManager</code>
370: */
371: public static final String MANAGER_LOOKUP = "compass.transaction.managerLookup";
372:
373: /**
374: * JNDI name of JTA <code>UserTransaction</code> object
375: */
376: public static final String USER_TRANSACTION = "compass.transaction.userTransactionName";
377:
378: /**
379: * Set whether to cache the JTA UserTransaction object fetched from JNDI.
380: * <p>Default is "true": UserTransaction lookup will only happen at startup,
381: * reusing the same UserTransaction handle for all transactions of all threads.
382: * This is the most efficient choice for all application servers that provide
383: * a shared UserTransaction object (the typical case).
384: * <p>Turn this flag off to enforce a fresh lookup of the UserTransaction
385: * for every transaction. This is only necessary for application servers
386: * that return a new UserTransaction for every transaction, keeping state
387: * tied to the UserTransaction object itself rather than the current thread.
388: */
389: public static final String CACHE_USER_TRANSACTION = "compass.transaction.cacheUserTransaction";
390:
391: /**
392: * The transaction isolation, can be one of the 4 constants values.
393: */
394: public static final String ISOLATION = "compass.transaction.isolation";
395:
396: /**
397: * The transaction isolation class name that will be used as the
398: * transaction. Overrides the TRANSACTION_ISOLATION if set.
399: */
400: public static final String ISOLATION_CLASS = "compass.transaction.isolation.class";
401:
402: /**
403: * Used as the value for the TRANSACTION_ISOLATION setting. Configures the
404: * transaction isolation level to have no support for transactions.
405: */
406: public static final String ISOLATION_NONE = "none";
407:
408: /**
409: * Used as the value for the TRANSACTION_ISOLATION setting. Configures the
410: * transaction isolation level to have a read uncommitted support for
411: * transactions. Dirty reads, non-repeatable reads and phantom reads can
412: * occur.
413: */
414: public static final String ISOLATION_READ_UNCOMMITTED = "read_uncommitted";
415:
416: /**
417: * Used as the value for the TRANSACTION_ISOLATION setting. Configures the
418: * transaction isolation level to have a read committed support for
419: * transactions. Dirty reads are prevented, non-repeatable reads and phantom
420: * reads can occur.
421: */
422: public static final String ISOLATION_READ_COMMITTED = "read_committed";
423:
424: /**
425: * Used as the value for the TRANSACTION_ISOLATION setting. Configures the
426: * transaction isolation level to have a repeatable read support for
427: * transactions. Dirty reads and non-repeatable reads are prevented, phantom
428: * reads can occur.
429: */
430: public static final String ISOLATION_REPEATABLE_READ = "repeatable_read";
431:
432: /**
433: * Used as the value for the TRANSACTION_ISOLATION setting. Configures the
434: * transaction isolation level to have a serializable support for
435: * transactions. Dirty reads, non-repeatable reads and phantom reads are
436: * prevented.
437: */
438: public static final String ISOLATION_SERIALIZABLE = "serializable";
439:
440: /**
441: * @deprecated Use LUCENE transaction isolation instead, defaults to it
442: */
443: public static final String ISOLATION_BATCH_INSERT = "batch_insert";
444:
445: /**
446: * Used as the value for the TRANSACTION_ISOLATION setting. Configures the
447: * transaction isolation level to have a lucene isolation level allowing for
448: * fast Create/Update/Delete operations whild read/search operations won't
449: * "see" the operations done during the transaction.
450: */
451: public static final String ISOLATION_LUCENE = "lucene";
452: /**
453: * When opening a session, Compass tries to automatically start a transaction
454: * and join it. This might mean that transaction settings when running within
455: * a managed environemnt won't take affect. The settings allows to disable
456: * the auto joining of a session to a transaction.
457: */
458: public static final String DISABLE_AUTO_JOIN_SESSION = "compass.transaction.disableAutoJoinSession";
459:
460: /**
461: * This settings allows to disable the default behaviour of the Local transaction factory to
462: * bind the session / transaction to the local thread. This means that each call to <code>beginTransaction</code>
463: * will create a new transaction and not join one if one is already in progress within the thread.
464: */
465: public static final String DISABLE_THREAD_BOUND_LOCAL_TRANSATION = "compass.transaction.disableThreadBoundLocalTransaction";
466: }
467:
468: /**
469: * Settings relating to the "all" property.
470: */
471: public abstract class All {
472:
473: /**
474: * Controls the name of the "all" property.
475: */
476: public static final String NAME = "compass.property.all";
477:
478: /**
479: * The default name for the "all" property. Defaults to <code>zzz-all</code>.
480: */
481: public static final String DEFAULT_NAME = "zzz-all";
482:
483: /**
484: * The term vector the will be used with the all property. Can be one out
485: * of: <code>no</code>, <code>yes</code>, <code>positions</code>,
486: * <code>offsets</code>, <code>positions_offsets</code>.
487: */
488: public static final String TERM_VECTOR = "compass.property.all.termVector";
489:
490: /**
491: * If all property will be globablly enabled or not. By default it is enabled.
492: *
493: * <p>Note, enabling and disabling all property can also be done on the mapping
494: * itself. If it is explicitly defined on the mappings, then it will override this
495: * setting.
496: */
497: public static final String ENABLED = "compass.property.all.enabled";
498:
499: /**
500: * Should the all property exclude the alias from all. Defaults to <code>true</code>.
501: *
502: * <p>Note, this can be explicitly set on the mapping level, which will then be used
503: * instead of this global setting.
504: */
505: public static final String EXCLUDE_ALIAS = "compass.property.all.excludeAlias";
506:
507: /**
508: * Should the all property omit norms. Defaults to <code>false</code>.
509: *
510: * <p>Note, this can be explicitly set on the mapping level, which will then be used
511: * instead of this global setting.
512: */
513: public static final String OMIT_NORMS = "compass.property.all.omitNorms";
514:
515: /**
516: * Should the all property honor boost settings on sepecific proeprties when searching.
517: * Defaults to <code>true</code>.
518: *
519: * <p>If set to <code>true</code>, more data will be saved in the index in case of a
520: * specific boost value, but searching experiance will be much improved.
521: */
522: public static final String BOOST_SUPPORT = "compass.property.all.boostSupport";
523: }
524:
525: /**
526: * Settings relating to the "alias" property
527: */
528: public abstract class Alias {
529:
530: /**
531: * The name of the "alias" proeprty.
532: */
533: public static final String NAME = "compass.property.alias";
534:
535: /**
536: * The default name for the "alias" property: <code>alias</code>.
537: */
538: public static final String DEFAULT_NAME = "alias";
539:
540: /**
541: * The name of the property where extended aliases are stored in the resource.
542: */
543: public static final String EXTENDED_ALIAS_NAME = "compass.property.extendedAlias";
544:
545: /**
546: * The default name for the extended alias property: <code>extendedAlias</code>.
547: */
548: public static final String DEFAULT_EXTENDED_ALIAS_NAME = "extendedAlias";
549: }
550:
551: public abstract class NamingStrategy {
552:
553: /**
554: * The naming strategy that will be used to save internal resource
555: * properties within a resource. A fully qualified class name of the naming
556: * strategy.
557: */
558: public static final String TYPE = "compass.property.naming";
559:
560: /**
561: * The fully qualified class name of the naming factory.
562: */
563: public static final String FACTORY_TYPE = "compass.property.naming.factory";
564: }
565:
566: /**
567: * Settings for cache management of objects / resources
568: */
569: public abstract class Cache {
570:
571: public abstract class FirstLevel {
572:
573: /**
574: * Sets the first level cache class.
575: */
576: public static final String TYPE = "compass.cache.first";
577: }
578: }
579:
580: public abstract class Osem {
581:
582: /**
583: * A setting for managed id index feature. When an internal managed id is
584: * created, it's index setting will be created using this global setting (if
585: * not defined locally in the mapping file). Possible values can be taken from
586: * {@link org.compass.core.Property.Index}, with the default value of <code>no</code>.
587: * (Note, the other possible value is <code>un_tokenized</code>).
588: */
589: public static final String MANAGED_ID_INDEX = "compass.osem.managedId.index";
590:
591: /**
592: * The default managed id for all property mappings based on {@link org.compass.core.mapping.osem.ClassPropertyMapping.ManagedId}
593: * configuration. Defaults to <code>AUTO</code>.
594: *
595: * <p>This can be overriden either by using class mapping level setting or property level mapping.
596: */
597: public static final String MANAGED_ID_DEFAULT = "compass.osem.managedId";
598:
599: /**
600: * Controls if the default support for un-marshalling within class mappings will
601: * default to <code>true</code> or <code>false</code> (unless it is explicitly set
602: * in the class mapping). Defaults to <code>true</code>.
603: */
604: public static final String SUPPORT_UNMARSHALL = "compass.osem.supportUnmarshall";
605: }
606:
607: /**
608: * Settings for cascading operations.
609: */
610: public abstract class Cascade {
611:
612: /**
613: * Disable all cascading operations.
614: */
615: public static final String DISABLE = "compass.cascade.disable";
616:
617: /**
618: * The fully qualified class name of a class implementing CompassCascadeFilter, which
619: * allows filtering of create/insert/delete cascade operations.
620: */
621: public static final String FILTER_TYPE = "compass.cascade.filter.type";
622: }
623:
624: public abstract class NullValue {
625:
626: /**
627: * When setting the globabl null value, some mappings might require to disable
628: * handling of null values for them. In such a case they can set the null value
629: * for this specific mappings to this constant value (<code>$disable$</code>).
630: */
631: public static final String DISABLE_NULL_VALUE_FOR_MAPPING = "$disable$";
632:
633: /**
634: * Allow to set a global null value that will be used. If this is set, the turning it off
635: * for specific mappings can be done by assiging them the value of
636: * {@link #DISABLE_NULL_VALUE_FOR_MAPPING}.
637: */
638: public static final String NULL_VALUE = "compass.nullvalue";
639: }
640:
641: /**
642: * A set of executor manager relevant settings.
643: */
644: public abstract class ExecutorManager {
645:
646: private static final String EXECUTOR_MANAGER_PREFIX = "compass.executorManager.";
647:
648: /**
649: * The type of the executor manager used. Can also be the FQN of the implementation.
650: * Defaults to the "concurrent" executor manager.
651: */
652: public static final String EXECUTOR_MANAGER_TYPE = EXECUTOR_MANAGER_PREFIX
653: + "type";
654:
655: /**
656: * A set of settings for the scheduled executor manager (based on java.util.concurrent).
657: */
658: public abstract class Scheduled {
659:
660: /**
661: * The name (type) of the scheduled executor manager.
662: */
663: public static final String NAME = "scheduled";
664:
665: private static final String PREFIX = EXECUTOR_MANAGER_PREFIX
666: + NAME + ".";
667:
668: /**
669: * The core pool size that is used with the scheduled executor service. Defaults to <code>10</code>.
670: */
671: public static final String CORE_POOL_SIZE = PREFIX
672: + "corePoolSize";
673: }
674:
675: /**
676: * A set of settings for the concurrent executor manager.
677: */
678: public abstract class Concurrent {
679:
680: /**
681: * The name (type) of the concurrent executor manager.
682: */
683: public static final String NAME = "concurrent";
684:
685: private static final String PREFIX = EXECUTOR_MANAGER_PREFIX
686: + NAME + ".";
687:
688: /**
689: * The core pool size of the scheduled executor service. Defaults to <code>1</code>.
690: */
691: public static final String SCHEDULED_CORE_POOL_SIZE = PREFIX
692: + "scheduledCorePoolSize";
693:
694: /**
695: * The core pool size of the executor service, defaults to <code>10</code>.
696: */
697: public static final String CORE_POOL_SIZE = PREFIX
698: + "corePoolSize";
699:
700: /**
701: * The maximum pool size of the executor service. Defaults to <code>30</code>.
702: */
703: public static final String MAXIMUM_POOL_SIZE = PREFIX
704: + "maximumPoolSize";
705:
706: /**
707: * The keep alive time of the executor service (in <b>milliseconds</b>).
708: * Defaults to <code>60000</code>, which is 60 seconds.
709: */
710: public static final String KEEP_ALIVE_TIME = PREFIX
711: + "keepAliveTime";
712:
713: }
714:
715: /**
716: * A set of settings of the work manager based executor manager.
717: */
718: public abstract class WorkManager {
719:
720: /**
721: * The name (type) of the work manager executor manager.
722: */
723: public static final String NAME = "workManager";
724:
725: private static final String PREFIX = EXECUTOR_MANAGER_PREFIX
726: + NAME + ".";
727:
728: /**
729: * The JNDI to lookup the JNDI name from. Required.
730: */
731: public static final String JNDI_NAME = PREFIX + "jndiName";
732: }
733: }
734: }
|