
com.google.code.play2.provider.play23.Play23EbeanEnhancer-tmp1 Maven / Gradle / Ivy
/*
* Copyright 2013-2014 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed 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.
*/
package com.google.code.play2.provider.play23;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.code.play2.provider.api.Play2EbeanEnhancer;
import com.avaje.ebean.enhance.agent.Transformer;
import com.avaje.ebean.enhance.ant.OfflineFileTransform;
import com.avaje.ebean.enhance.ant.TransformationListener;
public class Play23EbeanEnhancer
implements Play2EbeanEnhancer
{
private File outputDirectory;
private List classPathUrls = Collections.emptyList();
@Override
public void setOutputDirectory( File outputDirectory )
{
this.outputDirectory = outputDirectory;
}
@Override
public void setClassPathUrls( List classPathUrls )
{
this.classPathUrls = classPathUrls;
}
@Override
public List enhance( String models ) // what about exceptions?
{
final List enhancedFiles = new ArrayList();
URL[] cp = classPathUrls.toArray( new URL[classPathUrls.size()] );
ClassLoader cl = ClassLoader.getSystemClassLoader();
Transformer t = new Transformer( cp, "debug=-1" );
OfflineFileTransform ft =
new OfflineFileTransform( t, cl, outputDirectory.getAbsolutePath(), outputDirectory.getAbsolutePath() );
ft.setListener( new TransformationListener() {
public void logEvent(String msg)
{
if ( msg.startsWith( "Enhanced " ) )
{
String enhancedFilePath = msg.substring( "Enhanced ".length() );
enhancedFiles.add( new File( enhancedFilePath ) );
}
}
public void logError(String msg)
{
}
});
// try
// {
ft.process( models );
// }
// catch ( Throwable/* ? */e )
// {
//
// }
return enhancedFiles;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy