Skip navigation
2016

On Friday, Windup 2.6.0.Final was released. Download at the Windup website.

 

There are 2 particular things to highlight:

 

Mavenization.

Windup 2.6 can create a basic Maven project structure for your application. When you execute Windup with the --mavenize flag, Windup analyzes the structure of your application and creates POM files with the appropriate dependencies for each of your application modules.

 

Shared archives

If a big application contains same libraries or modules multiple times appear in multiple places in your input applications, and adjusts incident counts and effort estimates to avoid double-counting. If you analyze multiple applications together, Windup bundles information about the shared archives to present you with information on the common libraries shared across your applications.

 

Besides that, like always - performance improvement, bug fixes, design improvements, additional rules & rules fixes.

 

Enjoy!

When you validate a XML file, and this has a XSD URL for some namespace, and this XSD URL redirects to another URL, then the default EntityResolver2 takes that as a failure.

Jess noticed (and fixed) this when debugging WINDUP-997.

 

So for instance, this XML was not valid, because some of the URLs (perhaps in the linked XSD's) is behind a redirect:

 

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
   
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <mvc:resources mapping="/resources/**" location="/" />
   

 

 

So here's a fixed implementation. It follows only a single redirect, but change the if to a for and it will follow more (don't forget to prevent infinite loop).

 

package org.jboss.windup.rules.apps.xml.xml;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ext.EntityResolver2;

/**
* This is an {@link EntityResolver2} that has been enhanced to support URL redirection.
*
 * @author <a href="mailto:jesse.sightler@gmail.com">Jesse Sightler</a>
*/
public class EnhancedEntityResolver2 implements EntityResolver2
{
  @Override
  public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException
  {
  return null;
  }

  @Override
  public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
  {
  return resolveEntity(null, publicId, null, systemId);
  }

  @Override
  public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException
  {
  URL url = baseURI != null ? new URL(new URL(baseURI), systemId) : new URL(systemId);

  URLConnection connection = url.openConnection();

  // Not a HTTP connection... skip redirection logic
  if (!(connection instanceof HttpURLConnection))
  return new InputSource(connection.getInputStream());

  HttpURLConnection httpConnection = (HttpURLConnection)connection;

  int status = httpConnection.getResponseCode();
  if ((status != HttpURLConnection.HTTP_OK) &&
  (status == HttpURLConnection.HTTP_MOVED_TEMP
  || status == HttpURLConnection.HTTP_MOVED_PERM
  || status == HttpURLConnection.HTTP_SEE_OTHER))
  {
  String newUrl = httpConnection.getHeaderField("Location");
  httpConnection = (HttpURLConnection) new URL(newUrl).openConnection();
  }

  InputSource inputSource = new InputSource(httpConnection.getInputStream());
  inputSource.setSystemId(url.toString());
  inputSource.setPublicId(publicId);
  return inputSource;

  }

}

Filter Blog

By date:
By tag: