You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/05/09 23:26:11 UTC
svn commit: r536712 - in /incubator/xap/trunk/codebase/src: plugin.xml
xap/session/ClientSession.js xap/taghandling/PluginDocumentHandler.js
xap/taghandling/PluginRegistryImpl.js xap/taghandling/plugin.xml
Author: jmargaris
Date: Wed May 9 16:26:10 2007
New Revision: 536712
URL: http://svn.apache.org/viewvc?view=rev&rev=536712
Log:
https://issues.apache.org/jira/browse/XAP-425
Added:
incubator/xap/trunk/codebase/src/plugin.xml (with props)
Removed:
incubator/xap/trunk/codebase/src/xap/taghandling/plugin.xml
Modified:
incubator/xap/trunk/codebase/src/xap/session/ClientSession.js
incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js
incubator/xap/trunk/codebase/src/xap/taghandling/PluginRegistryImpl.js
Added: incubator/xap/trunk/codebase/src/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/plugin.xml?view=auto&rev=536712
==============================================================================
--- incubator/xap/trunk/codebase/src/plugin.xml (added)
+++ incubator/xap/trunk/codebase/src/plugin.xml Wed May 9 16:26:10 2007
@@ -0,0 +1,171 @@
+<!--
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements. See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership. The ASF licenses this file
+ - to you under the Apache License, Version 2.0 (the
+ - "License"); you may not use this file except in compliance
+ - with the License. You may obtain a copy of the License at
+ -
+ - http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+ -
+-->
+
+<plugin>
+
+ <tag-mappings namespace="http://openxal.org/core/xinclude" document="ui">
+ <mapping class="xap.bridges.basic.XInclude" name="include"/>
+ </tag-mappings>
+
+
+ <!-- IMPORTANT move data stuff to separate mapping file -->
+
+ <!-- Data-source mappings: -->
+ <tag-mappings namespace="http://openxal.org/core/data" document="dataSources">
+ <mapping class="xap.data.bridge.ObjectDataSourceBridge" name="objectDataSource"/>
+ <mapping class="xap.data.bridge.SimpleDocumentDataSourceBridge" name="documentDataSource"/>
+ </tag-mappings>
+
+ <!-- binding -->
+ <tag-mappings namespace="http://openxal.org/core/data" document="bindings">
+ <mapping class="xap.data.bridge.BindingBridge"
+ name="binding"/>
+ </tag-mappings>
+
+ <!-- mappings that apply to the ui document -->
+ <tag-mappings namespace="http://openxal.org/core/data">
+ <mapping class="xap.data.bridge.IteratorBridge"
+ name="iterator"/>
+ </tag-mappings>
+
+ <!-- mappings that apply to the document named "formatters" -->
+ <tag-mappings namespace="http://openxal.org/core/data" document="formatters">
+ <mapping name="formatter"
+ class="xap.data.bridge.FormatterBridge"
+ />
+ <mapping name="decimalFormatter"
+ class="xap.data.bridge.DecimalFormatterBridge"
+ />
+ <mapping name="messageFormatter"
+ class="xap.data.bridge.MessageFormatterBridge"
+ />
+ <mapping name="formatterChain"
+ class="xap.data.bridge.FormatterChainBridge"
+ />
+ </tag-mappings>
+
+
+
+ <!-- default mappings -->
+ <tag-mappings namespace="http://openxal.org/ui http://openxal.org/ui/html" document="ui">
+ <mapping class="xap.bridges.basic.HtmlHostBridge" name="htmlHost"/>
+
+ <mapping class="xap.bridges.basic.DefsBridge" name="defs"/>
+ <mapping class="xap.bridges.basic.HtmlViewBridge" name="htmlView"/>
+ <mapping class="xap.bridges.basic.HtmlViewBridge" name="textView"/>
+
+ <mapping class="xap.bridges.xap.LabelBridge" name="label"/>
+ <mapping class="xap.bridges.xap.LinkBridge" name="link"/>
+ <mapping class="xap.bridges.xap.ButtonBridge" name="button"/>
+ <mapping class="xap.bridges.xap.CheckboxBridge" name="checkBox"/>
+ <mapping class="xap.bridges.xap.RadioButtonBridge" name="radioButton"/>
+ <mapping class="xap.bridges.xap.XapComboBoxBridge" name="comboBox"/>
+ <mapping class="xap.bridges.xap.EditableComboBoxBridge" name="editableComboBox"/>
+ <mapping class="xap.bridges.xap.ListBoxBridge" name="listBox"/>
+ <mapping class="xap.bridges.xap.ListItemBridge" name="listItem"/>
+
+
+ <mapping class="xap.bridges.dojo.VerticalSplitPaneBridge" name="verticalSplitPane"/>
+ <mapping class="xap.bridges.dojo.HorizontalSplitPaneBridge" name="horizontalSplitPane"/>
+ <mapping class="xap.bridges.dojo.SplitChildBridge" name="top"/>
+ <mapping class="xap.bridges.dojo.SplitChildBridge" name="left"/>
+ <mapping class="xap.bridges.dojo.SecondSplitChildBridge" name="bottom"/>
+ <mapping class="xap.bridges.dojo.SecondSplitChildBridge" name="right"/>
+
+ <mapping class="xap.bridges.dojo.VerticalToolBarBridge" name="verticalToolBar"/>
+ <mapping class="xap.bridges.dojo.HorizontalToolBarBridge" name="horizontalToolBar"/>
+
+ <mapping class="xap.bridges.dojo.ScrollPaneBridge" name="scrollPane"/>
+ <mapping class="xap.bridges.dojo.DesktopPaneBridge" name="desktopPane"/>
+ <mapping class="xap.bridges.dojo.DesktopPaneBridge" name="rootPane"/>
+
+ <mapping class="xap.bridges.dojo.TableBridge" name="table"/>
+ <mapping class="xap.bridges.dojo.TreeTableBridge" name="treeTable"/>
+ <mapping class="xap.bridges.dojo.TreeBridge" name="tree"/>
+ <mapping class="xap.bridges.dojo.TabPaneBridge" name="tabPane"/>
+ <mapping class="xap.bridges.dojo.TabBridge" name="tab"/>
+ <mapping class="xap.bridges.dojo.FreePanelBridge" name="freePane"/>
+ <mapping class="xap.bridges.dojo.VerticalPanelBridge" name="verticalBoxPane"/>
+ <mapping class="xap.bridges.dojo.HorizontalPanelBridge" name="horizontalBoxPane"/>
+ <mapping class="xap.bridges.dojo.BorderPanelBridge" name="borderPane"/>
+ <mapping class="xap.bridges.dojo.TextFieldBridge" name="textField"/>
+ <mapping class="xap.bridges.dojo.PasswordFieldBridge" name="passwordField"/>
+ <mapping class="xap.bridges.dojo.TextAreaBridge" name="textArea"/>
+
+ <mapping class="xap.bridges.dojo.RowBridge" name="row"/>
+ <mapping class="xap.bridges.dojo.ColumnBridge" name="column"/>
+ <mapping class="xap.bridges.dojo.CellBridge" name="cell"/>
+
+ <mapping class="xap.bridges.dojo.MenuItemBridge" name="menuItem"/>
+ <mapping class="xap.bridges.dojo.MenuBarBridge" name="menuBar"/>
+ <mapping class="xap.bridges.dojo.MenuBridge" name="menu"/>
+ <mapping class="xap.bridges.dojo.PopupMenuBridge" name="popupMenu"/>
+ <mapping class="xap.bridges.dojo.HorizontalSeparatorBridge" name="horizontalSeparator"/>
+
+ <mapping class="xap.bridges.dojo.WindowBridge" name="window"/>
+
+ <mapping class="xap.bridges.dojo.HorizontalFlowPaneBridge" name="horizontalFlowPane"/>
+ <mapping class="xap.bridges.dojo.GridPanelBridge" name="gridPane"/>
+
+ <!-- for now cell just maps to label and header to button -->
+
+ <mapping class="xap.bridges.xap.ButtonBridge" name="header"/>
+
+ </tag-mappings>
+
+ <!-- old dojo mappings -->
+ <tag-mappings namespace="http://www.dojotoolkit.org/" document="ui">
+ <mapping class="xap.bridges.dojo.DojoButtonBridge" name="button"/>
+ <mapping class="xap.bridges.basic.DomNodeBridge" name="dom"/>
+ <mapping class="xap.bridges.dojo.DojoDatePickerBridge" name="datePicker"/>
+ <mapping class="xap.bridges.dojo.DojoColorPaletteBridge" name="colorPalette"/>
+ </tag-mappings>
+
+ <tag-mappings namespace="http://www.google.com" document="ui">
+ <mapping class="xap.bridges.google.GoogleMapBridge" name="map"/>
+ <mapping class="xap.bridges.google.GoogleInfoWindowBridge" name="infoWindow"/>
+ <mapping class="xap.bridges.google.GoogleMarkerBridge" name="marker"/>
+ <mapping class="xap.bridges.google.GoogleMarkersBridge" name="markers"/>
+ <mapping class="xap.bridges.google.GoogleIconsBridge" name="icons"/>
+ <mapping class="xap.bridges.google.GoogleIconBridge" name="icon"/>
+ </tag-mappings>
+
+ <tag-mappings namespace="http://www.yahoo.com" document="ui">
+ <mapping class="xap.bridges.yahoo.YahooMapBridge" name="map"/>
+ <mapping class="xap.bridges.yahoo.YahooInfoWindowBridge" name="infoWindow"/>
+ <mapping class="xap.bridges.yahoo.YahooMarkerBridge" name="marker"/>
+ <mapping class="xap.bridges.yahoo.YahooMarkersBridge" name="markers"/>
+ <mapping class="xap.bridges.yahoo.YahooIconsBridge" name="icons"/>
+ <mapping class="xap.bridges.yahoo.YahooIconBridge" name="icon"/>
+ </tag-mappings>
+
+ <tag-mappings namespace="http://www.microsoft.com" document="ui">
+ <mapping class="xap.bridges.microsoft.VEMapBridge" name="map"/>
+ <mapping class="xap.bridges.microsoft.VEInfoWindowBridge" name="infoWindow"/>
+ <mapping class="xap.bridges.microsoft.VEMarkerBridge" name="marker"/>
+ <mapping class="xap.bridges.microsoft.VEMarkersBridge" name="markers"/>
+ <mapping class="xap.bridges.microsoft.VEIconsBridge" name="icons"/>
+ <mapping class="xap.bridges.microsoft.VEIconBridge" name="icon"/>
+ </tag-mappings>
+
+ <tag-mappings namespace="http://openxal.org/ext" document="ui">
+ <mapping class="xap.bridges.ext.HelloWorldBridge" name="helloWorld"/>
+ <mapping class="xap.bridges.ext.EffectsBridge" name="effectsPane"/>
+ </tag-mappings>
+</plugin>
Propchange: incubator/xap/trunk/codebase/src/plugin.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/codebase/src/xap/session/ClientSession.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/session/ClientSession.js?view=diff&rev=536712&r1=536711&r2=536712
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/session/ClientSession.js (original)
+++ incubator/xap/trunk/codebase/src/xap/session/ClientSession.js Wed May 9 16:26:10 2007
@@ -81,7 +81,9 @@
this._uiDocumentHandler = new xap.taghandling.PluginDocumentHandler( this,
uiDocument, xap.xml.DocumentContainer.UI_DOCUMENT_NAME );
-}
+};
+
+
//-----------------------------------------------------------------------
// Public Methods.
//-----------------------------------------------------------------------
@@ -89,19 +91,19 @@
xap.session.ClientSession.prototype.getPluginRegistry = function() {
return this._pluginRegistry;
-}
+};
xap.session.ClientSession.prototype.getNamespaceHandlerManager = function() {
return this._namespaceHandlerManager;
-}
+};
xap.session.ClientSession.prototype.getResolutionHandler = function() {
return this._resolutionHandler;
-}
+};
xap.session.ClientSession.prototype.getApplication = function() {
return this._application;
-}
+};
/**
* Returns the container used to house user-defined MCOs.
@@ -109,7 +111,7 @@
*/
xap.session.ClientSession.prototype.getMcoContainer = function() {
return this._mcoContainer;
-}
+};
/**
* Returns the container used to house XML documents.
@@ -117,7 +119,7 @@
*/
xap.session.ClientSession.prototype.getDocumentContainer = function() {
return this._documentContainer;
-}
+};
/**
* Returns the container used to house system-defined services
@@ -125,7 +127,7 @@
*/
xap.session.ClientSession.prototype.getSystemContainer = function() {
return this._systemContainer;
-}
+};
/**
* Returns the xap.macro.MacroContainer which houses all the declared
@@ -133,14 +135,14 @@
*/
xap.session.ClientSession.prototype.getMacroContainer = function() {
return this._macroContainer;
-}
+};
/**
* Returns the request service for server requests.
*/
xap.session.ClientSession.prototype.getRequestService = function() {
return this._requestService;
-}
+};
@@ -151,11 +153,11 @@
*/
xap.session.ClientSession.prototype.getEventHandler = function() {
return this._eventHandler;
-}
+};
xap.session.ClientSession.prototype.getDeclarativeArgumentParser = function() {
- return this._declarativeArgumentParser
-}
+ return this._declarativeArgumentParser ;
+};
@@ -167,7 +169,7 @@
*/
xap.session.ClientSession.prototype.getContainer = function( name ) {
return this._namesToContainers.get(name);
-}
+};
/**
* Adds a container with the given name to the session.
@@ -176,12 +178,13 @@
*/
xap.session.ClientSession.prototype.addContainer = function( name, container ) {
this._namesToContainers.put(name, container);
-}
+};
+
xap.session.ClientSession.prototype.handleException = function( exception ) {
//IMPORTANT get rid of handleException entirelty and just use log
xap.log.Logger.getLogger("exception").error("Exception occured", exception);
-}
+};
/**
@@ -206,11 +209,12 @@
namespaceHandlerManager.dispatch( child );
}
}
-}
+};
+
xap.session.ClientSession.prototype.getUiDocumentHandler = function() {
return this._uiDocumentHandler;
-}
+};
//-----------------------------------------------------------------------
@@ -228,7 +232,7 @@
this._processPluginConfigurationClasses( this.getApplication().getConfiguration().pluginClasses );
}
- if (this.getApplication().getConfiguration().element != null){
+ if (this.getApplication().getConfiguration().element){
this._createInitialDocument(this.getApplication().getConfiguration().toolkitType,
this.getApplication().getConfiguration().element);
}
@@ -244,7 +248,7 @@
this.handleException( exception);
}
-}
+};
/**
* @private
@@ -253,10 +257,11 @@
var requestService = this.getRequestService();
for( var i = 0; i < pluginFiles.length; i++ ) {
var fileLocation = pluginFiles[ i ];
- var response = requestService.retrieve(this.getApplication().getConfiguration().context + fileLocation);
- this._pluginRegistry.addPluginDescription(response.responseText);
+ var fileUrl = this.getApplication().getConfiguration().context + fileLocation;
+ var response = requestService.retrieve(fileUrl);
+ this._pluginRegistry.addPluginDescription(response.responseText, fileUrl);
}
-}
+};
/**
* @private
@@ -266,7 +271,7 @@
var className = pluginClasses[ i ];
this._pluginRegistry.loadLifecycleObject(className);
}
-}
+};
/**
* @private
@@ -293,8 +298,9 @@
//keep track of the handlers.
this.getUiDocumentHandler().setHandlerForElement(htmlHostBridge.getElement(), htmlHostBridge);
- this.getUiDocumentHandler().setHandlerForElement(uiDocument.getRootElement(), htmlHostBridge);
+ // isn't that the same as above?
+ //this.getUiDocumentHandler().setHandlerForElement(uiDocument.getRootElement(), htmlHostBridge);
uiDocument.getRootElement().addStructureChangeListener( htmlHostBridge );
-}
+};
Modified: incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js?view=diff&rev=536712&r1=536711&r2=536712
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js (original)
+++ incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js Wed May 9 16:26:10 2007
@@ -57,7 +57,7 @@
//we had better be the first listener on the document!
doc.addStructureChangeListener( this );
-}
+};
/** @private */
xap.taghandling.PluginDocumentHandler.s_log = xap.log.Logger.getLogger( "xap.taghandling.PluginDocumentHandler" );
@@ -84,24 +84,24 @@
return;
}
this.parseChild( e.getChange(), e );
-}
+};
/**
* No-op xap.xml.dom.events.StructureChangeListener implementation.
* We might want to tie this in to the dergister logic?
* Tricky because document-level remove comes before element-level one
*/
-xap.taghandling.PluginDocumentHandler.prototype.onChildRemoved = function( e ) {}
+xap.taghandling.PluginDocumentHandler.prototype.onChildRemoved = function( e ) {};
/**
* No-op xap.xml.dom.events.StructureChangeListener implementation.
*/
-xap.taghandling.PluginDocumentHandler.prototype.beforeChildAdded = function( event ) {}
+xap.taghandling.PluginDocumentHandler.prototype.beforeChildAdded = function( event ) {};
/**
* No-op xap.xml.dom.events.StructureChangeListener implementation.
*/
-xap.taghandling.PluginDocumentHandler.prototype.beforeChildRemoved = function( event ) {}
+xap.taghandling.PluginDocumentHandler.prototype.beforeChildRemoved = function( event ) {};
/**
@@ -114,7 +114,7 @@
*/
xap.taghandling.PluginDocumentHandler.prototype.deregister = function( el ) {
var handler = this.getHandlerForElement( el );
- if ( handler != null ) {
+ if ( handler ) {
this._elementsToBridges.remove( el );
//IMPORTANT all handlers should have some unload or some
@@ -134,32 +134,48 @@
this.deregister( child );
}
}
-}
+};
+
+/**
+ * Finds and created a handler instance
+ *
+ * @param bridgeClassName
+ * @param pluginRoot
+ */
+xap.taghandling.PluginDocumentHandler.prototype.obtainHandler = function(bridgeClassName, pluginRoot){
-xap.taghandling.PluginDocumentHandler.prototype.obtainHandler = function(bridgeClassName){
- var handlerConstructor = null ;
//now that we have the name of the bridge class, make a
//new one, loading its class first if necessary:
+ var handlerConstructor = Xap.resolveConstructor(bridgeClassName) ;
+
try {
- // Even if the dojo.require() has already done this,
- // do this here in case we need to do a debug-load---
- // dojo won't load it again if it has before:
- Xap.require( bridgeClassName );
- handlerConstructor = Xap.resolveConstructor(bridgeClassName ) ;
+ if( ! handlerConstructor ) {
+ // lets see if we need to register module prefix
+ if( pluginRoot ) {
+ // TODO: do we need to un-register if it fails?
+ var prefix = bridgeClassName.substring(0, bridgeClassName.lastIndexOf('.'));
+ if(!dojo.hostenv.moduleHasPrefix(prefix)) {
+ var path = pluginRoot + '/' + prefix.replace(/\./g, '/');
+ dojo.hostenv.setModulePrefix(prefix, path);
+ }
+ }
+ // use regular Xap.require() to load the file
+ Xap.require(bridgeClassName);
+ handlerConstructor = Xap.resolveConstructor(bridgeClassName) ;
+ }
} catch (classNotLoadableException){
- xap.taghandling.PluginDocumentHandler.s_log.error( "Exception while loading: " + bridgeClassName,
- classNotLoadableException );
-
+ xap.taghandling.PluginDocumentHandler.s_log.error( "Exception while loading: " + bridgeClassName, classNotLoadableException );
// If we didn't create a new handler just now,
// handler==null, so this.setHandlerForElement below
// will bomb on the xap.util.Hashtable.put(aKey,handler) that
// it calls, and handler.setSession() below will also
// fail, so we might as well end it here:
throw classNotLoadableException ;
-
}
+
+ // success (?)
return new handlerConstructor() ;
-}
+};
@@ -175,24 +191,24 @@
* @return A new instance of the tag-handling class or null if no mapping exists.
*/
xap.taghandling.PluginDocumentHandler.prototype.parseChild = function( childElement, event ) {
- var handler = null;
-
+
var pluginRegistry = this._clientSession.getPluginRegistry();
try {
//step 1: Look up the class name for this tag name,
//then instantiate that class instance
var tagName = childElement.getLocalName();
- var namespace = childElement.getNamespaceUri();
- var bridgeClass = pluginRegistry.getTagMapping( tagName, namespace,
- this._documentName );
+ var namespaceString = childElement.getNamespaceUri();
+ var bridgeClass = pluginRegistry.getTagMapping( tagName, namespaceString, this._documentName );
+ var pluginRoot = pluginRegistry.getPluginRoot( tagName, namespaceString, this._documentName );
//if the implementing class name is null do what we used to do
//and print out an error
if ( bridgeClass == null ) {
- if (xap.taghandling.PluginDocumentHandler.s_log.isWarn())
+ if (xap.taghandling.PluginDocumentHandler.s_log.isWarn()) {
xap.taghandling.PluginDocumentHandler.s_log.warn( "No mapping for tag name [" +
tagName + "] with namespace [" +
- namespace + "] on document [" + this._documentName + "]");
+ namespaceString + "] on document [" + this._documentName + "]");
+ }
return null;
}
//if it's not a string this means it is a valid tag but
@@ -202,39 +218,14 @@
else if (( typeof bridgeClass ) != "string" ) {
return null;
}
- var handler = null;
-
+ var handler = null;
+
try {
- handler = this.obtainHandler( bridgeClass ) ;
+ handler = this.obtainHandler( bridgeClass, pluginRoot ) ;
}
catch( ex ) {
xap.taghandling.PluginDocumentHandler.s_log.error( "Exception during eval", ex);
-
- //if that fails, try again with just the stuff after the
- //last period. For example if we tried:
- //xap.bridges.zimbra.DwtButtonBridge now just try:
- //DwtButtonBridge.
- //TODO remove this attempt once we convert all the bridge
- //classes over to use provide/require and fully scoped
- //constructors/classes
- try{
- var lastPeriod = bridgeClass.lastIndexOf(".");
- if (lastPeriod>0){
- bridgeClass = bridgeClass.substring(lastPeriod+1);
- }
- handler = this.obtainHandler( bridgeClass ) ;
- }
- catch(ex2){
- xap.taghandling.PluginDocumentHandler.s_log.error( "Exception during eval", ex);
-
- // If we didn't create a new handler just now,
- // handler==null, so this.setHandlerForElement below
- // will bomb on the xap.util.Hashtable.put(aKey,handler) that
- // it calls, and handler.setSession() below will also
- // fail, so we might as well end it here:
- throw ex ;
- }
}
@@ -268,7 +259,7 @@
this._clientSession.handleException( ex );
}
return handler;
-}
+};
@@ -279,14 +270,14 @@
*/
xap.taghandling.PluginDocumentHandler.prototype.getHandlerForElement = function( el ){
return this._elementsToBridges.get( el );
-}
+};
/**
* For internal use only.
*/
xap.taghandling.PluginDocumentHandler.prototype.setHandlerForElement = function( el, tagImpl ){
this._elementsToBridges.put( el, tagImpl );
-}
+};
/**
* Sets up a mapping between a bridge tag-handler
@@ -302,7 +293,8 @@
*/
xap.taghandling.PluginDocumentHandler.prototype.setHandlerForPeer = function( peer, tagImpl ) {
this._peersToBridges.put( peer, tagImpl );
-}
+};
+
/**
* Removes the mpping between the peer and the handler.
@@ -312,7 +304,8 @@
*/
xap.taghandling.PluginDocumentHandler.prototype.removeHandlerForPeer = function( peer ) {
this._peersToBridges.remove( peer );
-}
+};
+
/**
* Returns the bridge class that controls the given component.
@@ -330,4 +323,4 @@
*/
xap.taghandling.PluginDocumentHandler.prototype.getHandlerForPeer = function( peer ) {
return this._peersToBridges.get( peer );
-}
+};
Modified: incubator/xap/trunk/codebase/src/xap/taghandling/PluginRegistryImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/taghandling/PluginRegistryImpl.js?view=diff&rev=536712&r1=536711&r2=536712
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/taghandling/PluginRegistryImpl.js (original)
+++ incubator/xap/trunk/codebase/src/xap/taghandling/PluginRegistryImpl.js Wed May 9 16:26:10 2007
@@ -52,18 +52,19 @@
xap.taghandling.PluginRegistryImpl = function( session ){
- this._pluginLifecycleObjects = new Array();
+ this._pluginLifecycleObjects = [];
this._tagDefinitions = new xap.util.Hashtable();
this._tagMappings = new xap.util.Hashtable();
+ this._tagLocations = new xap.util.Hashtable();
this._session = session;
this._uiShortcutNamespaceHandler = new xap.xml.UiNamespaceShortcutHandler(session);
-}
+};
xap.taghandling.PluginRegistryImpl.s_log = xap.log.Logger.getLogger( "xap.taghandling.PluginRegistryImpl" );
xap.taghandling.PluginRegistryImpl.TAG_MAPPINGS_PATH = "/plugin/tag-mappings";
-xap.taghandling.PluginRegistryImpl.UNMAPPED_TAGS_PATH = "/plugin/unmapped-tags"
+xap.taghandling.PluginRegistryImpl.UNMAPPED_TAGS_PATH = "/plugin/unmapped-tags";
xap.taghandling.PluginRegistryImpl.PLUGIN_LIFECYCLE_CLASS_PATH = "/plugin/@class";
@@ -77,13 +78,14 @@
/**
* Adds a plug-in decription file.
*
- * @param fileContents a String representing the actual content (NOT path)
- * of the description file
+ * @param fileContents a String representing the actual content (NOT path) of the description file
+ * @param url String file url
*/
-xap.taghandling.PluginRegistryImpl.prototype.addPluginDescription = function( fileContents ){
+xap.taghandling.PluginRegistryImpl.prototype.addPluginDescription = function( fileContents, fileUrl ) {
- if (xap.taghandling.PluginRegistryImpl.s_log.isTrace())
+ if (xap.taghandling.PluginRegistryImpl.s_log.isTrace()) {
xap.taghandling.PluginRegistryImpl.s_log.trace("Add plugin description");
+ }
var parser = xap.xml.ParserFactory.getParser();
var pluginDocument = null;
@@ -98,20 +100,29 @@
//TODO this returs what an array of nodes?
- var tagMappingSections =
- google.xpathDomEval(xap.taghandling.PluginRegistryImpl.TAG_MAPPINGS_PATH , pluginDocument);
-
- if (xap.taghandling.PluginRegistryImpl.s_log.isTrace())
+ if (xap.taghandling.PluginRegistryImpl.s_log.isTrace()) {
+ xap.taghandling.PluginRegistryImpl.s_log.trace("Parse mapped tags");
+ }
+
+ var tagMappingSections = google.xpathDomEval(xap.taghandling.PluginRegistryImpl.TAG_MAPPINGS_PATH , pluginDocument);
+
+ if (xap.taghandling.PluginRegistryImpl.s_log.isTrace()) {
xap.taghandling.PluginRegistryImpl.s_log.trace(tagMappingSections.value.length + " mapped tags");
- this._parseTagMappingElements(tagMappingSections.value,true);
+ }
+
+ this._parseTagMappingElements(tagMappingSections.value, true, fileUrl);
- if (xap.taghandling.PluginRegistryImpl.s_log.isTrace())
+ if (xap.taghandling.PluginRegistryImpl.s_log.isTrace()) {
xap.taghandling.PluginRegistryImpl.s_log.trace("Parse unmapped tags");
- tagMappingSections =
- google.xpathDomEval(xap.taghandling.PluginRegistryImpl.UNMAPPED_TAGS_PATH , pluginDocument);
- if (xap.taghandling.PluginRegistryImpl.s_log.isTrace())
+ }
+
+ tagMappingSections = google.xpathDomEval(xap.taghandling.PluginRegistryImpl.UNMAPPED_TAGS_PATH , pluginDocument);
+
+ if (xap.taghandling.PluginRegistryImpl.s_log.isTrace()) {
xap.taghandling.PluginRegistryImpl.s_log.trace(tagMappingSections.value.length + " unmapped tags");
- this._parseTagMappingElements(tagMappingSections.value,false);
+ }
+
+ this._parseTagMappingElements(tagMappingSections.value, false, fileUrl);
//TODO this returns an array but we want a string, get the first element node value?
var lifecycleClassName =
@@ -120,23 +131,35 @@
if (lifecycleClassName && lifecycleClassName.length >0){
this.loadLifecycleObject(lifecycleClassName);
}
-}
+
+};
xap.taghandling.PluginRegistryImpl.prototype.loadLifecycleObject = function( lifecycleClassName ){
- if (xap.taghandling.PluginRegistryImpl.s_log.isTrace())
+ if (xap.taghandling.PluginRegistryImpl.s_log.isTrace()) {
xap.taghandling.PluginRegistryImpl.s_log.trace("lifecycle class = " + lifecycleClassName);
+ }
+
+ if (lifecycleClassName) {
- if (lifecycleClassName){
try{
- Xap.require(lifecycleClassName);
+ // get class object
+ var lifecycleClass = null;
+ if(Xap.require(lifecycleClassName)) {
+ lifecycleClass = eval(lifecycleClassName);
+ }
+
+ // check if class is available
+ if(!lifecycleClass) {
+ throw new Error('Unable to load class ' + lifecycleClassName);
+ }
+
//TODO we need a generic "load this bean" type of method
// Only DataNamespaceHandler seems to need
// the session, but it doesn't hurt the others...
- var lifecycleObject = eval("new " + lifecycleClassName + "(this._session)");
+ var lifecycleObject = new lifecycleClass(this._session);
-
//TODO maybe we should just have a container for lifecycle objects
//so that you can look them up and the notification is done via
//standard container mechanism? Allow them to assign IDs etc?
@@ -151,7 +174,7 @@
this._session.handleException( exception );
}
}
-}
+};
/**
* Returns the original definition element that came from the tag-mapping/
@@ -160,7 +183,7 @@
xap.taghandling.PluginRegistryImpl.prototype.getPluginDefinition = function( tagName, nameSpace, documentName){
var theKey = xap.taghandling.PluginRegistryImpl._createHashtableKey(tagName,nameSpace,documentName) ;
return this._tagDefinitions.get(theKey);
-}
+};
/**
@@ -171,9 +194,19 @@
*/
xap.taghandling.PluginRegistryImpl.prototype.getTagMapping = function(tagName, nameSpace, documentName){
return this._tagMappings.get(xap.taghandling.PluginRegistryImpl._createHashtableKey(tagName,nameSpace,documentName));
-}
+};
+
+/**
+ * This will return plugin root path
+ */
+xap.taghandling.PluginRegistryImpl.prototype.getPluginRoot = function(tagName, nameSpace, documentName){
+ return this._tagLocations.get(xap.taghandling.PluginRegistryImpl._createHashtableKey(tagName,nameSpace,documentName));
+};
+
+
+
/**
* Does the work of parsing the main tag-mapping blocks
@@ -181,14 +214,14 @@
* tag-mapping and unmapped-tags roots
* @param isMappedTag if true, each item should map to a class
*/
-xap.taghandling.PluginRegistryImpl.prototype._parseTagMappingElements = function(tagMappingSections, isMappedTag){
+xap.taghandling.PluginRegistryImpl.prototype._parseTagMappingElements = function(tagMappingSections, isMappedTag, pluginFileUrl){
//for each tag in the block
- for (var section =0; section<tagMappingSections.length; section++){
+ for (var section = 0; section < tagMappingSections.length; section++){
var tagMappingRoot = tagMappingSections[section];
var documentName = tagMappingRoot.getAttribute("document");
- if (documentName==null){
+ if (documentName == null) {
documentName = xap.xml.DocumentContainer.UI_DOCUMENT_NAME;
}
@@ -229,64 +262,67 @@
if (tagElement.getLocalName()=="mapping"){
tagName = tagElement.getAttribute("name");
- if (tagName==null || tagName.length==0){
- if (xap.taghandling.PluginRegistryImpl.s_log.isError())
- xap.taghandling.PluginRegistryImpl.s_log.error(
- "Missing tag name (\"local name\") from tag element:\n"
- + tagElement
- +"\n...; mapping will continue for other tag defs.") ;
+ if (tagName == null || tagName.length == 0 ) {
+ if (xap.taghandling.PluginRegistryImpl.s_log.isError()) {
+ xap.taghandling.PluginRegistryImpl.s_log.error("Missing tag name (\"local name\") from tag element:\n" +
+ tagElement + "\n...; mapping will continue for other tag defs.") ;
+ }
continue;
}
- if (isMappedTag){
+ if (isMappedTag) {
className = tagElement.getAttribute("class");
- if (className==null || className.length==0){
+ if (className == null || className.length == 0){
//TODO report exception
continue;
}
}
//if we aren't supposed to be mapped to anything
//don't look for class
- else{
- className = xap.taghandling.PluginRegistryImpl.NO_MAPPED_CLASS
+ else {
+ className = xap.taghandling.PluginRegistryImpl.NO_MAPPED_CLASS;
}
}
else{
//TODO report exception
-
}
- if (xap.taghandling.PluginRegistryImpl.s_log.isTrace())
+ if (xap.taghandling.PluginRegistryImpl.s_log.isTrace()) {
xap.taghandling.PluginRegistryImpl.s_log.trace("Add tag mapping:" + tagName + ":" + className);
- this._addTagMapping(tagName,className,nameSpace,documentName,tagElement);
+ }
+ this._addTagMapping(tagName,className,nameSpace,documentName,tagElement,pluginFileUrl);
}
}
}
-}
+};
xap.taghandling.PluginRegistryImpl.prototype.toString = function(){
return this._tagMappings.toString();
-}
+};
/**
* @param {String} tagName The name of the tag
* @param {Object} className The name of the class or the special NO_MAPPED_CLASS object
* @param {String} nameSpace The namespace URI.
* @param {String} documentName The name of the document the tag applies to
* @param {xap.xml.dom.XapElement} originalDefinition The tag definition element
+ * @param {String} pluginFileUrl The original url of plugin file
*/
xap.taghandling.PluginRegistryImpl.prototype._addTagMapping = function( tagName, className, nameSpace,
- documentName, originalDefinition){
+ documentName, originalDefinition,pluginFileUrl){
//error: duplicate tag name
- if (this.getTagMapping(tagName,nameSpace,documentName)!=null){
+ if (this.getTagMapping(tagName,nameSpace,documentName)!= null) {
//TODO report exception but overwrite
}
var hashKey = xap.taghandling.PluginRegistryImpl._createHashtableKey(tagName,nameSpace,documentName);
this._tagMappings.put(hashKey,className);
this._tagDefinitions.put(hashKey,originalDefinition);
-}
+ if(pluginFileUrl) {
+ this._tagLocations.put(hashKey,pluginFileUrl.substring(0, pluginFileUrl.lastIndexOf('/')));
+ }
+};
@@ -299,4 +335,4 @@
// nameSpace = "http://xal.org/xal";
// }
return tagName + ":" + nameSpace + ":" + documentName;
-}
+};