[2/2] incubator-tamaya git commit: TAMAYA-19: Streamlined API and impl.
TAMAYA-19: Streamlined API and impl. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/0b5d4fee Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/0b5d4fee Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/0b5d4fee Branch: refs/heads/master Commit: 0b5d4feefb8d627a2a1f47984abe391fd781d86a Parents: 7183623 Author: anatole anat...@apache.org Authored: Fri Dec 26 01:42:41 2014 +0100 Committer: anatole anat...@apache.org Committed: Fri Dec 26 01:42:41 2014 +0100 -- api/src/main/java/org/apache/tamaya/Codec.java | 96 - .../java/org/apache/tamaya/ConfigChangeSet.java | 167 --- .../apache/tamaya/ConfigChangeSetBuilder.java | 432 --- .../main/java/org/apache/tamaya/MetaInfo.java | 161 --- .../java/org/apache/tamaya/MetaInfoBuilder.java | 200 - .../java/org/apache/tamaya/PropertyAdapter.java | 89 .../org/apache/tamaya/spi/ConfigurationSpi.java | 30 +- .../core/config/AbstractConfiguration.java | 35 +- .../tamaya/core/config/ConfigChangeSet.java | 169 .../core/config/ConfigChangeSetBuilder.java | 359 +++ .../core/config/ConfigurationBuilder.java | 36 +- .../tamaya/core/config/MappedConfiguration.java | 12 - .../config/DefaultConfigurationSpi.java | 17 +- .../inject/ConfigChangeCallbackMethod.java | 4 +- .../internal/inject/ConfiguredSetterMethod.java | 2 +- .../core/internal/inject/ConfiguredType.java| 2 +- .../core/internal/inject/InjectionUtils.java| 25 +- .../inject/WeakConfigListenerManager.java | 2 +- .../properties/AggregatedPropertySource.java| 21 +- .../properties/ContextualPropertySource.java| 17 +- .../properties/DelegatingPropertySource.java| 9 +- .../core/properties/FilteredPropertySource.java | 21 +- .../core/properties/FreezedPropertySource.java | 10 - .../core/properties/MapBasedPropertySource.java | 31 -- .../core/properties/PropertySourceBuilder.java | 40 +- .../core/properties/PropertySourceFactory.java | 18 +- .../properties/ReplacingPropertySource.java | 20 +- .../properties/SubtractingPropertySource.java | 20 - .../properties/ValueFilteredPropertySource.java | 51 +++ .../tamaya/core/config/MutableConfigTest.java | 102 +++-- .../internal/MutableTestConfigProvider.java | 21 +- .../tamaya/ucs/deltaspike/ConfigFiltering.java | 61 +++ 32 files changed, 865 insertions(+), 1415 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0b5d4fee/api/src/main/java/org/apache/tamaya/Codec.java -- diff --git a/api/src/main/java/org/apache/tamaya/Codec.java b/api/src/main/java/org/apache/tamaya/Codec.java deleted file mode 100644 index 90b9676..000 --- a/api/src/main/java/org/apache/tamaya/Codec.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya; - - -import org.apache.tamaya.annotation.WithCodec; -import org.apache.tamaya.spi.CodecSpi; -import org.apache.tamaya.spi.ServiceContext; - -/** - * Interface for an codec that converts a configured String into something else and vice versa. - * This is used for implementing type conversion from a property (String) to a certain target - * type. Hereby the target type can be multivalued (eg eollections), complex or even contain - * full subconfigurations, if needed. The operation converting from a type T to a String can be - * used by mutable configuration/property sources, when applying a {@link org.apache.tamaya.ConfigChangeSet} - * to render the correct String representation of a entry changed. - */ -public interface CodecT{ - -/** - * Adapt the given configuration keys to the required target type. - * @param value the configuration keys - * @return adapted keys - */ -T deserialize(String value); - -/** - * Adapt the given configuration keys to the required
[4/4] incubator-tamaya git commit: TAMAYA-19: Streamlined API and impl.
TAMAYA-19: Streamlined API and impl. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a60570e8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a60570e8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a60570e8 Branch: refs/heads/master Commit: a60570e8e9e561dd2c02c7d0978e846d4d9dd27e Parents: 0b5d4fe Author: anatole anat...@apache.org Authored: Fri Dec 26 01:49:55 2014 +0100 Committer: anatole anat...@apache.org Committed: Fri Dec 26 01:49:55 2014 +0100 -- .../org/apache/tamaya/AggregationPolicy.java| 131 --- .../java/org/apache/tamaya/Configuration.java | 37 +- .../java/org/apache/tamaya/PropertySource.java | 45 - .../tamaya/annotation/ConfiguredProperty.java | 2 +- .../org/apache/tamaya/annotation/WithCodec.java | 45 - .../tamaya/annotation/WithConfigOperator.java | 2 +- .../tamaya/annotation/WithPropertyAdapter.java | 45 + .../java/org/apache/tamaya/spi/CodecSpi.java| 89 -- .../tamaya/spi/DefaultServiceComparator.java| 85 -- .../spi/DefaultServiceContextProvider.java | 9 - .../java/org/apache/tamaya/spi/Orderable.java | 34 - .../org/apache/tamaya/spi/OrdinalProvider.java | 37 - .../apache/tamaya/spi/PropertyAdapterSpi.java | 72 ++ .../tamaya/TestConfigServiceSingletonSpi.java | 15 - .../TestPropertyAdaptersSingletonSpi.java | 66 +- .../services/org.apache.tamaya.spi.CodecSpi | 19 - .../org.apache.tamaya.spi.PropertyAdapterSpi| 19 + .../core/config/FreezedConfiguration.java | 4 +- .../core/internal/config/DefaultCodecSpi.java | 169 .../config/DefaultPropertyAdapterSpi.java | 168 .../config/FallbackSimpleConfigProvider.java| 2 +- .../core/internal/config/FileConfiguration.java | 2 - .../internal/resources/io/AntPathMatcher.java | 4 +- .../AbstractClasspathAwarePropertySource.java | 3 - .../core/properties/AbstractPropertySource.java | 3 +- .../core/properties/AggregationPolicy.java | 133 +++ .../properties/BuildablePropertySource.java | 2 - .../properties/EnvironmentPropertySource.java | 3 - .../core/properties/URLBasedPropertySource.java | 1 - .../tamaya/core/spi/CodecProviderSpi.java | 36 - .../core/spi/DefaultServiceComparator.java | 85 ++ .../core/spi/DefaultServiceContextProvider.java | 112 +++ .../org/apache/tamaya/core/spi/Orderable.java | 34 + .../apache/tamaya/core/spi/OrdinalProvider.java | 37 + .../core/spi/PropertyAdapterProviderSpi.java| 36 + .../services/org.apache.tamaya.spi.CodecSpi | 19 - .../org.apache.tamaya.spi.PropertyAdapterSpi| 19 + .../apache/tamaya/ucs/UC1ReadProperties.java| 5 +- .../apache/tamaya/ucs/UC2CombineProperties.java | 5 +- docs/src/main/asciidoc/design/2_API.adoc| 469 ++ .../main/asciidoc/design/2_CoreConcepts.adoc| 849 --- docs/src/main/asciidoc/design/3_Core.adoc | 356 docs/src/main/asciidoc/design/3_Extensions.adoc | 841 -- docs/src/main/asciidoc/design/4_Extensions.adoc | 841 ++ .../asciidoc/usecases/se/combine-configs.adoc | 14 + .../se/context-dependent-configuration.adoc | 7 + .../usecases/se/dynamic-provisioning.adoc | 17 + .../usecases/se/external-configuration.adoc | 6 + docs/src/main/asciidoc/usecases/se/formats.adoc | 7 + .../main/asciidoc/usecases/se/injection.adoc| 31 + docs/src/main/asciidoc/usecases/se/java8.adoc | 13 + .../main/asciidoc/usecases/se/locations.adoc| 9 + .../main/asciidoc/usecases/se/management.adoc | 7 + .../usecases/se/minimal-propertysource.adoc | 6 + .../usecases/se/multiple-configurations.adoc| 14 + .../usecases/se/scannable-properties.adoc | 4 + .../asciidoc/usecases/se/service-context.adoc | 14 + .../asciidoc/usecases/se/simple-access.adoc | 18 + .../usecases/se/simple-property-access.adoc | 7 + .../main/asciidoc/usecases/se/templates.adoc| 11 + .../usecases/se/type-safe-properties.adoc | 10 + .../usecases/se/value-placeholders.adoc | 8 + docs/src/main/asciidoc/usecases/usecases.adoc | 19 + 63 files changed, 2695 insertions(+), 2517 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a60570e8/api/src/main/java/org/apache/tamaya/AggregationPolicy.java -- diff --git a/api/src/main/java/org/apache/tamaya/AggregationPolicy.java b/api/src/main/java/org/apache/tamaya/AggregationPolicy.java deleted file mode 100644 index c0f7cc0..000 --- a/api/src/main/java/org/apache/tamaya/AggregationPolicy.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software
[1/4] incubator-tamaya git commit: TAMAYA-19: Streamlined API and impl.
Repository: incubator-tamaya Updated Branches: refs/heads/master 0b5d4feef - a60570e8e http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a60570e8/docs/src/main/asciidoc/design/4_Extensions.adoc -- diff --git a/docs/src/main/asciidoc/design/4_Extensions.adoc b/docs/src/main/asciidoc/design/4_Extensions.adoc new file mode 100644 index 000..db949ac --- /dev/null +++ b/docs/src/main/asciidoc/design/4_Extensions.adoc @@ -0,0 +1,841 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +[[CoreConcepts]] +== {name} Core Concepts +Though {name} is a very powerful and flexible solution there are basically only a few simple core concepts required that build +the base of all the other mechanisms: + +The API contains the following core concepts/artifacts: + +* Literal Key/Value Pairs +* _PropertyProvider:_ is the the SPI for a source that provides configuration data. A +PropertyProvider+ + hereby defines + ** a minimalistic SPI to be implemented by the config data source + ** provides data key/value pairs in raw format as String key/values only + ** providers should not have any dependencies other than to the datasource + ** providers may read context dependent data, but basically providers themselves are not contextual. +Context management should be done by the ConfigurationProvider implementation that also is responsible +for combining a set of property providers to a Configuration. + _Configuration_ is the API that users of Tamaya will see, when they access configuration in raw format. Hereby +Configuration+ + ** adds type support for non String types + ** provides functional extension points (+with,query+) + ** allows registering/deregistering of change listeners + ** is the entry point for evaluating the current +Configuration+ + ** each +PropertyProvider+ can be easily converted into a +Configuration+ + ** allows configuration entries to be injected + ** to access configuration _templates_ (annotated interfaces). + ** Configuration may support mutability by allowing instances of +ConfigChangeSet+ to be passed. +* _PropertyProviders_ allows to aggregate different property providers. Hereby property providers are + seen as sets, which can be combined to new providers using set styled operations (aggregate, intersect, subtract). + This allows to model and create composite container providers, to build up more complex configuration models + step by step. +* _MetaInfo_ is provided by each +Configuration, PropertyProvider+ and describes the configuration/provider and its entries. +* _Environment_ is the base model for modelling the environment and the accessor for getting the current +Environment+ instance. +* _Annotations_ a set of annotations allows to configure configuration injection on classes or interface (aka config templates). + +The SPI contains the following core concepts/artifacts: + +* _Bootstrap_ is the delegate singleton that is used by the framework to resolve components. The effective component + loading can be accessed by implementing and registering an instance of +ServiceProvider+ using +java.util.ServiceLoader+. +* All the singleton used explicitly (+PropertyAdapters,PropertyProviders+ are backed up corresponding API interfaces. + To override a singleton's behaviour the corresponding SPI has to be implemented and registered, so it can be loaded + by the current +Bootstrap+ setup (by default ServiceLoader based). +* Also the singleton used implicitly by +Configuration, Environment, Stage+ are backed up corresponding SPI interfaces. + To override a singleton's behaviour the corresponding SPI has to be implemented and registered, so it can be loaded + by the current +Bootstrap+ setup (by default ServiceLoader based). + +This is also reflected in the main parts of the API, which is quite small: + +* +org.apache.tamaya+ contains the main abstractions +Configuration, ConfigOperator, ConfigQuery, PropertyAdapter, Stage, + Environment, PropertyProvider, MetaInfo+ +* +org.apache.tamaya.spi+ contains the SPI interfaces to be implemented by implementations and the +Bootstrap+
[3/4] incubator-tamaya git commit: TAMAYA-19: Streamlined API and impl.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a60570e8/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceContextProvider.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceContextProvider.java b/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceContextProvider.java new file mode 100644 index 000..9a2fb1b --- /dev/null +++ b/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceContextProvider.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.core.spi; + +import org.apache.tamaya.spi.ServiceContext; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This class implements the (default) {@link org.apache.tamaya.spi.ServiceContext} interface and hereby uses the JDK + * {@link java.util.ServiceLoader} to load the services required. + */ +@SuppressWarnings({rawtypes, unchecked}) +class DefaultServiceContextProvider implements ServiceContext { +/** List current services loaded, per class. */ + private final ConcurrentHashMapClass, ListObject servicesLoaded = new ConcurrentHashMap(); +/** Singletons. */ +private final ConcurrentHashMapClass, Optional? singletons = new ConcurrentHashMap(); +/** Comparator for ordering of multiple services found. */ +private DefaultServiceComparator serviceComparator; + +public DefaultServiceContextProvider(){ +serviceComparator = new DefaultServiceComparator(getServices(OrdinalProvider.class, Collections.emptyList())); +} + +@Override +public T OptionalT getService(ClassT serviceType) { + OptionalT cached = (OptionalT)singletons.get(serviceType); +if(cached==null) { +List? extends T services = getServices(serviceType, Collections.emptyList()); +if (services.isEmpty()) { +cached = Optional.empty(); +} +else{ +cached = Optional.of(services.get(0)); +} +singletons.put(serviceType, cached); +} +return cached; +} + +/** + * Loads and registers services. + * + * @param serviceType + *The service type. + * @param T + *the concrete type. + * @param defaultList + *the list current items returned, if no services were found. + * @return the items found, never {@code null}. + */ +@Override +public T List? extends T getServices(final ClassT serviceType, final List? extends T defaultList) { +ListT found = (ListT) servicesLoaded.get(serviceType); +if (found != null) { +return found; +} +return loadServices(serviceType, defaultList); +} + +/** + * Loads and registers services. + * + * @param serviceType The service type. + * @param T the concrete type. + * @param defaultList the list current items returned, if no services were found. + * + * @return the items found, never {@code null}. + */ +private T List? extends T loadServices(final ClassT serviceType, final List? extends T defaultList) { +try { +ListT services = new ArrayList(); +for (T t : ServiceLoader.load(serviceType)) { +services.add(t); +} +if(services.isEmpty()){ +services.addAll(defaultList); +} +if(!serviceType.equals(OrdinalProvider.class)) { +services.sort(serviceComparator); +} +services = Collections.unmodifiableList(services); +final ListT previousServices = (ListT) servicesLoaded.putIfAbsent(serviceType, (ListObject)services); +return previousServices != null ? previousServices : services; +} catch (Exception e) { + Logger.getLogger(DefaultServiceContextProvider.class.getName()).log(Level.WARNING, + Error loading services
Build failed in Jenkins: Tamaya-Master-branch #72
See https://builds.apache.org/job/Tamaya-Master-branch/72/changes Changes: [anatole] TAMAYA-19: Streamlined API and impl. [anatole] TAMAYA-19: Streamlined API and impl. -- Started by an SCM change Building remotely on H11 (Ubuntu ubuntu) in workspace https://builds.apache.org/job/Tamaya-Master-branch/ws/ git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository git config remote.origin.url https://git-wip-us.apache.org/repos/asf/incubator-tamaya.git # timeout=10 Fetching upstream changes from https://git-wip-us.apache.org/repos/asf/incubator-tamaya.git git --version # timeout=10 git fetch --tags --progress https://git-wip-us.apache.org/repos/asf/incubator-tamaya.git +refs/heads/*:refs/remotes/origin/* git rev-parse refs/remotes/origin/master^{commit} # timeout=10 git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 Checking out Revision a60570e8e9e561dd2c02c7d0978e846d4d9dd27e (refs/remotes/origin/master) git config core.sparsecheckout # timeout=10 git checkout -f a60570e8e9e561dd2c02c7d0978e846d4d9dd27e git rev-list 71836233457512579a73f1bd1974aebbfe824796 # timeout=10 Parsing POMs ERROR: Failed to parse POMs java.io.IOException: remote file operation failed: https://builds.apache.org/job/Tamaya-Master-branch/ws/ at hudson.remoting.Channel@255eac78:H11 at hudson.FilePath.act(FilePath.java:916) at hudson.FilePath.act(FilePath.java:893) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:950) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:677) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1706) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:232) Caused by: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [ERROR] Child module https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/environment of https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/pom.xml does not exist @ at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1354) at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1088) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2474) at hudson.remoting.UserRequest.perform(UserRequest.java:118) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:328) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: hudson.remoting.ProxyException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [ERROR] Child module https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/environment of https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/pom.xml does not exist @ at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364) at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:361) at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:331) at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1291) ... 10 more
incubator-tamaya git commit: TAMAYA-34: Removed metainfo from ConfiguredValue.
Repository: incubator-tamaya Updated Branches: refs/heads/master a60570e8e - 644a7b1de TAMAYA-34: Removed metainfo from ConfiguredValue. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/644a7b1d Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/644a7b1d Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/644a7b1d Branch: refs/heads/master Commit: 644a7b1de511cb575bd4f4c117dd289a52e6888c Parents: a60570e Author: anatole anat...@apache.org Authored: Fri Dec 26 02:37:09 2014 +0100 Committer: anatole anat...@apache.org Committed: Fri Dec 26 02:37:09 2014 +0100 -- .../java/org/apache/tamaya/ConfiguredValue.java | 9 +- .../core/config/DefaultConfiguredValue.java | 158 +++ 2 files changed, 160 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/644a7b1d/api/src/main/java/org/apache/tamaya/ConfiguredValue.java -- diff --git a/api/src/main/java/org/apache/tamaya/ConfiguredValue.java b/api/src/main/java/org/apache/tamaya/ConfiguredValue.java index 839e67e..e75cd51 100644 --- a/api/src/main/java/org/apache/tamaya/ConfiguredValue.java +++ b/api/src/main/java/org/apache/tamaya/ConfiguredValue.java @@ -28,7 +28,8 @@ import java.util.function.Predicate; import java.util.function.Supplier; /** - * A accessor for a single configured value. This can be used to support values that may be reinjected, reconfigured. + * A accessor for a single configured value. This can be used to support values that may be reinjected, reconfigured or + * final. * h3Implementation Requirements/h3 * Instances of this class must be * ul @@ -84,12 +85,6 @@ public interface ConfiguredValueT { void removeListener(ConsumerPropertyChangeEvent l); /** - * Get some descriptive meta info on the current value. - * @return the meta info, not null. - */ -String getMetaInfo(); - -/** * Evaluate if the item value has been updated since the last access. * @return true, if item value has been updated since the last access. */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/644a7b1d/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java b/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java new file mode 100644 index 000..eae4057 --- /dev/null +++ b/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java @@ -0,0 +1,158 @@ +package org.apache.tamaya.core.config; + +import org.apache.tamaya.ConfiguredValue; +import org.apache.tamaya.annotation.LoadPolicy; + +import java.beans.PropertyChangeEvent; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; + +/** + * Implementation of a configured value (in progress). + */ +public class DefaultConfiguredValueT implements ConfiguredValueT{ + +private LoadPolicy loadPolicy = LoadPolicy.INITIAL; +private AtomicLong lastUpdate; +private AtomicLong lastAccess; +private OptionalT value; + +public static final DefaultConfiguredValue EMPTY = new DefaultConfiguredValue(null); + +/** + * Returns an empty {@code Optional} instance. No value is present for this + * Optional. + * + * @apiNote Though it may be tempting to do so, avoid testing if an object + * is empty by comparing with {@code ==} against instances returned by + * {@code Option.empty()}. There is no guarantee that it is a singleton. + * Instead, use {@link #isPresent()}. + * + * @param T Type of the non-existent value + * @return an empty {@code Optional} + */ +public static T DefaultConfiguredValueT empty() { +DefaultConfiguredValue v = (DefaultConfiguredValueT) EMPTY; +return v; +} + +private DefaultConfiguredValue(OptionalT item){ +this.value = item; +} + +public static T ConfiguredValueT of(T instance){ +return new DefaultConfiguredValue(Optional.of(instance)); +} + +public static T ConfiguredValueT ofNullable(T value){ +return value == null ? empty() : of(value); +} + +@Override +public LoadPolicy getLoadPolicy() { +return loadPolicy; +} + +@Override +public long getLastAccess() { +return lastAccess.get(); +} + +@Override +public long getLastUpdate() { +return
incubator-tamaya git commit: TAMAYA-34: Fixed serialization.
Repository: incubator-tamaya Updated Branches: refs/heads/master 644a7b1de - 986f99212 TAMAYA-34: Fixed serialization. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/986f9921 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/986f9921 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/986f9921 Branch: refs/heads/master Commit: 986f99212a42a3ff7b4e267059d005631e1db031 Parents: 644a7b1 Author: anatole anat...@apache.org Authored: Fri Dec 26 02:46:55 2014 +0100 Committer: anatole anat...@apache.org Committed: Fri Dec 26 02:46:55 2014 +0100 -- .../core/config/DefaultConfiguredValue.java | 26 +++- 1 file changed, 25 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/986f9921/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java b/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java index eae4057..311fb19 100644 --- a/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java +++ b/core/src/main/java/org/apache/tamaya/core/config/DefaultConfiguredValue.java @@ -4,6 +4,10 @@ import org.apache.tamaya.ConfiguredValue; import org.apache.tamaya.annotation.LoadPolicy; import java.beans.PropertyChangeEvent; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.Objects; import java.util.Optional; import java.util.concurrent.atomic.AtomicLong; @@ -15,7 +19,7 @@ import java.util.function.Supplier; /** * Implementation of a configured value (in progress). */ -public class DefaultConfiguredValueT implements ConfiguredValueT{ +public class DefaultConfiguredValueT implements ConfiguredValueT, Serializable{ private LoadPolicy loadPolicy = LoadPolicy.INITIAL; private AtomicLong lastUpdate; @@ -155,4 +159,24 @@ public class DefaultConfiguredValueT implements ConfiguredValueT{ public OptionalT toOptional(){ return value; } + +private void writeObject(ObjectOutputStream oos)throws IOException{ +oos.writeLong(this.lastAccess.get()); +oos.writeLong(this.lastUpdate.get()); +if(isPresent()) { +oos.writeObject(this.value.get()); +} +else{ +oos.writeObject(null); +} +} + +private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { +this.lastAccess.set(ois.readLong()); +this.lastUpdate.set(ois.readLong()); +if(isPresent()) { +this.value = Optional.of((T)ois.readObject()); +} + +} }
Build failed in Jenkins: Tamaya-Master-branch #74
See https://builds.apache.org/job/Tamaya-Master-branch/74/changes Changes: [anatole] TAMAYA-34: Fixed serialization. -- Started by an SCM change Building remotely on H11 (Ubuntu ubuntu) in workspace https://builds.apache.org/job/Tamaya-Master-branch/ws/ git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository git config remote.origin.url https://git-wip-us.apache.org/repos/asf/incubator-tamaya.git # timeout=10 Fetching upstream changes from https://git-wip-us.apache.org/repos/asf/incubator-tamaya.git git --version # timeout=10 git fetch --tags --progress https://git-wip-us.apache.org/repos/asf/incubator-tamaya.git +refs/heads/*:refs/remotes/origin/* git rev-parse refs/remotes/origin/master^{commit} # timeout=10 git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 Checking out Revision 986f99212a42a3ff7b4e267059d005631e1db031 (refs/remotes/origin/master) git config core.sparsecheckout # timeout=10 git checkout -f 986f99212a42a3ff7b4e267059d005631e1db031 git rev-list 644a7b1de511cb575bd4f4c117dd289a52e6888c # timeout=10 Parsing POMs ERROR: Failed to parse POMs java.io.IOException: remote file operation failed: https://builds.apache.org/job/Tamaya-Master-branch/ws/ at hudson.remoting.Channel@255eac78:H11 at hudson.FilePath.act(FilePath.java:916) at hudson.FilePath.act(FilePath.java:893) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:950) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:677) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1706) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:232) Caused by: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [ERROR] Child module https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/environment of https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/pom.xml does not exist @ at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1354) at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1088) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2474) at hudson.remoting.UserRequest.perform(UserRequest.java:118) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:328) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: hudson.remoting.ProxyException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [ERROR] Child module https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/environment of https://builds.apache.org/job/Tamaya-Master-branch/ws/modules/pom.xml does not exist @ at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364) at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:361) at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:331) at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1291) ... 10 more