This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConfigValue<Integer> port = config.resolve("myUrl) | |
.as(Integer.class) | |
.cacheFor(5,TimeUnit.Seconds) | |
.notifyOnChange(::somemethod); | |
... | |
port.get(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class DynamicConfigUsageSample { | |
private @Inject Config config; | |
private ConfigValue<String> serverUrlCfg; | |
private ConfigValue<Integer> serverPortCfg | |
@PostConstruct | |
private void init() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following small changes allows to use < and > 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestScoped | |
@Named("conversation") | |
public class ConversationWrapper { | |
private @Inject Conversation conv; | |
public Conversation get() { | |
return conv; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |