isolate path generation in Repository class

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163753 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-04 05:08:45 +00:00
parent a6bc152aca
commit 27363f855e
5 changed files with 243 additions and 144 deletions

View File

@ -5,6 +5,7 @@ import download.ArtifactDownloader;
import jar.JarMojo;
import model.Dependency;
import model.ModelReader;
import model.Repository;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import test.SurefirePlugin;
@ -18,6 +19,7 @@ import util.Os;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -91,10 +93,6 @@ public class MBoot
private ArtifactDownloader downloader;
private String repoLocal;
private List coreDeps;
private boolean online = true;
private static final String SCOPE_TEST = "test";
@ -138,8 +136,6 @@ public class MBoot
public void run( String[] args )
throws Exception
{
ModelReader reader = new ModelReader( downloader );
String mavenRepoLocal = System.getProperty( "maven.repo.local" );
SettingsReader userModelReader = new SettingsReader();
@ -202,7 +198,16 @@ public class MBoot
System.out.println( "HOWEVER, since you did not specify a repository path, maven will use: " +
repoDir.getAbsolutePath() + " to store artifacts locally." );
}
repoLocal = mavenRepoLocal;
File repoLocalFile = new File( mavenRepoLocal );
repoLocalFile.mkdirs();
if ( !repoLocalFile.canWrite() )
{
System.err.println( "Can't write to " + mavenRepoLocal );
System.exit( 1 );
}
String mavenHome = null;
@ -235,9 +240,13 @@ public class MBoot
online = false;
}
Repository localRepository = new Repository( mavenRepoLocal, Repository.LAYOUT_LEGACY );
ModelReader reader = new ModelReader( localRepository );
if ( online )
{
downloader = new ArtifactDownloader( repoLocal, reader.getRemoteRepositories() );
downloader = new ArtifactDownloader( localRepository, reader.getRemoteRepositories() );
if ( userModelReader.getActiveProxy() != null )
{
Proxy proxy = userModelReader.getActiveProxy();
@ -245,34 +254,38 @@ public class MBoot
}
}
reader = new ModelReader( downloader );
reader = new ModelReader( localRepository );
String basedir = System.getProperty( "user.dir" );
reader.parse( new File( basedir, "maven-mboot2/pom.xml" ) );
ClassLoader bootstrapClassLoader = createClassloaderFromDependencies( reader.getDependencies(), null );
ClassLoader bootstrapClassLoader = createClassloaderFromDependencies( reader.getDependencies(), null,
localRepository );
reader = new ModelReader( downloader );
reader = new ModelReader( localRepository );
reader.parse( new File( basedir, "maven-plugins/maven-surefire-plugin/pom.xml" ) );
List surefireDependencies = reader.getDependencies();
reader = new ModelReader( downloader );
reader = new ModelReader( localRepository );
// Install maven-components POM
installPomFile( repoLocal, new File( basedir, "pom.xml" ) );
installPomFile( localRepository, new File( basedir, "pom.xml" ) );
// Install plugin-parent POM
installPomFile( repoLocal, new File( basedir, "maven-plugins/pom.xml" ) );
installPomFile( localRepository, new File( basedir, "maven-plugins/pom.xml" ) );
// Install plugin-tools-parent POM
installPomFile( repoLocal, new File( basedir, "maven-plugin-tools/pom.xml" ) );
installPomFile( localRepository, new File( basedir, "maven-plugin-tools/pom.xml" ) );
// Install maven-script-parent POM
installPomFile( repoLocal, new File( basedir, "maven-script/pom.xml" ) );
installPomFile( localRepository, new File( basedir, "maven-script/pom.xml" ) );
// Install it-support POM
installPomFile( repoLocal, new File( basedir, "maven-core-it-support/pom.xml" ) );
installPomFile( localRepository, new File( basedir, "maven-core-it-support/pom.xml" ) );
List coreDeps = null;
Dependency corePom = null;
for ( int i = 0; i < builds.length; i++ )
{
@ -284,21 +297,25 @@ public class MBoot
System.setProperty( "basedir", directory );
reader = buildProject( directory, builds[i], bootstrapClassLoader, surefireDependencies );
reader = buildProject( directory, builds[i], bootstrapClassLoader, surefireDependencies, localRepository );
if ( reader.getArtifactId().equals( "maven-core" ) )
{
coreDeps = reader.getDependencies();
corePom = new Dependency( reader.getGroupId(), reader.getArtifactId(), reader.getVersion(),
reader.getPackaging() );
}
System.out.println( "--------------------------------------------------------------------" );
}
reader = new ModelReader( downloader );
reader = new ModelReader( localRepository );
reader.parse( new File( basedir, "maven-plugin-tools/maven-plugin-tools-pluggy/pom.xml" ) );
List dependencies = new ArrayList( reader.getDependencies() );
dependencies.add( new Dependency( reader.getGroupId(), reader.getArtifactId(), reader.getVersion() ) );
IsolatedClassLoader cl = createClassloaderFromDependencies( dependencies, bootstrapClassLoader );
dependencies.add(
new Dependency( reader.getGroupId(), reader.getArtifactId(), reader.getVersion(), reader.getPackaging() ) );
IsolatedClassLoader cl = createClassloaderFromDependencies( dependencies, bootstrapClassLoader,
localRepository );
for ( int i = 0; i < pluginBuilds.length; i++ )
{
@ -310,7 +327,7 @@ public class MBoot
System.setProperty( "basedir", directory );
reader = buildProject( directory, pluginBuilds[i], cl, surefireDependencies );
reader = buildProject( directory, pluginBuilds[i], cl, surefireDependencies, localRepository );
System.out.println( "--------------------------------------------------------------------" );
}
@ -370,7 +387,7 @@ public class MBoot
{
Dependency d = (Dependency) i.next();
File source = new File( repoLocal, d.getRepositoryPath() );
File source = localRepository.getArtifactFile( d );
if ( d.getArtifactId().equals( "classworlds" ) )
{
FileUtils.copyFileToDirectory( source, boot );
@ -386,9 +403,7 @@ public class MBoot
}
// Copy maven itself
// TODO: create a dependency object
FileUtils.copyFileToDirectory( new File( repoLocal, "org.apache.maven/jars/maven-core-2.0-SNAPSHOT.jar" ), lib );
FileUtils.copyFileToDirectory( localRepository.getArtifactFile( corePom ), lib );
System.out.println();
@ -429,13 +444,13 @@ public class MBoot
System.out.println( "Finished at: " + fullStop );
}
public ModelReader buildProject( String basedir, String projectId, ClassLoader classLoader,
List surefireDependencies )
private ModelReader buildProject( String basedir, String projectId, ClassLoader classLoader,
List surefireDependencies, Repository localRepository )
throws Exception
{
System.out.println( "Building project in " + basedir );
ModelReader reader = new ModelReader( downloader );
ModelReader reader = new ModelReader( localRepository );
if ( !reader.parse( new File( basedir, "pom.xml" ) ) )
{
@ -532,11 +547,12 @@ public class MBoot
if ( new File( generatedSources ).exists() )
{
compile( reader.getDependencies(), sources, classes, null, generatedSources, SCOPE_COMPILE );
compile( reader.getDependencies(), sources, classes, null, generatedSources, SCOPE_COMPILE,
localRepository );
}
else
{
compile( reader.getDependencies(), sources, classes, null, null, SCOPE_COMPILE );
compile( reader.getDependencies(), sources, classes, null, null, SCOPE_COMPILE, localRepository );
}
// ----------------------------------------------------------------------
@ -548,7 +564,7 @@ public class MBoot
System.out.println( "Generating maven plugin descriptor ..." );
generatePluginDescriptor( sources, new File( classes, "META-INF/maven" ).getAbsolutePath(),
new File( basedir, "pom.xml" ).getAbsolutePath(), classLoader );
new File( basedir, "pom.xml" ).getAbsolutePath(), classLoader, localRepository );
}
// ----------------------------------------------------------------------
@ -567,7 +583,7 @@ public class MBoot
List testDependencies = reader.getDependencies();
compile( testDependencies, testSources, testClasses, classes, null, SCOPE_TEST );
compile( testDependencies, testSources, testClasses, classes, null, SCOPE_TEST, localRepository );
// ----------------------------------------------------------------------
// Test resources
@ -581,7 +597,7 @@ public class MBoot
// Run tests
// ----------------------------------------------------------------------
runTests( basedir, classes, testClasses, reader, surefireDependencies );
runTests( basedir, classes, testClasses, reader, surefireDependencies, localRepository );
// ----------------------------------------------------------------------
// Create JAR
@ -589,30 +605,32 @@ public class MBoot
createJar( classes, buildDir, reader );
installPom( basedir, repoLocal, reader );
installPom( basedir, localRepository, reader );
String artifactId = reader.getArtifactId();
if ( !artifactId.equals( "maven-plugin" ) && artifactId.endsWith( "plugin" ) )
{
install( basedir, repoLocal, reader, "maven-plugin" );
install( basedir, localRepository, reader, "maven-plugin" );
}
else
{
install( basedir, repoLocal, reader, "jar" );
install( basedir, localRepository, reader, "jar" );
}
return reader;
}
private void generatePluginDescriptor( String sourceDirectory, String outputDirectory, String pom, ClassLoader cl )
private void generatePluginDescriptor( String sourceDirectory, String outputDirectory, String pom, ClassLoader cl,
Repository localRepository )
throws Exception
{
Class cls = cl.loadClass( "org.apache.maven.tools.plugin.pluggy.Main" );
Method m = cls.getMethod( "main", new Class[]{String[].class} );
String[] args = {"descriptor", sourceDirectory, outputDirectory, pom, repoLocal};
// Can pluggy really cope with the layout?
String[] args = {"descriptor", sourceDirectory, outputDirectory, pom, localRepository.getBasedir()};
m.invoke( null, new Object[]{args} );
}
@ -638,7 +656,8 @@ public class MBoot
Thread.currentThread().setContextClassLoader( old );
}
private IsolatedClassLoader createClassloaderFromDependencies( List dependencies, ClassLoader parent )
private IsolatedClassLoader createClassloaderFromDependencies( List dependencies, ClassLoader parent,
Repository localRepository )
throws Exception
{
if ( online )
@ -662,7 +681,7 @@ public class MBoot
{
Dependency dependency = (Dependency) i.next();
File f = new File( repoLocal, dependency.getRepositoryPath() );
File f = localRepository.getArtifactFile( dependency );
if ( !f.exists() )
{
String msg = ( !online ? "; run again online" : "; there was a problem downloading it earlier" );
@ -687,10 +706,10 @@ public class MBoot
jarMojo.execute( new File( classes ), buildDir, artifactId + "-" + version );
}
private void installPomFile( String repoLocal, File pomIn )
private void installPomFile( Repository localRepository, File pomIn )
throws Exception
{
ModelReader reader = new ModelReader( downloader );
ModelReader reader = new ModelReader( localRepository );
if ( !reader.parse( pomIn ) )
{
@ -699,21 +718,18 @@ public class MBoot
System.exit( 1 );
}
String artifactId = reader.getArtifactId();
String version = reader.getVersion();
String groupId = reader.getGroupId();
File pom = new File( repoLocal, "/" + groupId + "/poms/" + artifactId + "-" + version + ".pom" );
System.out.println( "Installing POM: " + pom );
FileUtils.copyFile( pomIn, pom );
installPomFile( reader, localRepository, pomIn );
}
private void installPom( String basedir, String repoLocal, ModelReader reader )
private void installPom( String basedir, Repository localRepository, ModelReader reader )
throws Exception
{
installPomFile( reader, localRepository, new File( basedir, "pom.xml" ) );
}
private void installPomFile( ModelReader reader, Repository localRepository, File source )
throws IOException
{
String artifactId = reader.getArtifactId();
@ -721,14 +737,14 @@ public class MBoot
String groupId = reader.getGroupId();
File pom = new File( repoLocal, "/" + groupId + "/poms/" + artifactId + "-" + version + ".pom" );
File pom = localRepository.getArtifactFile( groupId, artifactId, version, "pom" );
System.out.println( "Installing POM: " + pom );
FileUtils.copyFile( new File( basedir, "pom.xml" ), pom );
FileUtils.copyFile( source, pom );
}
private void install( String basedir, String repoLocal, ModelReader reader, String type )
private void install( String basedir, Repository localRepository, ModelReader reader, String type )
throws Exception
{
String artifactId = reader.getArtifactId();
@ -739,22 +755,24 @@ public class MBoot
String finalName = artifactId + "-" + version;
File file = new File( repoLocal, "/" + groupId + "/" + type + "s/" + finalName + ".jar" );
File file = localRepository.getArtifactFile( groupId, artifactId, version, type );
System.out.println( "Installing: " + file );
FileUtils.copyFile( new File( basedir, BUILD_DIR + "/" + finalName + ".jar" ), file );
if ( version.indexOf( "SNAPSHOT" ) >= 0 )
{
File metadata = new File( repoLocal, "/" + groupId + "/poms/" + finalName + ".version.txt" );
File metadata = localRepository.getMetadataFile( groupId, artifactId, version, type,
finalName + ".version.txt" );
IOUtil.copy( new StringReader( version ), new FileWriter( metadata ) );
}
FileUtils.copyFile( new File( basedir, BUILD_DIR + "/" + finalName + ".jar" ), file );
}
private void runTests( String basedir, String classes, String testClasses, ModelReader reader,
List surefireDependencies )
List surefireDependencies, Repository localRepository )
throws Exception
{
SurefirePlugin testRunner = new SurefirePlugin();
@ -776,7 +794,7 @@ public class MBoot
List depList = new ArrayList( reader.getDependencies() );
depList.addAll( surefireDependencies );
List classpath = classpath( depList, null, SCOPE_TEST );
List classpath = classpath( depList, null, SCOPE_TEST, localRepository );
classpath.add( classes );
classpath.add( testClasses );
boolean success = testRunner.execute( basedir, includes, excludes, classpath, reportsDir );
@ -791,7 +809,7 @@ public class MBoot
// Compile
// ----------------------------------------------------------------------
private List classpath( List dependencies, String extraClasspath, String scope )
private List classpath( List dependencies, String extraClasspath, String scope, Repository localRepository )
{
List classpath = new ArrayList( dependencies.size() + 1 );
@ -799,7 +817,7 @@ public class MBoot
{
Dependency d = (Dependency) dependencies.get( i );
String element = repoLocal + "/" + d.getRepositoryPath();
String element = localRepository.getArtifactFile( d ).getAbsolutePath();
if ( SCOPE_COMPILE.equals( scope ) )
{
@ -827,7 +845,7 @@ public class MBoot
}
private void compile( List dependencies, String sourceDirectory, String outputDirectory, String extraClasspath,
String generatedSources, String scope )
String generatedSources, String scope, Repository localRepository )
throws Exception
{
JavacCompiler compiler = new JavacCompiler();
@ -861,7 +879,8 @@ public class MBoot
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
compilerConfiguration.setOutputLocation( outputDirectory );
compilerConfiguration.setClasspathEntries( classpath( dependencies, extraClasspath, scope ) );
compilerConfiguration.setClasspathEntries(
classpath( dependencies, extraClasspath, scope, localRepository ) );
compilerConfiguration.setSourceLocations( Arrays.asList( sourceDirectories ) );
/* Compile with debugging info */

View File

@ -1,6 +1,7 @@
package download;
import model.Dependency;
import model.Repository;
import java.io.File;
import java.io.FileNotFoundException;
@ -14,8 +15,6 @@ public class ArtifactDownloader
{
public static final String SNAPSHOT_SIGNATURE = "-SNAPSHOT";
private File mavenRepoLocal;
private List remoteRepos;
private boolean useTimestamp = true;
@ -30,7 +29,9 @@ public class ArtifactDownloader
private String proxyPassword;
public ArtifactDownloader( String localRepository, List remoteRepositories )
private Repository localRepository;
public ArtifactDownloader( Repository localRepository, List remoteRepositories )
throws Exception
{
setRemoteRepos( remoteRepositories );
@ -42,34 +43,12 @@ public class ArtifactDownloader
System.exit( 1 );
}
mavenRepoLocal = new File( localRepository );
this.localRepository = localRepository;
if ( !mavenRepoLocal.exists() )
{
if ( !mavenRepoLocal.mkdirs() )
{
System.err.println( "Cannot create the specified local repository: " + mavenRepoLocal );
System.exit( 1 );
}
}
if ( !mavenRepoLocal.canWrite() )
{
System.err.println( "Can't write to " + mavenRepoLocal.getAbsolutePath() );
System.exit( 1 );
}
System.out.println( "Using the following for your local repository: " + mavenRepoLocal );
System.out.println( "Using the following for your local repository: " + localRepository );
System.out.println( "Using the following for your remote repositories: " + remoteRepos );
}
public File getMavenRepoLocal()
{
return mavenRepoLocal;
}
private Set downloadedArtifacts = new HashSet();
public void setProxy( String host, String port, String userName, String password )
@ -90,8 +69,7 @@ public class ArtifactDownloader
if ( !downloadedArtifacts.contains( dep.getId() ) )
{
String repositoryPath = dep.getRepositoryPath();
File destinationFile = new File( mavenRepoLocal, repositoryPath );
File destinationFile = localRepository.getArtifactFile( dep );
// The directory structure for this project may
// not exists so create it if missing.
File directory = destinationFile.getParentFile();
@ -106,7 +84,7 @@ public class ArtifactDownloader
continue;
}
getRemoteArtifact( repositoryPath, destinationFile );
getRemoteArtifact( dep, destinationFile );
if ( !destinationFile.exists() )
{
@ -129,26 +107,22 @@ public class ArtifactDownloader
if ( repositories.isEmpty() )
{
remoteRepos.add( "http://repo1.maven.org" );
// TODO: configure layout
remoteRepos.add( new Repository( "http://repo1.maven.org", Repository.LAYOUT_LEGACY ) );
}
}
private List getRemoteRepos()
{
return remoteRepos;
}
private boolean getRemoteArtifact( String file, File destinationFile )
private boolean getRemoteArtifact( Dependency dep, File destinationFile )
{
boolean fileFound = false;
for ( Iterator i = getRemoteRepos().iterator(); i.hasNext(); )
for ( Iterator i = remoteRepos.iterator(); i.hasNext(); )
{
String remoteRepo = (String) i.next();
Repository remoteRepo = (Repository) i.next();
// The username and password parameters are not being
// used here. Those are the "" parameters you see below.
String url = remoteRepo + "/" + file;
String url = remoteRepo.getArtifactPath( dep );
if ( !url.startsWith( "file" ) )
{

View File

@ -43,11 +43,12 @@ public class Dependency
{
}
public Dependency( String groupId, String artifactId, String version )
public Dependency( String groupId, String artifactId, String version, String type )
{
this.version = version;
this.artifactId = artifactId;
this.groupId = groupId;
this.type = type;
}
public void setId( String id )
@ -193,14 +194,4 @@ public class Dependency
return false;
}
public String getRepositoryPath()
{
return getArtifactDirectory() + "/" + getType() + "s/" + getArtifact();
}
public String toString()
{
return getRepositoryPath();
}
}

View File

@ -16,12 +16,10 @@ package model;
* limitations under the License.
*/
import download.ArtifactDownloader;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import util.AbstractReader;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -51,7 +49,7 @@ public class ModelReader
private List dependencies = new ArrayList();
private List remoteRepositories = new ArrayList();
private List repositories = new ArrayList();
private List resources = new ArrayList();
@ -71,16 +69,18 @@ public class ModelReader
private StringBuffer bodyText = new StringBuffer();
private final ArtifactDownloader downloader;
private final Repository localRepository;
public ModelReader( ArtifactDownloader downloader )
private Repository currentRepository;
public ModelReader( Repository downloader )
{
this.downloader = downloader;
this.localRepository = downloader;
}
public List getRemoteRepositories()
{
return remoteRepositories;
return repositories;
}
public List getDependencies()
@ -101,6 +101,8 @@ public class ModelReader
}
else if ( rawName.equals( "repository" ) )
{
currentRepository = new Repository();
insideRepository = true;
}
else if ( rawName.equals( "dependency" ) )
@ -140,8 +142,6 @@ public class ModelReader
// support both v3 <extend> and v4 <parent>
if ( rawName.equals( "parent" ) )
{
File f;
if ( parentArtifactId == null || parentArtifactId.trim().length() == 0 )
{
throw new SAXException( "Missing required element in <parent>: artifactId." );
@ -167,12 +167,9 @@ public class ModelReader
version = parentVersion;
}
f = new File( downloader.getMavenRepoLocal(), parentGroupId + "/poms/" + parentArtifactId + "-" +
parentVersion + ".pom" );
ModelReader p = new ModelReader( localRepository );
ModelReader p = new ModelReader( downloader );
if ( !p.parse( f ) )
if ( !p.parse( localRepository.getArtifactFile( parentGroupId, parentArtifactId, parentVersion, "pom" ) ) )
{
throw new SAXException( "Could not parse parent pom.xml" );
}
@ -201,6 +198,12 @@ public class ModelReader
insideResource = false;
}
else if ( rawName.equals( "repository" ) )
{
repositories.add( currentRepository );
insideRepository = false;
}
else if ( insideParent )
{
if ( rawName.equals( "groupId" ) )
@ -262,6 +265,17 @@ public class ModelReader
currentResource.addExclude( getBodyText() );
}
}
else if ( insideRepository )
{
if ( rawName.equals( "url" ) )
{
currentRepository.setBasedir( getBodyText() );
}
else if ( rawName.equals( "layout" ) )
{
currentRepository.setLayout( getBodyText() );
}
}
else if ( depth == 2 )
{
if ( rawName.equals( "artifactId" ) )
@ -280,17 +294,6 @@ public class ModelReader
{
packaging = getBodyText();
}
else if ( rawName.equals( "repository" ) )
{
insideRepository = false;
}
}
else if ( insideRepository )
{
if ( rawName.equals( "url" ) )
{
remoteRepositories.add( getBodyText() );
}
}
bodyText = new StringBuffer();

View File

@ -0,0 +1,112 @@
package model;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* 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.
*/
import java.io.File;
/**
* Repository path management.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class Repository
{
private String basedir;
public static final String LAYOUT_LEGACY = "legacy";
private String layout = LAYOUT_LEGACY;
public Repository()
{
}
public Repository( String basedir, String layout )
{
this.basedir = basedir;
this.layout = layout;
}
public File getArtifactFile( String groupId, String artifactId, String version, String type )
{
Dependency d = new Dependency( groupId, artifactId, version, type );
return getArtifactFile( d );
}
public File getArtifactFile( Dependency dependency )
{
String repositoryPath = getArtifactPath( dependency );
return new File( basedir, repositoryPath );
}
public String getArtifactPath( Dependency dependency )
{
String repositoryPath;
if ( LAYOUT_LEGACY.equals( layout ) )
{
repositoryPath = dependency.getArtifactDirectory() + "/" + dependency.getType() + "s/" +
dependency.getArtifact();
}
else
{
throw new IllegalStateException( "Unknown layout: " + layout );
}
return repositoryPath;
}
public File getMetadataFile( String groupId, String artifactId, String version, String type, String filename )
{
Dependency d = new Dependency( groupId, artifactId, version, type );
String repositoryPath;
if ( LAYOUT_LEGACY.equals( layout ) )
{
repositoryPath = d.getArtifactDirectory() + "/poms/" + filename;
}
else
{
throw new IllegalStateException( "Unknown layout: " + layout );
}
return new File( basedir, repositoryPath );
}
public String toString()
{
return basedir;
}
public String getBasedir()
{
return basedir;
}
public void setBasedir( String basedir )
{
this.basedir = basedir;
}
public void setLayout( String layout )
{
this.layout = layout;
}
}