View Javadoc

1   /*
2    * Copyright 2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.properties.admin.domain.service;
17  
18  import java.net.URL;
19  import java.util.Collection;
20  
21  import de.smartics.properties.api.config.app.FactoryConfiguration;
22  import de.smartics.properties.api.config.domain.CompoundConfigurationException;
23  import de.smartics.properties.api.config.domain.ConfigurationException;
24  import de.smartics.properties.api.config.domain.ConfigurationProperties;
25  import de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement;
26  import de.smartics.properties.api.config.domain.PropertyProvider;
27  import de.smartics.properties.api.config.domain.key.ConfigurationKey;
28  import de.smartics.properties.api.core.domain.PropertyDescriptorRegistry;
29  import de.smartics.properties.resource.domain.ArtifactId;
30  import de.smartics.properties.resource.domain.ArtifactRef;
31  import de.smartics.properties.resource.repository.RepositoryException;
32  import de.smartics.properties.spi.config.support.ConfigurationPropertiesManagementFactory;
33  import de.smartics.util.lang.NullArgumentException;
34  
35  /**
36   * Provides the URL to the remote repository and otherwise delegates to a passed
37   * in factory.
38   */
39  public final class RemoteConfigurationPropertiesManagementFactory implements
40      ConfigurationPropertiesManagementFactory
41  {
42    // ********************************* Fields *********************************
43  
44    // --- constants ------------------------------------------------------------
45  
46    /**
47     * The class version identifier.
48     */
49    private static final long serialVersionUID = 1L;
50  
51    // --- members --------------------------------------------------------------
52  
53    /**
54     * The factory to delegate calls to.
55     */
56    private final ConfigurationPropertiesManagementFactory delegate;
57  
58    /**
59     * The URL to the remote repository.
60     */
61    private final String remoteUrl;
62  
63    // ****************************** Initializer *******************************
64  
65    // ****************************** Constructors ******************************
66  
67    /**
68     * Default constructor.
69     *
70     * @param delegate the factory to delegate calls to.
71     * @param remoteUrl the URL to the remote repository.
72     */
73    public RemoteConfigurationPropertiesManagementFactory(
74        final ConfigurationPropertiesManagementFactory delegate,
75        final String remoteUrl)
76    {
77      this.delegate = delegate;
78      this.remoteUrl = remoteUrl;
79    }
80  
81    // ****************************** Inner Classes *****************************
82  
83    // ********************************* Methods ********************************
84  
85    // --- init -----------------------------------------------------------------
86  
87    // --- get&set --------------------------------------------------------------
88  
89    /**
90     * Returns the URL to the remote repository.
91     *
92     * @return the URL to the remote repository.
93     */
94    public String getRemoteUrl()
95    {
96      return remoteUrl;
97    }
98  
99    // --- business -------------------------------------------------------------
100 
101   @Override
102   public ConfigurationPropertiesManagement create(final ConfigurationKey<?> key)
103     throws NullPointerException
104   {
105     return delegate.create(key);
106   }
107 
108   @Override
109   public FactoryConfiguration getFactoryConfiguration()
110   {
111     return delegate.getFactoryConfiguration();
112   }
113 
114   @Override
115   public ConfigurationPropertiesManagement remove(final ConfigurationKey<?> key)
116     throws NullPointerException
117   {
118     return delegate.remove(key);
119   }
120 
121   @Override
122   public void addRootLocations(final Collection<URL> urls)
123   {
124     delegate.addRootLocations(urls);
125   }
126 
127   @Override
128   public void release()
129   {
130     delegate.release();
131   }
132 
133   @Override
134   public void addRootLocations(final URL... urls)
135   {
136     delegate.addRootLocations(urls);
137   }
138 
139   @Override
140   public void addPropertyProviders(final Collection<PropertyProvider> providers)
141   {
142     delegate.addPropertyProviders(providers);
143   }
144 
145   @Override
146   public void addPropertyProviders(final PropertyProvider... providers)
147   {
148     delegate.addPropertyProviders(providers);
149   }
150 
151   @Override
152   public ConfigurationPropertiesManagement createManagement(
153       final ConfigurationKey<?> key) throws NullPointerException,
154     ConfigurationException
155   {
156     return delegate.createManagement(key);
157   }
158 
159   @Override
160   public ConfigurationProperties createDefault() throws ConfigurationException
161   {
162     return delegate.createDefault();
163   }
164 
165   @Override
166   public ConfigurationPropertiesManagement createDefaultManagement()
167     throws ConfigurationException
168   {
169     return delegate.createDefaultManagement();
170   }
171 
172   @Override
173   public Collection<ConfigurationKey<?>> getRegisteredConfigurationKeys()
174   {
175     return delegate.getRegisteredConfigurationKeys();
176   }
177 
178   @Override
179   public PropertyDescriptorRegistry getRegistry()
180   {
181     return delegate.getRegistry();
182   }
183 
184   @Override
185   public Collection<ConfigurationKey<?>> materialize()
186   {
187     return delegate.materialize();
188   }
189 
190   @Override
191   public String addRootUrls(final ArtifactId artifactId)
192     throws NullArgumentException, RepositoryException,
193     CompoundConfigurationException
194   {
195     return delegate.addRootUrls(artifactId);
196   }
197 
198   @Override
199   public ArtifactRef getArtifactRef(final String artifactId)
200     throws NullPointerException
201   {
202     return delegate.getArtifactRef(artifactId);
203   }
204 
205   // --- object basics --------------------------------------------------------
206 
207 }