001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.interfaces;
034:
035: import com.flexive.shared.CustomSequencer;
036: import com.flexive.shared.exceptions.FxApplicationException;
037:
038: import javax.ejb.Remote;
039: import java.util.List;
040:
041: /**
042: * Interface for the sequencer beans.
043: * <p/>
044: * The beans generates Id's for any data-table.
045: * It should be used instead of database spezific autoincrements or sequences.
046: *
047: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
048: * @author Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
049: */
050: @Remote
051: public interface SequencerEngine {
052:
053: /**
054: * System defined sequencers
055: */
056: enum System {
057: CONTENT, ACCOUNT, GROUP, ACL, MANDATOR, TYPEDEF, TYPEGROUP, TYPEPROP, ASSIGNMENT, BINARY, WORKFLOW, ROUTE, STEPDEFINITION, SCRIPTS, STEP, BRIEFCASE, SEARCHCACHE_MEMORY(
058: true), SEARCHCACHE_PERM(true), TEMPLATE, SELECTLIST, SELECTLIST_ITEM, TREE_EDIT, TREE_LIVE;
059:
060: private boolean allowRollover;
061: private String sequencerName;
062:
063: System(boolean allowRollover) {
064: this .allowRollover = allowRollover;
065: this .sequencerName = "SYS_" + this .name();
066: }
067:
068: System() {
069: this .allowRollover = false;
070: this .sequencerName = "SYS_" + this .name();
071: }
072:
073: public boolean isAllowRollover() {
074: return allowRollover;
075: }
076:
077: public String getSequencerName() {
078: return sequencerName;
079: }
080: }
081:
082: /**
083: * Maximum possible id
084: */
085: public final static long MAX_ID = ((long) Integer.MAX_VALUE) * 2 - 50;
086:
087: /**
088: * Get a new unique id for the requested type.
089: * Internal method!! Safe to use but of no use to 'end-users'!
090: *
091: * @param type the type (database table) to get an id for
092: * @return new id
093: * @throws FxApplicationException on errors
094: */
095: long getId(System type) throws FxApplicationException;
096:
097: /**
098: * Create a new sequencer
099: *
100: * @param name desired name
101: * @param allowRollover allow id's that reach the limit (MAX_ID) to be reset to zero?
102: * @param startNumber the number to start at
103: * @throws FxApplicationException on errors
104: */
105: void createSequencer(String name, boolean allowRollover,
106: long startNumber) throws FxApplicationException;
107:
108: /**
109: * Remove an existing sequencer
110: *
111: * @param name name of the sequencer
112: * @throws FxApplicationException on errors
113: */
114: void removeSequencer(String name) throws FxApplicationException;
115:
116: /**
117: * Get a new id from a registered sequencer
118: *
119: * @param sequencer name of the sequencer to use
120: * @return new id
121: * @throws FxApplicationException on errors
122: */
123: long getId(String sequencer) throws FxApplicationException;
124:
125: /**
126: * Check existance of a sequencer
127: *
128: * @param name name of the sequencer to check
129: * @return if the sequencer exists
130: * @throws FxApplicationException on errors
131: */
132: boolean sequencerExists(String name) throws FxApplicationException;
133:
134: /**
135: * Get a list of all known (user-created) sequencer
136: *
137: * @return list of all known (user-created) sequencer
138: * @throws FxApplicationException on errors
139: */
140: List<CustomSequencer> getCustomSequencers()
141: throws FxApplicationException;
142:
143: }
|