Skip to content

Commit

Permalink
WELD-1949 Keep the original method signature (DeltaSpike compatibility),
Browse files Browse the repository at this point in the history
use WeldClassLoaderResourceLoader and ignore the param completely
  • Loading branch information
mkouba committed Jun 22, 2015
1 parent f4404dd commit 3af1eac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Expand Up @@ -136,7 +136,7 @@
public class WeldStartup {

static {
VersionLogger.LOG.version(Formats.version(WeldBootstrap.class));
VersionLogger.LOG.version(Formats.version(null));
}

private BeanManagerImpl deploymentManager;
Expand Down
32 changes: 24 additions & 8 deletions impl/src/main/java/org/jboss/weld/util/reflection/Formats.java
Expand Up @@ -73,7 +73,7 @@ public class Formats {

private static final String INIT_METHOD_NAME = "<init>";

private static final String BUILD_PROPERTIES_FILE = "/weld-build.properties";
private static final String BUILD_PROPERTIES_FILE = "weld-build.properties";

private Formats() {
}
Expand Down Expand Up @@ -483,13 +483,18 @@ public static String formatAnnotations(Annotation[] annotations) {
return formatIterable(annotations, ANNOTATION_LIST_FUNCTION);
}

public static String version(Class<?> weldClass) {
/**
*
* @param pkg This param is completely ignored
* @return the formatted version
*/
public static String version(@Deprecated Package pkg) {

String version = null;
String timestamp = null;

// First try to get weld-build.properties file
try (InputStream in = weldClass.getResourceAsStream(BUILD_PROPERTIES_FILE)) {
// First try the weld-build.properties file
try (InputStream in = getBuildPropertiesResource()) {
if (in != null) {
Properties buildProperties = new Properties();
buildProperties.load(in);
Expand All @@ -502,12 +507,12 @@ public static String version(Class<?> weldClass) {

if (version == null) {
// If needed use the manifest info
Package pkg = weldClass.getPackage();
if (pkg == null) {
Package pack = WeldClassLoaderResourceLoader.class.getPackage();
if (pack == null) {
throw new IllegalArgumentException("Package can not be null");
}
version = pkg.getSpecificationVersion();
timestamp = pkg.getImplementationVersion();
version = pack.getSpecificationVersion();
timestamp = pack.getImplementationVersion();
}
return version(version, timestamp);
}
Expand Down Expand Up @@ -640,4 +645,15 @@ public static String getNameOfMissingClassLoaderDependency(Throwable e) {
return "[unknown]";
}
}

private static InputStream getBuildPropertiesResource() {
URL url = WeldClassLoaderResourceLoader.INSTANCE.getResource(BUILD_PROPERTIES_FILE);
try {
return url != null ? url.openStream() : null;
} catch (IOException e) {
return null;
}
}


}
Expand Up @@ -121,7 +121,6 @@
import org.jboss.weld.bean.builtin.AbstractBuiltInBean;
import org.jboss.weld.bean.builtin.InstanceImpl;
import org.jboss.weld.bean.proxy.ProxyObject;
import org.jboss.weld.bootstrap.WeldBootstrap;
import org.jboss.weld.bootstrap.enablement.ModuleEnablement;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.BeanDiscoveryMode;
Expand Down Expand Up @@ -166,7 +165,7 @@ static String createDeploymentJson(BeanManagerImpl beanManager, Probe probe) {
JsonObjectBuilder deploymentBuilder = Json.objectBuilder();

// WELD VERSION
deploymentBuilder.add(VERSION, Formats.version(WeldBootstrap.class));
deploymentBuilder.add(VERSION, Formats.version(null));

// BEAN DEPLOYMENT ARCHIVES
JsonArrayBuilder bdasBuilder = Json.arrayBuilder();
Expand Down

0 comments on commit 3af1eac

Please sign in to comment.