add a system property to configure lab js cache for script loading: true in dev env

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235041 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-01-23 22:32:45 +00:00
parent 57ae3fdc6a
commit ad26a0d39e
6 changed files with 77 additions and 42 deletions

View File

@ -59,4 +59,10 @@ public interface CommonServices
*/
String getAllI18nResources( @QueryParam( "locale" ) String locale )
throws ArchivaRestServiceException;
@Path( "devMode" )
@GET
@Produces( { MediaType.TEXT_PLAIN } )
@RedbackAuthorization( noRestriction = true )
Boolean devMode();
}

View File

@ -168,4 +168,9 @@ public class DefaultCommonServices
IOUtils.closeQuietly( inputStream );
}
}
public Boolean devMode()
{
return Boolean.getBoolean( "archiva.devMode" );
}
}

View File

@ -39,6 +39,8 @@ public class ArchivaRuntimeInfo
private long timestamp;
private boolean devMode;
@Inject
public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties )
@ -46,6 +48,7 @@ public class ArchivaRuntimeInfo
this.version = (String) archivaRuntimeProperties.get( "archiva.version" );
this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" );
this.timestamp = NumberUtils.createLong( (String) archivaRuntimeProperties.get( "archiva.timestamp" ) );
this.devMode = Boolean.getBoolean( "archiva.devMode" );
}
public String getVersion()
@ -78,6 +81,16 @@ public class ArchivaRuntimeInfo
this.timestamp = timestamp;
}
public boolean isDevMode()
{
return devMode;
}
public void setDevMode( boolean devMode )
{
this.devMode = devMode;
}
@Override
public String toString()
{
@ -86,6 +99,7 @@ public class ArchivaRuntimeInfo
sb.append( "{version='" ).append( version ).append( '\'' );
sb.append( ", buildNumber='" ).append( buildNumber ).append( '\'' );
sb.append( ", timestamp=" ).append( timestamp );
sb.append( ", devMode=" ).append( devMode );
sb.append( '}' );
return sb.toString();
}

View File

@ -34,6 +34,7 @@
<tomcatContextXml>${basedir}/src/test/tomcat/tomcat-context.xml</tomcatContextXml>
<tomcatRunPort>9091</tomcatRunPort>
<tomcatRunPath>/archiva</tomcatRunPath>
<archiva.devMode>true</archiva.devMode>
</properties>
<dependencies>
@ -544,6 +545,7 @@
<redback.admin.creation.file>${basedir}/target/auto-admin-creation.properties</redback.admin.creation.file>
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
<archiva.user.configFileName>${project.build.directory}/appserver-base/conf/archiva.xml</archiva.user.configFileName>
<archiva.devMode>${archiva.devMode}</archiva.devMode>
</systemProperties>
</configuration>
<dependencies>
@ -576,6 +578,7 @@
</redback.admin.creation.file>
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
<archiva.user.configFileName>${project.build.directory}/appserver-base/conf/archiva.xml</archiva.user.configFileName>
<archiva.devMode>${archiva.devMode}</archiva.devMode>
</systemProperties>
</configuration>
<dependencies>
@ -606,6 +609,7 @@
<redback.admin.creation.file>${basedir}/target/auto-admin-creation.properties</redback.admin.creation.file>
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
<archiva.user.configFileName>${project.build.directory}/appserver-base/conf/archiva.xml</archiva.user.configFileName>
<archiva.devMode>${archiva.devMode}</archiva.devMode>
</systemProperties>
</configuration>
<dependencies>

View File

@ -40,48 +40,53 @@
</div>
<script type="text/javascript">
require.config({
baseUrl: "js/"
});
// CacheBust is for dev purpose use false in prod env !
var options = {
AlwaysPreserveOrder:true,
BasePath:"js/",
explicit_preloading:false,
CacheBust:true
};
$LAB.setGlobalDefaults(options);
$LAB
.script("jquery.tmpl.js").wait()
.script("archiva/utils.js").wait()
.script("jquery.i18n.properties-1.0.9.js").wait()
.script("archiva/i18nload.js").wait()
.script("jquery.cookie.1.0.0.js").wait()
.script("knockout-debug.js").wait()
.script("jquery-ui-1.8.16.custom.min.js").wait()
.script("jquery.validate.js").wait()
.script("jquery.json-2.3.min.js").wait()
.script("archiva/main-tmpl.js").wait()
.script("archiva/repositories.js").wait()
.script("redback/operation.js").wait()
.script("redback/redback-tmpl.js").wait()
.script("bootstrap-tabs.js")
.script("bootstrap-modal.js")
.script("bootstrap-alerts.js")
.script("bootstrap-dropdown.js")
.script("bootstrap-twipsy.js")
.script("bootstrap-popover.js")
.script("knockout.simpleGrid.js")
.script("knockout.mapping-latest.debug.js")
.script("redback/user.js").wait()
.script("redback/users.js").wait()
.script("redback/redback.js").wait()
.script("redback/register.js").wait()
.script("redback/permission.js").wait()
.script("redback/resource.js").wait()
.script("redback/roles.js").wait()
.script("archiva/main.js");
$.ajax(
{
url: "restServices/archivaServices/commonServices/devMode",
success:function(data){
require.config({
baseUrl: "js/"
});
// CacheBust is for dev purpose use false in prod env !
var options = {
AlwaysPreserveOrder:true,
BasePath:"js/",
explicit_preloading:false,
CacheBust:data=='true'
};
$LAB.setGlobalDefaults(options);
$LAB
.script("jquery.tmpl.js").wait()
.script("archiva/utils.js").wait()
.script("jquery.i18n.properties-1.0.9.js").wait()
.script("archiva/i18nload.js").wait()
.script("jquery.cookie.1.0.0.js").wait()
.script("knockout-debug.js").wait()
.script("jquery-ui-1.8.16.custom.min.js").wait()
.script("jquery.validate.js").wait()
.script("jquery.json-2.3.min.js").wait()
.script("archiva/main-tmpl.js").wait()
.script("archiva/repositories.js").wait()
.script("redback/operation.js").wait()
.script("redback/redback-tmpl.js").wait()
.script("bootstrap-tabs.js")
.script("bootstrap-modal.js")
.script("bootstrap-alerts.js")
.script("bootstrap-dropdown.js")
.script("bootstrap-twipsy.js")
.script("bootstrap-popover.js")
.script("knockout.simpleGrid.js")
.script("knockout.mapping-latest.debug.js")
.script("redback/user.js").wait()
.script("redback/users.js").wait()
.script("redback/redback.js").wait()
.script("redback/register.js").wait()
.script("redback/permission.js").wait()
.script("redback/resource.js").wait()
.script("redback/roles.js").wait()
.script("archiva/main.js");
}
})
</script>
</html>

View File

@ -351,6 +351,7 @@
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<appserver.home>${project.build.directory}/appserver-base</appserver.home>
<derby.system.home>${project.build.directory}</derby.system.home>
<archiva.devMode>true</archiva.devMode>
</systemProperties>
<contextFile>src/test/${container.name}/Catalina/localhost/archiva.xml</contextFile>
<useNaming>true</useNaming>