001: /*
002: * Created on Nov 23, 2005
003: */
004: package uk.org.ponder.rsf.mappings;
005:
006: import uk.org.ponder.conversion.DateParser;
007: import uk.org.ponder.rsf.components.ELReference;
008: import uk.org.ponder.rsf.components.ELReferenceParser;
009: import uk.org.ponder.rsf.components.UIAnchor;
010: import uk.org.ponder.rsf.components.UIBranchContainer;
011: import uk.org.ponder.rsf.components.UICommand;
012: import uk.org.ponder.rsf.components.UIDeletionBinding;
013: import uk.org.ponder.rsf.components.UIELBinding;
014: import uk.org.ponder.rsf.components.UIError;
015: import uk.org.ponder.rsf.components.UIForm;
016: import uk.org.ponder.rsf.components.UIInput;
017: import uk.org.ponder.rsf.components.UIInputMany;
018: import uk.org.ponder.rsf.components.UIInternalLink;
019: import uk.org.ponder.rsf.components.UIJointContainer;
020: import uk.org.ponder.rsf.components.UILink;
021: import uk.org.ponder.rsf.components.UIMessage;
022: import uk.org.ponder.rsf.components.UIOutput;
023: import uk.org.ponder.rsf.components.UIOutputMany;
024: import uk.org.ponder.rsf.components.UIOutputMultiline;
025: import uk.org.ponder.rsf.components.UIReplicator;
026: import uk.org.ponder.rsf.components.UISelect;
027: import uk.org.ponder.rsf.components.UISwitch;
028: import uk.org.ponder.rsf.components.UIVerbatim;
029: import uk.org.ponder.rsf.components.decorators.UIDecorator;
030: import uk.org.ponder.rsf.expander.DirectIndexStrategy;
031: import uk.org.ponder.rsf.expander.IDRemapStrategy;
032: import uk.org.ponder.rsf.flow.ARIResult;
033: import uk.org.ponder.rsf.flow.errors.StaticActionErrorStrategy;
034: import uk.org.ponder.rsf.view.ViewRoot;
035: import uk.org.ponder.rsf.viewstate.AnyViewParameters;
036: import uk.org.ponder.rsf.viewstate.EntityCentredViewParameters;
037: import uk.org.ponder.rsf.viewstate.SimpleViewParameters;
038: import uk.org.ponder.rsf.viewstate.ViewParameters;
039: import uk.org.ponder.rsf.viewstate.support.ViewParamsLeafParser;
040: import uk.org.ponder.saxalizer.SAXalizerMappingContext;
041: import uk.org.ponder.saxalizer.mapping.ContainerTypeRegistry;
042: import uk.org.ponder.saxalizer.mapping.MappableXMLProvider;
043: import uk.org.ponder.saxalizer.mapping.MappingLoadManager;
044: import uk.org.ponder.saxalizer.mapping.MappingLoader;
045:
046: /** This somewhat "kitchen-sink" class is the central point of coordination for
047: * all (XML) mapping files required by RSF.
048: * @author Antranig Basman (amb26@ponder.org.uk)
049: *
050: */
051:
052: public class RSFMappingLoader implements MappingLoader {
053: public static final Class[] allBuiltin = new Class[] {
054: UICommand.class, UIForm.class, UIInput.class,
055: UIInternalLink.class, UILink.class, UIMessage.class,
056: UIOutput.class, UIOutputMultiline.class,
057: UIJointContainer.class, UIDecorator.class,
058: UIBranchContainer.class, UIELBinding.class,
059: UIDeletionBinding.class, UIReplicator.class,
060: UISwitch.class, UISelect.class, UIInputMany.class,
061: UIOutputMany.class, UIError.class, UIAnchor.class,
062: UIVerbatim.class };
063: private ViewParamsLeafParser viewparamsleafparser;
064:
065: // do this in a somewhat ad hoc way, since leafparsers do not currently
066: // advertise their parsed types.
067: public void setViewParamsLeafParser(
068: ViewParamsLeafParser viewparamsleafparser) {
069: this .viewparamsleafparser = viewparamsleafparser;
070: }
071:
072: public void registerContainerTypes(ContainerTypeRegistry ctr) {
073: }
074:
075: public void loadExtendedMappings(SAXalizerMappingContext context) {
076: context.setChainedInferrer(new ComponentMapperInferrer());
077: for (int i = 0; i < allBuiltin.length; ++i) {
078: Class clazz = allBuiltin[i];
079: String classname = clazz.getName();
080: int lastdotpos = classname.lastIndexOf('.');
081: // the nickname is the lowercase form of the text following "UI" in the classname.
082: String nick = classname.substring(lastdotpos + 3)
083: .toLowerCase();
084: context.classnamemanager.registerClass(nick, clazz);
085: }
086: context.classnamemanager.registerClass("directindex",
087: DirectIndexStrategy.class);
088: context.classnamemanager.registerClass("idremap",
089: IDRemapStrategy.class);
090: context.classnamemanager.registerClass("staticstrategy",
091: StaticActionErrorStrategy.class);
092: context.classnamemanager.registerClass("entitycentred",
093: EntityCentredViewParameters.class);
094: context.classnamemanager.registerClass("simple",
095: SimpleViewParameters.class);
096:
097: context.classnamemanager.registerClass("elref",
098: ELReference.class);
099: context.classnamemanager.registerClass("dateparser",
100: DateParser.class);
101:
102: context.classnamemanager.registerClass("ariresult",
103: ARIResult.class);
104:
105: context.classnamemanager.registerClass("view", ViewRoot.class);
106:
107: context.saxleafparser.registerParser(ViewParameters.class,
108: viewparamsleafparser);
109: context.saxleafparser.registerParser(AnyViewParameters.class,
110: viewparamsleafparser);
111: context.saxleafparser.registerParser(ELReference.class,
112: new ELReferenceParser());
113: }
114:
115: public void loadStandardMappings(MappableXMLProvider xmlprovider) {
116: // mappings for flow-lite
117: MappingLoadManager.loadClasspathMapping(xmlprovider,
118: "uk/org/ponder/rsf/mappings/flow-map.xml");
119: MappingLoadManager.loadClasspathMapping(xmlprovider,
120: "uk/org/ponder/rsf/mappings/actionstate-map.xml");
121: MappingLoadManager.loadClasspathMapping(xmlprovider,
122: "uk/org/ponder/rsf/mappings/viewstate-map.xml");
123: MappingLoadManager.loadClasspathMapping(xmlprovider,
124: "uk/org/ponder/rsf/mappings/endstate-map.xml");
125: MappingLoadManager.loadClasspathMapping(xmlprovider,
126: "uk/org/ponder/rsf/mappings/action-map.xml");
127: MappingLoadManager.loadClasspathMapping(xmlprovider,
128: "uk/org/ponder/rsf/mappings/transition-map.xml");
129: // mappings for JSFNav
130: MappingLoadManager.loadClasspathMapping(xmlprovider,
131: "uk/org/ponder/rsf/mappings/navigation-map-map.xml");
132: MappingLoadManager.loadClasspathMapping(xmlprovider,
133: "uk/org/ponder/rsf/mappings/navigation-case-map.xml");
134: MappingLoadManager.loadClasspathMapping(xmlprovider,
135: "uk/org/ponder/rsf/mappings/navigation-rule-map.xml");
136: // mappings for components
137: MappingLoadManager.loadClasspathMapping(xmlprovider,
138: "uk/org/ponder/rsf/mappings/viewroot-map.xml");
139: MappingLoadManager.loadClasspathMapping(xmlprovider,
140: "uk/org/ponder/rsf/mappings/branchcontainer-map.xml");
141: MappingLoadManager.loadClasspathMapping(xmlprovider,
142: "uk/org/ponder/rsf/mappings/form-map.xml");
143: MappingLoadManager.loadClasspathMapping(xmlprovider,
144: "uk/org/ponder/rsf/mappings/parameter-map.xml");
145: MappingLoadManager.loadClasspathMapping(xmlprovider,
146: "uk/org/ponder/rsf/mappings/idremapstrategy-map.xml");
147: // mapping for EntityID - should really be in PonderUtilCore
148: MappingLoadManager.loadClasspathMapping(xmlprovider,
149: "uk/org/ponder/rsf/mappings/entityid-map.xml");
150:
151: }
152:
153: }
|