Skip to content

Instantly share code, notes, and snippets.

View hferentschik's full-sized avatar

Hardy Ferentschik hferentschik

View GitHub Profile
Good news for all of you waiting for an early version of Hibernate Validator 5 in order to experiment with the new Bean Validation 1.1 ([JSR 349](http://jcp.org/en/jsr/detail?id=349)) features. Hibernate Validator 5.0.0.Alpha1 is now available for download in the [JBoss Maven Repository](http://repository.jboss.org/nexus) under the GAV *org.hibernate:hibernate-validator:5.0.0.Alpha1* or via [SourceForge](http://sourceforge.net/projects/hibernate/files/hibernate-validator/5.0.0.Alpha1).
The focus of the release was the alignment of Hibernate Validator with the first [early draft](http://beanvalidation.org/1.1/) of Bean Validation 1.1 (1.1.0.Alpha1). The Hibernate Validator [changelog](https://hibernate.onjira.com/browse/HV/fixforversion/12051) circles for this reason around [HV-571](https://hibernate.onjira.com/browse/HV-571) which served as placeholder for those specification changes. Of course the biggest change was the formalisation of [method validation](http://beanvalidation.org/1.1/spec/#d0e2147), but t
@hferentschik
hferentschik / awestruct stacktrace
Created September 26, 2012 15:16
in.relation.to
Cached: /Users/hardy/work/hibernate/git/in.relation.to/_site/feed.atom
/Users/hardy/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: [BUG] object allocation during garbage collection phase
ruby 1.9.3p236 (2012-06-11 revision 36031) [x86_64-darwin11.4.0]
-- Control frame information -----------------------------------------------
c:0016 p:---- s:0049 b:0049 l:000048 d:000048 CFUNC :require
c:0015 p:0053 s:0045 b:0045 l:000044 d:000044 METHOD /Users/hardy/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36
c:0014 p:0095 s:0038 b:0038 l:000037 d:000037 TOP /Users/hardy/.rvm/gems/[email protected]/gems/daemons-1.1.9/lib/daemons.rb:12
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 FINISH
c:0012 p:---- s:0034 b:0034 l:000033 d:000033 CFUNC :require
@hferentschik
hferentschik / Log
Created October 8, 2012 14:58
Arquillian w/ Weld SE container multiple deployments
/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/bin/java -Didea.launcher.port=7533 "-Didea.launcher.bin.path=/Applications/Development/IDE/IntelliJ IDEA 11.app/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/Development/IDE/IntelliJ IDEA 11.app/lib/idea_rt.jar:/Applications/Development/IDE/IntelliJ IDEA 11.app/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home/jre/lib/ma
@hferentschik
hferentschik / gist:3910827
Created October 18, 2012 09:59
Java EE integration of BV

This section describes the metadata annotations and deployment descriptor entries that allow an application to obtain instances of the Bean Validation Validator and ValidatorFactory types.

Applications that need to use those interfaces can find appropriate objects by looking up the name java:comp/Validator for Validator and java:comp/ValidatorFactory for ValidatorFactory, or by requesting the injection of an object of the appropriate type via the Resource annotation. The authenticationType and shareable elements of the Resource annotation must not be specified.

@Resource ValidatorFactory validatorFactory;
@Resource Validator validator;

For Validator objects, the default validation context is used. This means that all such Validators will be equivalent to those obtained by first acquiring a ValidatorFactory and then invoking the getValidator method on it with no arguments. In other words, the following two code snippets are equivalent:

private Object invokeMethod(Method m, Object base, Object[] params) {
Class[] parameterTypes = m.getParameterTypes();
Object[] parameters = null;
if (parameterTypes.length > 0) {
ExpressionFactory exprFactory = ExpressionFactory.newInstance();
if (m.isVarArgs()) {
// TODO
} else {
parameters = new Object[parameterTypes.length];
@hferentschik
hferentschik / BeanELResolver
Created January 23, 2013 16:13
How a method is resolved in JUEL
private Method findMethod(Object base, String name, Class<?>[] types, int paramCount) {
if (types != null) {
try {
return findAccessibleMethod(base.getClass().getMethod(name, types));
} catch (NoSuchMethodException e) {
return null;
}
}
Method varArgsMethod = null;
for (Method method : base.getClass().getMethods()) {
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source
~ Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors
~ by the @authors tag. See the copyright.txt in the distribution for a
~ full listing of individual contributors.
~
~ 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source
~ Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors
~ by the @authors tag. See the copyright.txt in the distribution for a
~ full listing of individual contributors.
~
~ 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
@hferentschik
hferentschik / gist:4723955
Created February 6, 2013 16:53
HV 5.0.0.Beta1 release blog

In unison release of Hibernate Validator 5.0.0.Beta1 and Bean Validation TCK 1.1.0.Beta3

Playing catchup with last week's Bean Valdiation specification release (1.1.0.Beta3) we are happy to make the following releases available as well:

  • Bean Validation TCK 1.1.0.Beta3

    • Maven artefacts on the JBoss Maven repository under the GAV org.hibernate.beanvalidation.tck:beanvalidation-tck-tests:1.1.0.Beta3
    • Zip and tar bundles on SourceForge
  • Hibernate Validator 5.0.0.Beta1

  • Maven artefacts on the JBoss Maven repository under the GAV org.hibernate:hibernate-validator:5.0.0.Beta1

#!/bin/bash
# cpustatus
#
# Prints the current state of the CPU like temperature, voltage and speed.
# The temperature is reported in degrees Celsius (C) while
# the CPU speed is calculated in megahertz (MHz).
function convert_to_MHz {
let value=$1/1000
echo "$value"