mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Spring Modularization
ACS is now comprised of a hierarchy of spring application contexts. Each plugin can contribute configuration files to add to an existing module or create it's own module. Additionally, for the mgmt server, ACS custom AOP is no longer used and instead we use Spring AOP to manage interceptors.
This commit is contained in:
parent
8466fad6ca
commit
67186429e1
@ -0,0 +1,2 @@
|
||||
name=api-planner
|
||||
parent=planner
|
||||
@ -0,0 +1,34 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="UserDispersingPlanner" class="com.cloud.deploy.UserDispersingPlanner">
|
||||
<property name="name" value="UserDispersingPlanner" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -57,7 +57,7 @@ public class CallContext {
|
||||
private User user;
|
||||
private final Map<Object, Object> context = new HashMap<Object, Object>();
|
||||
|
||||
private static EntityManager s_entityMgr;
|
||||
static EntityManager s_entityMgr;
|
||||
|
||||
public static void init(EntityManager entityMgr) {
|
||||
s_entityMgr = entityMgr;
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<!-- There is no reason to put anything here -->
|
||||
|
||||
</beans>
|
||||
@ -152,6 +152,14 @@ under the License.
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
<category name="org.springframework">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="org.apache.cloudstack.spring.module.context.ResourceApplicationContext">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="net">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
name=allocator
|
||||
parent=core
|
||||
@ -0,0 +1,32 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="usageEventUtils" class="com.cloud.event.UsageEventUtils" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,42 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="hostAllocatorsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.agent.manager.allocator.HostAllocator" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="consoleProxyAllocatorsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.consoleproxy.ConsoleProxyAllocator" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
2
core/resources/META-INF/cloudstack/api/module.properties
Normal file
2
core/resources/META-INF/cloudstack/api/module.properties
Normal file
@ -0,0 +1,2 @@
|
||||
name=api
|
||||
parent=core
|
||||
@ -0,0 +1,53 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="userAuthenticatorsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.server.auth.UserAuthenticator" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="securityCheckersRegistry" />
|
||||
<property name="typeClass"
|
||||
value="org.apache.cloudstack.acl.SecurityChecker" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="apiCheckersRegistry" />
|
||||
<property name="typeClass" value="org.apache.cloudstack.acl.APIChecker" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="userPasswordEncodersRegistry" />
|
||||
<property name="typeClass" value="com.cloud.server.auth.UserAuthenticator" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=backend
|
||||
parent=core
|
||||
@ -0,0 +1 @@
|
||||
name=bootstrap
|
||||
@ -0,0 +1,39 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<context:annotation-config />
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="order" value="100" />
|
||||
<property name="ignoreResourceNotFound" value="true" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="locations" ref="DefaultConfigResources" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,32 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.CloudStackLog4jSetup" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=compute
|
||||
parent=backend
|
||||
@ -0,0 +1,45 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="haInvestigatorsRegistry" />
|
||||
<property name="typeClass" value="com.cloud.ha.Investigator" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="haFenceBuildersRegistry" />
|
||||
<property name="typeClass" value="com.cloud.ha.FenceBuilder" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="hypervisorGurusRegistry" />
|
||||
<property name="typeClass" value="com.cloud.hypervisor.HypervisorGuru" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=core
|
||||
parent=system
|
||||
@ -0,0 +1,36 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext">
|
||||
<property name="initializeBeans" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="encryptionSecretKeyChecker" class="com.cloud.utils.crypt.EncryptionSecretKeyChecker" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,41 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="registryRegistry" />
|
||||
<property name="typeClass" value="com.cloud.utils.component.Registry" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.PluggableServiceLifecycle">
|
||||
<property name="registry" ref="apiCommandsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.utils.component.PluggableService" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,187 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="userAuthenticatorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="orderConfigKey" value="user.authenticators.order" />
|
||||
<property name="excludeKey" value="user.authenticators.exclude" />
|
||||
<property name="orderConfigDefault" value="SHA256SALT,MD5,LDAP,PLAINTEXT" />
|
||||
</bean>
|
||||
|
||||
<bean id="userPasswordEncodersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="orderConfigKey" value="user.password.encoders.order" />
|
||||
<property name="excludeKey" value="user.password.encoders.exclude" />
|
||||
<property name="orderConfigDefault" value="SHA256SALT,MD5,LDAP,PLAINTEXT" />
|
||||
</bean>
|
||||
|
||||
<bean id="securityCheckersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="orderConfigKey" value="security.checkers.order" />
|
||||
<property name="excludeKey" value="security.checkers.exclude" />
|
||||
<property name="orderConfigDefault"
|
||||
value="AffinityGroupAccessChecker,DomainChecker" />
|
||||
</bean>
|
||||
|
||||
<bean id="resourceDiscoverersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="resource.discoverers.exclude" />
|
||||
<property name="excludeDefault" value="dummyHostDiscoverer" />
|
||||
</bean>
|
||||
|
||||
<bean id="haInvestigatorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="orderConfigKey" value="ha.investigators.order" />
|
||||
<property name="orderConfigDefault"
|
||||
value="SimpleInvestigator,XenServerInvestigator,PingInvestigator,ManagementIPSysVMInvestigator,KVMInvestigator" />
|
||||
<property name="excludeKey" value="ha.investigators.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="haFenceBuildersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="ha.fence.builders.exclude" />
|
||||
<property name="excludeDefault" value="RecreatableFencer" />
|
||||
</bean>
|
||||
|
||||
<bean id="deploymentPlannersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="orderConfigKey" value="deployment.planners.order" />
|
||||
<property name="orderConfigDefault"
|
||||
value="FirstFitPlanner,UserDispersingPlanner,UserConcentratedPodPlanner,ImplicitDedicationPlanner,BareMetalPlanner" />
|
||||
<property name="excludeKey" value="deployment.planners.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="podAllocatorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="pod.allocators.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="hostAllocatorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="host.allocators.exclude" />
|
||||
<property name="excludeDefault"
|
||||
value="RandomAllocator,TestingAllocator,FirstFitAllocator,RecreateHostAllocator" />
|
||||
</bean>
|
||||
|
||||
<bean id="storagePoolAllocatorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="orderConfigKey" value="storage.pool.allocators.order" />
|
||||
<property name="orderConfigDefault"
|
||||
value="LocalStorage,ClusterScopeStoragePoolAllocator,ZoneWideStoragePoolAllocator" />
|
||||
<property name="excludeKey" value="storage.pool.allocators.exclude" />
|
||||
<property name="excludeDefault" value="GCStorage" />
|
||||
</bean>
|
||||
|
||||
<bean id="secondaryStorageVmAllocatorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey"
|
||||
value="secondary.storage.vm.allocators.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="consoleProxyAllocatorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="console.proxy.allocator.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="templateAdapterRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="template.adapter.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="ipDeployersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="ip.deployers.exclude" />
|
||||
<property name="excludeDefault" value="MidoNetElement" />
|
||||
</bean>
|
||||
|
||||
<bean id="dhcpProvidersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="dhcp.providers.exclude" />
|
||||
<property name="excludeDefault" value="MidoNetElement" />
|
||||
</bean>
|
||||
|
||||
<bean id="networkGurusRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="network.gurus.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="networkElementsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="network.elements.registry.exclude" />
|
||||
<property name="excludeDefault" value="ElasticLoadBalancerElement" />
|
||||
<property name="preRegistered">
|
||||
<list>
|
||||
<ref bean="VpcVirtualRouter" />
|
||||
<ref bean="InternalLbVm" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="affinityProcessorsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="orderConfigKey" value="affinity.processors.order" />
|
||||
<property name="orderConfigDefault"
|
||||
value="HostAntiAffinityProcessor,ExplicitDedicationProcessor" />
|
||||
<property name="excludeKey" value="affinity.processors.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.DumpRegistry" >
|
||||
<property name="registries" value="#{registryRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="registryRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
</bean>
|
||||
|
||||
<bean id="apiCheckersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="api.checkers.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="apiCommandsRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="api.commands.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="hypervisorGurusRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="hypervisor.gurus.exclude" />
|
||||
</bean>
|
||||
|
||||
<bean id="vpcProvidersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="vpc.providers.exclude" />
|
||||
<property name="preRegistered">
|
||||
<list>
|
||||
<ref bean="VpcVirtualRouter" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=discoverer
|
||||
parent=core
|
||||
@ -0,0 +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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="resourceDiscoverersRegistry" />
|
||||
<property name="typeClass" value="com.cloud.resource.Discoverer" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=network
|
||||
parent=backend
|
||||
@ -0,0 +1,58 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="ipDeployersRegistry" />
|
||||
<property name="typeClass" value="com.cloud.network.element.IpDeployer" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="dhcpProvidersRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.network.element.DhcpServiceProvider" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="networkGurusRegistry" />
|
||||
<property name="typeClass" value="com.cloud.network.guru.NetworkGuru" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="networkElementsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.network.element.NetworkElement" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="vpcProvidersRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.network.element.VpcProvider" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=planner
|
||||
parent=allocator
|
||||
@ -0,0 +1,41 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="deploymentPlannersRegistry" />
|
||||
<property name="typeClass" value="com.cloud.deploy.DeploymentPlanner" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="affinityProcessorsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="org.apache.cloudstack.affinity.AffinityGroupProcessor" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=storage
|
||||
parent=backend
|
||||
@ -0,0 +1,60 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registryBeanName" value="dataStoreProviderManager" />
|
||||
<property name="typeClass"
|
||||
value="org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="storagePoolAllocatorsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="secondaryStorageVmAllocatorsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.storage.secondary.SecondaryStorageVmAllocator" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="templateAdapterRegistry" />
|
||||
<property name="typeClass" value="com.cloud.template.TemplateAdapter" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
|
||||
<property name="registry" ref="podAllocatorsRegistry" />
|
||||
<property name="typeClass"
|
||||
value="com.cloud.agent.manager.allocator.PodAllocator" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=system
|
||||
parent=bootstrap
|
||||
@ -0,0 +1,54 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<!--
|
||||
LifeCycle
|
||||
-->
|
||||
<bean id="cloudStackLifeCycle" class="org.apache.cloudstack.spring.lifecycle.CloudStackExtendedLifeCycle" />
|
||||
<bean id="moduleStartup" class="org.apache.cloudstack.spring.lifecycle.CloudStackExtendedLifeCycleStart" >
|
||||
<property name="lifeCycle" ref="cloudStackLifeCycle" />
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
AOP
|
||||
-->
|
||||
<bean id="transactionContextInterceptor" class="com.cloud.utils.db.TransactionContextInterceptor" />
|
||||
<bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
|
||||
<aop:config>
|
||||
<aop:advisor advice-ref="transactionContextInterceptor"
|
||||
pointcut="target(com.cloud.utils.db.GenericDaoBase)" />
|
||||
<aop:advisor advice-ref="transactionContextInterceptor"
|
||||
pointcut="execution(* com.cloud.utils.db.EntityManager.*(..))" />
|
||||
<aop:advisor advice-ref="actionEventInterceptor"
|
||||
pointcut="execution(* *(..)) && @annotation(com.cloud.event.ActionEvent)" />
|
||||
<aop:advisor advice-ref="actionEventInterceptor"
|
||||
pointcut="execution(* *(..)) && @annotation(com.cloud.event.ActionEvents)" />
|
||||
</aop:config>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,50 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<!--
|
||||
Managed Context
|
||||
-->
|
||||
<bean id="ManagedContext" class="org.apache.cloudstack.managed.context.impl.DefaultManagedContext" >
|
||||
<property name="listeners">
|
||||
<list>
|
||||
<!-- Put CallContext listener first because it will open and then close a DB connection.
|
||||
If you put it after the TransactionContextListener, the thread will hold open a DB
|
||||
connection for the life of the thread -->
|
||||
<bean class="org.apache.cloudstack.context.CallContextListener" />
|
||||
<bean class="com.cloud.utils.db.TransactionContextListener" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.managed.context.ManagedContextRunnable" factory-method="initializeGlobalContext"
|
||||
autowire-candidate="false" >
|
||||
<constructor-arg><ref bean="ManagedContext"/></constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,44 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="clusterRestService"
|
||||
class="org.apache.cloudstack.engine.rest.service.api.ClusterRestService" />
|
||||
<bean id="dataDisk"
|
||||
class="org.apache.cloudstack.engine.subsystem.api.storage.type.DataDisk" />
|
||||
<bean id="podRestService" class="org.apache.cloudstack.engine.rest.service.api.PodRestService" />
|
||||
<bean id="iso" class="org.apache.cloudstack.engine.subsystem.api.storage.type.Iso" />
|
||||
<bean id="networkRestService" class="org.apache.cloudstack.engine.rest.service.api.NetworkRestService" />
|
||||
<bean id="provisioningServiceImpl" class="org.apache.cloudstack.engine.service.api.ProvisioningServiceImpl" />
|
||||
<bean id="rootDisk" class="org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk" />
|
||||
<bean id="virtualMachineRestService" class="org.apache.cloudstack.engine.rest.service.api.VirtualMachineRestService" />
|
||||
<bean id="volumeRestService" class="org.apache.cloudstack.engine.rest.service.api.VolumeRestService" />
|
||||
<bean id="volumeTypeHelper" class="org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper" />
|
||||
<bean id="zoneRestService" class="org.apache.cloudstack.engine.rest.service.api.ZoneRestService" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,30 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,71 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="clusterBasedAgentLoadBalancerPlanner"
|
||||
class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner">
|
||||
<property name="name" value="ClusterBasedAgentLoadBalancerPlanner" />
|
||||
</bean>
|
||||
|
||||
<bean id="volumeOrchestrator"
|
||||
class="org.apache.cloudstack.engine.orchestration.VolumeOrchestrator">
|
||||
<property name="podAllocators" value="#{podAllocatorsRegistry.registered}" />
|
||||
<property name="storagePoolAllocators"
|
||||
value="#{storagePoolAllocatorsRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl">
|
||||
<property name="hostAllocators" value="#{hostAllocatorsRegistry.registered}" />
|
||||
<property name="storagePoolAllocators"
|
||||
value="#{storagePoolAllocatorsRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="networkOrchestrator"
|
||||
class="org.apache.cloudstack.engine.orchestration.NetworkOrchestrator">
|
||||
<property name="networkGurus" value="#{networkGurusRegistry.registered}" />
|
||||
<property name="networkElements" value="#{networkElementsRegistry.registered}" />
|
||||
<property name="ipDeployers" value="#{ipDeployersRegistry.registered}" />
|
||||
<property name="dhcpProviders" value="#{dhcpProvidersRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="clusteredAgentManagerImpl" class="com.cloud.agent.manager.ClusteredAgentManagerImpl" />
|
||||
|
||||
|
||||
<bean id="cloudOrchestrator"
|
||||
class="org.apache.cloudstack.engine.orchestration.CloudOrchestrator" />
|
||||
<bean id="dataCenterResourceManagerImpl"
|
||||
class="org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManagerImpl" />
|
||||
|
||||
<bean id="vMEntityManagerImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VMEntityManagerImpl" >
|
||||
<property name="planners" value="#{deploymentPlannersRegistry.registered}" />
|
||||
</bean>
|
||||
|
||||
<bean id="virtualMachineEntityImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl" />
|
||||
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,321 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<!--
|
||||
DAO with customized configuration
|
||||
-->
|
||||
<bean id="serviceOfferingDaoImpl" class="com.cloud.service.dao.ServiceOfferingDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="50" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="50" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="50" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="50" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="30" />
|
||||
<entry key="cache.time.to.live" value="3600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="5000" />
|
||||
<entry key="cache.time.to.live" value="300" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="100" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="100" />
|
||||
<entry key="cache.time.to.live" value="600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="cache.size" value="30" />
|
||||
<entry key="cache.time.to.live" value="3600" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
DAOs with default configuration
|
||||
-->
|
||||
<bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />
|
||||
<bean id="accountDetailsDaoImpl" class="com.cloud.user.AccountDetailsDaoImpl" />
|
||||
<bean id="accountJoinDaoImpl" class="com.cloud.api.query.dao.AccountJoinDaoImpl" />
|
||||
<bean id="accountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
|
||||
<bean id="accountVlanMapDaoImpl" class="com.cloud.dc.dao.AccountVlanMapDaoImpl" />
|
||||
<bean id="alertDaoImpl" class="com.cloud.alert.dao.AlertDaoImpl" />
|
||||
<bean id="asyncJobJoinDaoImpl" class="com.cloud.api.query.dao.AsyncJobJoinDaoImpl" />
|
||||
<bean id="autoScalePolicyConditionMapDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyConditionMapDaoImpl" />
|
||||
<bean id="autoScalePolicyDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyDaoImpl" />
|
||||
<bean id="autoScaleVmGroupDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmGroupDaoImpl" />
|
||||
<bean id="autoScaleVmGroupPolicyMapDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmGroupPolicyMapDaoImpl" />
|
||||
<bean id="autoScaleVmProfileDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmProfileDaoImpl" />
|
||||
<bean id="capacityDaoImpl" class="com.cloud.capacity.dao.CapacityDaoImpl" />
|
||||
<bean id="certificateDaoImpl" class="com.cloud.certificate.dao.CertificateDaoImpl" />
|
||||
<bean id="clusterDaoImpl" class="com.cloud.dc.dao.ClusterDaoImpl" />
|
||||
<bean id="clusterDetailsDaoImpl" class="com.cloud.dc.ClusterDetailsDaoImpl" />
|
||||
<bean id="clusterVSMMapDaoImpl" class="com.cloud.dc.dao.ClusterVSMMapDaoImpl" />
|
||||
<bean id="commandExecLogDaoImpl" class="com.cloud.secstorage.CommandExecLogDaoImpl" />
|
||||
<bean id="conditionDaoImpl" class="com.cloud.network.as.dao.ConditionDaoImpl" />
|
||||
<bean id="consoleProxyDaoImpl" class="com.cloud.vm.dao.ConsoleProxyDaoImpl" />
|
||||
<bean id="counterDaoImpl" class="com.cloud.network.as.dao.CounterDaoImpl" />
|
||||
<bean id="dataCenterIpAddressDaoImpl" class="com.cloud.dc.dao.DataCenterIpAddressDaoImpl" />
|
||||
<bean id="dataCenterJoinDaoImpl" class="com.cloud.api.query.dao.DataCenterJoinDaoImpl" />
|
||||
<bean id="dataCenterLinkLocalIpAddressDaoImpl" class="com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl" />
|
||||
<bean id="dataCenterVnetDaoImpl" class="com.cloud.dc.dao.DataCenterVnetDaoImpl" />
|
||||
<bean id="dcDetailsDaoImpl" class="com.cloud.dc.dao.DcDetailsDaoImpl" />
|
||||
<bean id="engineDcDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DcDetailsDaoImpl" />
|
||||
<bean id="diskOfferingJoinDaoImpl" class="com.cloud.api.query.dao.DiskOfferingJoinDaoImpl" />
|
||||
<bean id="domainDaoImpl" class="com.cloud.domain.dao.DomainDaoImpl" />
|
||||
<bean id="domainRouterDaoImpl" class="com.cloud.vm.dao.DomainRouterDaoImpl" />
|
||||
<bean id="domainRouterJoinDaoImpl" class="com.cloud.api.query.dao.DomainRouterJoinDaoImpl" />
|
||||
<bean id="engineClusterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDaoImpl" />
|
||||
<bean id="engineDataCenterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDaoImpl" />
|
||||
<bean id="engineHostDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDaoImpl" />
|
||||
<bean id="engineHostPodDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDaoImpl" />
|
||||
<bean id="eventDaoImpl" class="com.cloud.event.dao.EventDaoImpl" />
|
||||
<bean id="eventJoinDaoImpl" class="com.cloud.event.dao.EventJoinDaoImpl" />
|
||||
<bean id="externalFirewallDeviceDaoImpl" class="com.cloud.network.dao.ExternalFirewallDeviceDaoImpl" />
|
||||
<bean id="externalLoadBalancerDeviceDaoImpl" class="com.cloud.network.dao.ExternalLoadBalancerDeviceDaoImpl" />
|
||||
<bean id="externalPublicIpStatisticsDaoImpl" class="com.cloud.usage.dao.ExternalPublicIpStatisticsDaoImpl" />
|
||||
<bean id="firewallRulesCidrsDaoImpl" class="com.cloud.network.dao.FirewallRulesCidrsDaoImpl" />
|
||||
<bean id="firewallRulesDaoImpl" class="com.cloud.network.dao.FirewallRulesDaoImpl" />
|
||||
<bean id="globalLoadBalancerDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerDaoImpl" />
|
||||
<bean id="globalLoadBalancerLbRuleMapDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerLbRuleMapDaoImpl" />
|
||||
<bean id="guestOSCategoryDaoImpl" class="com.cloud.storage.dao.GuestOSCategoryDaoImpl" />
|
||||
<bean id="guestOSDaoImpl" class="com.cloud.storage.dao.GuestOSDaoImpl" />
|
||||
<bean id="guestOSHypervisorDaoImpl" class="com.cloud.storage.dao.GuestOSHypervisorDaoImpl" />
|
||||
<bean id="highAvailabilityDaoImpl" class="com.cloud.ha.dao.HighAvailabilityDaoImpl" />
|
||||
<bean id="hostDaoImpl" class="com.cloud.host.dao.HostDaoImpl" />
|
||||
<bean id="engineHostDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDetailsDaoImpl" />
|
||||
<bean id="hostDetailsDaoImpl" class="com.cloud.host.dao.HostDetailsDaoImpl" />
|
||||
<bean id="hostJoinDaoImpl" class="com.cloud.api.query.dao.HostJoinDaoImpl" />
|
||||
<bean id="engineHostTagsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostTagsDaoImpl" />
|
||||
<bean id="hostTagsDaoImpl" class="com.cloud.host.dao.HostTagsDaoImpl" />
|
||||
<bean id="hostTransferMapDaoImpl" class="com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl" />
|
||||
<bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
|
||||
<bean id="identityDaoImpl" class="com.cloud.uuididentity.dao.IdentityDaoImpl" />
|
||||
<bean id="imageStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDaoImpl" />
|
||||
<bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" />
|
||||
<bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />
|
||||
<bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" />
|
||||
<bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" />
|
||||
<bean id="templateJoinDaoImpl" class="com.cloud.api.query.dao.TemplateJoinDaoImpl" />
|
||||
<bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />
|
||||
<bean id="inlineLoadBalancerNicMapDaoImpl" class="com.cloud.network.dao.InlineLoadBalancerNicMapDaoImpl" />
|
||||
<bean id="instanceGroupDaoImpl" class="com.cloud.vm.dao.InstanceGroupDaoImpl" />
|
||||
<bean id="instanceGroupJoinDaoImpl" class="com.cloud.api.query.dao.InstanceGroupJoinDaoImpl" />
|
||||
<bean id="instanceGroupVMMapDaoImpl" class="com.cloud.vm.dao.InstanceGroupVMMapDaoImpl" />
|
||||
<bean id="itWorkDaoImpl" class="com.cloud.vm.ItWorkDaoImpl" />
|
||||
<bean id="keystoreDaoImpl" class="com.cloud.keystore.KeystoreDaoImpl" />
|
||||
<bean id="lBHealthCheckPolicyDaoImpl" class="com.cloud.network.dao.LBHealthCheckPolicyDaoImpl" />
|
||||
<bean id="lBStickinessPolicyDaoImpl" class="com.cloud.network.dao.LBStickinessPolicyDaoImpl" />
|
||||
<bean id="launchPermissionDaoImpl" class="com.cloud.storage.dao.LaunchPermissionDaoImpl" />
|
||||
<bean id="loadBalancerDaoImpl" class="com.cloud.network.dao.LoadBalancerDaoImpl" />
|
||||
<bean id="loadBalancerVMMapDaoImpl" class="com.cloud.network.dao.LoadBalancerVMMapDaoImpl" />
|
||||
<bean id="managementServerHostDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostDaoImpl" />
|
||||
<bean id="managementServerHostPeerDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostPeerDaoImpl" />
|
||||
<bean id="networkAccountDaoImpl" class="com.cloud.network.dao.NetworkAccountDaoImpl" />
|
||||
<bean id="networkACLDaoImpl" class="com.cloud.network.vpc.dao.NetworkACLDaoImpl" />
|
||||
<bean id="networkACLItemDaoImpl" class="com.cloud.network.vpc.dao.NetworkACLItemDaoImpl" />
|
||||
<bean id="networkDaoImpl" class="com.cloud.network.dao.NetworkDaoImpl" />
|
||||
<bean id="networkDomainDaoImpl" class="com.cloud.network.dao.NetworkDomainDaoImpl" />
|
||||
<bean id="networkExternalFirewallDaoImpl" class="com.cloud.network.dao.NetworkExternalFirewallDaoImpl" />
|
||||
<bean id="networkExternalLoadBalancerDaoImpl" class="com.cloud.network.dao.NetworkExternalLoadBalancerDaoImpl" />
|
||||
<bean id="networkOfferingDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl" />
|
||||
<bean id="networkOfferingServiceMapDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl" />
|
||||
<bean id="networkOpDaoImpl" class="com.cloud.network.dao.NetworkOpDaoImpl" />
|
||||
<bean id="networkRuleConfigDaoImpl" class="com.cloud.network.dao.NetworkRuleConfigDaoImpl" />
|
||||
<bean id="networkServiceMapDaoImpl" class="com.cloud.network.dao.NetworkServiceMapDaoImpl" />
|
||||
<bean id="nicDaoImpl" class="com.cloud.vm.dao.NicDaoImpl" />
|
||||
<bean id="nicDetailDaoImpl" class="com.cloud.vm.dao.NicDetailDaoImpl" />
|
||||
<bean id="nicSecondaryIpDaoImpl" class="com.cloud.vm.dao.NicSecondaryIpDaoImpl" />
|
||||
<bean id="nicIpAliasDaoImpl" class="com.cloud.vm.dao.NicIpAliasDaoImpl" />
|
||||
<bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
|
||||
<bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
|
||||
<bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
|
||||
<bean id="physicalNetworkDaoImpl" class="com.cloud.network.dao.PhysicalNetworkDaoImpl" />
|
||||
<bean id="physicalNetworkIsolationMethodDaoImpl" class="com.cloud.network.dao.PhysicalNetworkIsolationMethodDaoImpl" />
|
||||
<bean id="physicalNetworkServiceProviderDaoImpl" class="com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl" />
|
||||
<bean id="physicalNetworkTagDaoImpl" class="com.cloud.network.dao.PhysicalNetworkTagDaoImpl" />
|
||||
<bean id="physicalNetworkTrafficTypeDaoImpl" class="com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl" />
|
||||
<bean id="podVlanDaoImpl" class="com.cloud.dc.dao.PodVlanDaoImpl" />
|
||||
<bean id="podVlanMapDaoImpl" class="com.cloud.dc.dao.PodVlanMapDaoImpl" />
|
||||
<bean id="PortableIpDaoImpl" class="org.apache.cloudstack.region.PortableIpDaoImpl" />
|
||||
<bean id="PortableIpRangeDaoImpl" class="org.apache.cloudstack.region.PortableIpRangeDaoImpl" />
|
||||
<bean id="portForwardingRulesDaoImpl" class="com.cloud.network.rules.dao.PortForwardingRulesDaoImpl" />
|
||||
<bean id="portProfileDaoImpl" class="com.cloud.network.dao.PortProfileDaoImpl" />
|
||||
<bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
|
||||
<bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" />
|
||||
<bean id="privateIpDaoImpl" class="com.cloud.network.vpc.dao.PrivateIpDaoImpl" />
|
||||
<bean id="projectAccountDaoImpl" class="com.cloud.projects.dao.ProjectAccountDaoImpl" />
|
||||
<bean id="projectAccountJoinDaoImpl" class="com.cloud.api.query.dao.ProjectAccountJoinDaoImpl" />
|
||||
<bean id="projectDaoImpl" class="com.cloud.projects.dao.ProjectDaoImpl" />
|
||||
<bean id="projectInvitationDaoImpl" class="com.cloud.projects.dao.ProjectInvitationDaoImpl" />
|
||||
<bean id="projectInvitationJoinDaoImpl" class="com.cloud.api.query.dao.ProjectInvitationJoinDaoImpl" />
|
||||
<bean id="projectJoinDaoImpl" class="com.cloud.api.query.dao.ProjectJoinDaoImpl" />
|
||||
<bean id="regionDaoImpl" class="org.apache.cloudstack.region.dao.RegionDaoImpl" />
|
||||
<bean id="remoteAccessVpnDaoImpl" class="com.cloud.network.dao.RemoteAccessVpnDaoImpl" />
|
||||
<bean id="resourceCountDaoImpl" class="com.cloud.configuration.dao.ResourceCountDaoImpl" />
|
||||
<bean id="resourceLimitDaoImpl" class="com.cloud.configuration.dao.ResourceLimitDaoImpl" />
|
||||
<bean id="resourceTagJoinDaoImpl" class="com.cloud.api.query.dao.ResourceTagJoinDaoImpl" />
|
||||
<bean id="resourceTagsDaoImpl" class="com.cloud.tags.dao.ResourceTagsDaoImpl" />
|
||||
<bean id="routerNetworkDaoImpl" class="com.cloud.network.dao.RouterNetworkDaoImpl" />
|
||||
<bean id="sSHKeyPairDaoImpl" class="com.cloud.user.dao.SSHKeyPairDaoImpl" />
|
||||
<bean id="secondaryStorageVmDaoImpl" class="com.cloud.vm.dao.SecondaryStorageVmDaoImpl" />
|
||||
<bean id="securityGroupDaoImpl" class="com.cloud.network.security.dao.SecurityGroupDaoImpl" />
|
||||
<bean id="securityGroupJoinDaoImpl" class="com.cloud.api.query.dao.SecurityGroupJoinDaoImpl" />
|
||||
<bean id="securityGroupRuleDaoImpl" class="com.cloud.network.security.dao.SecurityGroupRuleDaoImpl" />
|
||||
<bean id="securityGroupRulesDaoImpl" class="com.cloud.network.security.dao.SecurityGroupRulesDaoImpl" />
|
||||
<bean id="securityGroupVMMapDaoImpl" class="com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl" />
|
||||
<bean id="securityGroupWorkDaoImpl" class="com.cloud.network.security.dao.SecurityGroupWorkDaoImpl" />
|
||||
<bean id="serviceOfferingJoinDaoImpl" class="com.cloud.api.query.dao.ServiceOfferingJoinDaoImpl" />
|
||||
<bean id="site2SiteCustomerGatewayDaoImpl" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" />
|
||||
<bean id="site2SiteVpnConnectionDaoImpl" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" />
|
||||
<bean id="site2SiteVpnGatewayDaoImpl" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" />
|
||||
<bean id="snapshotDaoImpl" class="com.cloud.storage.dao.SnapshotDaoImpl" />
|
||||
<bean id="snapshotPolicyDaoImpl" class="com.cloud.storage.dao.SnapshotPolicyDaoImpl" />
|
||||
<bean id="snapshotScheduleDaoImpl" class="com.cloud.storage.dao.SnapshotScheduleDaoImpl" />
|
||||
<bean id="staticRouteDaoImpl" class="com.cloud.network.vpc.dao.StaticRouteDaoImpl" />
|
||||
<bean id="storageNetworkIpAddressDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpAddressDaoImpl" />
|
||||
<bean id="storageNetworkIpRangeDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpRangeDaoImpl" />
|
||||
<bean id="storagePoolDetailsDaoImpl" class="com.cloud.storage.dao.StoragePoolDetailsDaoImpl" />
|
||||
<bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl" />
|
||||
<bean id="storagePoolJoinDaoImpl" class="com.cloud.api.query.dao.StoragePoolJoinDaoImpl" />
|
||||
<bean id="storagePoolWorkDaoImpl" class="com.cloud.storage.dao.StoragePoolWorkDaoImpl" />
|
||||
<bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl" />
|
||||
<bean id="uploadDaoImpl" class="com.cloud.storage.dao.UploadDaoImpl" />
|
||||
<bean id="usageDaoImpl" class="com.cloud.usage.dao.UsageDaoImpl" />
|
||||
<bean id="usageEventDaoImpl" class="com.cloud.event.dao.UsageEventDaoImpl" />
|
||||
<bean id="usageIPAddressDaoImpl" class="com.cloud.usage.dao.UsageIPAddressDaoImpl" />
|
||||
<bean id="usageJobDaoImpl" class="com.cloud.usage.dao.UsageJobDaoImpl" />
|
||||
<bean id="usageLoadBalancerPolicyDaoImpl" class="com.cloud.usage.dao.UsageLoadBalancerPolicyDaoImpl" />
|
||||
<bean id="usageNetworkDaoImpl" class="com.cloud.usage.dao.UsageNetworkDaoImpl" />
|
||||
<bean id="usageNetworkOfferingDaoImpl" class="com.cloud.usage.dao.UsageNetworkOfferingDaoImpl" />
|
||||
<bean id="usagePortForwardingRuleDaoImpl" class="com.cloud.usage.dao.UsagePortForwardingRuleDaoImpl" />
|
||||
<bean id="usageSecurityGroupDaoImpl" class="com.cloud.usage.dao.UsageSecurityGroupDaoImpl" />
|
||||
<bean id="usageStorageDaoImpl" class="com.cloud.usage.dao.UsageStorageDaoImpl" />
|
||||
<bean id="usageVMInstanceDaoImpl" class="com.cloud.usage.dao.UsageVMInstanceDaoImpl" />
|
||||
<bean id="usageVPNUserDaoImpl" class="com.cloud.usage.dao.UsageVPNUserDaoImpl" />
|
||||
<bean id="usageVolumeDaoImpl" class="com.cloud.usage.dao.UsageVolumeDaoImpl" />
|
||||
<bean id="usageVmDiskDaoImpl" class="com.cloud.usage.dao.UsageVmDiskDaoImpl" />
|
||||
<bean id="userAccountDaoImpl" class="com.cloud.user.dao.UserAccountDaoImpl" />
|
||||
<bean id="userAccountJoinDaoImpl" class="com.cloud.api.query.dao.UserAccountJoinDaoImpl" />
|
||||
<bean id="userIpv6AddressDaoImpl" class="com.cloud.network.dao.UserIpv6AddressDaoImpl" />
|
||||
<bean id="userStatisticsDaoImpl" class="com.cloud.user.dao.UserStatisticsDaoImpl" />
|
||||
<bean id="userStatsLogDaoImpl" class="com.cloud.user.dao.UserStatsLogDaoImpl" />
|
||||
<bean id="userVmDiskStatsDaoImpl" class="com.cloud.user.dao.VmDiskStatisticsDaoImpl" />
|
||||
<bean id="userVmCloneSettingDaoImpl" class="com.cloud.vm.dao.UserVmCloneSettingDaoImpl" />
|
||||
<bean id="userVmDaoImpl" class="com.cloud.vm.dao.UserVmDaoImpl" />
|
||||
<bean id="userVmDetailsDaoImpl" class="com.cloud.vm.dao.UserVmDetailsDaoImpl" />
|
||||
<bean id="userVmJoinDaoImpl" class="com.cloud.api.query.dao.UserVmJoinDaoImpl" />
|
||||
<bean id="vMComputeTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMComputeTagDaoImpl" />
|
||||
<bean id="vMEntityDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDaoImpl" />
|
||||
<bean id="vMInstanceDaoImpl" class="com.cloud.vm.dao.VMInstanceDaoImpl" />
|
||||
<bean id="vMNetworkMapDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDaoImpl" />
|
||||
<bean id="vMReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDaoImpl" />
|
||||
<bean id="vMRootDiskTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMRootDiskTagDaoImpl" />
|
||||
<bean id="vMSnapshotDaoImpl" class="com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl" />
|
||||
<bean id="vMTemplateDetailsDaoImpl" class="com.cloud.storage.dao.VMTemplateDetailsDaoImpl" />
|
||||
<bean id="vMTemplateHostDaoImpl" class="com.cloud.storage.dao.VMTemplateHostDaoImpl" />
|
||||
<bean id="vMTemplatePoolDaoImpl" class="com.cloud.storage.dao.VMTemplatePoolDaoImpl" />
|
||||
<bean id="vMTemplateZoneDaoImpl" class="com.cloud.storage.dao.VMTemplateZoneDaoImpl" />
|
||||
<bean id="virtualRouterProviderDaoImpl" class="com.cloud.network.dao.VirtualRouterProviderDaoImpl" />
|
||||
<bean id="vmRulesetLogDaoImpl" class="com.cloud.network.security.dao.VmRulesetLogDaoImpl" />
|
||||
<bean id="volumeDaoImpl" class="com.cloud.storage.dao.VolumeDaoImpl" />
|
||||
<bean id="volumeDetailsDaoImpl" class="com.cloud.storage.dao.VolumeDetailsDaoImpl" />
|
||||
<bean id="volumeHostDaoImpl" class="com.cloud.storage.dao.VolumeHostDaoImpl" />
|
||||
<bean id="volumeJoinDaoImpl" class="com.cloud.api.query.dao.VolumeJoinDaoImpl" />
|
||||
<bean id="volumeReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VolumeReservationDaoImpl" />
|
||||
<bean id="vpcDaoImpl" class="com.cloud.network.vpc.dao.VpcDaoImpl" />
|
||||
<bean id="vpcGatewayDaoImpl" class="com.cloud.network.vpc.dao.VpcGatewayDaoImpl" />
|
||||
<bean id="vpcOfferingDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDaoImpl" />
|
||||
<bean id="vpcOfferingServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingServiceMapDaoImpl" />
|
||||
<bean id="vpcServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcServiceMapDaoImpl" />
|
||||
<bean id="vpnUserDaoImpl" class="com.cloud.network.dao.VpnUserDaoImpl" />
|
||||
<bean id="applicationLbRuleDaoImpl" class="org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDaoImpl" />
|
||||
<bean id="networkOfferingDetailsDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDetailsDaoImpl" />
|
||||
<bean id="serviceOfferingDetailsDaoImpl" class="com.cloud.service.dao.ServiceOfferingDetailsDaoImpl"/>
|
||||
|
||||
<bean id="AffinityGroupDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDaoImpl" />
|
||||
<bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl" />
|
||||
<bean id="AffinityGroupDomainMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDaoImpl" />
|
||||
|
||||
<bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,34 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
|
||||
|
||||
<bean id="versionDaoImpl" class="com.cloud.upgrade.dao.VersionDaoImpl" />
|
||||
|
||||
</beans>
|
||||
@ -31,6 +31,7 @@ import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -66,7 +67,6 @@ import com.cloud.upgrade.dao.Upgrade420to430;
|
||||
import com.cloud.upgrade.dao.UpgradeSnapshot217to224;
|
||||
import com.cloud.upgrade.dao.UpgradeSnapshot223to224;
|
||||
import com.cloud.upgrade.dao.VersionDao;
|
||||
import com.cloud.upgrade.dao.VersionDaoImpl;
|
||||
import com.cloud.upgrade.dao.VersionVO;
|
||||
import com.cloud.upgrade.dao.VersionVO.Step;
|
||||
import com.cloud.utils.component.SystemIntegrityChecker;
|
||||
@ -81,10 +81,10 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
|
||||
protected HashMap<String, DbUpgrade[]> _upgradeMap = new HashMap<String, DbUpgrade[]>();
|
||||
|
||||
@Inject
|
||||
VersionDao _dao;
|
||||
|
||||
public DatabaseUpgradeChecker() {
|
||||
_dao = new VersionDaoImpl();
|
||||
_upgradeMap.put("2.1.7", new DbUpgrade[] {new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(),
|
||||
new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade224to225(), new Upgrade225to226(),
|
||||
new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(),
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="storageCacheRandomAllocator"
|
||||
class="org.apache.cloudstack.storage.cache.allocator.StorageCacheRandomAllocator" />
|
||||
<bean id="storageCacheManagerImpl"
|
||||
class="org.apache.cloudstack.storage.cache.manager.StorageCacheManagerImpl" />
|
||||
<bean id="StorageCacheReplacementAlgorithm"
|
||||
class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />
|
||||
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,45 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
<bean id="ancientDataMotionStrategy"
|
||||
class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
|
||||
<bean id="xenserverStorageMotionStrategy"
|
||||
class="org.apache.cloudstack.storage.motion.XenServerStorageMotionStrategy" />
|
||||
|
||||
<bean id="dataMotionServiceImpl"
|
||||
class="org.apache.cloudstack.storage.motion.DataMotionServiceImpl">
|
||||
<property name="strategies">
|
||||
<list>
|
||||
<ref local="ancientDataMotionStrategy" />
|
||||
<ref local="xenserverStorageMotionStrategy" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,45 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="templateServiceImpl"
|
||||
class="org.apache.cloudstack.storage.image.TemplateServiceImpl"
|
||||
depends-on="dataObjectManagerImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl, defaultEndPointSelector, templateDataFactoryImpl" />
|
||||
|
||||
<bean id="templateDataFactoryImpl"
|
||||
class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl" />
|
||||
|
||||
<bean id="imageStoreHelper"
|
||||
class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper" />
|
||||
<bean id="imageFormatHelper"
|
||||
class="org.apache.cloudstack.storage.image.format.ImageFormatHelper" />
|
||||
|
||||
<bean id="imageStoreProviderMgr"
|
||||
class="org.apache.cloudstack.storage.image.manager.ImageStoreProviderManagerImpl" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,63 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<!--Image formats-->
|
||||
<bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
|
||||
<bean id="OVA" class="org.apache.cloudstack.storage.image.format.OVA" />
|
||||
<bean id="QCOW2" class="org.apache.cloudstack.storage.image.format.QCOW2" />
|
||||
<bean id="VHD" class="org.apache.cloudstack.storage.image.format.VHD" />
|
||||
<bean id="VHDX" class="org.apache.cloudstack.storage.image.format.VHDX" />
|
||||
<bean id="unknown" class="org.apache.cloudstack.storage.image.format.Unknown" />
|
||||
<bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
|
||||
|
||||
|
||||
<bean id="objectInDataStoreManagerImpl"
|
||||
class="org.apache.cloudstack.storage.datastore.ObjectInDataStoreManagerImpl" />
|
||||
|
||||
<bean id="dataObjectManagerImpl"
|
||||
class="org.apache.cloudstack.storage.datastore.DataObjectManagerImpl" />
|
||||
|
||||
<bean id="defaultEndPointSelector"
|
||||
class="org.apache.cloudstack.storage.endpoint.DefaultEndPointSelector" />
|
||||
|
||||
<bean id="dataStoreManagerImpl"
|
||||
class="org.apache.cloudstack.storage.datastore.DataStoreManagerImpl"
|
||||
depends-on="dataStoreProviderManager">
|
||||
<property name="primaryStoreMgr" ref="primaryDataStoreProviderMgr" />
|
||||
<property name="imageDataStoreMgr" ref="imageStoreProviderMgr" />
|
||||
</bean>
|
||||
|
||||
<bean id="dataStoreProviderManager"
|
||||
class="org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManagerImpl">
|
||||
<property name="providers">
|
||||
<list />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,2 @@
|
||||
name=storage-allocator
|
||||
parent=storage
|
||||
@ -0,0 +1,49 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="LocalStoragePoolAllocator"
|
||||
class="org.apache.cloudstack.storage.allocator.LocalStoragePoolAllocator">
|
||||
<property name="name" value="LocalStorage" />
|
||||
</bean>
|
||||
|
||||
<bean id="clusterScopeStoragePoolAllocator"
|
||||
class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator" />
|
||||
<bean id="zoneWideStoragePoolAllocator"
|
||||
class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator" />
|
||||
<bean id="garbageCollectingStoragePoolAllocator"
|
||||
class="org.apache.cloudstack.storage.allocator.GarbageCollectingStoragePoolAllocator">
|
||||
<property name="name" value="GCStorage" />
|
||||
</bean>
|
||||
|
||||
<bean id="UserConcentratedAllocator"
|
||||
class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator">
|
||||
<property name="name" value="UserFirst" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,44 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="snapshotServiceImpl"
|
||||
class="org.apache.cloudstack.storage.snapshot.SnapshotServiceImpl"
|
||||
depends-on="snapshotStateMachineManagerImpl, snapshotDataFactoryImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl" />
|
||||
|
||||
<bean id="xenserverSnapshotStrategy"
|
||||
class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy" />
|
||||
|
||||
<bean id="snapshotDataFactoryImpl"
|
||||
class="org.apache.cloudstack.storage.snapshot.SnapshotDataFactoryImpl"
|
||||
depends-on="dataStoreManagerImpl, snapshotDataStoreDaoImpl, volumeDataFactoryImpl" />
|
||||
|
||||
<bean id="snapshotStateMachineManagerImpl"
|
||||
class="org.apache.cloudstack.storage.snapshot.SnapshotStateMachineManagerImpl" />
|
||||
|
||||
</beans>
|
||||
@ -20,6 +20,8 @@ package org.apache.cloudstack.storage.datastore.provider;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.component.Registry;
|
||||
|
||||
import org.apache.cloudstack.api.response.StorageProviderResponse;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider.DataStoreProviderType;
|
||||
@ -33,18 +35,22 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@Component
|
||||
public class DataStoreProviderManagerImpl extends ManagerBase implements DataStoreProviderManager {
|
||||
public class DataStoreProviderManagerImpl extends ManagerBase implements DataStoreProviderManager, Registry<DataStoreProvider> {
|
||||
private static final Logger s_logger = Logger.getLogger(DataStoreProviderManagerImpl.class);
|
||||
@Inject
|
||||
|
||||
List<DataStoreProvider> providers;
|
||||
protected Map<String, DataStoreProvider> providerMap = new HashMap<String, DataStoreProvider>();
|
||||
protected Map<String, DataStoreProvider> providerMap = new ConcurrentHashMap<String, DataStoreProvider>();
|
||||
@Inject
|
||||
PrimaryDataStoreProviderManager primaryDataStoreProviderMgr;
|
||||
@Inject
|
||||
@ -96,41 +102,52 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
Map<String, Object> copyParams = new HashMap<String, Object>(params);
|
||||
|
||||
for (DataStoreProvider provider : providers) {
|
||||
String providerName = provider.getName();
|
||||
if (providerMap.get(providerName) != null) {
|
||||
s_logger.debug("Failed to register data store provider, provider name: " + providerName
|
||||
+ " is not unique");
|
||||
return false;
|
||||
if ( providers != null ) {
|
||||
for (DataStoreProvider provider : providers) {
|
||||
registerProvider(provider);
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.debug("registering data store provider:" + provider.getName());
|
||||
providers = new CopyOnWriteArrayList<DataStoreProvider>(providers);
|
||||
|
||||
providerMap.put(providerName, provider);
|
||||
try {
|
||||
boolean registrationResult = provider.configure(copyParams);
|
||||
if (!registrationResult) {
|
||||
providerMap.remove(providerName);
|
||||
s_logger.debug("Failed to register data store provider: " + providerName);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<DataStoreProviderType> types = provider.getTypes();
|
||||
if (types.contains(DataStoreProviderType.PRIMARY)) {
|
||||
primaryDataStoreProviderMgr.registerDriver(provider.getName(),
|
||||
(PrimaryDataStoreDriver) provider.getDataStoreDriver());
|
||||
primaryDataStoreProviderMgr.registerHostListener(provider.getName(), provider.getHostListener());
|
||||
} else if (types.contains(DataStoreProviderType.IMAGE)) {
|
||||
imageStoreProviderMgr.registerDriver(provider.getName(),
|
||||
(ImageStoreDriver) provider.getDataStoreDriver());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("configure provider failed", e);
|
||||
protected boolean registerProvider(DataStoreProvider provider) {
|
||||
Map<String, Object> copyParams = new HashMap<String, Object>();
|
||||
|
||||
String providerName = provider.getName();
|
||||
if (providerMap.get(providerName) != null) {
|
||||
s_logger.debug("Did not register data store provider, provider name: " + providerName
|
||||
+ " is not unique");
|
||||
return false;
|
||||
}
|
||||
|
||||
s_logger.debug("registering data store provider:" + provider.getName());
|
||||
|
||||
providerMap.put(providerName, provider);
|
||||
try {
|
||||
boolean registrationResult = provider.configure(copyParams);
|
||||
if (!registrationResult) {
|
||||
providerMap.remove(providerName);
|
||||
s_logger.debug("Failed to register data store provider: " + providerName);
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<DataStoreProviderType> types = provider.getTypes();
|
||||
if (types.contains(DataStoreProviderType.PRIMARY)) {
|
||||
primaryDataStoreProviderMgr.registerDriver(provider.getName(),
|
||||
(PrimaryDataStoreDriver) provider.getDataStoreDriver());
|
||||
primaryDataStoreProviderMgr.registerHostListener(provider.getName(), provider.getHostListener());
|
||||
} else if (types.contains(DataStoreProviderType.IMAGE)) {
|
||||
imageStoreProviderMgr.registerDriver(provider.getName(),
|
||||
(ImageStoreDriver) provider.getDataStoreDriver());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("configure provider failed", e);
|
||||
providerMap.remove(providerName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -167,6 +184,27 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean register(DataStoreProvider type) {
|
||||
if ( registerProvider(type) ) {
|
||||
providers.add(type);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(DataStoreProvider type) {
|
||||
/* Sorry, no unregister supported... */
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataStoreProvider> getRegistered() {
|
||||
return Collections.unmodifiableList(providers);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setProviders(List<DataStoreProvider> providers) {
|
||||
this.providers = providers;
|
||||
}
|
||||
@ -178,4 +216,9 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
|
||||
public void setImageStoreProviderMgr(ImageStoreProviderManager imageDataStoreProviderMgr) {
|
||||
this.imageStoreProviderMgr = imageDataStoreProviderMgr;
|
||||
}
|
||||
|
||||
public List<DataStoreProvider> getProviders() {
|
||||
return providers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<!--Filesystem types -->
|
||||
<bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
|
||||
<bean id="networkFileSystem"
|
||||
class="org.apache.cloudstack.storage.datastore.type.NetworkFileSystem" />
|
||||
|
||||
<bean id="volumeServiceImpl"
|
||||
class="org.apache.cloudstack.storage.volume.VolumeServiceImpl"
|
||||
depends-on="snapshotManagerImpl, dataMotionServiceImpl" />
|
||||
|
||||
<bean id="volumeDataFactoryImpl"
|
||||
class="org.apache.cloudstack.storage.volume.VolumeDataFactoryImpl" />
|
||||
|
||||
|
||||
<bean id="primaryDataStoreHelper"
|
||||
class="org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper" />
|
||||
|
||||
<bean id="primaryDataStoreProviderMgr"
|
||||
class="org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreProviderManagerImpl" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,36 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="clusterServiceServletAdapter" class="com.cloud.cluster.ClusterServiceServletAdapter" />
|
||||
|
||||
<bean id="clusterManagerImpl" class="com.cloud.cluster.ClusterManagerImpl" />
|
||||
|
||||
<bean id="clusterFenceManagerImpl" class="com.cloud.cluster.ClusterFenceManagerImpl" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,38 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle" >
|
||||
<property name="registry" ref="scopedConfigStorageRegistry" />
|
||||
<property name="typeClass" value="org.apache.cloudstack.framework.config.ScopedConfigStorage" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.cloudstack.spring.lifecycle.ConfigDepotLifeCycle" />
|
||||
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,51 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="configurationDaoImpl"
|
||||
class="org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl">
|
||||
<property name="configParams">
|
||||
<map>
|
||||
<entry key="premium" value="${premium}" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="configDepot"
|
||||
class="org.apache.cloudstack.framework.config.impl.ConfigDepotImpl">
|
||||
<property name="scopedStorages"
|
||||
value="#{scopedConfigStorageRegistry.registered}" />
|
||||
<property name="configurables">
|
||||
<list />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="scopedConfigStorageRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry" />
|
||||
|
||||
</beans>
|
||||
@ -32,5 +32,7 @@ public interface ConfigDepotAdmin {
|
||||
*/
|
||||
void populateConfigurations();
|
||||
|
||||
void populateConfiguration(Configurable configurable);
|
||||
|
||||
List<String> getComponentsInDepot();
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
@ -128,6 +129,14 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() throws ConfigurationException {
|
||||
/* This bean is loaded in bootstrap and beans
|
||||
* in bootstrap don't go through the CloudStackExtendedLifeCycle
|
||||
*/
|
||||
configure(getName(), getConfigParams());
|
||||
}
|
||||
|
||||
//Use update method with category instead
|
||||
@Override
|
||||
@Deprecated
|
||||
|
||||
@ -17,14 +17,16 @@
|
||||
package org.apache.cloudstack.framework.config.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepotAdmin;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
@ -32,9 +34,9 @@ import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.config.ScopedConfigStorage;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.SystemIntegrityChecker;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
/**
|
||||
@ -64,14 +66,13 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
* when constructing a ConfigKey then configuration server should use the
|
||||
* validation class to validate the value the admin input for the key.
|
||||
*/
|
||||
public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin, SystemIntegrityChecker {
|
||||
public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
|
||||
private final static Logger s_logger = Logger.getLogger(ConfigDepotImpl.class);
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@Inject
|
||||
List<Configurable> _configurables;
|
||||
@Inject
|
||||
List<ScopedConfigStorage> _scopedStorages;
|
||||
Set<Configurable> _configured = Collections.synchronizedSet(new HashSet<Configurable>());
|
||||
|
||||
HashMap<String, Pair<String, ConfigKey<?>>> _allKeys = new HashMap<String, Pair<String, ConfigKey<?>>>(1007);
|
||||
|
||||
@ -85,29 +86,53 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin, SystemInt
|
||||
return value != null ? value.second() : null;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
@Override
|
||||
public void populateConfigurations() {
|
||||
Date date = new Date();
|
||||
for (Configurable configurable : _configurables) {
|
||||
for (ConfigKey<?> key : configurable.getConfigKeys()) {
|
||||
ConfigurationVO vo = _configDao.findById(key.key());
|
||||
if (vo == null) {
|
||||
vo = new ConfigurationVO(configurable.getConfigComponentName(), key);
|
||||
populateConfiguration(date, configurable);
|
||||
}
|
||||
}
|
||||
|
||||
protected void populateConfiguration(Date date, Configurable configurable) {
|
||||
if ( _configured.contains(configurable) )
|
||||
return;
|
||||
|
||||
s_logger.debug("Retrieving keys from " + configurable.getClass().getSimpleName());
|
||||
|
||||
for (ConfigKey<?> key : configurable.getConfigKeys()) {
|
||||
Pair<String, ConfigKey<?>> previous = _allKeys.get(key.key());
|
||||
if (previous != null && !previous.first().equals(configurable.getConfigComponentName())) {
|
||||
throw new CloudRuntimeException("Configurable " + configurable.getConfigComponentName() + " is adding a key that has been added before by " + previous.first() +
|
||||
": " + key.toString());
|
||||
}
|
||||
_allKeys.put(key.key(), new Pair<String, ConfigKey<?>>(configurable.getConfigComponentName(), key));
|
||||
|
||||
ConfigurationVO vo = _configDao.findById(key.key());
|
||||
if (vo == null) {
|
||||
vo = new ConfigurationVO(configurable.getConfigComponentName(), key);
|
||||
vo.setUpdated(date);
|
||||
_configDao.persist(vo);
|
||||
} else {
|
||||
if (vo.isDynamic() != key.isDynamic() ||
|
||||
!ObjectUtils.equals(vo.getDescription(), key.description()) ||
|
||||
!ObjectUtils.equals(vo.getDefaultValue(), key.defaultValue())) {
|
||||
vo.setDynamic(key.isDynamic());
|
||||
vo.setDescription(key.description());
|
||||
vo.setDefaultValue(key.defaultValue());
|
||||
vo.setUpdated(date);
|
||||
_configDao.persist(vo);
|
||||
} else {
|
||||
if (vo.isDynamic() != key.isDynamic() ||
|
||||
!ObjectUtils.equals(vo.getDescription(), key.description()) ||
|
||||
!ObjectUtils.equals(vo.getDefaultValue(), key.defaultValue())) {
|
||||
vo.setDynamic(key.isDynamic());
|
||||
vo.setDescription(key.description());
|
||||
vo.setDefaultValue(key.defaultValue());
|
||||
vo.setUpdated(date);
|
||||
_configDao.persist(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_configured.add(configurable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateConfiguration(Configurable configurable) {
|
||||
populateConfiguration(new Date(), configurable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,22 +140,6 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin, SystemInt
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void check() {
|
||||
for (Configurable configurable : _configurables) {
|
||||
s_logger.debug("Retrieving keys from " + configurable.getClass().getSimpleName());
|
||||
for (ConfigKey<?> key : configurable.getConfigKeys()) {
|
||||
Pair<String, ConfigKey<?>> previous = _allKeys.get(key.key());
|
||||
if (previous != null && !previous.first().equals(configurable.getConfigComponentName())) {
|
||||
throw new CloudRuntimeException("Configurable " + configurable.getConfigComponentName() + " is adding a key that has been added before by " + previous.first() +
|
||||
": " + key.toString());
|
||||
}
|
||||
_allKeys.put(key.key(), new Pair<String, ConfigKey<?>>(configurable.getConfigComponentName(), key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationDao global() {
|
||||
return _configDao;
|
||||
}
|
||||
@ -144,4 +153,23 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin, SystemInt
|
||||
|
||||
throw new CloudRuntimeException("Unable to find config storage for this scope: " + config.scope() + " for " + config.key());
|
||||
}
|
||||
|
||||
public List<ScopedConfigStorage> getScopedStorages() {
|
||||
return _scopedStorages;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setScopedStorages(List<ScopedConfigStorage> scopedStorages) {
|
||||
this._scopedStorages = scopedStorages;
|
||||
}
|
||||
|
||||
public List<Configurable> getConfigurables() {
|
||||
return _configurables;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setConfigurables(List<Configurable> configurables) {
|
||||
this._configurables = configurables;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -95,6 +95,7 @@ public class ConfigDepotAdminTest extends TestCase {
|
||||
verify(_configDao, times(1)).persist(any(ConfigurationVO.class));
|
||||
|
||||
when(_configDao.findById(DynamicIntCK.key())).thenReturn(dynamicIntCV);
|
||||
_depotAdmin._configured.clear();
|
||||
_depotAdmin.populateConfigurations();
|
||||
// This is two because DynamicIntCK also returns null.
|
||||
verify(_configDao, times(2)).persist(any(ConfigurationVO.class));
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="entityManagerImpl" class="com.cloud.dao.EntityManagerImpl" />
|
||||
|
||||
</beans>
|
||||
@ -138,7 +138,9 @@ public class Transaction {
|
||||
// the existing DAO features
|
||||
//
|
||||
public void transitToUserManagedConnection(Connection conn) {
|
||||
assert(_conn == null /*&& _stack.size() <= 1*/) : "Can't change to a user managed connection unless the stack is empty and the db connection is null, you may have forgotten to invoke transitToAutoManagedConnection to close out the DB connection: " + toString();
|
||||
if ( _conn != null )
|
||||
throw new IllegalStateException("Can't change to a user managed connection unless the db connection is null");
|
||||
|
||||
_conn = conn;
|
||||
_dbId = CONNECTED_DB;
|
||||
}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 com.cloud.utils.db;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
public class TransactionContextInterceptor implements MethodInterceptor {
|
||||
|
||||
public TransactionContextInterceptor() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public Object invoke(MethodInvocation m) throws Throwable {
|
||||
Transaction txn = Transaction.open(m.getMethod().getName());
|
||||
try {
|
||||
return m.proceed();
|
||||
} finally {
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 com.cloud.utils.db;
|
||||
|
||||
import org.apache.cloudstack.managed.context.ManagedContextListener;
|
||||
|
||||
public class TransactionContextListener implements ManagedContextListener<Transaction> {
|
||||
|
||||
@Override
|
||||
public Transaction onEnterContext(boolean reentry) {
|
||||
if ( ! reentry ) {
|
||||
return Transaction.open(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeaveContext(Transaction data, boolean reentry) {
|
||||
if ( ! reentry ) {
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<!--
|
||||
RPC/Async/EventBus
|
||||
-->
|
||||
<bean id="onwireRegistry" class="org.apache.cloudstack.framework.serializer.OnwireClassRegistry"
|
||||
init-method="scan" >
|
||||
<property name="packages">
|
||||
<list>
|
||||
<value>org.apache.cloudstack.framework</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="messageSerializer" class="org.apache.cloudstack.framework.serializer.JsonMessageSerializer">
|
||||
<property name="onwireClassRegistry" ref="onwireRegistry" />
|
||||
</bean>
|
||||
|
||||
<bean id="transportProvider" class="org.apache.cloudstack.framework.server.ServerTransportProvider" init-method="initialize">
|
||||
<property name="workerPoolSize" value="5" />
|
||||
<property name="nodeId" value="Node1" />
|
||||
<property name="messageSerializer" ref="messageSerializer" />
|
||||
</bean>
|
||||
|
||||
<bean id="rpcProvider" class="org.apache.cloudstack.framework.rpc.RpcProviderImpl" init-method="initialize">
|
||||
<constructor-arg ref="transportProvider" />
|
||||
<property name="messageSerializer" ref="messageSerializer" />
|
||||
</bean>
|
||||
|
||||
<bean id="messageBus" class = "org.apache.cloudstack.framework.messagebus.MessageBusBase" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,48 @@
|
||||
<!--
|
||||
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: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/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"
|
||||
>
|
||||
|
||||
<bean id="asyncJobDaoImpl"
|
||||
class="org.apache.cloudstack.framework.jobs.dao.AsyncJobDaoImpl" />
|
||||
<bean id="asyncJobJournalDaoImpl"
|
||||
class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJournalDaoImpl" />
|
||||
<bean id="asyncJobJoinMapDaoImpl"
|
||||
class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDaoImpl" />
|
||||
<bean id="asyncJobManagerImpl"
|
||||
class="org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl" />
|
||||
<bean id="asyncJobMonitor"
|
||||
class="org.apache.cloudstack.framework.jobs.impl.AsyncJobMonitor" />
|
||||
<bean id="syncQueueDaoImpl"
|
||||
class="org.apache.cloudstack.framework.jobs.dao.SyncQueueDaoImpl" />
|
||||
<bean id="syncQueueItemDaoImpl"
|
||||
class="org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDaoImpl" />
|
||||
<bean id="syncQueueManagerImpl"
|
||||
class="org.apache.cloudstack.framework.jobs.impl.SyncQueueManagerImpl" />
|
||||
|
||||
|
||||
</beans>
|
||||
@ -38,5 +38,7 @@
|
||||
<module>db</module>
|
||||
<module>config</module>
|
||||
<module>managed-context</module>
|
||||
<module>spring/lifecycle</module>
|
||||
<module>spring/module</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
||||
34
framework/spring/lifecycle/pom.xml
Normal file
34
framework/spring/lifecycle/pom.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<!-- 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. -->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-framework-spring-lifecycle</artifactId>
|
||||
<name>Apache CloudStack Framework - Spring Life Cycle</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-maven-standard</artifactId>
|
||||
<version>4.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../../maven-standard/pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-utils</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-config</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
|
||||
/**
|
||||
* This class provides a method to do basically the same as @Inject of a type, but
|
||||
* it will only find the types in the current context and not the parent. This class
|
||||
* should only be used for very specific Spring bootstrap logic. In general @Inject
|
||||
* is infinitely better. Basically you need a very good reason to use this.
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractBeanCollector extends AbstractSmartLifeCycle implements BeanPostProcessor {
|
||||
|
||||
Class<?>[] typeClasses = new Class<?>[] {};
|
||||
Map<Class<?>, Set<Object>> beans = new HashMap<Class<?>, Set<Object>>();
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
for ( Class<?> typeClass : typeClasses ) {
|
||||
if ( typeClass.isAssignableFrom(bean.getClass()) ) {
|
||||
doPostProcessBeforeInitialization(bean, beanName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
protected void doPostProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
}
|
||||
|
||||
protected void doPostProcessAfterInitialization(Object bean, Class<?> typeClass, String beanName) throws BeansException {
|
||||
Set<Object> beansOfType = beans.get(typeClass);
|
||||
|
||||
if ( beansOfType == null ) {
|
||||
beansOfType = new HashSet<Object>();
|
||||
beans.put(typeClass, beansOfType);
|
||||
}
|
||||
|
||||
beansOfType.add(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
for ( Class<?> typeClass : typeClasses ) {
|
||||
if ( typeClass.isAssignableFrom(bean.getClass()) ) {
|
||||
doPostProcessAfterInitialization(bean, typeClass, beanName);
|
||||
}
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
protected <T> Set<T> getBeans(Class<T> typeClass) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<T> result = (Set<T>) beans.get(typeClass);
|
||||
|
||||
if ( result == null )
|
||||
return Collections.emptySet();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Class<?> getTypeClass() {
|
||||
if ( typeClasses == null || typeClasses.length == 0 )
|
||||
return null;
|
||||
|
||||
return typeClasses[0];
|
||||
}
|
||||
|
||||
public void setTypeClass(Class<?> typeClass) {
|
||||
this.typeClasses = new Class<?>[] { typeClass };
|
||||
}
|
||||
|
||||
public Class<?>[] getTypeClasses() {
|
||||
return typeClasses;
|
||||
}
|
||||
|
||||
public void setTypeClasses(Class<?>[] typeClasses) {
|
||||
this.typeClasses = typeClasses;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
|
||||
public abstract class AbstractSmartLifeCycle implements SmartLifecycle {
|
||||
|
||||
boolean running = false;
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
running = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
running = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(Runnable callback) {
|
||||
stop();
|
||||
callback.run();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import javax.management.MBeanRegistrationException;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.cloud.utils.component.ComponentLifecycle;
|
||||
import com.cloud.utils.component.SystemIntegrityChecker;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.mgmt.JmxUtil;
|
||||
import com.cloud.utils.mgmt.ManagementBean;
|
||||
|
||||
public class CloudStackExtendedLifeCycle extends AbstractBeanCollector {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CloudStackExtendedLifeCycle.class);
|
||||
|
||||
Map<Integer, Set<ComponentLifecycle>> sorted = new TreeMap<Integer, Set<ComponentLifecycle>>();
|
||||
|
||||
public CloudStackExtendedLifeCycle() {
|
||||
super();
|
||||
setTypeClasses(new Class<?>[] {
|
||||
ComponentLifecycle.class,
|
||||
SystemIntegrityChecker.class
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
sortBeans();
|
||||
checkIntegrity();
|
||||
configure();
|
||||
|
||||
super.start();
|
||||
}
|
||||
|
||||
protected void checkIntegrity() {
|
||||
for ( SystemIntegrityChecker checker : getBeans(SystemIntegrityChecker.class) ) {
|
||||
log.info("Running system integrity checker {}", checker);
|
||||
|
||||
checker.check();
|
||||
}
|
||||
}
|
||||
|
||||
public void startBeans() {
|
||||
log.info("Starting CloudStack Components");
|
||||
|
||||
with(new WithComponentLifeCycle() {
|
||||
@Override
|
||||
public void with(ComponentLifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
|
||||
if ( lifecycle instanceof ManagementBean ) {
|
||||
ManagementBean mbean = (ManagementBean)lifecycle;
|
||||
try {
|
||||
JmxUtil.registerMBean(mbean);
|
||||
} catch (MalformedObjectNameException e) {
|
||||
log.warn("Unable to register MBean: " + mbean.getName(), e);
|
||||
} catch (InstanceAlreadyExistsException e) {
|
||||
log.warn("Unable to register MBean: " + mbean.getName(), e);
|
||||
} catch (MBeanRegistrationException e) {
|
||||
log.warn("Unable to register MBean: " + mbean.getName(), e);
|
||||
} catch (NotCompliantMBeanException e) {
|
||||
log.warn("Unable to register MBean: " + mbean.getName(), e);
|
||||
}
|
||||
log.info("Registered MBean: " + mbean.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
log.info("Done Starting CloudStack Components");
|
||||
}
|
||||
|
||||
public void stopBeans() {
|
||||
with(new WithComponentLifeCycle() {
|
||||
@Override
|
||||
public void with(ComponentLifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void configure() {
|
||||
log.info("Configuring CloudStack Components");
|
||||
|
||||
with(new WithComponentLifeCycle() {
|
||||
@Override
|
||||
public void with(ComponentLifecycle lifecycle) {
|
||||
try {
|
||||
lifecycle.configure(lifecycle.getName(), lifecycle.getConfigParams());
|
||||
} catch (ConfigurationException e) {
|
||||
log.error("Failed to configure {}", lifecycle.getName(), e);
|
||||
throw new CloudRuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
log.info("Done Configuring CloudStack Components");
|
||||
}
|
||||
|
||||
private void sortBeans() {
|
||||
for ( ComponentLifecycle lifecycle : getBeans(ComponentLifecycle.class) ) {
|
||||
Set<ComponentLifecycle> set = sorted.get(lifecycle.getRunLevel());
|
||||
|
||||
if ( set == null ) {
|
||||
set = new HashSet<ComponentLifecycle>();
|
||||
sorted.put(lifecycle.getRunLevel(), set);
|
||||
}
|
||||
|
||||
set.add(lifecycle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
with(new WithComponentLifeCycle() {
|
||||
@Override
|
||||
public void with(ComponentLifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
});
|
||||
|
||||
super.stop();
|
||||
}
|
||||
|
||||
protected void with(WithComponentLifeCycle with) {
|
||||
for ( Set<ComponentLifecycle> lifecycles : sorted.values() ) {
|
||||
for ( ComponentLifecycle lifecycle : lifecycles ) {
|
||||
with.with(lifecycle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return 2000;
|
||||
}
|
||||
|
||||
private static interface WithComponentLifeCycle {
|
||||
public void with(ComponentLifecycle lifecycle);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle;
|
||||
|
||||
public class CloudStackExtendedLifeCycleStart extends AbstractSmartLifeCycle implements Runnable {
|
||||
|
||||
CloudStackExtendedLifeCycle lifeCycle;
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
lifeCycle.stopBeans();
|
||||
super.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return 3000;
|
||||
}
|
||||
|
||||
public CloudStackExtendedLifeCycle getLifeCycle() {
|
||||
return lifeCycle;
|
||||
}
|
||||
|
||||
public void setLifeCycle(CloudStackExtendedLifeCycle lifeCycle) {
|
||||
this.lifeCycle = lifeCycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
lifeCycle.startBeans();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
|
||||
import com.cloud.utils.LogUtils;
|
||||
|
||||
public class CloudStackLog4jSetup implements SmartLifecycle {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
LogUtils.initLog4j("log4j-cloud.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(Runnable callback) {
|
||||
callback.run();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.framework.config.ConfigDepotAdmin;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
|
||||
public class ConfigDepotLifeCycle implements BeanPostProcessor {
|
||||
|
||||
@Inject
|
||||
ConfigDepotAdmin configDepotAdmin;
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if ( bean instanceof Configurable ) {
|
||||
configDepotAdmin.populateConfiguration((Configurable)bean);
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle.registry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.component.ComponentLifecycleBase;
|
||||
import com.cloud.utils.component.Named;
|
||||
import com.cloud.utils.component.Registry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DumpRegistry extends ComponentLifecycleBase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DumpRegistry.class);
|
||||
|
||||
List<Registry<?>> registries;
|
||||
|
||||
public List<Registry<?>> getRegistries() {
|
||||
return registries;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setRegistries(List<Registry<?>> registries) {
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
for ( Registry<?> registry : registries ) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
for ( Object o : registry.getRegistered() ) {
|
||||
if ( buffer.length() > 0 )
|
||||
buffer.append(", ");
|
||||
|
||||
buffer.append(getName(o));
|
||||
}
|
||||
|
||||
log.info("Registry [{}] contains [{}]", registry.getName(), buffer);
|
||||
}
|
||||
|
||||
return super.start();
|
||||
}
|
||||
|
||||
protected String getName(Object o) {
|
||||
String name = null;
|
||||
if (o instanceof Named) {
|
||||
name = ((Named) o).getName();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = o.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,245 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle.registry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
import com.cloud.utils.component.Named;
|
||||
import com.cloud.utils.component.Registry;
|
||||
|
||||
public class ExtensionRegistry implements Registry<Object>, Configurable, BeanNameAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ExtensionRegistry.class);
|
||||
|
||||
String name;
|
||||
String beanName;
|
||||
|
||||
String orderConfigKey;
|
||||
String orderConfigDefault;
|
||||
ConfigKey<String> orderConfigKeyObj;
|
||||
|
||||
String excludeKey;
|
||||
String excludeDefault;
|
||||
ConfigKey<String> excludeKeyObj;
|
||||
|
||||
String configComponentName;
|
||||
List<Object> preRegistered;
|
||||
List<Object> registered = new CopyOnWriteArrayList<Object>();
|
||||
List<Object> readOnly = Collections.unmodifiableList(registered);
|
||||
|
||||
@Override
|
||||
public boolean register(Object item) {
|
||||
if ( registered.contains(item) )
|
||||
return false;
|
||||
|
||||
String[] order = new String[] {};
|
||||
Set<String> exclude = new HashSet<String>();
|
||||
|
||||
if ( orderConfigKeyObj != null ) {
|
||||
Object value = orderConfigKeyObj.value();
|
||||
if ( value != null && value.toString().trim().length() > 0 ) {
|
||||
order = value.toString().trim().split("\\s*,\\s*");
|
||||
}
|
||||
}
|
||||
|
||||
if ( excludeKeyObj != null ) {
|
||||
Object value = excludeKeyObj.value();
|
||||
if ( value != null && value.toString().trim().length() > 0 ) {
|
||||
for ( String e : value.toString().trim().split("\\s*,\\s*") ) {
|
||||
exclude.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String name = getName(item);
|
||||
|
||||
if ( name != null && exclude.size() > 0 && exclude.contains(name) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( name == null && order.length > 0 ) {
|
||||
throw new RuntimeException("getName() is null for [" + item + "]");
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for ( String orderTest : order ) {
|
||||
if ( orderTest.equals(name) ) {
|
||||
registered.add(i, item);
|
||||
i = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( registered.size() <= i ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( getName(registered.get(i)).equals(orderTest) ) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( i != -1 ) {
|
||||
registered.add(item);
|
||||
}
|
||||
|
||||
log.debug("Registering extension [{}] in [{}]", name, this.name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getName(Object object) {
|
||||
if ( object instanceof Named ) {
|
||||
String name = ((Named)object).getName();
|
||||
if ( name != null )
|
||||
return name;
|
||||
}
|
||||
|
||||
return object == null ? null : object.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(Object type) {
|
||||
registered.remove(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRegistered() {
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return configComponentName == null ? this.getClass().getSimpleName() : configComponentName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
List<ConfigKey<String>> result = new ArrayList<ConfigKey<String>>();
|
||||
|
||||
if ( orderConfigKey != null && orderConfigKeyObj == null ) {
|
||||
orderConfigKeyObj = new ConfigKey<String>("Advanced", String.class, orderConfigKey, orderConfigDefault,
|
||||
"The order of precedence for the extensions", false);
|
||||
}
|
||||
|
||||
if ( orderConfigKeyObj != null )
|
||||
result.add(orderConfigKeyObj);
|
||||
|
||||
if ( excludeKey != null && excludeKeyObj == null ) {
|
||||
excludeKeyObj = new ConfigKey<String>("Advanced", String.class, excludeKey, excludeDefault,
|
||||
"Extensions to exclude from being registered", false);
|
||||
}
|
||||
|
||||
if ( excludeKeyObj != null ) {
|
||||
result.add(excludeKeyObj);
|
||||
}
|
||||
|
||||
return result.toArray(new ConfigKey[result.size()]);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if ( name == null ) {
|
||||
for ( String part : beanName.replaceAll("([A-Z])", " $1").split("\\s+") ) {
|
||||
part = StringUtils.capitalize(part.toLowerCase());;
|
||||
|
||||
name = name == null ? part : name + " " + part;
|
||||
}
|
||||
}
|
||||
|
||||
if ( preRegistered != null ) {
|
||||
for ( Object o : preRegistered ) {
|
||||
register(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getOrderConfigKey() {
|
||||
return orderConfigKey;
|
||||
}
|
||||
|
||||
public void setOrderConfigKey(String orderConfigKey) {
|
||||
this.orderConfigKey = orderConfigKey;
|
||||
}
|
||||
|
||||
public void setConfigComponentName(String configComponentName) {
|
||||
this.configComponentName = configComponentName;
|
||||
}
|
||||
|
||||
public String getOrderConfigDefault() {
|
||||
return orderConfigDefault;
|
||||
}
|
||||
|
||||
public void setOrderConfigDefault(String orderConfigDefault) {
|
||||
this.orderConfigDefault = orderConfigDefault;
|
||||
}
|
||||
|
||||
public String getExcludeKey() {
|
||||
return excludeKey;
|
||||
}
|
||||
|
||||
public void setExcludeKey(String excludeKey) {
|
||||
this.excludeKey = excludeKey;
|
||||
}
|
||||
|
||||
public String getExcludeDefault() {
|
||||
return excludeDefault;
|
||||
}
|
||||
|
||||
public void setExcludeDefault(String excludeDefault) {
|
||||
this.excludeDefault = excludeDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
public List<Object> getPreRegistered() {
|
||||
return preRegistered;
|
||||
}
|
||||
|
||||
public void setPreRegistered(List<Object> preRegistered) {
|
||||
this.preRegistered = preRegistered;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle.registry;
|
||||
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public class PluggableServiceLifecycle extends RegistryLifecycle {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
super.start();
|
||||
|
||||
for (Object obj : beans) {
|
||||
if (obj instanceof PluggableService) {
|
||||
for (Class<?> cmd : ((PluggableService) obj).getCommands()) {
|
||||
ComponentContext.addDelegateContext(cmd, applicationContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
for (Object obj : beans) {
|
||||
if (obj instanceof PluggableService) {
|
||||
for (Class<?> cmd : ((PluggableService) obj).getCommands()) {
|
||||
ComponentContext.removeDelegateContext(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.stop();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.lifecycle.registry;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
|
||||
import com.cloud.utils.component.Registry;
|
||||
|
||||
public class RegistryLifecycle implements BeanPostProcessor, SmartLifecycle, ApplicationContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RegistryLifecycle.class);
|
||||
|
||||
Registry<Object> registry;
|
||||
|
||||
/* The bean name works around circular dependency issues in Spring. This shouldn't be
|
||||
* needed if your beans are already nicely organized. If they look like spaghetti, then you
|
||||
* can use this.
|
||||
*/
|
||||
String registryBeanName;
|
||||
Set<Object> beans = new HashSet<Object>();
|
||||
Class<?> typeClass;
|
||||
ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if ( typeClass.isAssignableFrom(bean.getClass()) )
|
||||
beans.add(bean);
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
Iterator<Object> iter = beans.iterator();
|
||||
Registry<Object> registry = lookupRegistry();
|
||||
|
||||
while ( iter.hasNext() ) {
|
||||
Object next = iter.next();
|
||||
if ( registry.register(next) ) {
|
||||
log.debug("Registered {}", next);
|
||||
} else {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
Registry<Object> registry = lookupRegistry();
|
||||
|
||||
for ( Object bean : beans ) {
|
||||
registry.unregister(bean);
|
||||
}
|
||||
|
||||
beans.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(Runnable callback) {
|
||||
stop();
|
||||
callback.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Registry<Object> lookupRegistry() {
|
||||
return registry == null ? applicationContext.getBean(registryBeanName, Registry.class) : registry;
|
||||
}
|
||||
|
||||
public Registry<Object> getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
public void setRegistry(Registry<Object> registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
public Class<?> getTypeClass() {
|
||||
return typeClass;
|
||||
}
|
||||
|
||||
public void setTypeClass(Class<?> typeClass) {
|
||||
this.typeClass = typeClass;
|
||||
}
|
||||
|
||||
public String getRegistryBeanName() {
|
||||
return registryBeanName;
|
||||
}
|
||||
|
||||
public void setRegistryBeanName(String registryBeanName) {
|
||||
this.registryBeanName = registryBeanName;
|
||||
}
|
||||
|
||||
}
|
||||
50
framework/spring/module/pom.xml
Normal file
50
framework/spring/module/pom.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-framework-spring-module</artifactId>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-maven-standard</artifactId>
|
||||
<version>4.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../../maven-standard/pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-utils</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.context;
|
||||
|
||||
import org.springframework.context.support.AbstractXmlApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
public class ResourceApplicationContext extends AbstractXmlApplicationContext {
|
||||
|
||||
Resource[] configResources;
|
||||
String applicationName = "";
|
||||
|
||||
public ResourceApplicationContext() {
|
||||
}
|
||||
|
||||
public ResourceApplicationContext(Resource... configResources) {
|
||||
super();
|
||||
this.configResources = configResources;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Resource[] getConfigResources() {
|
||||
return configResources;
|
||||
}
|
||||
|
||||
public void setConfigResources(Resource[] configResources) {
|
||||
this.configResources = configResources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationName() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
public void setApplicationName(String applicationName) {
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.factory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.spring.module.locator.ModuleDefinitionLocator;
|
||||
import org.apache.cloudstack.spring.module.locator.impl.ClasspathModuleDefinitionLocator;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinitionSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
public class CloudStackSpringContext {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CloudStackSpringContext.class);
|
||||
|
||||
public static final String CLOUDSTACK_CONTEXT = "META-INF/cloudstack";
|
||||
public static final String CLOUDSTACK_BASE = "bootstrap";
|
||||
|
||||
ModuleBasedContextFactory factory = new ModuleBasedContextFactory();
|
||||
ModuleDefinitionLocator loader = new ClasspathModuleDefinitionLocator();
|
||||
ModuleDefinitionSet moduleDefinitionSet;
|
||||
String baseName;
|
||||
String contextName;
|
||||
|
||||
public CloudStackSpringContext(String context, String base) throws IOException {
|
||||
this.baseName = base;
|
||||
this.contextName = context;
|
||||
|
||||
factory = new ModuleBasedContextFactory();
|
||||
loader = new ClasspathModuleDefinitionLocator();
|
||||
init();
|
||||
}
|
||||
|
||||
public CloudStackSpringContext() throws IOException {
|
||||
this(CLOUDSTACK_CONTEXT, CLOUDSTACK_BASE);
|
||||
}
|
||||
|
||||
public void init() throws IOException {
|
||||
Collection<ModuleDefinition> defs = loader.locateModules(contextName);
|
||||
|
||||
if ( defs.size() == 0 )
|
||||
throw new RuntimeException("No modules found to load for Spring");
|
||||
|
||||
moduleDefinitionSet = factory.loadModules(defs, baseName);
|
||||
}
|
||||
|
||||
public void registerShutdownHook() {
|
||||
ApplicationContext base = moduleDefinitionSet.getApplicationContext(baseName);
|
||||
|
||||
if ( base instanceof ConfigurableApplicationContext ) {
|
||||
((ConfigurableApplicationContext)base).registerShutdownHook();
|
||||
}
|
||||
}
|
||||
|
||||
public ModuleDefinition getModuleDefinitionForWeb(String name) {
|
||||
ModuleDefinition def = moduleDefinitionSet.getModuleDefinition(name);
|
||||
|
||||
if ( def != null ) {
|
||||
return def;
|
||||
}
|
||||
|
||||
/* Grab farthest descendant that is deterministic */
|
||||
def = moduleDefinitionSet.getModuleDefinition(baseName);
|
||||
|
||||
if ( def == null ) {
|
||||
throw new RuntimeException("Failed to find base spring module to extend for web");
|
||||
}
|
||||
|
||||
while ( def.getChildren().size() == 1 ) {
|
||||
def = def.getChildren().iterator().next();
|
||||
}
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
public ApplicationContext getApplicationContextForWeb(String name) {
|
||||
ModuleDefinition def = getModuleDefinitionForWeb(name);
|
||||
|
||||
return moduleDefinitionSet.getApplicationContext(def.getName());
|
||||
}
|
||||
|
||||
public String[] getConfigLocationsForWeb(String name, String[] configured) {
|
||||
if ( configured == null )
|
||||
configured = new String[] {};
|
||||
|
||||
ModuleDefinition def = getModuleDefinitionForWeb(name);
|
||||
|
||||
List<Resource> inherited = new ArrayList<Resource>();
|
||||
|
||||
while ( def != null ) {
|
||||
inherited.addAll(def.getInheritableContextLocations());
|
||||
def = moduleDefinitionSet.getModuleDefinition(def.getParentName());
|
||||
}
|
||||
|
||||
List<String> urlList = new ArrayList<String>();
|
||||
|
||||
for ( Resource r : inherited ) {
|
||||
try {
|
||||
String urlString = r.getURL().toExternalForm();
|
||||
urlList.add(urlString);
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to create URL for {}", r.getDescription(), e);
|
||||
}
|
||||
}
|
||||
|
||||
String[] result = new String[urlList.size() + configured.length];
|
||||
result = urlList.toArray(result);
|
||||
|
||||
System.arraycopy(configured, 0, result, urlList.size(), configured.length);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.factory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinitionSet;
|
||||
import org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet;
|
||||
|
||||
public class ModuleBasedContextFactory {
|
||||
|
||||
public ModuleDefinitionSet loadModules(Collection<ModuleDefinition> defs, String root) throws IOException {
|
||||
|
||||
Map<String, ModuleDefinition> modules = wireUpModules(root, defs);
|
||||
|
||||
DefaultModuleDefinitionSet moduleSet = new DefaultModuleDefinitionSet(modules, root);
|
||||
moduleSet.load();
|
||||
|
||||
return moduleSet;
|
||||
}
|
||||
|
||||
protected Map<String, ModuleDefinition> wireUpModules(String root, Collection<ModuleDefinition> defs) throws IOException {
|
||||
Map<String, ModuleDefinition> modules = new HashMap<String, ModuleDefinition>();
|
||||
|
||||
for ( ModuleDefinition def : defs ) {
|
||||
modules.put(def.getName(), def);
|
||||
}
|
||||
|
||||
ModuleDefinition rootDef = null;
|
||||
Map<String, ModuleDefinition> result = new HashMap<String, ModuleDefinition>();
|
||||
|
||||
for ( ModuleDefinition def : modules.values() ) {
|
||||
if ( def.getName().equals(root) ) {
|
||||
rootDef = def;
|
||||
}
|
||||
|
||||
if ( def.getParentName() != null ) {
|
||||
ModuleDefinition parentDef = modules.get(def.getParentName());
|
||||
|
||||
if ( parentDef != null )
|
||||
parentDef.addChild(def);
|
||||
}
|
||||
}
|
||||
|
||||
return traverse(rootDef, result);
|
||||
}
|
||||
|
||||
protected Map<String, ModuleDefinition> traverse(ModuleDefinition base, Map<String, ModuleDefinition> result) {
|
||||
if ( base == null )
|
||||
return result;
|
||||
|
||||
if ( result.containsKey(base.getName()) ) {
|
||||
throw new RuntimeException("Circular dependency to [" + base.getName() + "] from current set " +
|
||||
result.keySet());
|
||||
}
|
||||
|
||||
result.put(base.getName(), base);
|
||||
|
||||
for ( ModuleDefinition childDef : base.getChildren() )
|
||||
traverse(childDef, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.locator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
|
||||
/**
|
||||
* Responsible for locating the ModuleDefinition for a given context. The implementation
|
||||
* of this class should take extra care to set the ClassLoader of the ModuleDefinition
|
||||
* properly.
|
||||
*
|
||||
*/
|
||||
public interface ModuleDefinitionLocator {
|
||||
|
||||
Collection<ModuleDefinition> locateModules(String context) throws IOException;
|
||||
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.locator.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.spring.module.locator.ModuleDefinitionLocator;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
import org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinition;
|
||||
import org.apache.cloudstack.spring.module.util.ModuleLocationUtils;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
public class ClasspathModuleDefinitionLocator implements ModuleDefinitionLocator {
|
||||
|
||||
protected ResourcePatternResolver getResolver() {
|
||||
return new PathMatchingResourcePatternResolver();
|
||||
}
|
||||
|
||||
public Collection<ModuleDefinition> locateModules(String context) throws IOException {
|
||||
ResourcePatternResolver resolver = getResolver();
|
||||
|
||||
Map<String, ModuleDefinition> allModules = discoverModules(context, resolver);
|
||||
|
||||
return allModules.values();
|
||||
}
|
||||
|
||||
protected Map<String, ModuleDefinition> discoverModules(String baseDir, ResourcePatternResolver resolver) throws IOException {
|
||||
Map<String, ModuleDefinition> result = new HashMap<String, ModuleDefinition>();
|
||||
|
||||
for ( Resource r : resolver.getResources(ModuleLocationUtils.getModulesLocation(baseDir)) ) {
|
||||
DefaultModuleDefinition def = new DefaultModuleDefinition(baseDir, r, resolver);
|
||||
def.init();
|
||||
|
||||
if ( def.isValid() )
|
||||
result.put(def.getName(), def);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
public interface ModuleDefinition {
|
||||
|
||||
ClassLoader getClassLoader();
|
||||
|
||||
String getName();
|
||||
|
||||
String getParentName();
|
||||
|
||||
List<Resource> getConfigLocations();
|
||||
|
||||
List<Resource> getContextLocations();
|
||||
|
||||
List<Resource> getInheritableContextLocations();
|
||||
|
||||
List<Resource> getOverrideContextLocations();
|
||||
|
||||
boolean isValid();
|
||||
|
||||
Collection<ModuleDefinition> getChildren();
|
||||
|
||||
void addChild(ModuleDefinition childDef);
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.model;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
public interface ModuleDefinitionSet {
|
||||
|
||||
ModuleDefinition getModuleDefinition(String name);
|
||||
|
||||
ApplicationContext getApplicationContext(String name);
|
||||
|
||||
Resource[] getConfigResources(String name);
|
||||
|
||||
}
|
||||
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.model.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
import org.apache.cloudstack.spring.module.util.ModuleLocationUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public class DefaultModuleDefinition implements ModuleDefinition {
|
||||
|
||||
public static final String NAME = "name";
|
||||
public static final String PARENT = "parent";
|
||||
|
||||
String name;
|
||||
String baseDir;
|
||||
String parent;
|
||||
Resource moduleProperties;
|
||||
ResourcePatternResolver resolver;
|
||||
boolean valid;
|
||||
|
||||
List<Resource> configLocations;
|
||||
List<Resource> contextLocations;
|
||||
List<Resource> inheritableContextLocations;
|
||||
List<Resource> overrideContextLocations;
|
||||
Map<String, ModuleDefinition> children = new TreeMap<String, ModuleDefinition>();
|
||||
|
||||
public DefaultModuleDefinition(String baseDir, Resource moduleProperties, ResourcePatternResolver resolver) {
|
||||
this.baseDir = baseDir;
|
||||
this.resolver = resolver;
|
||||
this.moduleProperties = moduleProperties;
|
||||
}
|
||||
|
||||
public void init() throws IOException {
|
||||
|
||||
if ( ! moduleProperties.exists() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
resolveNameAndParent();
|
||||
|
||||
contextLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getContextLocation(baseDir, name)));
|
||||
configLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getDefaultsLocation(baseDir, name)));
|
||||
inheritableContextLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getInheritableContextLocation(baseDir, name)));
|
||||
overrideContextLocations = Arrays.asList(resolver.getResources(ModuleLocationUtils.getOverrideContextLocation(baseDir, name)));
|
||||
|
||||
valid = true;
|
||||
}
|
||||
|
||||
protected void resolveNameAndParent() throws IOException {
|
||||
InputStream is = null;
|
||||
|
||||
try {
|
||||
is = moduleProperties.getInputStream();
|
||||
Properties props = new Properties();
|
||||
props.load(is);
|
||||
|
||||
name = props.getProperty(NAME);
|
||||
parent = props.getProperty(PARENT);
|
||||
|
||||
if ( ! StringUtils.hasText(name) ) {
|
||||
throw new IOException("Missing name property in [" + location() + "]");
|
||||
}
|
||||
|
||||
if ( ! StringUtils.hasText(parent) ) {
|
||||
parent = null;
|
||||
}
|
||||
|
||||
checkNameMatchesSelf();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkNameMatchesSelf() throws IOException {
|
||||
String expectedLocation = ModuleLocationUtils.getModuleLocation(baseDir, name);
|
||||
Resource self = resolver.getResource(expectedLocation);
|
||||
|
||||
if ( ! self.exists() ) {
|
||||
throw new IOException("Resource [" + location() + "] is expected to exist at [" +
|
||||
expectedLocation + "] please ensure the name property is correct");
|
||||
}
|
||||
|
||||
String moduleUrl = moduleProperties.getURL().toExternalForm();
|
||||
String selfUrl = self.getURL().toExternalForm();
|
||||
|
||||
if ( ! moduleUrl.equals(selfUrl) ) {
|
||||
throw new IOException("Resource [" + location() + "] and [" +
|
||||
self.getURL() + "] do not appear to be the same resource, " +
|
||||
"please ensure the name property is correct");
|
||||
}
|
||||
}
|
||||
|
||||
private String location() throws IOException {
|
||||
return moduleProperties.getURL().toString();
|
||||
}
|
||||
|
||||
public void addChild(ModuleDefinition def) {
|
||||
children.put(def.getName(), def);
|
||||
}
|
||||
|
||||
public Collection<ModuleDefinition> getChildren() {
|
||||
return children.values();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public List<Resource> getConfigLocations() {
|
||||
return configLocations;
|
||||
}
|
||||
|
||||
public List<Resource> getContextLocations() {
|
||||
return contextLocations;
|
||||
}
|
||||
|
||||
public List<Resource> getInheritableContextLocations() {
|
||||
return inheritableContextLocations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Resource> getOverrideContextLocations() {
|
||||
return overrideContextLocations;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
return resolver.getClassLoader();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.model.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.cloudstack.spring.module.context.ResourceApplicationContext;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinitionSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
|
||||
public class DefaultModuleDefinitionSet implements ModuleDefinitionSet {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DefaultModuleDefinitionSet.class);
|
||||
|
||||
public static final String DEFAULT_CONFIG_RESOURCES = "DefaultConfigResources";
|
||||
public static final String DEFAULT_CONFIG_XML = "defaults-context.xml";
|
||||
|
||||
String root;
|
||||
Map<String, ModuleDefinition> modules;
|
||||
Map<String, ApplicationContext> contexts = new HashMap<String, ApplicationContext>();
|
||||
ApplicationContext rootContext = null;
|
||||
|
||||
public DefaultModuleDefinitionSet(Map<String, ModuleDefinition> modules, String root) {
|
||||
super();
|
||||
this.root = root;
|
||||
this.modules = modules;
|
||||
}
|
||||
|
||||
public void load() throws IOException {
|
||||
if ( ! loadRootContext() )
|
||||
return;
|
||||
|
||||
printHierarchy();
|
||||
loadContexts();
|
||||
startContexts();
|
||||
}
|
||||
|
||||
protected boolean loadRootContext() {
|
||||
ModuleDefinition def = modules.get(root);
|
||||
|
||||
if ( def == null )
|
||||
return false;
|
||||
|
||||
ApplicationContext defaultsContext = getDefaultsContext();
|
||||
|
||||
rootContext = loadContext(def, defaultsContext);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void startContexts() {
|
||||
withModule(new WithModule() {
|
||||
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
|
||||
try {
|
||||
ApplicationContext context = getApplicationContext(def.getName());
|
||||
try {
|
||||
Runnable runnable = context.getBean("moduleStartup", Runnable.class);
|
||||
log.info("Starting module [{}]", def.getName());
|
||||
runnable.run();
|
||||
} catch ( BeansException e ) {
|
||||
// Ignore
|
||||
}
|
||||
} catch ( EmptyStackException e ) {
|
||||
// The root context is already loaded, so ignore the exception
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void loadContexts() {
|
||||
withModule(new WithModule() {
|
||||
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
|
||||
try {
|
||||
ApplicationContext parent = getApplicationContext(parents.peek().getName());
|
||||
loadContext(def, parent);
|
||||
} catch ( EmptyStackException e ) {
|
||||
// The root context is already loaded, so ignore the exception
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
protected ApplicationContext loadContext(ModuleDefinition def, ApplicationContext parent) {
|
||||
ResourceApplicationContext context = new ResourceApplicationContext();
|
||||
context.setApplicationName("/" + def.getName());
|
||||
|
||||
Resource[] resources = getConfigResources(def.getName());
|
||||
context.setConfigResources(resources);
|
||||
context.setParent(parent);
|
||||
context.setClassLoader(def.getClassLoader());
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
if ( log.isInfoEnabled() ) {
|
||||
for ( Resource resource : resources ) {
|
||||
log.info("Loading module context [{}] from {}", def.getName(), resource);
|
||||
}
|
||||
}
|
||||
context.refresh();
|
||||
log.info("Loaded module context [{}] in {} ms", def.getName(), (System.currentTimeMillis() - start));
|
||||
|
||||
contexts.put(def.getName(), context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
protected boolean shouldLoad(ModuleDefinition def) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ApplicationContext getDefaultsContext() {
|
||||
URL config = DefaultModuleDefinitionSet.class.getResource(DEFAULT_CONFIG_XML);
|
||||
|
||||
ResourceApplicationContext context = new ResourceApplicationContext(new UrlResource(config));
|
||||
context.setApplicationName("/defaults");
|
||||
context.refresh();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<Resource> resources = (List<Resource>) context.getBean(DEFAULT_CONFIG_RESOURCES);
|
||||
|
||||
withModule(new WithModule() {
|
||||
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
|
||||
for ( Resource defaults : def.getConfigLocations() ) {
|
||||
resources.add(defaults);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
protected void printHierarchy() {
|
||||
withModule(new WithModule() {
|
||||
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
|
||||
log.info(String.format("Module Hierarchy:%" + ((parents.size() * 2) + 1) + "s%s", "", def.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void withModule(WithModule with) {
|
||||
ModuleDefinition rootDef = modules.get(root);
|
||||
withModule(rootDef, new Stack<ModuleDefinition>(), with);
|
||||
}
|
||||
|
||||
protected void withModule(ModuleDefinition def, Stack<ModuleDefinition> parents, WithModule with) {
|
||||
if ( def == null )
|
||||
return;
|
||||
|
||||
if ( ! shouldLoad(def) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
with.with(def, parents);
|
||||
|
||||
parents.push(def);
|
||||
|
||||
for ( ModuleDefinition child : def.getChildren() ) {
|
||||
withModule(child, parents, with);
|
||||
}
|
||||
|
||||
parents.pop();
|
||||
}
|
||||
|
||||
private static interface WithModule {
|
||||
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class ConfigContext {
|
||||
|
||||
List<Resource> resources;
|
||||
|
||||
public ConfigContext(List<Resource> resources) {
|
||||
super();
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
@Bean(name = DEFAULT_CONFIG_RESOURCES)
|
||||
public List<Resource> defaultConfigResources() {
|
||||
return new ArrayList<Resource>();
|
||||
}
|
||||
}
|
||||
|
||||
public ApplicationContext getApplicationContext(String name) {
|
||||
return contexts.get(name);
|
||||
}
|
||||
|
||||
public Resource[] getConfigResources(String name) {
|
||||
Set<Resource> resources = new LinkedHashSet<Resource>();
|
||||
|
||||
ModuleDefinition original = null;
|
||||
ModuleDefinition def = original = modules.get(name);
|
||||
|
||||
if ( def == null )
|
||||
return new Resource[] {};
|
||||
|
||||
resources.addAll(def.getContextLocations());
|
||||
|
||||
while ( def != null ) {
|
||||
resources.addAll(def.getInheritableContextLocations());
|
||||
def = modules.get(def.getParentName());
|
||||
}
|
||||
|
||||
resources.addAll(original.getOverrideContextLocations());
|
||||
|
||||
return resources.toArray(new Resource[resources.size()]);
|
||||
}
|
||||
|
||||
public ModuleDefinition getModuleDefinition(String name) {
|
||||
return modules.get(name);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.util;
|
||||
|
||||
import org.apache.cloudstack.spring.module.factory.CloudStackSpringContext;
|
||||
|
||||
public class Main {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
public Main() {
|
||||
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
CloudStackSpringContext context = new CloudStackSpringContext();
|
||||
context.registerShutdownHook();
|
||||
|
||||
if ( Boolean.getBoolean("force.exit") ) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return System.currentTimeMillis() - start;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String... args) {
|
||||
Main main = new Main();
|
||||
|
||||
try {
|
||||
main.start();
|
||||
System.out.println("STARTUP COMPLETE [" + main.getTime() + "] ms");
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
System.out.println("STARTUP FAILED [" + main.getTime() + "] ms");
|
||||
System.err.println("STARTUP FAILED [" + main.getTime() + "] ms");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.util;
|
||||
|
||||
public class ModuleLocationUtils {
|
||||
|
||||
private static final String ALL_MODULE_PROPERTIES = "classpath*:%s/*/module.properties";
|
||||
private static final String MODULE_PROPERTIES = "classpath:%s/%s/module.properties";
|
||||
private static final String CONTEXT_LOCATION = "classpath*:%s/%s/*context.xml";
|
||||
private static final String INHERTIABLE_CONTEXT_LOCATION = "classpath*:%s/%s/*context-inheritable.xml";
|
||||
private static final String OVERRIDE_CONTEXT_LOCATION = "classpath*:%s/%s/*context-override.xml";
|
||||
private static final String DEFAULTS_LOCATION = "classpath*:%s/%s/*defaults.properties";
|
||||
|
||||
public static String getModulesLocation(String baseDir) {
|
||||
return String.format(ALL_MODULE_PROPERTIES, baseDir);
|
||||
}
|
||||
|
||||
public static String getModuleLocation(String baseDir, String name) {
|
||||
return String.format(MODULE_PROPERTIES, baseDir, name);
|
||||
}
|
||||
|
||||
public static String getContextLocation(String baseDir, String name) {
|
||||
return String.format(CONTEXT_LOCATION, baseDir, name);
|
||||
}
|
||||
|
||||
public static String getInheritableContextLocation(String baseDir, String name) {
|
||||
return String.format(INHERTIABLE_CONTEXT_LOCATION, baseDir, name);
|
||||
}
|
||||
|
||||
public static String getOverrideContextLocation(String baseDir, String name) {
|
||||
return String.format(OVERRIDE_CONTEXT_LOCATION, baseDir, name);
|
||||
}
|
||||
|
||||
public static String getDefaultsLocation(String baseDir, String name) {
|
||||
return String.format(DEFAULTS_LOCATION, baseDir, name);
|
||||
}
|
||||
}
|
||||
@ -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.cloudstack.spring.module.web;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import org.apache.cloudstack.spring.module.factory.CloudStackSpringContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.web.context.ConfigurableWebApplicationContext;
|
||||
import org.springframework.web.context.ContextLoaderListener;
|
||||
|
||||
public class CloudStackContextLoaderListener extends ContextLoaderListener {
|
||||
|
||||
public static final String WEB_PARENT_MODULE = "parentModule";
|
||||
public static final String WEB_PARENT_MODULE_DEFAULT = "web";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CloudStackContextLoaderListener.class);
|
||||
|
||||
CloudStackSpringContext cloudStackContext;
|
||||
String configuredParentName;
|
||||
|
||||
@Override
|
||||
protected ApplicationContext loadParentContext(ServletContext servletContext) {
|
||||
return cloudStackContext.getApplicationContextForWeb(configuredParentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
try {
|
||||
cloudStackContext = new CloudStackSpringContext();
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to start CloudStack", e);
|
||||
throw new RuntimeException("Failed to initialize CloudStack Spring modules", e);
|
||||
}
|
||||
|
||||
configuredParentName = event.getServletContext().getInitParameter(WEB_PARENT_MODULE);
|
||||
if ( configuredParentName == null ) {
|
||||
configuredParentName = WEB_PARENT_MODULE_DEFAULT;
|
||||
}
|
||||
|
||||
super.contextInitialized(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
|
||||
super.customizeContext(servletContext, applicationContext);
|
||||
|
||||
String[] newLocations = cloudStackContext.getConfigLocationsForWeb(configuredParentName,
|
||||
applicationContext.getConfigLocations());
|
||||
|
||||
applicationContext.setConfigLocations(newLocations);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
<!--
|
||||
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"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<bean id="DefaultConfigResources" class="java.util.ArrayList" />
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.factory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
public class InitTest {
|
||||
|
||||
public static boolean initted = false;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
setInitted(true);
|
||||
}
|
||||
|
||||
public boolean isInitted() {
|
||||
return initted;
|
||||
}
|
||||
|
||||
public void setInitted(boolean initted) {
|
||||
InitTest.initted = initted;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.factory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.cloudstack.spring.module.locator.impl.ClasspathModuleDefinitionLocator;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinitionSet;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
public class ModuleBasedContextFactoryTest {
|
||||
|
||||
Collection<ModuleDefinition> defs;
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
InstantiationCounter.count = 0;
|
||||
|
||||
ClasspathModuleDefinitionLocator locator = new ClasspathModuleDefinitionLocator();
|
||||
defs = locator.locateModules("testhierarchy");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoad() throws IOException {
|
||||
|
||||
ModuleBasedContextFactory factory = new ModuleBasedContextFactory();
|
||||
|
||||
ModuleDefinitionSet set = factory.loadModules(defs, "base");
|
||||
|
||||
assertNotNull(set.getApplicationContext("base"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverride() throws IOException {
|
||||
|
||||
InitTest.initted = false;
|
||||
|
||||
ModuleBasedContextFactory factory = new ModuleBasedContextFactory();
|
||||
|
||||
ModuleDefinitionSet set = factory.loadModules(defs, "base");
|
||||
|
||||
assertTrue(!InitTest.initted);
|
||||
assertEquals("a string", set.getApplicationContext("child1").getBean("override", String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeans() throws IOException {
|
||||
ModuleBasedContextFactory factory = new ModuleBasedContextFactory();
|
||||
ModuleDefinitionSet set = factory.loadModules(defs, "base");
|
||||
|
||||
testBeansInContext(set, "base", 1, new String[] { "base" }, new String[] { "child1", "child2", "child1-1" });
|
||||
testBeansInContext(set, "child1", 2, new String[] { "base", "child1" }, new String[] { "child2", "child1-1" });
|
||||
testBeansInContext(set, "child2", 4, new String[] { "base", "child2" }, new String[] { "child1", "child1-1" });
|
||||
testBeansInContext(set, "child1-1", 3, new String[] { "base", "child1", "child1-1" }, new String[] { "child2" });
|
||||
}
|
||||
|
||||
protected void testBeansInContext(ModuleDefinitionSet set, String name, int order, String[] parents, String[] notTheres) {
|
||||
ApplicationContext context = set.getApplicationContext(name);
|
||||
|
||||
String nameBean = context.getBean("name", String.class);
|
||||
assertEquals(name, nameBean);
|
||||
|
||||
for ( String parent : parents ) {
|
||||
String parentBean = context.getBean(parent, String.class);
|
||||
assertEquals(parent, parentBean);
|
||||
}
|
||||
|
||||
for ( String notThere : notTheres ) {
|
||||
try {
|
||||
context.getBean(notThere, String.class);
|
||||
fail();
|
||||
} catch ( NoSuchBeanDefinitionException e ) {
|
||||
}
|
||||
}
|
||||
|
||||
int count = context.getBean("count", InstantiationCounter.class).getCount();
|
||||
|
||||
assertEquals(order, count);
|
||||
}
|
||||
|
||||
public static class InstantiationCounter {
|
||||
public static Integer count = 0;
|
||||
|
||||
int myCount;
|
||||
|
||||
public InstantiationCounter() {
|
||||
synchronized (count) {
|
||||
myCount = count + 1;
|
||||
count = myCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return myCount;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.locator.impl;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.cloudstack.spring.module.model.ModuleDefinition;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ClasspathModuleDefinitionSetLocatorTest {
|
||||
|
||||
@Test
|
||||
public void testDiscover() throws IOException {
|
||||
ClasspathModuleDefinitionLocator factory = new ClasspathModuleDefinitionLocator();
|
||||
|
||||
Collection<ModuleDefinition> modules = factory.locateModules("testhierarchy");
|
||||
|
||||
assertEquals(5, modules.size());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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.cloudstack.spring.module.model.impl;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.spring.module.util.ModuleLocationUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
public class DefaultModuleDefinitionTest {
|
||||
|
||||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
|
||||
protected DefaultModuleDefinition createDef(String name) {
|
||||
Resource resource =
|
||||
resolver.getResource(ModuleLocationUtils.getModuleLocation("testfiles", name));
|
||||
|
||||
return new DefaultModuleDefinition("testfiles", resource, resolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlankName() {
|
||||
DefaultModuleDefinition def = createDef("blankname");
|
||||
|
||||
try {
|
||||
def.init();
|
||||
fail();
|
||||
} catch ( IOException e ) {
|
||||
assertTrue(e.getMessage().contains("Missing name property"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingName() {
|
||||
DefaultModuleDefinition def = createDef("missingname");
|
||||
|
||||
try {
|
||||
def.init();
|
||||
fail();
|
||||
} catch ( IOException e ) {
|
||||
assertTrue(e.getMessage().contains("Missing name property"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadName() {
|
||||
DefaultModuleDefinition def = createDef("badname");
|
||||
|
||||
try {
|
||||
def.init();
|
||||
fail();
|
||||
} catch ( IOException e ) {
|
||||
assertTrue(e.getMessage().contains("is expected to exist at"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGood() throws IOException {
|
||||
DefaultModuleDefinition def = createDef("good");
|
||||
def.init();
|
||||
assertTrue(def.isValid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrongName() {
|
||||
DefaultModuleDefinition def = createDef("wrongname");
|
||||
|
||||
try {
|
||||
def.init();
|
||||
fail();
|
||||
} catch ( IOException e ) {
|
||||
assertTrue(e.getMessage().contains("do not appear to be the same resource"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFiles() throws IOException {
|
||||
DefaultModuleDefinition def = createDef("all");
|
||||
|
||||
def.init();
|
||||
|
||||
assertEquals(2, def.getContextLocations().size());
|
||||
has(def.getContextLocations(), "empty-context.xml", "empty2-context.xml");
|
||||
|
||||
assertEquals(2, def.getConfigLocations().size());
|
||||
has(def.getConfigLocations(), "test2-defaults.properties", "defaults.properties");
|
||||
|
||||
assertEquals(2, def.getInheritableContextLocations().size());
|
||||
has(def.getInheritableContextLocations(), "empty-context-inheritable.xml", "empty2-context-inheritable.xml");
|
||||
}
|
||||
|
||||
protected void has(List<Resource> resources, String... files) throws IOException {
|
||||
int count = 0;
|
||||
|
||||
for ( Resource r : resources ) {
|
||||
for ( String file : files ) {
|
||||
if ( r.getURL().toExternalForm().contains(file) ) {
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(resources + " does not contain " + Arrays.toString(files), files.length, count);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
# 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.
|
||||
|
||||
blah=1
|
||||
@ -0,0 +1,26 @@
|
||||
<!--
|
||||
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"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,26 @@
|
||||
<!--
|
||||
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"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,26 @@
|
||||
<!--
|
||||
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"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,26 @@
|
||||
<!--
|
||||
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"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,17 @@
|
||||
# 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.
|
||||
name=all
|
||||
@ -0,0 +1,17 @@
|
||||
# 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.
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
# 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.
|
||||
name=what
|
||||
@ -0,0 +1,18 @@
|
||||
# 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.
|
||||
# A bunch of whitespace is after name
|
||||
name=
|
||||
@ -0,0 +1,26 @@
|
||||
<!--
|
||||
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"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
</beans>
|
||||
@ -0,0 +1,17 @@
|
||||
# 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.
|
||||
name=good
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user