001 /* 002 * Copyright 2006 Stephen J. McConnell. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.lang; 020 021 import dpml.util.ElementHelper; 022 023 import java.io.IOException; 024 025 import net.dpml.util.Resolver; 026 027 import org.w3c.dom.Element; 028 029 /** 030 * Antlib strategy handler implementation. 031 * 032 * @author <a href="http://www.dpml.net">Digital Product Management Library</a> 033 * @version 2.1.0 034 */ 035 public class AntlibStrategyHandler implements StrategyHandler 036 { 037 /** 038 * Antlib strategy namespace constant. 039 */ 040 public static final String NAMESPACE = "dpml:antlib"; 041 042 /** 043 * Creation of a new antlib strategy. 044 * @param c the target class 045 * @return the strategy instance 046 * @exception IOException if an IO error occurs 047 */ 048 public Strategy newStrategy( Class<?> c ) throws IOException 049 { 050 return newStrategy( c, null ); 051 } 052 053 /** 054 * Creation of a new antlib strategy. 055 * @param c the target class 056 * @param name the name to assign to the strategy 057 * @return the strategy instance 058 * @exception IOException if an IO error occurs 059 */ 060 public Strategy newStrategy( Class<?> c, String name ) throws IOException 061 { 062 throw new UnsupportedOperationException( "newStrategy" ); 063 } 064 065 /** 066 * Construct a strategy definition using a supplied element and value resolver. 067 * @param classloader the classloader 068 * @param element the DOM element definining the deployment strategy 069 * @param resolver symbolic property resolver 070 * @param partition the enclosing partition 071 * @param query the query fragment (ignored) 072 * @param validate the validation policy 073 * @return the strategy definition 074 * @exception IOException if an I/O error occurs 075 */ 076 public Strategy build( 077 ClassLoader classloader, Element element, Resolver resolver, String partition, 078 String query, boolean validate ) throws IOException 079 { 080 String urn = ElementHelper.getAttribute( element, "urn", null, resolver ); 081 String path = ElementHelper.getAttribute( element, "path", null, resolver ); 082 return new AntlibStrategy( classloader, urn, path ); 083 } 084 }