Skip to content

Instantly share code, notes, and snippets.

View struberg's full-sized avatar

Mark Struberg struberg

  • Vienna
View GitHub Profile
Consider the following annotation
@Qualifier
public @interface ConfigProperty {
@Nonbinding
String value() default "";
}
If I like to programmatically create an annotation instance then I can write
ConfigValue<Integer> port = config.resolve("myUrl)
.as(Integer.class)
.cacheFor(5,TimeUnit.Seconds)
.notifyOnChange(::somemethod);
...
port.get();
public Optional<String> getDings() {
String dings = ...;
return Optional.ofNullable(dings);
}
public void usageWithOptional(Optional<String> val) {
String x = val.orElse("defaultValue");
or
String x = val.get() // and boom if missing instead of Validate.notNull
public class ConfigLocator implements Extension {
private Config config;
public void initConfig(@Observes BeforeBeanDiscovery bbd, BeanManager bm) {
List<ConfigSource> collectedConfigSources = new ArrayList<>();
bm.fireEvent(new CollectConfig(collectedConfigSources));
this.config = ConfigProvider.newConfig()......;
bm.fireEvent(config);
@ApplicationScoped
public class DynamicConfigUsageSample {
private @Inject Config config;
private ConfigValue<String> serverUrlCfg;
private ConfigValue<Integer> serverPortCfg
@PostConstruct
private void init() {
The following small changes allows to use &lt; and &gt; in asciidoctor code parts in reveal.js
-------
(function () {
var optionKeys = ['attributes'];
var defaultOptions = ['showtitle'];
var sections = document.querySelectorAll('[data-asciidoctor]');
var attributes, options;
for (var i = 0, len = sections.length; i < len; i++) {
var currentAttr = sections[i].getAttribute('data-attributes');
Hi Vlad!
The 140 char limit on Twitter isn't really helpful to make to the point statements. At least it seems you totally missed my 2nd tweet. But since the context between 2 tweets often gets lost I thus added a longer explanation as blog post https://struberg.wordpress.com/2016/10/15/tostring-equals-and-hashcode-in-jpa-entities/
I you have read my blog post carefully then you might notice that your first sentence is quite off from what I expressed. You missed that I am focusing on PORTABLE behaviour (which you as a Hibernate maintainer obviously don't care about) and on DEFAULT IDE generated behaviour (which will hit Hibernate as well).
To get things straight: most IDEs do a bad job in GENERATING a good toString(), equals() and hashCode() method. They usually just pick all the attributes. Those generated methods usually also include attributes which are @ElementCollections or @OneToMany fields. I guess you agree with me that touching those fields in e.g. toString() will also trigger lazyLoading even in
import org.apache.deltaspike.core.api.config.ConfigResolver;
import java.util.concurrent.TimeUnit;
/**
* A value taken from DeltaSpike configuration.
* But with configurable expiry time
*
* Use the {@link #get()} method to resolve the cached or re-loaded value
*
* @author Mark Struberg
@RequestScoped
@Named("conversation")
public class ConversationWrapper {
private @Inject Conversation conv;
public Conversation get() {
return conv;
}
}
@struberg
struberg / getrelease.sh
Created September 27, 2016 08:03
Shell script to propagate the Apache OpenWebBeans dist area after the VOTE succeeded
#!/bin/sh
# shell script to propagate the Apache OpenWebBeans dist area
cd $1
curl -O https://repository.apache.org/content/groups/public/org/apache/openwebbeans/openwebbeans-distribution/${1}/openwebbeans-distribution-${1}-binary.tar.gz
curl -O https://repository.apache.org/content/groups/public/org/apache/openwebbeans/openwebbeans-distribution/${1}/openwebbeans-distribution-${1}-binary.tar.gz.asc
curl -O https://repository.apache.org/content/groups/public/org/apache/openwebbeans/openwebbeans-distribution/${1}/openwebbeans-distribution-${1}-binary.tar.gz.md5
curl -O https://repository.apache.org/content/groups/public/org/apache/openwebbeans/openwebbeans-distribution/${1}/openwebbeans-distribution-${1}-binary.tar.gz.sha1
curl -O https://repository.apache.org/content/groups/public/org/apache/openwebbeans/openwebbeans-distribution/${1}/openwebbeans-distribution-${1}-binary.zip