1 Reply Latest reply on Jun 21, 2009 6:28 AM by Nick Belaevski

    Shorten the Develop-Build-Deploy Times

    Christoph Mayerhofer Newbie

      Hi!

      I'm trying to tune the performance of some widgets. Currently it is very hard to test the changes from the javascript files, because I have to make a new build (mvn clean install), copy the build into the JSF Project, build the JSF Project and deploy it to the server. And a build of the ui components takes about 10 minutes.

      How can I shorten my develop-deploy times?

      Thanks for your help,
      Christoph

        • 1. Re: Shorten the Develop-Build-Deploy Times
          Nick Belaevski Master

          Hi Cristoph,

          We are using Eclipse IDE for development; there is a special feature called "Module projects" - using it we don't have to rebuild the whole stuff from the scratch for each JS file change. Please take a look: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151984&postdays=0&postorder=asc&start=0
          http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151282

          Also for development convenience, I've developed a version of ResourceBuilder that first searches for resources in web application folder, then in classpath, so the whole process looks like a development of conventional web application. Here is the code compatible with 3.3.x versions:

          import java.io.IOException;
          import java.io.InputStream;
          import java.util.Date;
          import java.util.Map;
          
          import javax.faces.context.FacesContext;
          
          import org.ajax4jsf.resource.InternetResource;
          import org.ajax4jsf.resource.JarResource;
          import org.ajax4jsf.resource.ResourceBuilderImpl;
          import org.ajax4jsf.resource.ResourceContext;
          import org.ajax4jsf.resource.ResourceNotFoundException;
          import org.ajax4jsf.resource.ResourceRenderer;
          
          
          public class DebugResourceBuilder extends ResourceBuilderImpl {
          
           public DebugResourceBuilder() {
           System.err.println("****************************************************");
           System.err.println("Debug resource builder activated - caching is off!!!");
           System.err.println("****************************************************");
           }
          
           private InternetResource createStubForJarResource(final InternetResource resource) {
           return new InternetResource() {
          
           /**
           * @param context
           * @param data
           * @param attributes
           * @throws IOException
           * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
           */
           public void encode(FacesContext context, Object data,
           Map<String, Object> attributes) throws IOException {
           resource.encode(context, data, attributes);
           }
          
           /**
           * @param context
           * @param data
           * @throws IOException
           * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext, java.lang.Object)
           */
           public void encode(FacesContext context, Object data)
           throws IOException {
           resource.encode(context, data);
           }
          
           /**
           * @param context
           * @param component
           * @param attrs
           * @throws IOException
           * @see org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
           */
           public void encodeBegin(FacesContext context, Object component,
           Map<String, Object> attrs) throws IOException {
           resource.encodeBegin(context, component, attrs);
           }
          
           /**
           * @param context
           * @param component
           * @throws IOException
           * @see org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext, java.lang.Object)
           */
           public void encodeEnd(FacesContext context, Object component)
           throws IOException {
           resource.encodeEnd(context, component);
           }
          
           /**
           * @param resourceContext
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getContentLength(org.ajax4jsf.resource.ResourceContext)
           */
           public int getContentLength(ResourceContext resourceContext) {
           return resource.getContentLength(resourceContext);
           }
          
           /**
           * @param resourceContext
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getContentType(org.ajax4jsf.resource.ResourceContext)
           */
           public String getContentType(ResourceContext resourceContext) {
           return resource.getContentType(resourceContext);
           }
          
           /**
           * @param resourceContext
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getExpired(org.ajax4jsf.resource.ResourceContext)
           */
           public long getExpired(ResourceContext resourceContext) {
           return resource.getExpired(resourceContext);
           }
          
           /**
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getKey()
           */
           public String getKey() {
           return resource.getKey();
           }
          
           /**
           * @param resourceContext
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getLastModified(org.ajax4jsf.resource.ResourceContext)
           */
           public Date getLastModified(ResourceContext resourceContext) {
           return resource.getLastModified(resourceContext);
           }
          
           /**
           * @param key
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
           */
           public Object getProperty(Object key) {
           return resource.getProperty(key);
           }
          
           /**
           * @param resourceContext
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getRenderer(org.ajax4jsf.resource.ResourceContext)
           */
           public ResourceRenderer getRenderer(ResourceContext resourceContext) {
           return resource.getRenderer(resourceContext);
           }
          
           /**
           * @param context
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getResourceAsStream(org.ajax4jsf.resource.ResourceContext)
           */
           public InputStream getResourceAsStream(ResourceContext context) {
           String key = getKey();
           InputStream is = context.getResourceAsStream("/" + key);
           if (is == null) {
           is = resource.getResourceAsStream(context);
           }
          
           return is;
           }
          
           /**
           * @param context
           * @param data
           * @return
           * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext, java.lang.Object)
           */
           public String getUri(FacesContext context, Object data) {
           return resource.getUri(context, data);
           }
          
           /**
           * @param resourceContext
           * @return
           * @see org.ajax4jsf.resource.InternetResource#isCacheable(org.ajax4jsf.resource.ResourceContext)
           */
           public boolean isCacheable(ResourceContext resourceContext) {
           return false;
           }
          
           /**
           * @return
           * @see org.ajax4jsf.resource.InternetResource#isSessionAware()
           */
           public boolean isSessionAware() {
           return resource.isSessionAware();
           }
          
           /**
           * @return
           * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
           */
           public boolean requireFacesContext() {
           return true;
           }
          
           /**
           * @param context
           * @throws IOException
           * @see org.ajax4jsf.resource.InternetResource#send(org.ajax4jsf.resource.ResourceContext)
           */
           public void send(ResourceContext context) throws IOException {
           String key = getKey();
           try {
           InternetResource staticResource = createStaticResource("/" + key);
           staticResource.send(context);
           } catch (ResourceNotFoundException e) {
           resource.send(context);
           }
           }
          
           /**
           * @param response
           * @see org.ajax4jsf.resource.InternetResource#sendHeaders(org.ajax4jsf.resource.ResourceContext)
           */
           public void sendHeaders(ResourceContext response) {
           String key = getKey();
           try {
           InternetResource staticResource = createStaticResource("/" + key);
           staticResource.sendHeaders(response);
           } catch (ResourceNotFoundException e) {
           resource.sendHeaders(response);
           }
           }
          
           /**
           * @param cacheable
           * @see org.ajax4jsf.resource.InternetResource#setCacheable(boolean)
           */
           public void setCacheable(boolean cacheable) {
           resource.setCacheable(cacheable);
           }
          
           /**
           * @param expired
           * @see org.ajax4jsf.resource.InternetResource#setExpired(long)
           */
           public void setExpired(long expired) {
           resource.setExpired(expired);
           }
          
           /**
           * @param key
           * @see org.ajax4jsf.resource.InternetResource#setKey(java.lang.String)
           */
           public void setKey(String key) {
           resource.setKey(key);
           }
          
           /**
           * @param lastModified
           * @see org.ajax4jsf.resource.InternetResource#setLastModified(java.util.Date)
           */
           public void setLastModified(Date lastModified) {
           resource.setLastModified(lastModified);
           }
          
           /**
           * @param key
           * @param value
           * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object, java.lang.Object)
           */
           public void setProperty(Object key, Object value) {
           resource.setProperty(key, value);
           }
          
           /**
           * @param renderer
           * @see org.ajax4jsf.resource.InternetResource#setRenderer(org.ajax4jsf.resource.ResourceRenderer)
           */
           public void setRenderer(ResourceRenderer renderer) {
           resource.setRenderer(renderer);
           }
          
           /**
           * @param sessionAware
           * @see org.ajax4jsf.resource.InternetResource#setSessionAware(boolean)
           */
           public void setSessionAware(boolean sessionAware) {
           resource.setSessionAware(sessionAware);
           }
          
           };
           }
          
           @Override
           public void addResource(InternetResource resource) {
           if (resource instanceof JarResource) {
           resource = createStubForJarResource(resource);
           }
           super.addResource(resource);
           }
          
           @Override
           public void addResource(String key, InternetResource resource) {
           if (resource instanceof JarResource) {
           resource = createStubForJarResource(resource);
           }
           super.addResource(key, resource);
           }
          }
          


          It's being registered using SPI file META-INF\services\org.ajax4jsf.resource.InternetResourceBuilder with
          DebugResourceBuilder
          content.

          Note: this version of ResourceBuilder turns caching off and it's only for development purposes, not for production and it's not supported.