View Javadoc

1   package org.codehaus.mojo.javascript.assembler;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.File;
20  import java.io.FileReader;
21  
22  import org.apache.maven.plugin.MojoExecutionException;
23  import org.codehaus.mojo.javascript.assembler.io.xpp3.AssemblerXpp3Reader;
24  import org.codehaus.plexus.logging.LogEnabled;
25  import org.codehaus.plexus.logging.Logger;
26  
27  /**
28   * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
29   */
30  public class DefaultAssemblerReader
31      implements AssemblerReader, LogEnabled
32  {
33      private Logger logger;
34  
35      /**
36       * {@inheritDoc}
37       * 
38       * @see org.codehaus.plexus.logging.LogEnabled#enableLogging(org.codehaus.plexus.logging.Logger)
39       */
40      public void enableLogging( Logger logger )
41      {
42          this.logger = logger;
43      }
44  
45      /**
46       * {@inheritDoc}
47       * 
48       * @see org.codehaus.mojo.javascript.assembler.AssemblerReader#getAssembler(java.io.File)
49       */
50      public Assembler getAssembler( File file )
51          throws Exception
52      {
53          AssemblerXpp3Reader reader = new AssemblerXpp3Reader();
54          try
55          {
56              logger.info( "Reading assembler descriptor " + file.getAbsolutePath() );
57              return reader.read( new FileReader( file ) );
58          }
59          catch ( Exception e )
60          {
61              throw new MojoExecutionException( "Failed to read the script assembler descriptor", e );
62          }
63      }
64  }