Make nonoss build work under Spring

This commit is contained in:
Kelven Yang 2013-01-25 17:18:36 -08:00
parent 2b67fc8441
commit 767f54cc9a
4 changed files with 50 additions and 7 deletions

View File

@ -1,3 +1,35 @@
<!--
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.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- <!--
@ -263,8 +295,9 @@
<bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl"> <bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl">
<property name="configParams"> <property name="configParams">
<map> <map>
<entry key="premium" value="1" /> <entry key="premium" value="true" />
</map> </map>
</property> </property>
</bean> </bean>
</beans>

View File

@ -21,8 +21,6 @@ import java.util.Map;
import javax.ejb.Local; import javax.ejb.Local;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.springframework.stereotype.Component;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VMInstanceVO;
@ -41,7 +39,6 @@ public class VmwareFencer implements FenceBuilder {
@Override @Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
_name = name;
return true; return true;
} }
@ -49,6 +46,10 @@ public class VmwareFencer implements FenceBuilder {
public String getName() { public String getName() {
return _name; return _name;
} }
public void setName(String name) {
_name = name;
}
@Override @Override
public boolean start() { public boolean start() {

View File

@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.Local; import javax.ejb.Local;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
@ -62,6 +63,15 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String
return _premium; return _premium;
} }
@PostConstruct
void initComponent() {
try {
configure(this.getClass().getSimpleName(), this.getConfigParams());
} catch (ConfigurationException e) {
s_logger.warn("Self configuration failed", e);
}
}
@Override @Override
public void invalidateCache() { public void invalidateCache() {
_configs = null; _configs = null;

View File

@ -446,11 +446,10 @@ public class ManagementServerImpl implements ManagementServer {
Map<String, GenericDaoBase> daos = ComponentContext.getApplicationContext().getBeansOfType( Map<String, GenericDaoBase> daos = ComponentContext.getApplicationContext().getBeansOfType(
GenericDaoBase.class); GenericDaoBase.class);
Map<String, Object> params = new HashMap<String, Object>();
for (GenericDaoBase dao : daos.values()) { for (GenericDaoBase dao : daos.values()) {
try { try {
s_logger.info("Starting dao " + ComponentContext.getTargetClass(dao).getName()); s_logger.info("Starting dao " + ComponentContext.getTargetClass(dao).getName());
dao.configure(dao.getClass().getSimpleName(), params); dao.configure(dao.getClass().getSimpleName(), dao.getConfigParams());
} catch (Exception e) { } catch (Exception e) {
s_logger.error("Problems with running checker:" + ComponentContext.getTargetClass(dao).getName(), e); s_logger.error("Problems with running checker:" + ComponentContext.getTargetClass(dao).getName(), e);
System.exit(1); System.exit(1);