Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@apache.org Received: (qmail 91569 invoked from network); 21 Aug 2002 21:23:05 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 21 Aug 2002 21:23:05 -0000 Received: (qmail 10532 invoked by uid 97); 21 Aug 2002 21:23:29 -0000 Delivered-To: qmlist-jakarta-archive-ant-user@jakarta.apache.org Received: (qmail 10516 invoked by uid 97); 21 Aug 2002 21:23:29 -0000 Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 10503 invoked by uid 98); 21 Aug 2002 21:23:28 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <28336AC23B25D411BEA300105AC7F5441199A600@ICEXCH2> From: "Shackelford, John-Mason" To: 'Ant Users List' Subject: RE: polymorphic data types as nested elements Date: Wed, 21 Aug 2002 16:22:56 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Erik, > I can't quite follow the details of what you're trying to > build exactly I won't waste more of your time on this as I think I am on the right track. For the sake of providing an example (possibly a lousy one) to others working on a similiar project I will summarize what I have been trying to achieve and how I think I can get there using the DynamicConfigurator interface. I am rewriting the PVCS task. The top level task is a command processor that does not know anything about the commands it executes other than that they conform to the PCLICommand interface (abstractly implemented by AbstractCommand which subclasses DataType). Specific commands, Get for instance, subclass AbstractCommand. Since I don't want my PCLI class to know anything about the concrete command classes, I use the DynamicConfigurator to instantiate the appropriate command based on element name. public Object createDynamicElement(String name) throws BuildException { String dataTypeFQN = (String) getProject().getDataTypeDefinitions().get(name); Object obj; try { Class c = Class.forName(dataTypeFQN); obj = c.newInstance(); } catch (Exception e) { throw new BuildException("Element " + name + " not supported."); } // make sure we have a command object if (!(obj instanceof PCLICommand)) throw new BuildException( "Element " + name + " is not a PCLI command and cannot be executed."); return obj; } John-Mason Shackelford Software Developer NCS Pearson - Measurement Services 2510 North Dodge St. Iowa City, IA 52245 319-354-9200x6214 shacjo@ncs.com **************************************************************************** This email may contain confidential material. If you were not an intended recipient, Please notify the sender and delete all copies. We may monitor email to and from our network. **************************************************************************** -- To unsubscribe, e-mail: For additional commands, e-mail: