Author: hlship Date: Sat Oct 28 10:21:51 2006 New Revision: 468706 URL: http://svn.apache.org/viewvc?view=rev&rev=468706 Log: Fill out some details about the development process, and add some comments to ConcurrentBarrier.
Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/ConcurrentBarrier.java tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.html tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.xml Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/ConcurrentBarrier.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/ConcurrentBarrier.java?view=diff&rev=468706&r1=468705&r2=468706 ============================================================================== --- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/ConcurrentBarrier.java (original) +++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/ConcurrentBarrier.java Sat Oct 28 10:21:51 2006 @@ -18,7 +18,10 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; /** - * A barrier used to execute code in a context where it is guarded by read/write locks. + * A barrier used to execute code in a context where it is guarded by read/write locks. In addition, + * handles upgrading read locks to write locks (and vice versa). Execution of code within a lock is + * in terms of a [EMAIL PROTECTED] Runnable} object (that returns no value), or a [EMAIL PROTECTED] Invokable} object + * (which does return a value). */ public class ConcurrentBarrier { @@ -49,7 +52,9 @@ * the lock has already been acquired, then the status of the lock is not changed. * <p> * TODO: Check to see if the write lock is acquired and <em>not</em> acquire the read lock in - * that situation. + * that situation. Currently this code is not re-entrant. If a write lock is already acquired + * and the thread attempts to get the read lock, then the thread will hang. For the moment, all + * the uses of ConcurrentBarrier are coded in such a way that reentrant locks are not a problem. * * @param <T> * @param invokable @@ -81,6 +86,10 @@ } } + /** + * As with [EMAIL PROTECTED] #withRead(Invokable)}, creating an [EMAIL PROTECTED] Invokable} wrapper around the + * runnable object. + */ public void withRead(final Runnable runnable) { Invokable<Void> invokable = new Invokable<Void>() @@ -97,9 +106,16 @@ } /** - * Acquires the single write lock before invoking the Invokable. If the current thread has a - * read lock, it is released before attempting to acquire the write lock, and re-acquired after - * the write lock is released. + * Acquires the exclusive write lock before invoking the Invokable. The code will be executed + * exclusively, no other reader or writer threads will exist (they will be blocked waiting for + * the lock). If the current thread has a read lock, it is released before attempting to acquire + * the write lock, and re-acquired after the write lock is released. Note that in that short + * window, between releasing the read lock and acquiring the write lock, it is entirely possible + * that some other thread will sneak in and do some work, so the [EMAIL PROTECTED] Invokable} object should + * be prepared for cases where the state has changed slightly, despite holding the read lock. + * This usually manifests as race conditions where either a) some parallel unrelated bit of work + * has occured or b) duplicate work has occured. The latter is only problematic if the operation + * is very expensive. * * @param <T> * @param invokable @@ -138,6 +154,10 @@ } } + /** + * As with [EMAIL PROTECTED] #withWrite(Invokable)}, creating an [EMAIL PROTECTED] Invokable} wrapper around the + * runnable object. + */ public void withWrite(final Runnable runnable) { Invokable<Void> invokable = new Invokable<Void>() Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.html URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.html?view=diff&rev=468706&r1=468705&r2=468706 ============================================================================== --- tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.html (original) +++ tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.html Sat Oct 28 10:21:51 2006 @@ -5169,6 +5169,7 @@ <div tiddler="ComponentEvent" modifier="HowardLewisShip" modified="200610081359" created="200610081351" tags="requests events">Component events represent the way in which incoming requests are routed to user-supplied Java methods.\n\nComponent events //primarily// originate as a result of a ComponentActionRequest, though certain other LifecycleEvents will also originate component events.\n\nEach component event contains:\n* An event type; a string that identifies the type of event\n* An event source; a component that orginates the event (where applicable)\n* A context; an array of strings associated with the event\n\nEvent processing starts with the component that originates the event.\n\nHandler methods for the event within the component are invoked.\n\nIf no handler method aborts the event, then handlers for the originating component's container are invoked.\n\nThis containues until handlers for the page (the root component) are invoked, or until some handler method aborts the event.\n\nThe event is aborted when a handler method returns a non-null, non-void value. The interpretation of that value varies based on the type of event.\n\nEvents are routed to handler methods using the @~OnEvent annotation.\n\nThis annotation is attached to a method within a component class. This method becomes a handler method for an event.\n\nThe annotation allows events to be filtered by event type or by originating component.\n\n{{{\n @OnEvent(value="submit", component="form")\n String handleSubmit()\n {\n // . . .\n\n return "PostSubmit";\n }\n}}}\n\nIn the above hypothetical example, a handler method is attached to a particular component's submit event. After processing the data in the form, the LogicalPageName of another page within the application is returned. The client browser will be redirected to that page.\n\nHandler methods need not be public; they are most often package private (which facilitated UnitTesting of the component class).\n\nHandler methods may take parameters. This is most useful with handler methods related to links, rather than forms.\n\nAssociated with each event is the context, a set of strings defined by the application programmer.\n\nParameters are coerced (see TypeCoercion) from these strings. Alternately, a parameter of type String[] receives the set of strings.\n\n{{{\n @OnEvent(component="delete")\n String deleteAccount(long accountId)\n {\n // . . .\n\n return "AccountPage";\n }\n}}}\n\nHere, ther first context value has been coerced to a long and passed to the deleteAccount() method. Presemuable, an action link on the page, named "delete", is the source of this event.\n\n</div> <div tiddler="ComponentMixins" modifier="HowardLewisShip" modified="200610051243" created="200610051234" tags="mixins">One of the more exciting ideas in Tapestry 5 is //mixins//; the ability to add behavior to a component without writing code. \n\nIt is expected that much common behavior, especially for form control components, will be provided by mixins. Further, many Ajax techniques will take the form of mixins applied to otherwise ordinary components.\n\nA mixin is an additional component class that operates //with// the main component. For a component element within the page, the functionality is provided by the main component class and by\nthe mixin. \n\nMixins are primarily about rendering. Mixin render methods are //mixed in// to the components' render methods. In effect, the different rendering phases of a component are different AOP-like //joinpoints//, and the mixins can provide //before advice//.\n\nMixins can be specified for an //instance// of a component, or c an be specified as part of the //implementation// of a component.\n\nIn the former case, the @Component annotation will be supplemented with a @Mixin annotation. The @Mixin is a list of one or more mixin classes for that component.\n\n''Todo: Template syntax for mixins?''\n\nIn the latter case, the @ComponentClass annotation will be supplemented with a @Mixin annotation.\n\nMixins can be configured. They can have parameters, just like ordinary components. When a formal parameter name is ambiguous, it will be prefixed with the unqualified class name. Thus, you might have to say, "MyMixin.parameterName=someProperty" if "parameterName" is ambiguous (by ambiguous, we mean, a parameter of more than one mixin or of the component itself). \n\nThis disambiguation is //simple//. It is assumed that the unqualified class name will be sufficient to uniquely identify a mixin. That is, it is expected that you will not have the same class name even in different packag es (as mixins, on a single component). In a //degenerate case// where this is not so, it will be necessary to disambiguate the mixin name by create a subclass of the mixin with a new name.\n\n''Todo: how are mixins on a component implementation configured?''\n\nMixins may have persistent state, just as with ordinary components.\n\n</div> <div tiddler="ComponentTemplates" modifier="HowardLewisShip" modified="200610201807" created="200610201801" tags="">There are some issues related to component templates.\n\nFirstly, people are really interested in seeing the return of InvisibleInstrumentation. That is coming.\n\nSecondly, the idea that templates are well-formed XML documents is causing some issues.\n\nThe problem is related to entities and doctypes.\n\nUnless you provide a doctype for the template, [[entities|http://www.htmlhelp.com/reference/html40/entities/]] don't work; they result in template parse errors.\n\nIf you provide a standard doctype, say\n{{{\n <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"\n "http://www.w3.org/TR/REC-html40/loose.dtd">\n}}}\n\nYou also get parse errors, because the DTD does some odd things with comments that the Java SAX parser doesn't seem to understand.\n\nI've had better luck with the XHTML doctype:\n{{{\n<!DOCTYPE htm l PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n}}}\n\nBut this doesn't render quite the way I want it to.\n\nFurther, entities in the text are converted to unicode by the parser, then converted to <numeric> entities on output. Not quite WYSIWYG and potentially confusing.\n\nIt may be necessary to discard SAX and build a limited XML parser that allows entities to be passed through unchanged (they would become a special type of document token).\n\nLastly, the question is how to get the correct DOCTYPE into the rendered output, espcially in the common case that a Border component provides the outer tags, as is common in Tapestry 4. This may have to be configured as a annotation on page classes.</div> +<div tiddler="DeveloperProcedures" modifier="HowardLewisShip" modified="200610281525" created="200610281524" tags="">Tapestry is a big chunk of code, growing every day. We need to not step on each other's toes.\n\n//At this time, Tapestry is pretty single threaded, with Howard setting up the main infrastructure. Soon there's going to be a crowd of folks working on it, and we need to coordinate on this ahead of time.//\n\nBasic guidelines:\n\n* WorkInYourOwnBranch\n* WatchCodeCoverage\n* FocusOnTesting\n* DontTouchInternals\n</div> <div tiddler="DynamicPageState" modifier="HowardLewisShip" modified="200609211635" created="200609211610" tags="">Tapestry 4 has left tracking of dynamic page state as an exercise to the developer. Mostly, this is done using the ''parameters'' parameter of the ~DirectLink component.\n\nDynamic page state is anything that isn't inside a persistent page property. For the most part, this includes page properties updated by a For component\n\nIt seems likely that this information could be automatically encoded into ~URLs. \n\nI'm envisioning a service that accumulates a series of //commands//. Each command is used to store a bit of page state. The commands are serializable. The commands are ultimately serialized into a MIME string and attached as a query parameter to each URL.\n\nWhen such a link is triggered, the commands are de-serialized and each executed in turn. Only when that is finished is any further event processing executed, including calling into to user code.\n\nM y outline for this is to store a series of tuples; each tuple is a component id plus the command to execute.\n\n{{{\npublic interface ComponentCommand<T>\n{\n void execute(T component);\n}\n}}}\n\nThese commands should be immutable.\n\nSo a component, such as a For loop component, could provide itself and a ComponentCommand instance (probably a static inner class) to some kind of PageStateTracker service.\n\n{{{\npublic interface PageStateTracker\n{\n void <T> addCommand(T component, ComponentCommand<T> command);\n}\n}}}\n\nThe commands are kept in the order that they are added, except that new commands for the same component //replace// previous commands for that component.\n\nAs with the Tapestry 4 For component, some mechanism will be needed to store object ids inside the URLs (that is, inside the commands serialized into URL query parameters) and translate back to //equivalent// objects when the link is triggered.\n\nDynamic page state outside of a Fo rm will overlap with some of the FormProcessing inside the form.</div> <div tiddler="EditTemplate" modifier="HowardLewisShip" modified="200609210649" created="200609210648" tags=""><div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div>\n<div class='title' macro='view title'></div>\n<div class='editor' macro='edit title'></div>\n<div class='editor' macro='edit text'></div>\n<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div></div> <div tiddler="EnvironmentalServices" modifier="HowardLewisShip" modified="200609260145" created="200609251547" tags="">Frequently, different components need to //cooperate// during the rendering process.\n\nThis is an established pattern from Tapestry 4, which an enclosing component provides services to the components it encloses. By //encloses// we mean, any components that are rendered as part of the Form's body; give the use of the Block/~RenderBlock components, this can not be determined statically, but is instead determined dynamically, as part of the rendering process.\n\nThe canoncial example of this pattern is Form component, and the complex relationship it has with each form element component it encloses.\n\nIn Tapestry 4, this mechanism was based on the ~IRequestCycle which could store named attributes. The service providing component would store itself into the cycle using a well known name, and service consuming components would retrieve the service using the sam e well known name.\n\nFor Tapestry 5, this will be formalized. A new service will be used to manage this information:\n\n{{{\npublic interface Enviroment\n{\n <T> T push(Class<T> type, T instance);\n\n <T> peek(Class<T> type);\n\n <T> T pop(Class<T> type);\n}\n}}}\n\nThe Environment is unique to a request.</div> @@ -5176,7 +5177,7 @@ <div tiddler="InvisibleInstrumentation" modifier="HowardLewisShip" modified="200610201803" created="200610201802" tags="">A feature of Tapestry 4 where the component id, type and parameters were "hidden" inside ordinary HTML tags.\n\nThis will show up inside Tapestry 5 pretty soon, and look something like:\n{{{\n<span t:type="If" t:test="prop:showWarning" class="warning"> \n . . .\n</span>\n}}}</div> <div tiddler="LogicalPageName" modifier="HowardLewisShip" modified="200610081330" created="200610081330" tags="">A logical page name is the name of a page as it is represented in a URI.\n\nInternally, Tapestry operates on pages using full qualified class names. Technically, the FQCN is the class of the page's root element, but from an end developer point of view, the root element is the page.\n\nThe logical page name must be converted to a fully qualified class name.\n\nA set of LibraryMappings are used. Each library mapping is used to express a folder name, such as "core", with a Java package name, such as org.apache.tapestry.corelib. For pages, the page name is searched for in the pages sub-package (i.e., org.apache.tapestry.corelib.pages). Component libraries have unique folder names mapped to root packages that contain the pages (and components, and mixins) of that library.\n\nWhen there is no folder name, the page is expected to be part of the application, under the pages sub-package of the application's root package.\n\nIf not found there, as a special case, the name is treated as if it were prefixed with "core/". This allows access to the core pages (and more importantly, components -- the search algorithm is the same).\n\nFinally, pages may be organized into folders. These folders become further sub-packages. Thus as page name of "admin/EditUsers" may be resolved to class org.example.myapp.pages.admin.EditUsers.\n\n</div> <div tiddler="MainMenu" modifier="HowardLewisShip" modified="200609210701" created="200609210643" tags="">MasterIndex\n[[RSS feed|tap5devwiki.xml]]\n\n[[Tapestry 5 Home|http://tapestry.apache.org/tapestry5/]]\n[[Howard's Blog|http://howardlewisship.com/blog/]]\n\n[[Formatting Help|http://www.blogjones.com/TiddlyWikiTutorial.html#EasyToEdit%20Welcome%20NewFeatures%20WhereToFindHelp]]</div> -<div tiddler="MasterIndex" modifier="HowardLewisShip" modified="200610201757" created="200609202214" tags="">Top level concepts within Tapestry 5.\n\n* PropBinding -- Notes on the workhorse "prop:" binding prefix\n* TypeCoercion -- How Tapestry 5 extensibly addresses type conversion\n* FormProcessing\n* DynamicPageState -- tracking changes to page state during the render\n* EnvironmentalServices -- how components cooperate during page render\n* ComponentMixins -- A new fundamental way to build web functionality\n* RequestTypes -- Requests, request processing, URL formats\n* ComponentTemplates -- Issues about Component Templates</div> +<div tiddler="MasterIndex" modifier="HowardLewisShip" modified="200610281524" created="200609202214" tags="">Top level concepts within Tapestry 5.\n\nA //meta-note//: This is where new ideas are first explained, usually before being implemented. In many cases, the final implementation is\nnot a perfect match for the notes. That's OK ... as long as the official Maven documentation does a good job. It's not reasonable to expect developers to jump back in here and dot every i and cross every t if they're already expected to generate good Maven documentation.\n\n* PropBinding -- Notes on the workhorse "prop:" binding prefix\n* TypeCoercion -- How Tapestry 5 extensibly addresses type conversion\n* FormProcessing\n* DynamicPageState -- tracking changes to page state during the render\n* EnvironmentalServices -- how components cooperate during page render\n* ComponentMixins -- A new fundamental way to build web functionality\n* RequestTypes -- Requests, request processing , URL formats\n* ComponentTemplates -- Issues about Component Templates\n* DeveloperProcedures -- Your a Tapestry committer ... how do you makes changes?</div> <div tiddler="OGNL" modifier="HowardLewisShip" modified="200610071249" created="200609202254" tags="">The [[Object Graph Navigation Library|http://ognl.org]] was an essential part of Tapestry 4.\n\nOGNL is both exceptionally powerful (especially the higher order things it can do, such as list selections and projections). However, for the highest\nend sites, it is also a performance problem, both because of its heavy use of reflection, and because it uses a lot of code inside synchronized blocks.\n\nIt will be optional in Tapestry 5. I believe it will not be part of the tapestry-core, but may be packaged as tapestry-ognl.\n\nThe "prop:" binding prefix is an effective replacement for OGNL in Tapestry 5. See PropBinding.\n</div> <div tiddler="PageRenderRequest" modifier="HowardLewisShip" modified="200610081333" created="200610071313" tags="">Page render requests are requests used to render a specific page. //render// is the term meaning to compose the HTML response to be sent to the client. Note: HTML is used here only as the most common case, other markups are entirely possible.\n\nIn many cases, pages are stand-alone. No extra information in the URL is necesarry to render them. PersistentProperties of the page will factor in to the rendering of the page.\n\nIn specific cases, a page needs to render within a particular context. The most common example of this is a page that is used to present a specific instance of a database persistent entity. In such a case, the page must be combined with additional data, in the URL, to identify the specific entity to access and render.\n\n! URI Format\n\n{{{\n/page-name.html/id\n}}}\n\nHere "page-name" is the LogicalPageName for the page. \n\nThe &q uot;.html" file extension is used as a delimiter between the page name portion of the URI, and the context portion of the URI. This is necessary because it is not possible (given the plethora of libraries and folders) to determine how many slashes will appear in the URI.\n\nThe context consists of one ore more ids (though a single id is the normal case). The id is used to identify the specific data to be displayed. Further, a page may require multiple ids, which will separated with slashes. Example: /admin/DisplayDetail.html/loginfailures/2006\n\nNote that these context values, the ids, are simply //strings//. Tapestry 4 had a mechanism, the DataSqueezer, that would encode the type of object with its value, as a single string, and convert it back. While seemingly desirable, this facility was easy to abuse, resulting in long and extremely ugly URIs.\n\nAny further information needed by Tapestry will be added to the URI as query parameters. This may include things like us er locale, persistent page properties, applicaition flow identifiers, or anything else we come up with.\n\n! Request Processing\n\nOnce the page and id parameters are identified, the corresponding page will be loaded.\n\nTapestry will fire two events before rendering the page.\n\nThe first event is of type "setupPageRender". This allows the page to process the context (the set of ids). This typically involves reading objects from an external persistent store (a database)\nand storing those objects into transient page properties, in expectaion of the render.\n\nThe @SetupPageRender annotation marks a method to be invoked when this event is triggered. The method may take one or more strings, or an array of strings, as parameters; these will be\nthe context values. The method will normally return void. Other values are ''TBD''. It may also take other simple types, which will be coerced from the string [EMAIL PROTECTED] setup(long id)\n{\n . . .\n}\n}}}\n\n\n\nThe second event is of type "pageValidate". It allows the page to decide whether the page is valid for rendering at this time. This most often involves a check to see if the user is logged into the application, and has the necessary privileges to display the contents of the page. User identity and privileges are //not// concepts built into Tapestry, but are fundamental to the majority of Tapestry applications.</div> <div tiddler="PropBinding" modifier="HowardLewisShip" modified="200610201450" created="200609202203" tags="bindings">The "prop:" binding prefix is the default in a lot of cases, i.e., in any Java code (annotations).\n\nThis binding prefix supports several common idioms even though they are not, precisely, the names of properties. In many cases, this will save developers the bother of using a "literal:" prefix.\n\nThe goal of the "prop:" prefix is to be highly efficient and useful in 90%+ of the cases. [[OGNL]], or synthetic properties in the component class, will pick up the remaining cases.\n\n!Numeric literals\n\nSimple numeric literals should be parsed into read-only, invariant bindings.\n{{{\nprop:5\n\nprop:-22.7\n}}}\n\nThe resulting objects will be of type Long or type Double. TypeCoercion will ensure that component parameters get values (say, int or float) of the correct type.\n\n!Range literals\n\nExpresses a range of integer values, either ascending or descending.\n{{{\nprop:1..10\n\nprop:100..-100\n}}}\n\nThe value of such a binding is Iterable; it can be used by the Loop component.\n\n!Boolean literals\n\n"true" and "false" should also be converted to invariant bindings.\n{{{\nprop:true\n\nprop:false\n}}}\n\n!String literals\n\n//Simple// string literals, enclosed in single quotes. Example:\n{{{\nprop:'Hello World'\n}}}\n\n//Remember that the binding expression will always be enclosed in double quotes.//\n\n!This literal\n\nIn some cases, it is useful to be able to identify the current component:\n{{{\nprop:this\n}}}\n\nEven though a component is not immutable, the value of //this// does not ever change,\nand this binding is also invariant.\n\n!Null literal\n\n{{{\nprop:null\n}}}\n\nThis value is always exactly null. This can be used to set a parameter who'se default value is non-null to the explicit value null.\n\n!Property paths\n\nMulti-step property paths are extremely importa nt.\n\n{{{\nprop:poll.title\n\nprop:identity.user.name\n}}}\n\nThe initial terms need to be readable, they are never updated. Only the final property name must be read/write, and in fact, it is valid to be read-only or write-only.\n\nThe prop: binding factory builds a Java expression to read and update properties. It does not use reflection at runtime. Therefore, the properties of the //declared// type are used. By contrast, [[OGNL]] uses the //actual// type, which is reflection-intensive. Also, unlike OGNL, errors (such as missing properties in the property path) are identified when the page is loaded, rather than when the expression is evaluated.\n</div> @@ -5187,6 +5188,7 @@ <div tiddler="SiteUrl" modifier="HowardLewisShip" modified="200609210703" created="200609210641" tags="">http://tapestry.apache.org/tapestry5/tap5devwiki.html</div> <div tiddler="TabAll" modifier="HowardLewisShip" modified="200609210650" created="200609210650" tags=""><<list all>></div> <div tiddler="TypeCoercion" modifier="HowardLewisShip" modified="200610051240" created="200609202217" tags="parameters types">Automatic coercion of types is essential. This primarily applies to component parameters.\n\nParameters are tied to the [[Binding|http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/Binding.html]] interface.\n\nTapestry component parameters look like simple instance variables, but Tapestry's RuntimeTransformation of component classes means that reading the value of a parameter instance variable //may// invoke Binding.get(), and changing the value of a parameter instance variable will invoke Binding.set().\n\n!Reading From Parameters\n\nReading a parameter value involves two steps:\n* Invoking Binding.get()\n* Converting the result to the type of the parameter (where different)\n\nWhen reading parameters, the binding will provide an object of the type of the bound property. Various kinds of invariant bindings will returned a fixed type, typically a String.\n\nThe parameter will be assigned to a variable that has a known type, possibly a primtive type (int, boolean) or an object type (Map, Date).\n\n!Writing To Parameters\n\nWriting to, or updating, a parameter is in two steps:\n* Converting the new value into a type appropriate for the binding\n* Invoking Binding.set()\n\nWe will be adding a getPropertyType() method to the Binding interface, that will identify the property type of the property bound to the parameter.\n\nThe component will be responsible for performing a coercion from the value provided to the proper type, before invoking Binding.set().\n\n!Coercion Tuples\n\nAt the core of this will be a service that performs type coercions.\n\nCoercions are based on //coercion tuples// that define:\n* A source type\n* A target type\n* An object to perform the coercion from source to target\n* A "cost" for the conversion (possibly, but usually with a standard default value) ''(not yet implemented) ''\n\nAs a special case, the type of null will be treated as type void (i.e., void.class). Thus we can use the same mechanism to identify how to convert from null to other types, such as Boolean or Integer.\n\nThere should be a large number of these tuples available. The most common tuples may be conversions between various types and String.\n\n!Coercion Algorithm\n* Determine the source type (treating null as void.class)\n* Determine the target type (converting primitive types to equivalent wrapper types)\n* If the source type is assignable to the target type, then the input value is valid and the process is complete\n* Find a converter that converts between the source type and the target type, pass the source value through the converter to get a target value\n\nThat last part needs a bit of expansion.\n\nFirst off, there will often ''not'' be a tuple for coercing directly form the source type to the target type.\n\nIn that scenario, the conversion will involve a search to find a sequence of tuples that will perform the coercion. This will take the form a breadth-first search where we look for tuples that coerce from the source type to an intermediate type, then search for tuples from the intermediate type to the target type. This may involve more than two coercions.\n\nYou can think of the set of tuples as a kind of directed graph. Each type is a node on the graph, and each tuple represents a connection between one type and another type (say, from String to Double). What we're trying to do is find a path form a source type (or some super-class or super-interface of the source type) to some target type (or sub-class or sub-interface of the target type).\n\nMay need to express a "cost" of the coercion from start type to target type; this might be useful if there are multiple paths for the conversion. Cost may factor in both the computing expense, and any loss of detail. Basic cost is established in terms of the number of steps and enforced by the order in which tuples are considered and combined.\n\nFor example, a coercion tuple from Number to Float may be represented as the tuple:\n(Number, Float, {{{ return new Float(input.floatValue()); }}})\n\n{{{\npublic interface Coercion<S,T>\n{\n T coerce(S input);\n}\n}}}\n\nIf the input type is an Integer, then a search for Integer->Float will find no entries. At that point, it will be necessary to "climb" the inheritance tree and look for coercions from Number (the super class of Integer); this will find the Number->Float tuple.\n\nAgain, in terms of cost, we might also find a pair of tuples: Object->String and String->Float. This will have a higher cost than the Number->Float tuple and should be rejected in favor of the lower cost coercion.\n\n//Note: cost hasn't been implemented, and likely won't be, unless and until the algorithm as it stands is shown to provide less than optimal results.//\n\nThe algorithm caches t he result of this search, with proper guards for concurrent access. The cache is cleared when an invalidation of the component class loader occurs.\n\n!Configuring the service\n\nThis has been implemented as service tapestry.TypeCoercer.\n\nThe configuration of this service is an unordered collection of CoercionTuple.</div> +<div tiddler="WorkInYourOwnBranch" modifier="HowardLewisShip" modified="200610281536" created="200610281528" tags="">Working in the trunk can be a problem. ''The SVN trunk is where merges happen, not where development happens.''\n\nFor any bit of code change you make, you want to do the following:\n\n* Branch trunk to form your own sandbox\n* Work in the sandbox\n* Ensure high quality: high code coverage, unit and integration tests, up-to-date documentation\n* Announce (on the developer mailing list) that you are committing to trunk\n* Switch your workspace back to trunk\n* Tag trunk as premerge\n* Merge from your sandbox\n* Ensure a good merge (including documentation, tests, and code coverage)\n* Commit your merge to trunk\n* Tag trunk as postmerge\n\n!Branch names\n\nBranch names should consist of your user id, the current date as YYYYMMDD, and a short mneumonic, such as a bug id. Example: {{{hlship-20061027-removeaspectj}}}.\n\nThere's a branches folder for tapestry5/t apestry-core, i.e. [http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/branches/]\n\n!Tag names\n\nPrefix the branch name with "premerge" or "postmerge". i.e. [http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/tags/]\n\nThese are really important when trying to back out a change, the pre and the post give a lot of context to see what actually changed.\n\n!Announcing\n\nMerging is hard enough, it's worse if two people are making possibly conflicting changes at the same time. A little coordination goes a long way.\n\n!Small increments are ''Good''\n\nThis looks like a lot of overhead, but thanks to Subversion, it really isn't. It's still better to do small increments of work. Don't go away for six months and expect an easy job of committing changes. You can do this style of work several times a day (Subversion was created specifically to make tagging, branching, and merging fast).</div> </div> <!--POST-BODY-START--> Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.xml URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.xml?view=diff&rev=468706&r1=468705&r2=468706 ============================================================================== --- tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.xml (original) +++ tapestry/tapestry5/tapestry-core/trunk/src/site/resources/tap5devwiki.xml Sat Oct 28 10:21:51 2006 @@ -6,27 +6,39 @@ <description>The quick and dirty one-stop shopping of random ideas for Tapestry 5.</description> <language>en-us</language> <copyright>Copyright 2006 HowardLewisShip</copyright> -<pubDate>Fri, 20 Oct 2006 18:07:34 GMT</pubDate> -<lastBuildDate>Fri, 20 Oct 2006 18:07:34 GMT</lastBuildDate> +<pubDate>Sat, 28 Oct 2006 15:36:05 GMT</pubDate> +<lastBuildDate>Sat, 28 Oct 2006 15:36:05 GMT</lastBuildDate> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <generator>TiddlyWiki 2.0.11</generator> <item> +<title>WorkInYourOwnBranch</title> +<description>Working in the trunk can be a problem. ''The SVN trunk is where merges happen, not where development happens.''<br /><br />For any bit of code change you make, you want to do the following:<br /><br />* Branch trunk to form your own sandbox<br />* Work in the sandbox<br />* Ensure high quality: high code coverage, unit and integration tests, up-to-date documentation<br />* Announce (on the developer mailing list) that you are committing to trunk<br />* Switch your workspace back to trunk<br />* Tag trunk as premerge<br />* Merge from your sandbox<br />* Ensure a good merge (including documentation, tests, and code coverage)<br />* Commit your merge to trunk<br />* Tag trunk as postmerge<br /><br />!Branch names<br /><br />Branch names should consist of your user id, the current date as YYYYMMDD, and a short mneumonic, such as a bug id. Example: {{{hlship-20061 027-removeaspectj}}}.<br /><br />There's a branches folder for tapestry5/tapestry-core, i.e. [http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/branches/]<br /><br />!Tag names<br /><br />Prefix the branch name with "premerge" or "postmerge". i.e. [http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/tags/]<br /><br />These are really important when trying to back out a change, the pre and the post give a lot of context to see what actually changed.<br /><br />!Announcing<br /><br />Merging is hard enough, it's worse if two people are making possibly conflicting changes at the same time. A little coordination goes a long way.<br /><br />!Small increments are ''Good''<br /><br />This looks like a lot of overhead, but thanks to Subversion, it really isn't. It's still better to do small increments of work. Don't go away for six months and exp ect an easy job of committing changes. You can do this style of work several times a day (Subversion was created specifically to make tagging, branching, and merging fast).</description> +<link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#WorkInYourOwnBranch</link> +<pubDate>Sat, 28 Oct 2006 15:36:05 GMT</pubDate> +</item> +<item> +<title>DeveloperProcedures</title> +<description>Tapestry is a big chunk of code, growing every day. We need to not step on each other's toes.<br /><br />//At this time, Tapestry is pretty single threaded, with Howard setting up the main infrastructure. Soon there's going to be a crowd of folks working on it, and we need to coordinate on this ahead of time.//<br /><br />Basic guidelines:<br /><br />* WorkInYourOwnBranch<br />* WatchCodeCoverage<br />* FocusOnTesting<br />* DontTouchInternals<br /></description> +<link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#DeveloperProcedures</link> +<pubDate>Sat, 28 Oct 2006 15:25:11 GMT</pubDate> +</item> +<item> +<title>MasterIndex</title> +<description>Top level concepts within Tapestry 5.<br /><br />A //meta-note//: This is where new ideas are first explained, usually before being implemented. In many cases, the final implementation is<br />not a perfect match for the notes. That's OK ... as long as the official Maven documentation does a good job. It's not reasonable to expect developers to jump back in here and dot every i and cross every t if they're already expected to generate good Maven documentation.<br /><br />* PropBinding -- Notes on the workhorse "prop:" binding prefix<br />* TypeCoercion -- How Tapestry 5 extensibly addresses type conversion<br />* FormProcessing<br />* DynamicPageState -- tracking changes to page state during the render<br />* EnvironmentalServices -- how components cooperate during page render<br />* ComponentMixins -- A new fundamental way to build web functionality<br />* RequestTypes -- Requests, requ est processing, URL formats<br />* ComponentTemplates -- Issues about Component Templates<br />* DeveloperProcedures -- Your a Tapestry committer ... how do you makes changes?</description> +<link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#MasterIndex</link> +<pubDate>Sat, 28 Oct 2006 15:24:18 GMT</pubDate> +</item> +<item> <title>ComponentTemplates</title> <description>There are some issues related to component templates.<br /><br />Firstly, people are really interested in seeing the return of InvisibleInstrumentation. That is coming.<br /><br />Secondly, the idea that templates are well-formed XML documents is causing some issues.<br /><br />The problem is related to entities and doctypes.<br /><br />Unless you provide a doctype for the template, [[entities|http://www.htmlhelp.com/reference/html40/entities/]] don't work; they result in template parse errors.<br /><br />If you provide a standard doctype, say<br />{{{<br /> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"<br /> "http://www.w3.org/TR/REC-html40/loose.dtd"><br />}}}<br /><br />You also get parse errors, because the DTD does some odd things with comments that the Java SAX parser doesn't seem to understand.<br />&l t;br />I've had better luck with the XHTML doctype:<br />{{{<br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />}}}<br /><br />But this doesn't render quite the way I want it to.<br /><br />Further, entities in the text are converted to unicode by the parser, then converted to <numeric> entities on output. Not quite WYSIWYG and potentially confusing.<br /><br />It may be necessary to discard SAX and build a limited XML parser that allows entities to be passed through unchanged (they would become a special type of document token).<br /><br />Lastly, the question is how to get the correct DOCTYPE into the rendered output, espcially in the common case that a Border component provides the outer tags, as is common in Tapestry 4. This may have to be configured as a annotation on page class es.</description> <link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#ComponentTemplates</link> -<pubDate>Fri, 20 Oct 2006 18:07:34 GMT</pubDate> +<pubDate>Fri, 20 Oct 2006 18:07:00 GMT</pubDate> </item> <item> <title>InvisibleInstrumentation</title> <description>A feature of Tapestry 4 where the component id, type and parameters were "hidden" inside ordinary HTML tags.<br /><br />This will show up inside Tapestry 5 pretty soon, and look something like:<br />{{{<br /><span t:type="If" t:test="prop:showWarning" class="warning"> <br /> . . .<br /></span><br />}}}</description> <link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#InvisibleInstrumentation</link> -<pubDate>Fri, 20 Oct 2006 18:03:21 GMT</pubDate> -</item> -<item> -<title>MasterIndex</title> -<description>Top level concepts within Tapestry 5.<br /><br />* PropBinding -- Notes on the workhorse "prop:" binding prefix<br />* TypeCoercion -- How Tapestry 5 extensibly addresses type conversion<br />* FormProcessing<br />* DynamicPageState -- tracking changes to page state during the render<br />* EnvironmentalServices -- how components cooperate during page render<br />* ComponentMixins -- A new fundamental way to build web functionality<br />* RequestTypes -- Requests, request processing, URL formats<br />* ComponentTemplates -- Issues about Component Templates</description> -<link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#MasterIndex</link> -<pubDate>Fri, 20 Oct 2006 17:57:13 GMT</pubDate> +<pubDate>Fri, 20 Oct 2006 18:03:00 GMT</pubDate> </item> <item> <title>PropBinding</title> @@ -125,18 +137,6 @@ <description><<tabs txtMainTab Timeline Timeline TabTimeline All 'All tiddlers' TabAll Tags 'All tags' TabTags More 'More lists' TabMore>><br /></description> <link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#SideBarTabs</link> <pubDate>Thu, 21 Sep 2006 06:52:00 GMT</pubDate> -</item> -<item> -<title>TabAll</title> -<description><<list all>></description> -<link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#TabAll</link> -<pubDate>Thu, 21 Sep 2006 06:50:00 GMT</pubDate> -</item> -<item> -<title>EditTemplate</title> -<description><div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div><br /><div class='title' macro='view title'></div><br /><div class='editor' macro='edit title'></div><br /><div class='editor' macro='edit text'></div><br /><div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div></description> -<link>http://tapestry.apache.org/tapestry5/tap5devwiki.html#EditTemplate</link> -<pubDate>Thu, 21 Sep 2006 06:49:00 GMT</pubDate> </item> </channel> </rss>