You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2011/04/27 01:19:49 UTC
svn commit: r1096953 - in /geronimo/server/trunk/framework:
buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/
configs/client-system/src/main/plan/ configs/j2ee-system/src/main/plan/
modules/geronimo-kernel/src/main/java/...
Author: djencks
Date: Tue Apr 26 23:19:49 2011
New Revision: 1096953
URL: http://svn.apache.org/viewvc?rev=1096953&view=rev
Log:
get the attribute manager working as a service. Add support for wrapping services as gbeans. Make ConfigurationExtender asynchronous to avoid deadlocks with blueprint
Added:
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java (with props)
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java (with props)
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java (with props)
Modified:
geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/FrameworkHelper.java
geronimo/server/trunk/framework/configs/client-system/src/main/plan/plan.xml
geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationExtender.java
geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/SwitchableLocalAttributeManager.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/serverinfo/WrappingServerInfo.java
geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/FrameworkHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/FrameworkHelper.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/FrameworkHelper.java (original)
+++ geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/FrameworkHelper.java Tue Apr 26 23:19:49 2011
@@ -101,7 +101,7 @@ public class FrameworkHelper {
}
public Framework start() throws Exception {
-// ThreadLocalProperties.install();
+ ThreadLocalProperties.install();
for (Iterator<Map.Entry<Object, Object>> it = System.getProperties().entrySet().iterator(); it.hasNext(); ) {
Map.Entry<Object, Object> entry = it.next();
if (((String)entry.getKey()).startsWith("karaf.")) {
@@ -119,7 +119,7 @@ public class FrameworkHelper {
try {
destroy();
} finally {
-// ThreadLocalProperties.uninstall();
+ ThreadLocalProperties.uninstall();
}
}
Modified: geronimo/server/trunk/framework/configs/client-system/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/client-system/src/main/plan/plan.xml?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/client-system/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/framework/configs/client-system/src/main/plan/plan.xml Tue Apr 26 23:19:49 2011
@@ -30,21 +30,23 @@
<!--</gbean>-->
<!--Configuration Store service-->
- <!--<gbean name="Local" class="org.apache.geronimo.system.configuration.RepositoryConfigurationStore">-->
+ <gbean name="Local" class="org.apache.geronimo.system.configuration.WrapperConfigurationStore">
<!--<reference name="Repository">-->
<!--<name>Repository</name>-->
<!--</reference>-->
- <!--</gbean>-->
+ <!--<reference name="ConfigurationDataTransformer">-->
+ <!--<name>ConfigurationDataTransformer</name>-->
+ <!--</reference>-->
+ </gbean>
<!--User-editable attribute service-->
- <gbean name="AttributeManager" class="org.apache.geronimo.system.configuration.LocalAttributeManager">
+ <gbean name="AttributeManager" class="org.apache.geronimo.system.configuration.WrapperAttributeManager">
<!--<reference name="ServerInfo">-->
<!--<name>ServerInfo</name>-->
<!--</reference>-->
- <attribute name="readOnly">true</attribute>
- <attribute name="configFile">var/config/config.xml</attribute>
- <attribute name="substitutionsFile">var/config/config-substitutions.properties</attribute>
- <attribute name="substitutionPrefix">org.apache.geronimo.config.substitution.</attribute>
+ <!--<attribute name="configFile">var/config/config.xml</attribute>-->
+ <!--<attribute name="substitutionsFile">var/config/config-substitutions.properties</attribute>-->
+ <!--<attribute name="substitutionPrefix">org.apache.geronimo.config.substitution.</attribute>-->
</gbean>
<!-- ArtifactManager -->
Modified: geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml Tue Apr 26 23:19:49 2011
@@ -49,23 +49,23 @@ specific services - those should be prov
<!--<gbean name="ConfigurationDataTransformer" class="org.apache.geronimo.kernel.config.transformer.GroovyTransformer" />-->
<!--Configuration Store service-->
- <!--<gbean name="Local" class="org.apache.geronimo.system.configuration.RepositoryConfigurationStore">-->
+ <gbean name="Local" class="org.apache.geronimo.system.configuration.WrapperConfigurationStore">
<!--<reference name="Repository">-->
<!--<name>Repository</name>-->
<!--</reference>-->
- <!--<!–<reference name="ConfigurationDataTransformer">–>-->
- <!--<!–<name>ConfigurationDataTransformer</name>–>-->
- <!--<!–</reference>–>-->
- <!--</gbean>-->
+ <!--<reference name="ConfigurationDataTransformer">-->
+ <!--<name>ConfigurationDataTransformer</name>-->
+ <!--</reference>-->
+ </gbean>
<!--User-editable attribute service-->
- <gbean name="AttributeManager" class="org.apache.geronimo.system.configuration.LocalAttributeManager">
- <reference name="ServerInfo">
- <name>ServerInfo</name>
- </reference>
- <attribute name="configFile">var/config/config.xml</attribute>
- <attribute name="substitutionsFile">var/config/config-substitutions.properties</attribute>
- <attribute name="substitutionPrefix">org.apache.geronimo.config.substitution.</attribute>
+ <gbean name="AttributeManager" class="org.apache.geronimo.system.configuration.WrapperAttributeManager">
+ <!--<reference name="ServerInfo">-->
+ <!--<name>ServerInfo</name>-->
+ <!--</reference>-->
+ <!--<attribute name="configFile">var/config/config.xml</attribute>-->
+ <!--<attribute name="substitutionsFile">var/config/config-substitutions.properties</attribute>-->
+ <!--<attribute name="substitutionPrefix">org.apache.geronimo.config.substitution.</attribute>-->
</gbean>
<!-- ArtifactManager -->
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java?rev=1096953&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java Tue Apr 26 23:19:49 2011
@@ -0,0 +1,75 @@
+/*
+ * 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.geronimo.gbean.wrapper;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * A GBean that exposes an osgi service as a gbean. The service has to be a singleton of the supplied interface
+ * @version $Rev:$ $Date:$
+ */
+public class AbstractServiceWrapper<T> {
+
+ private T actual;
+ private CountDownLatch latch = new CountDownLatch(1);
+
+ public AbstractServiceWrapper(final Bundle bundle, Class<T> clazz) {
+ final BundleContext bundleContext = bundle.getBundleContext();
+ ServiceTracker t = new ServiceTracker(bundleContext, clazz.getName(), new ServiceTrackerCustomizer() {
+
+ @Override
+ public Object addingService(ServiceReference serviceReference) {
+ actual = (T) bundleContext.getService(serviceReference);
+ latch.countDown();
+ return null;
+ }
+
+ @Override
+ public void modifiedService(ServiceReference serviceReference, Object o) {
+ }
+
+ @Override
+ public void removedService(ServiceReference serviceReference, Object o) {
+ latch = new CountDownLatch(1);
+ actual = null;
+ }
+ });
+ t.open();
+ }
+
+ protected T get() {
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+
+ }
+ return actual;
+ }
+
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/wrapper/AbstractServiceWrapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationExtender.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationExtender.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationExtender.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationExtender.java Tue Apr 26 23:19:49 2011
@@ -20,20 +20,17 @@ package org.apache.geronimo.kernel.confi
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.util.IOUtils;
import org.osgi.framework.Bundle;
@@ -52,7 +49,10 @@ public class ConfigurationExtender {
private static final Logger logger = LoggerFactory.getLogger(ConfigurationExtender.class);
- private final Map<Long, Configuration> configurationMap = new ConcurrentHashMap<Long, Configuration>();
+ private final Map<Long, GetConfiguration> configurationMap = new ConcurrentHashMap<Long, GetConfiguration>();
+
+ private final Executor executor = Executors.newCachedThreadPool();
+
private BundleTracker bt;
@@ -113,9 +113,9 @@ public class ConfigurationExtender {
@Override
public void removedBundle(Bundle bundle, BundleEvent bundleEvent, Object o) {
if (bundleEvent.getType() == BundleEvent.STOPPED) {
- stopConfiguration(bundle, (Configuration)o);
+ stopConfiguration(bundle, (GetConfiguration)o);
} else if (bundleEvent.getType() == BundleEvent.UNRESOLVED) {
- unloadConfiguration(bundle, (Configuration)o);
+ unloadConfiguration(bundle, (GetConfiguration)o);
}
}
}
@@ -156,65 +156,65 @@ public class ConfigurationExtender {
// } while (bundleStatusChanged);
// }
- private Configuration loadConfiguration(Bundle bundle) {
+ private LoadConfiguration loadConfiguration(Bundle bundle) {
// loadedBundleIds.add(bundle.getBundleId());
URL configSerURL = bundle.getEntry("META-INF/config.ser");
if (configSerURL == null) {
return null;
}
- InputStream in = null;
- try {
- in = configSerURL.openStream();
- //TODO there are additional consistency checks in RepositoryConfigurationStore that we should use.
- ConfigurationData data = ConfigurationUtil.readConfigurationData(in);
- data.setBundle(bundle);
- Configuration configuration = new Configuration(data, manageableAttributeStore);
- configurationMap.put(bundle.getBundleId(), configuration);
- ConfigurationUtil.loadConfigurationGBeans(configuration, kernel);
-// for (GBeanData gBeanData: configuration.getGBeans().values()) {
-// kernel.loadGBean(gBeanData, configuration.getBundle());
-// }
- return configuration;
-
-// configurationManager.loadConfiguration(data);
-// bundleIdArtifactMap.put(bundle.getBundleId(), data.getId());
- } catch (IOException e) {
- logger.error("Could not read the config.ser file from bundle " + bundle.getLocation(), e);
- } catch (ClassNotFoundException e) {
- logger.error("Could not load required classes from bundle " + bundle.getLocation(), e);
- } catch (InvalidConfigException e) {
- logger.error("Could not load Configuration from bundle " + bundle.getLocation(), e);
-// } catch (GBeanAlreadyExistsException e) {
-// logger.error("Duplicate gbean in bundle " + bundle.getLocation(), e);
- } finally {
- IOUtils.close(in);
- }
- return null;
+ LoadConfiguration loader = new LoadConfiguration(bundle, configSerURL);
+ executor.execute(loader);
+ configurationMap.put(bundle.getBundleId(), loader);
+ return loader;
+//
+// InputStream in = null;
+// try {
+// in = configSerURL.openStream();
+// //TODO there are additional consistency checks in RepositoryConfigurationStore that we should use.
+// ConfigurationData data = ConfigurationUtil.readConfigurationData(in);
+// data.setBundle(bundle);
+// Configuration configuration = new Configuration(data, manageableAttributeStore);
+// configurationMap.put(bundle.getBundleId(), configuration);
+// ConfigurationUtil.loadConfigurationGBeans(configuration, kernel);
+//// for (GBeanData gBeanData: configuration.getGBeans().values()) {
+//// kernel.loadGBean(gBeanData, configuration.getBundle());
+//// }
+// return configuration;
+//
+//// configurationManager.loadConfiguration(data);
+//// bundleIdArtifactMap.put(bundle.getBundleId(), data.getId());
+// } catch (IOException e) {
+// logger.error("Could not read the config.ser file from bundle " + bundle.getLocation(), e);
+// } catch (ClassNotFoundException e) {
+// logger.error("Could not load required classes from bundle " + bundle.getLocation(), e);
+// } catch (InvalidConfigException e) {
+// logger.error("Could not load Configuration from bundle " + bundle.getLocation(), e);
+//// } catch (GBeanAlreadyExistsException e) {
+//// logger.error("Duplicate gbean in bundle " + bundle.getLocation(), e);
+// } finally {
+// IOUtils.close(in);
+// }
+// return null;
}
- private Configuration startConfiguration(Bundle bundle) {
- Configuration configuration = configurationMap.get(bundle.getBundleId());
- if (configuration != null) {
- try {
- ConfigurationUtil.startConfigurationGBeans(configuration, kernel);
- } catch (InvalidConfigException e) {
- logger.error("Could not start Configuration from bundle " + bundle.getLocation(), e);
- }
+ private StartConfiguration startConfiguration(Bundle bundle) {
+ GetConfiguration loader = configurationMap.get(bundle.getBundleId());
+ if (loader != null) {
+ StartConfiguration startConfiguration = new StartConfiguration(loader);
+ executor.execute(startConfiguration);
+ configurationMap.put(bundle.getBundleId(), startConfiguration);
+ return startConfiguration;
}
-
- return configuration;
+ return null;
}
- protected void stopConfiguration(Bundle bundle, Configuration configuration) {
+ protected void stopConfiguration(Bundle bundle, GetConfiguration configuration) {
if (configuration != null) {
- for (AbstractName abstractName: configuration.getGBeans().keySet()) {
- try {
- kernel.stopGBean(abstractName);
- } catch (GBeanNotFoundException e) {
- logger.error("Could not stop gbean " + abstractName + " from bundle " + bundle.getLocation(), e);
- }
- }
+ GetConfiguration start = configurationMap.get(bundle.getBundleId());
+ StopConfiguration stopConfiguration = new StopConfiguration(start);
+ executor.execute(stopConfiguration);
+ configurationMap.put(bundle.getBundleId(), stopConfiguration);
}
// Artifact id = getArtifact(bundle);
// if (id == null) {
@@ -257,42 +257,179 @@ public class ConfigurationExtender {
// }
}
- private void unloadConfiguration(Bundle bundle, Configuration configuration) {
+ private void unloadConfiguration(Bundle bundle, GetConfiguration configuration) {
if (configuration != null) {
- for (AbstractName abstractName: configuration.getGBeans().keySet()) {
+ GetConfiguration start = configurationMap.get(bundle.getBundleId());
+ UnloadConfiguration unloadConfiguration = new UnloadConfiguration(start);
+ executor.execute(unloadConfiguration);
+ configurationMap.remove(bundle.getBundleId());
+ }
+ }
+
+ private interface GetConfiguration {
+
+ Configuration getConfiguration();
+
+ Bundle getBundle();
+
+ }
+
+ private class LoadConfiguration implements Runnable, GetConfiguration {
+
+ private final URL configSerURL;
+ private final Bundle bundle;
+ private Configuration configuration;
+ private CountDownLatch latch = new CountDownLatch(1);
+
+ private LoadConfiguration(Bundle bundle, URL configSerURL) {
+ this.bundle = bundle;
+ this.configSerURL = configSerURL;
+ }
+
+ @Override
+ public void run() {
+ InputStream in = null;
+ try {
+ in = configSerURL.openStream();
+ //TODO there are additional consistency checks in RepositoryConfigurationStore that we should use.
+ ConfigurationData data = ConfigurationUtil.readConfigurationData(in);
+ data.setBundle(bundle);
+ Configuration configuration = new Configuration(data, manageableAttributeStore);
+ ConfigurationUtil.loadConfigurationGBeans(configuration, kernel);
+// for (GBeanData gBeanData: configuration.getGBeans().values()) {
+// kernel.loadGBean(gBeanData, configuration.getBundle());
+// }
+ this.configuration = configuration;
+
+// configurationManager.loadConfiguration(data);
+// bundleIdArtifactMap.put(bundle.getBundleId(), data.getId());
+ } catch (IOException e) {
+ logger.error("Could not read the config.ser file from bundle " + bundle.getLocation(), e);
+ } catch (ClassNotFoundException e) {
+ logger.error("Could not load required classes from bundle " + bundle.getLocation(), e);
+ } catch (InvalidConfigException e) {
+ logger.error("Could not load Configuration from bundle " + bundle.getLocation(), e);
+// } catch (GBeanAlreadyExistsException e) {
+// logger.error("Duplicate gbean in bundle " + bundle.getLocation(), e);
+ } finally {
+ IOUtils.close(in);
+ }
+ latch.countDown();
+
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+
+ }
+ return configuration;
+ }
+
+ @Override
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ }
+
+ private class StartConfiguration implements Runnable, GetConfiguration {
+
+ private final GetConfiguration loader;
+ private CountDownLatch latch = new CountDownLatch(1);
+
+ private StartConfiguration(GetConfiguration loader) {
+ this.loader = loader;
+ }
+
+ @Override
+ public void run() {
+ Configuration configuration = loader.getConfiguration();
+ if (configuration != null) {
try {
- kernel.unloadGBean(abstractName);
- } catch (GBeanNotFoundException e) {
- logger.error("Could not unload gbean " + abstractName + " from bundle " + bundle.getLocation(), e);
+ ConfigurationUtil.startConfigurationGBeans(configuration, kernel);
+ } catch (InvalidConfigException e) {
+ logger.error("Could not start Configuration from bundle " + loader.getBundle().getLocation(), e);
}
}
+ latch.countDown();
+ }
+ @Override
+ public Configuration getConfiguration() {
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+
+ }
+ return loader.getConfiguration();
+ }
+ @Override
+ public Bundle getBundle() {
+ return loader.getBundle();
}
- }
+ }
- private class BundleListener {
+ private class StopConfiguration implements Runnable, GetConfiguration {
- private Bundle hostBundle;
+ private final GetConfiguration loader;
+ private CountDownLatch latch = new CountDownLatch(1);
- private Set<Long> dependentBundleIds = new HashSet<Long>();
+ private StopConfiguration(GetConfiguration loader) {
+ this.loader = loader;
+ }
- public BundleListener(Bundle hostBundle, Set<Long> dependentBundleIds) {
- this.hostBundle = hostBundle;
- this.dependentBundleIds = dependentBundleIds;
+ @Override
+ public void run() {
+ Configuration configuration = loader.getConfiguration();
+ if (configuration != null) {
+ try {
+ ConfigurationUtil.stopConfigurationGBeans(configuration, kernel);
+ } catch (InvalidConfigException e) {
+ logger.error("Could not start Configuration from bundle " + loader.getBundle().getLocation(), e);
+ }
+ }
+ latch.countDown();
}
+ @Override
+ public Configuration getConfiguration() {
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
- public boolean bundleChanged(Bundle bundle) {
- Long dependentBundleId = bundle.getBundleId();
- if (!dependentBundleIds.contains(dependentBundleId)) {
- return false;
}
- dependentBundleIds.remove(dependentBundleId);
- if (dependentBundleIds.size() == 0) {
-// _loadConfiguration(hostBundle);
- return true;
+ return loader.getConfiguration();
+ }
+
+ @Override
+ public Bundle getBundle() {
+ return loader.getBundle();
+ }
+ }
+
+ private class UnloadConfiguration implements Runnable {
+
+ private final GetConfiguration loader;
+ private CountDownLatch latch = new CountDownLatch(1);
+
+ private UnloadConfiguration(GetConfiguration loader) {
+ this.loader = loader;
+ }
+
+ @Override
+ public void run() {
+ Configuration configuration = loader.getConfiguration();
+ if (configuration != null) {
+ try {
+ ConfigurationUtil.unloadConfigurationGBeans(configuration, kernel);
+ } catch (InvalidConfigException e) {
+ logger.error("Could not start Configuration from bundle " + loader.getBundle().getLocation(), e);
+ }
}
- return false;
+ latch.countDown();
}
}
Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Tue Apr 26 23:19:49 2011
@@ -1793,21 +1793,21 @@ public class PluginInstallerGBean implem
return;
}
if (!pluginData.getConfigSubstitution().isEmpty()) {
- Map<String, Properties> propertiesMap = toPropertiesMap(pluginData.getConfigSubstitution());
- for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) {
+ Map<String, Map<String, String>> propertiesMap = toPropertiesMap(pluginData.getConfigSubstitution());
+ for (Map.Entry<String, Map<String, String>> entry : propertiesMap.entrySet()) {
String serverName = entry.getKey();
ServerInstance serverInstance = getServerInstance(serverName, servers);
serverInstance.getAttributeStore().addConfigSubstitutions(entry.getValue());
}
}
- if (!pluginData.getArtifactAlias().isEmpty()) {
- Map<String, Properties> propertiesMap = toPropertiesMap(pluginData.getArtifactAlias());
- for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) {
- String serverName = entry.getKey();
- ServerInstance serverInstance = getServerInstance(serverName, servers);
- serverInstance.getArtifactResolver().addAliases(entry.getValue());
- }
- }
+// if (!pluginData.getArtifactAlias().isEmpty()) {
+// Map<String, Map<String, String>> propertiesMap = toPropertiesMap(pluginData.getArtifactAlias());
+// for (Map.Entry<String, Map<String, String>> entry : propertiesMap.entrySet()) {
+// String serverName = entry.getKey();
+// ServerInstance serverInstance = getServerInstance(serverName, servers);
+// serverInstance.getArtifactResolver().addAliases(entry.getValue());
+// }
+// }
}
private ServerInstance getServerInstance(String serverName, Map<String, ServerInstance> servers) throws NoServerInstanceException {
@@ -1818,16 +1818,16 @@ public class PluginInstallerGBean implem
return serverInstance;
}
- private Map<String, Properties> toPropertiesMap(List<PropertyType> propertyTypes) {
- Map<String, Properties> propertiesMap = new HashMap<String, Properties>();
+ private Map<String, Map<String, String>> toPropertiesMap(List<PropertyType> propertyTypes) {
+ Map<String, Map<String, String>> propertiesMap = new HashMap<String, Map<String, String>>();
for (PropertyType propertyType : propertyTypes) {
String serverName = propertyType.getServer();
- Properties properties = propertiesMap.get(serverName);
+ Map<String, String> properties = propertiesMap.get(serverName);
if (properties == null) {
- properties = new Properties();
+ properties = new HashMap<String, String>();
propertiesMap.put(serverName, properties);
}
- properties.setProperty(propertyType.getKey(), propertyType.getValue());
+ properties.put(propertyType.getKey(), propertyType.getValue());
}
return propertiesMap;
}
Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java Tue Apr 26 23:19:49 2011
@@ -30,6 +30,7 @@ import org.apache.geronimo.kernel.reposi
import org.apache.geronimo.kernel.repository.ListableRepository;
import org.apache.geronimo.system.configuration.LocalAttributeManager;
import org.apache.geronimo.system.configuration.LocalPluginAttributeStore;
+import org.apache.geronimo.system.configuration.PluginAttributeStore;
import org.apache.geronimo.system.resolver.ExplicitDefaultArtifactResolver;
import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -112,20 +113,17 @@ public class ServerInstanceData {
artifactManager,
Collections.singleton(targetRepo),
serverInfo);
- LocalPluginAttributeStore attributeStore;
+ PluginAttributeStore attributeStore;
if (attributeManagerFrom == null) {
- attributeStore = new LocalAttributeManager(getConfigFile(),
- getConfigSubstitutionsFile(),
- getConfigSubstitutionsPrefix(),
- false,
- serverInfo);
- ((LocalAttributeManager)attributeStore).load();
+ attributeStore = new LocalAttributeManager();
+ //TODO osgi
+ ((LocalAttributeManager)attributeStore).activate(null);
} else {
ServerInstance shared = serverInstances.get(attributeManagerFrom);
if (shared == null) {
throw new IllegalArgumentException("Incorrect configuration: no server instance named '" + attributeManagerFrom + "' defined before being shared from '" + name + "'");
}
- attributeStore = (LocalPluginAttributeStore) shared.getAttributeStore();
+ attributeStore = shared.getAttributeStore();
}
return new ServerInstance(name, attributeStore, geronimoArtifactResolver);
}
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Tue Apr 26 23:19:49 2011
@@ -25,9 +25,13 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -39,23 +43,21 @@ import java.util.TimerTask;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanInfoFactory;
-import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.gbean.GReferenceInfo;
import org.apache.geronimo.gbean.MultiGBeanInfoFactory;
import org.apache.geronimo.gbean.ReferencePatterns;
import org.apache.geronimo.kernel.InvalidGBeanException;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.config.PersistentConfigurationList;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.system.configuration.condition.JexlExpressionParser;
@@ -64,15 +66,20 @@ import org.apache.geronimo.system.plugin
import org.apache.geronimo.system.plugin.model.GbeanType;
import org.apache.geronimo.system.plugin.model.ModuleType;
import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.xml.sax.SAXException;
import org.osgi.framework.Bundle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
/**
* Stores managed attributes in an XML file on the local filesystem.
*
* @version $Rev$ $Date$
*/
-public class LocalAttributeManager implements LocalPluginAttributeStore, PersistentConfigurationList, GBeanLifecycle {
+
+@Service()
+@Component(metatype = true)
+public class LocalAttributeManager implements PluginAttributeStore, PersistentConfigurationList {
private static final Logger log = LoggerFactory.getLogger(LocalAttributeManager.class);
private static final String CONFIG_FILE_PROPERTY = "org.apache.geronimo.config.file";
@@ -83,26 +90,26 @@ public class LocalAttributeManager imple
private static final String TEMP_EXTENSION = ".working";
private static final int SAVE_BUFFER_MS = 5000;
- private final ServerInfo serverInfo;
- private final String configFile;
- private final boolean readOnly;
- private final JexlExpressionParser expressionParser;
-
- private File attributeFile;
- private File backupFile;
- private File tempFile;
+// private final ServerInfo serverInfo;
+// private final String configFile;
+ private boolean readOnly;
+ private JexlExpressionParser expressionParser;
+
+// private File attributeFile;
+// private File backupFile;
+// private File tempFile;
private ServerOverride serverOverride;
- private Timer timer;
- private TimerTask currentTask;
+// private Timer timer;
+// private TimerTask currentTask;
private boolean kernelFullyStarted;
private String prefix;
- private File configSubstitutionsFile;
- private Properties localConfigSubstitutions;
- private String resolvedPropertiesFile;
- private final GBeanInfoFactory infoFactory;
+// private File configSubstitutionsFile;
+ private Map<String, String> localConfigSubstitutions;
+// private String resolvedPropertiesFile;
+ private final GBeanInfoFactory infoFactory = new MultiGBeanInfoFactory();
private static final byte[] INSTRUCTION = ("# Put variables and their substitution values in this file. \n"
+ "# They will be used when processing the corresponding config.xml. \n"
+ "# Values in this file can be overridden by environment variables and system properties \n"
@@ -111,45 +118,52 @@ public class LocalAttributeManager imple
+ "# can be overridden by an environment variable or system property org.apache.geronimo.config.substitution.hostName=foo \n"
+ "# When running multiple instances of Geronimo choose a PortOffset value such that none of the ports conflict. \n"
+ "# For example, try PortOffset=10 \n").getBytes();
+ private org.osgi.service.cm.Configuration configuration;
- public LocalAttributeManager(String configFile, String configSubstitutionsFileName, String configSubstitutionsPrefix, boolean readOnly, ServerInfo serverInfo) {
- this.configFile = System.getProperty(CONFIG_FILE_PROPERTY, configFile);
- resolvedPropertiesFile = System.getProperty(SUBSTITUTIONS_FILE_PROPERTY, configSubstitutionsFileName);
- configSubstitutionsFile = resolvedPropertiesFile == null? null: serverInfo.resolveServer(resolvedPropertiesFile);
- localConfigSubstitutions = loadConfigSubstitutions(configSubstitutionsFile);
+ @Property()
+ static final String OVERRIDES_KEY = ".overrides";
+ @Property(value = "org.apache.geronimo.config.substitution.")
+ static final String PREFIX_KEY = ".configSubstitutionsPrefix";
+ @Property(boolValue = false)
+ static final String READ_ONLY_KEY = "readOnly";
+
+
+// public LocalAttributeManager(String configFile, String configSubstitutionsFileName, String configSubstitutionsPrefix, boolean readOnly, ServerInfo serverInfo) {
+// this.configFile = System.getProperty(CONFIG_FILE_PROPERTY, configFile);
+// resolvedPropertiesFile = System.getProperty(SUBSTITUTIONS_FILE_PROPERTY, configSubstitutionsFileName);
+// configSubstitutionsFile = resolvedPropertiesFile == null? null: serverInfo.resolveServer(resolvedPropertiesFile);
+// localConfigSubstitutions = loadConfigSubstitutions(configSubstitutionsFile);
+// prefix = System.getProperty(SUBSTITUTION_PREFIX_PREFIX, configSubstitutionsPrefix);
+// Map<String, Object> configSubstitutions = loadAllConfigSubstitutions(localConfigSubstitutions, prefix);
+// expressionParser = new JexlExpressionParser(configSubstitutions);
+// this.readOnly = readOnly;
+// this.serverInfo = serverInfo;
+// serverOverride = new ServerOverride();
+//
+// log.debug("setting configSubstitutionsFile to: {}", configSubstitutionsFile);
+//
+// infoFactory = newGBeanInfoFactory();
+// }
+
+ @Activate
+ public void activate(org.osgi.service.cm.Configuration configuration) throws IOException {
+ this.configuration = configuration;
+ Dictionary dictionary = configuration.getProperties();
+ String overrides = (String) dictionary.remove(OVERRIDES_KEY);
+ String configSubstitutionsPrefix = (String) dictionary.remove(PREFIX_KEY);
+ readOnly = (Boolean) dictionary.get(READ_ONLY_KEY);
+ localConfigSubstitutions = loadConfigSubstitutions(dictionary);
prefix = System.getProperty(SUBSTITUTION_PREFIX_PREFIX, configSubstitutionsPrefix);
Map<String, Object> configSubstitutions = loadAllConfigSubstitutions(localConfigSubstitutions, prefix);
expressionParser = new JexlExpressionParser(configSubstitutions);
- this.readOnly = readOnly;
- this.serverInfo = serverInfo;
- serverOverride = new ServerOverride();
-
- log.debug("setting configSubstitutionsFile to: {}", configSubstitutionsFile);
- infoFactory = newGBeanInfoFactory();
- }
-
- protected GBeanInfoFactory newGBeanInfoFactory() {
- return new MultiGBeanInfoFactory();
+ load(overrides);
}
public boolean isReadOnly() {
return readOnly;
}
-
- public String getConfigFile() {
- return configFile;
- }
-
- public String getConfigSubstitutionsFile() {
- return resolvedPropertiesFile;
- }
-
- public String getConfigSubstitutionsPrefix() {
- return prefix;
- }
-
public synchronized Collection<GBeanData> applyOverrides(Artifact configName, Collection<GBeanData> untypedGbeanDatas, Bundle bundle) throws InvalidConfigException {
// clone the datas since we will be modifying this collection
Collection<GBeanData> gbeanDatas = new ArrayList<GBeanData>(untypedGbeanDatas);
@@ -257,10 +271,10 @@ public class LocalAttributeManager imple
return expressionParser.parse(in);
}
- public void addConfigSubstitutions(Properties properties) {
+ public void addConfigSubstitutions(Map<String, String> properties) {
localConfigSubstitutions.putAll(properties);
Map<String, Object> configSubstutions = loadAllConfigSubstitutions(localConfigSubstitutions, prefix);
- storeConfigSubstitutions(configSubstitutionsFile, localConfigSubstitutions);
+ storeConfigSubstitutions(configuration, localConfigSubstitutions);
expressionParser.setVariables(configSubstutions);
}
@@ -345,12 +359,13 @@ public class LocalAttributeManager imple
}
}
- public synchronized void load() throws IOException {
- ensureParentDirectory();
- if (!attributeFile.exists()) {
+ public synchronized void load(String overrides) throws IOException {
+// ensureParentDirectory();
+ if (overrides == null || overrides.isEmpty()) {
+ serverOverride = new ServerOverride();
return;
}
- Reader input = new BufferedReader(new FileReader(attributeFile));
+ Reader input = new StringReader(overrides);
try {
serverOverride = read(input, expressionParser);
@@ -380,36 +395,42 @@ public class LocalAttributeManager imple
if (readOnly) {
return;
}
- ensureParentDirectory();
- if (!tempFile.exists() && !tempFile.createNewFile()) {
- throw new IOException("Unable to create manageable attribute working file for save " + tempFile.getAbsolutePath());
- }
- if (!tempFile.canWrite()) {
- throw new IOException("Unable to write to manageable attribute working file for save " + tempFile.getAbsolutePath());
- }
+// ensureParentDirectory();
+// if (!tempFile.exists() && !tempFile.createNewFile()) {
+// throw new IOException("Unable to create manageable attribute working file for save " + tempFile.getAbsolutePath());
+// }
+// if (!tempFile.canWrite()) {
+// throw new IOException("Unable to write to manageable attribute working file for save " + tempFile.getAbsolutePath());
+// }
// write the new configuration to the temp file
- saveXmlToFile(tempFile, serverOverride);
-
- // delete the current backup file
- if (backupFile.exists()) {
- if (!backupFile.delete()) {
- throw new IOException("Unable to delete old backup file in order to back up current manageable attribute working file for save");
- }
- }
-
- // rename the existing configuration file to the backup file
- if (attributeFile.exists()) {
- if (!attributeFile.renameTo(backupFile)) {
- throw new IOException("Unable to rename " + attributeFile.getAbsolutePath() + " to " + backupFile.getAbsolutePath() + " in order to back up manageable attribute save file");
- }
- }
-
- // rename the temp file the the configuration file
- if (!tempFile.renameTo(attributeFile)) {
- throw new IOException(
- "EXTREMELY CRITICAL! Unable to move manageable attributes working file to proper file name! Configuration will revert to defaults unless this is manually corrected! (could not rename " + tempFile.getAbsolutePath() + " to " + attributeFile.getAbsolutePath() + ")");
- }
+ String overrides = saveXml(serverOverride);
+ if (overrides == null) {
+ throw new IOException("Could not save serverOverride: " + serverOverride);
+ }
+ Dictionary d = configuration.getProperties();
+ d.put(OVERRIDES_KEY, overrides);
+ configuration.update(d);
+
+// // delete the current backup file
+// if (backupFile.exists()) {
+// if (!backupFile.delete()) {
+// throw new IOException("Unable to delete old backup file in order to back up current manageable attribute working file for save");
+// }
+// }
+//
+// // rename the existing configuration file to the backup file
+// if (attributeFile.exists()) {
+// if (!attributeFile.renameTo(backupFile)) {
+// throw new IOException("Unable to rename " + attributeFile.getAbsolutePath() + " to " + backupFile.getAbsolutePath() + " in order to back up manageable attribute save file");
+// }
+// }
+//
+// // rename the temp file the the configuration file
+// if (!tempFile.renameTo(attributeFile)) {
+// throw new IOException(
+// "EXTREMELY CRITICAL! Unable to move manageable attributes working file to proper file name! Configuration will revert to defaults unless this is manually corrected! (could not rename " + tempFile.getAbsolutePath() + " to " + attributeFile.getAbsolutePath() + ")");
+// }
}
void write(Writer writer) throws XMLStreamException, JAXBException,
@@ -419,22 +440,21 @@ public class LocalAttributeManager imple
writer.flush();
}
- private static void saveXmlToFile(File file, ServerOverride serverOverride) {
+ private static String saveXml(ServerOverride serverOverride) {
try {
- Writer fileOut = new FileWriter(file);
try {
- Writer writer = new BufferedWriter(fileOut);
+ Writer writer = new StringWriter();
write(serverOverride, writer);
+ return writer.toString();
} catch (JAXBException e) {
log.error("Unable to write config.xml", e);
} catch (XMLStreamException e) {
log.error("Unable to write config.xml", e);
- } finally {
- fileOut.close();
}
} catch (IOException e) {
log.error("Unable to write config.xml", e);
}
+ return null;
}
static void write(ServerOverride serverOverride, Writer writer) throws XMLStreamException, JAXBException, IOException {
@@ -553,87 +573,33 @@ public class LocalAttributeManager imple
return configInfo != null && !configInfo.getGBeans().isEmpty();
}
- //GBeanLifeCycle
- public synchronized void doStart() throws Exception {
- load();
- if (!readOnly) {
- timer = new Timer(true);
- }
- log.debug("Started LocalAttributeManager with data on {} configurations", serverOverride.getConfigurations().size());
- }
-
- public synchronized void doStop() throws Exception {
- boolean doSave = false;
- synchronized (this) {
- if (timer != null) {
- timer.cancel();
- if (currentTask != null) {
- currentTask.cancel();
- doSave = true;
- }
- }
- }
- if (doSave) {
- save();
- }
- log.debug("Stopped LocalAttributeManager with data on {} configurations", serverOverride.getConfigurations().size());
- serverOverride = new ServerOverride();
- }
-
- public synchronized void doFail() {
- synchronized (this) {
- if (timer != null) {
- timer.cancel();
- if (currentTask != null) {
- currentTask.cancel();
- }
- }
- }
- serverOverride = new ServerOverride();
- }
-
- private synchronized void ensureParentDirectory() throws IOException {
- if (attributeFile == null) {
- attributeFile = serverInfo.resolveServer(configFile);
- tempFile = new File(attributeFile.getAbsolutePath() + TEMP_EXTENSION);
- backupFile = new File(attributeFile.getAbsolutePath() + BACKUP_EXTENSION);
- }
- File parent = attributeFile.getParentFile();
- if (!parent.isDirectory()) {
- if (!parent.mkdirs()) {
- throw new IOException("Unable to create directory for list:" + parent);
- }
- }
- if (!parent.canRead()) {
- throw new IOException("Unable to read manageable attribute files in directory " + parent.getAbsolutePath());
- }
- if (!readOnly && !parent.canWrite()) {
- throw new IOException("Unable to write manageable attribute files to directory " + parent.getAbsolutePath());
- }
- }
-
private synchronized void attributeChanged() {
- if (currentTask != null) {
- currentTask.cancel();
- }
- if (timer != null) {
- currentTask = new TimerTask() {
-
- public void run() {
- try {
- LocalAttributeManager.this.save();
- } catch (IOException e) {
- log.error("IOException occurred while saving attributes", e);
- } catch (Throwable t) {
- log.error("Error occurred during execution of attributeChanged TimerTask", t);
- }
- }
- };
- timer.schedule(currentTask, SAVE_BUFFER_MS);
+ try {
+ save();
+ } catch (IOException e) {
+ log.error("could not save serverOverrides", e);
}
+// if (currentTask != null) {
+// currentTask.cancel();
+// }
+// if (timer != null) {
+// currentTask = new TimerTask() {
+//
+// public void run() {
+// try {
+// LocalAttributeManager.this.save();
+// } catch (IOException e) {
+// log.error("IOException occurred while saving attributes", e);
+// } catch (Throwable t) {
+// log.error("Error occurred during execution of attributeChanged TimerTask", t);
+// }
+// }
+// };
+// timer.schedule(currentTask, SAVE_BUFFER_MS);
+// }
}
- private static Map<String, Object> loadAllConfigSubstitutions(Properties configSubstitutions, String prefix) {
+ private static Map<String, Object> loadAllConfigSubstitutions(Map<String, String> configSubstitutions, String prefix) {
Map<String, Object> vars = new HashMap<String, Object>();
//most significant are the command line system properties
addGeronimoSubstitutions(vars, System.getProperties(), prefix);
@@ -641,51 +607,58 @@ public class LocalAttributeManager imple
addGeronimoSubstitutions(vars, System.getenv(), prefix);
//properties file is least significant
if (configSubstitutions != null) {
- addGeronimoSubstitutions(vars, configSubstitutions, "");
+ addGeronimoSubstitutions(vars, configSubstitutions, ".");
}
ParserUtils.addDefaultVariables(vars);
return vars;
}
- private static Properties loadConfigSubstitutions(File configSubstitutionsFile) {
- Properties properties = new Properties();
- if (configSubstitutionsFile != null) {
- if (!configSubstitutionsFile.exists()) {
- //write out empty file with instructions as a hint to users.
- storeConfigSubstitutions(configSubstitutionsFile, properties);
- } else {
- try {
- FileInputStream in = new FileInputStream(configSubstitutionsFile);
- try {
- properties.load(in);
- } finally {
- in.close();
- }
- } catch (Exception e) {
- log.error("Caught exception {} trying to read properties file {}", e, configSubstitutionsFile.getAbsolutePath());
- }
+// private static Properties loadConfigSubstitutions(File configSubstitutionsFile) {
+// Properties properties = new Properties();
+// if (configSubstitutionsFile != null) {
+// if (!configSubstitutionsFile.exists()) {
+// //write out empty file with instructions as a hint to users.
+// storeConfigSubstitutions(configSubstitutionsFile, properties);
+// } else {
+// try {
+// FileInputStream in = new FileInputStream(configSubstitutionsFile);
+// try {
+// properties.load(in);
+// } finally {
+// in.close();
+// }
+// } catch (Exception e) {
+// log.error("Caught exception {} trying to read properties file {}", e, configSubstitutionsFile.getAbsolutePath());
+// }
+// }
+// }
+// return properties;
+// }
+ private static Map<String, String> loadConfigSubstitutions(Dictionary<?, ?> dictionary) {
+ Map<String, String> properties = new HashMap<String, String>();
+ for (Enumeration<?> e = dictionary.keys(); e.hasMoreElements(); ) {
+ String key = (String) e.nextElement();
+ if (key.startsWith(".")) {
+ String value = (String) dictionary.get(key);
+ properties.put(key.substring(1), value);
}
}
return properties;
}
- private static void storeConfigSubstitutions(File configSubstitutionsFile, Properties properties) {
- if (configSubstitutionsFile != null) {
- try {
- FileOutputStream out = new FileOutputStream(configSubstitutionsFile);
- try {
- out.write(INSTRUCTION);
- properties.store(out, null);
- } finally {
- out.close();
- }
- } catch (Exception e) {
- log.error("Caught exception {} trying to write properties file {}", e, configSubstitutionsFile.getAbsolutePath());
- }
+ private static void storeConfigSubstitutions(org.osgi.service.cm.Configuration configuration, Map<String, String> properties) {
+ Dictionary<Object, Object> d = configuration.getProperties();
+ for (Map.Entry<String, String> entry: properties.entrySet()) {
+ d.put("." + entry.getKey(), entry.getValue());
+ }
+ try {
+ configuration.update(d);
+ } catch (IOException e) {
+ log.error("Caught exception {} trying to update Configuration dictionary", e);
}
}
- private static void addGeronimoSubstitutions(Map<String, Object> vars, Map props, String prefix) {
+ private static void addGeronimoSubstitutions(Map<String, Object> vars, Map<?, ?> props, String prefix) {
if (prefix != null) {
int start = prefix.length();
for (Object o : props.entrySet()) {
@@ -700,24 +673,4 @@ public class LocalAttributeManager imple
}
}
- public static final GBeanInfo GBEAN_INFO;
-
- static {
- GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(LocalAttributeManager.class, "AttributeStore");
- infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
- infoFactory.addAttribute("configFile", String.class, true);
- infoFactory.addAttribute("readOnly", boolean.class, true);
- infoFactory.addAttribute("substitutionsFile", String.class, true);
- infoFactory.addAttribute("substitutionPrefix", String.class, true);
- infoFactory.addInterface(ManageableAttributeStore.class);
- infoFactory.addInterface(PersistentConfigurationList.class);
-
- infoFactory.setConstructor(new String[]{"configFile", "substitutionsFile", "substitutionPrefix", "readOnly", "ServerInfo"});
-
- GBEAN_INFO = infoFactory.getBeanInfo();
- }
-
- public static GBeanInfo getGBeanInfo() {
- return GBEAN_INFO;
- }
}
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java Tue Apr 26 23:19:49 2011
@@ -17,6 +17,7 @@
package org.apache.geronimo.system.configuration;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.geronimo.kernel.config.ManageableAttributeStore;
@@ -38,7 +39,7 @@ public interface PluginAttributeStore ex
*/
public void setModuleGBeans(Artifact moduleName, List<GbeanType> gbeans, boolean load, String condition) throws InvalidGBeanException;
- void addConfigSubstitutions(Properties properties);
+ void addConfigSubstitutions(Map<String, String> properties);
boolean isModuleInstalled(Artifact artifact);
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/SwitchableLocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/SwitchableLocalAttributeManager.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/SwitchableLocalAttributeManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/SwitchableLocalAttributeManager.java Tue Apr 26 23:19:49 2011
@@ -22,20 +22,25 @@ import java.util.List;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.SwitchablePersistentConfigurationList;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.osgi.framework.Bundle;
/**
*
* @version $Rev: 486815 $ $Date: 2006-12-14 06:45:10 +1100 (Thu, 14 Dec 2006) $
*/
-public class SwitchableLocalAttributeManager extends LocalAttributeManager implements SwitchablePersistentConfigurationList {
+@GBean
+public class SwitchableLocalAttributeManager extends WrapperAttributeManager implements SwitchablePersistentConfigurationList {
private boolean online;
- public SwitchableLocalAttributeManager(String configFile, String substitutionsFile, String configSubstitutionsPrefix, boolean readOnly, ServerInfo serverInfo) {
- super(configFile, substitutionsFile, configSubstitutionsPrefix, readOnly, serverInfo);
+ public SwitchableLocalAttributeManager(@ParamSpecial(type = SpecialAttributeType.bundle)final Bundle bundle) {
+ super(bundle);
}
@Override
@@ -86,18 +91,4 @@ public class SwitchableLocalAttributeMan
}
}
- public static final GBeanInfo GBEAN_INFO;
-
- static {
- GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(SwitchableLocalAttributeManager.class, LocalAttributeManager.GBEAN_INFO);
-
- infoFactory.addInterface(SwitchablePersistentConfigurationList.class);
-
- GBEAN_INFO = infoFactory.getBeanInfo();
- }
-
- public static GBeanInfo getGBeanInfo() {
- return GBEAN_INFO;
- }
-
}
Added: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java?rev=1096953&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java Tue Apr 26 23:19:49 2011
@@ -0,0 +1,141 @@
+/*
+ * 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.geronimo.system.configuration;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.gbean.wrapper.AbstractServiceWrapper;
+import org.apache.geronimo.kernel.InvalidGBeanException;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.PersistentConfigurationList;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.system.plugin.model.GbeanType;
+import org.osgi.framework.Bundle;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+
+@GBean
+public class WrapperAttributeManager extends AbstractServiceWrapper<PluginAttributeStore> implements PluginAttributeStore, PersistentConfigurationList {
+
+
+ public WrapperAttributeManager(@ParamSpecial(type = SpecialAttributeType.bundle)final Bundle bundle) {
+ super(bundle, PluginAttributeStore.class);
+ }
+
+ private PersistentConfigurationList getPersistentConfigurationList() {
+ return (PersistentConfigurationList)get();
+ }
+
+ public void addConfigSubstitutions(Map<String, String> properties) {
+ get().addConfigSubstitutions(properties);
+ }
+
+ public boolean isModuleInstalled(Artifact artifact) {
+ return get().isModuleInstalled(artifact);
+ }
+
+ public void setModuleGBeans(Artifact moduleName, List<GbeanType> gbeans, boolean load, String condition) throws InvalidGBeanException {
+ get().setModuleGBeans(moduleName, gbeans, load, condition);
+ }
+
+ public String substitute(String in) {
+ return get().substitute(in);
+ }
+
+ public void addGBean(Artifact configurationName, GBeanData gbeanData, Bundle bundle) {
+ get().addGBean(configurationName, gbeanData, bundle);
+ }
+
+ public Collection<GBeanData> applyOverrides(Artifact configurationName, Collection<GBeanData> datas, Bundle bundle) throws InvalidConfigException {
+ return get().applyOverrides(configurationName, datas, bundle);
+ }
+
+ @Override
+ public void save() throws IOException {
+ get().save();
+ }
+
+ public void setKernelFullyStarted(boolean kernelFullyStarted) {
+ getPersistentConfigurationList().setKernelFullyStarted(kernelFullyStarted);
+ }
+
+ public void startConfiguration(Artifact configName) {
+ getPersistentConfigurationList().startConfiguration(configName);
+ }
+
+ public void stopConfiguration(Artifact configName) {
+ getPersistentConfigurationList().stopConfiguration(configName);
+ }
+
+ public void setReferencePatterns(Artifact configurationName, AbstractName gbean, GReferenceInfo reference, ReferencePatterns patterns) {
+ get().setReferencePatterns(configurationName, gbean, reference, patterns);
+ }
+
+ public void setShouldLoad(Artifact configurationName, AbstractName gbean, boolean load) {
+ get().setShouldLoad(configurationName, gbean, load);
+ }
+
+ public void setValue(Artifact configurationName, AbstractName gbeanName, GAttributeInfo attribute, Object value, Bundle bundle) {
+ get().setValue(configurationName, gbeanName, attribute, value, bundle);
+ }
+
+ public void addConfiguration(Artifact configName) {
+ getPersistentConfigurationList().addConfiguration(configName);
+ }
+
+ public Artifact[] getListedConfigurations(Artifact query) {
+ return getPersistentConfigurationList().getListedConfigurations(query);
+ }
+
+ public boolean hasGBeanAttributes(Artifact configName) {
+ return getPersistentConfigurationList().hasGBeanAttributes(configName);
+ }
+
+ public boolean isKernelFullyStarted() {
+ return getPersistentConfigurationList().isKernelFullyStarted();
+ }
+
+ public void migrateConfiguration(Artifact oldName, Artifact newName, Configuration configuration) {
+ getPersistentConfigurationList().migrateConfiguration(oldName, newName, configuration);
+ }
+
+ public void removeConfiguration(Artifact configName) {
+ getPersistentConfigurationList().removeConfiguration(configName);
+ }
+
+ public List<Artifact> restore() throws IOException {
+ return getPersistentConfigurationList().restore();
+ }
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperAttributeManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java?rev=1096953&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java Tue Apr 26 23:19:49 2011
@@ -0,0 +1,96 @@
+/*
+ * 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.geronimo.system.configuration;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.gbean.wrapper.AbstractServiceWrapper;
+import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.osgi.framework.Bundle;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class WrapperConfigurationStore extends AbstractServiceWrapper<ConfigurationStore> implements ConfigurationStore {
+
+ public WrapperConfigurationStore(@ParamSpecial(type = SpecialAttributeType.bundle) final Bundle bundle) {
+ super(bundle, ConfigurationStore.class);
+ }
+
+ public boolean containsConfiguration(Artifact configId) {
+ return get().containsConfiguration(configId);
+ }
+
+ public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
+ return get().createNewConfigurationDir(configId);
+ }
+
+ public void exportConfiguration(Artifact configId, OutputStream output) throws IOException, NoSuchConfigException {
+ get().exportConfiguration(configId, output);
+ }
+
+ public AbstractName getAbstractName() {
+ return get().getAbstractName();
+ }
+
+ public String getObjectName() {
+ return get().getObjectName();
+ }
+
+ public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
+ get().install(configurationData);
+ }
+
+ public boolean isInPlaceConfiguration(Artifact configId) throws NoSuchConfigException, IOException {
+ return get().isInPlaceConfiguration(configId);
+ }
+
+ public List<ConfigurationInfo> listConfigurations() {
+ return get().listConfigurations();
+ }
+
+ public ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException {
+ return get().loadConfiguration(configId);
+ }
+
+ public Set<URL> resolve(Artifact configId, String moduleName, String path) throws NoSuchConfigException, MalformedURLException {
+ return get().resolve(configId, moduleName, path);
+ }
+
+ public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
+ get().uninstall(configId);
+ }
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/WrapperConfigurationStore.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/serverinfo/WrappingServerInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/serverinfo/WrappingServerInfo.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/serverinfo/WrappingServerInfo.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/serverinfo/WrappingServerInfo.java Tue Apr 26 23:19:49 2011
@@ -26,100 +26,76 @@ import java.net.URI;
import org.apache.geronimo.gbean.annotation.GBean;
import org.apache.geronimo.gbean.annotation.ParamSpecial;
import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.gbean.wrapper.AbstractServiceWrapper;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
/**
* @version $Rev:$ $Date:$
*/
@GBean
-public class WrappingServerInfo implements ServerInfo {
-
- private ServerInfo serverInfo;
+public class WrappingServerInfo extends AbstractServiceWrapper<ServerInfo> implements ServerInfo {
public WrappingServerInfo(@ParamSpecial(type = SpecialAttributeType.bundle)final Bundle bundle) {
- final BundleContext bundleContext = bundle.getBundleContext();
- ServiceTracker t = new ServiceTracker(bundleContext, ServerInfo.class.getName(), new ServiceTrackerCustomizer() {
-
- @Override
- public Object addingService(ServiceReference serviceReference) {
- serverInfo = (ServerInfo) bundleContext.getService(serviceReference);
- return null;
- }
-
- @Override
- public void modifiedService(ServiceReference serviceReference, Object o) {
- }
-
- @Override
- public void removedService(ServiceReference serviceReference, Object o) {
- serverInfo = null;
- }
- });
- t.open();
+ super(bundle, ServerInfo.class);
}
-
@Override
public String getBaseDirectory() {
- return serverInfo.getBaseDirectory();
+ return get().getBaseDirectory();
}
- @Override
+ @Override
public String getBuildDate() {
- return serverInfo.getBuildDate();
+ return get().getBuildDate();
}
@Override
public String getBuildTime() {
- return serverInfo.getBuildTime();
+ return get().getBuildTime();
}
@Override
public String getCopyright() {
- return serverInfo.getCopyright();
+ return get().getCopyright();
}
@Override
public String getCurrentBaseDirectory() {
- return serverInfo.getCurrentBaseDirectory();
+ return get().getCurrentBaseDirectory();
}
@Override
public String getVersion() {
- return serverInfo.getVersion();
+ return get().getVersion();
}
@Override
public File resolve(String filename) {
- return serverInfo.resolve(filename);
+ return get().resolve(filename);
}
@Override
public URI resolve(URI uri) {
- return serverInfo.resolve(uri);
+ return get().resolve(uri);
}
@Override
public String resolvePath(String filename) {
- return serverInfo.resolvePath(filename);
+ return get().resolvePath(filename);
}
@Override
public File resolveServer(String filename) {
- return serverInfo.resolveServer(filename);
+ return get().resolveServer(filename);
}
@Override
public URI resolveServer(URI uri) {
- return serverInfo.resolveServer(uri);
+ return get().resolveServer(uri);
}
@Override
public String resolveServerPath(String filename) {
- return serverInfo.resolveServerPath(filename);
+ return get().resolveServerPath(filename);
}
}
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java?rev=1096953&r1=1096952&r2=1096953&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/test/java/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java Tue Apr 26 23:19:49 2011
@@ -16,13 +16,17 @@
*/
package org.apache.geronimo.system.configuration;
+import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Dictionary;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.LinkedHashSet;
+import java.util.Map;
import java.util.Set;
import javax.management.ObjectName;
@@ -42,6 +46,7 @@ import org.apache.geronimo.kernel.osgi.M
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.system.serverinfo.BasicServerInfo;
import org.osgi.framework.Bundle;
+import org.osgi.service.cm.Configuration;
/**
* @version $Rev$ $Date$
@@ -236,13 +241,61 @@ public class LocalAttributeManagerTest e
assertEquals(attributeValue, gbeanData.getAttribute(attributeInfo.getName()));
}
- public void testSwitchableLocalAttributeManager() throws Exception {
- GBeanInfo gBeanInfo = SwitchableLocalAttributeManager.getGBeanInfo();
- }
+// public void testSwitchableLocalAttributeManager() throws Exception {
+// GBeanInfo gBeanInfo = SwitchableLocalAttributeManager.getGBeanInfo();
+// }
protected void setUp() throws Exception {
super.setUp();
- localAttributeManager = new LocalAttributeManager("target/test-config.xml", "target/test-config-substitutions.properties", "org.apache.geronimo.config.substitution.", false, new BasicServerInfo(basedir));
+ localAttributeManager = new LocalAttributeManager();
+ Configuration configuration = new Configuration() {
+
+ private Hashtable<String, Object> dictionary = new Hashtable<String, Object>();
+
+ @Override
+ public String getPid() {
+ return null;
+ }
+
+ @Override
+ public Dictionary getProperties() {
+ Hashtable<String, Object> d = new Hashtable<String, Object>();
+ d.putAll(dictionary);
+ d.put(LocalAttributeManager.READ_ONLY_KEY, false);
+ d.put(LocalAttributeManager.PREFIX_KEY, "org.apache.geronimo.config.substitution.");
+ return d;
+ }
+
+ @Override
+ public void update(Dictionary dictionary) throws IOException {
+ this.dictionary.clear();
+ this.dictionary.putAll((Map<String, Object>)dictionary);
+ }
+
+ @Override
+ public void delete() throws IOException {
+ }
+
+ @Override
+ public String getFactoryPid() {
+ return null;
+ }
+
+ @Override
+ public void update() throws IOException {
+ }
+
+ @Override
+ public void setBundleLocation(String s) {
+ }
+
+ @Override
+ public String getBundleLocation() {
+ return null;
+ }
+ };
+ localAttributeManager.activate(configuration);
+
configurationName = Artifact.create("configuration/name/1/car");
ObjectName objectName = ObjectName.getInstance(":name=gbean,parent="+configurationName+",foo=bar");
gbeanName = new AbstractName(configurationName, objectName.getKeyPropertyList(), objectName);