Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel

<beans xmlns="http://www.springframework.org/schema/beans"

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

  xmlns:context="http://www.springframework.org/schema/context"

  xmlns:tx="http://www.springframework.org/schema/tx" 

  xmlns:aop="http://www.springframework.org/schema/aop"

  xsi:schemaLocation="http://www.springframework.org/schema/beans

                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

                      http://www.springframework.org/schema/tx&nbsp;

                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

                      http://www.springframework.org/schema/aop

                      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

                      http://www.springframework.org/schema/context

                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">                     

  <!--

      Compose a CloudStack deployment with selected components here

  -->

  <bean id="databaseUpgradeChecker" />

  <bean id="management-server" class ="com.cloud.server.ManagementServerExtImpl" />

  <bean id="configuration-server" />

  <bean id="clusterManagerImpl" />

  <bean id="clusteredAgentManagerImpl" />

  <bean id="clusteredVirtualMachineManagerImpl" />

  <bean id="highAvailabilityManagerExtImpl" />

  <!-- bean id="bareMetalVmManagerImpl" / -->

  <bean id="userVmManagerImpl" />

  <bean id="consoleProxyManagerImpl" />

  <bean id="securityGroupManagerImpl2" />

  <bean id="premiumSecondaryStorageManagerImpl" />

  <bean id="randomlyIncreasingVMInstanceDaoImpl" /> 

  <!--

      Network Elements

  -->

  <bean id="Ovs">

    <property name="name" value="Ovs"/>

  </bean>

  <bean id="ExternalDhcpServer">

    <property name="name" value="ExternalDhcpServer"/>

  </bean>

  <bean id="BareMetal">

    <property name="name" value="BareMetal"/>

  </bean>

  <bean id="SecurityGroupProvider">

    <property name="name" value="SecurityGroupProvider"/>

  </bean>

  <bean id="VirtualRouter">

    <property name="name" value="VirtualRouter"/>

  </bean>

  <bean id="VpcVirtualRouter">

    <property name="name" value="VpcVirtualRouter"/>

  </bean>

  <bean id="NiciraNvp">

    <property name="name" value="NiciraNvp"/>

  </bean>

  ...

  ...

</beans> 

...

Following is an example of such hacking way, inside BaseCmd class, developer tried to resolve all the references for every used components into static variables at  BaseCmd. It also means that, when you add a new Command class to the system, you will have to remember to do something about your new service at BaseCmd class

Panel
Wiki Markup
public abstract class BaseCmd {

&nbsp; &nbsp; private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName());
\\

&nbsp; &nbsp; public static final String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator";

&nbsp; &nbsp; public static final int PROGRESS_INSTANCE_CREATED = 1;
\\

&nbsp; &nbsp; public static final String RESPONSE_TYPE_XML = "xml"ConfigurationService \_configService;

&nbsp; &nbsp; public static final String RESPONSE_TYPE_JSON = "json";
\\

&nbsp; &nbsp; public enum CommandType    ...
&nbsp; &nbsp;&nbsp;private Object \_responseObject = null;

&nbsp; &nbsp; private Map<String, String> fullUrlParams;
\\public AccountService \_accountService;

&nbsp; &nbsp; @Parameter(name = "response", type = CommandType.STRING)

&nbsp; &nbsp; private String responseType;
\\

*&nbsp; &nbsp; public&nbsp;static ConfigurationService \_configService;*

*&nbsp; &nbsp; public&nbsp;static AccountService \_accountService;*

*&nbsp; &nbsp; public&nbsp;static UserVmService \_userVmService;*

*&nbsp; &nbsp; public&nbsp;static ManagementService \_mgr;*

*&nbsp; &nbsp; public&nbsp;static StorageService \_storageService;*

*&nbsp; &nbsp; public&nbsp;static ResourceService \_resourceService;*

*&nbsp; &nbsp; public&nbsp;static NetworkService \_networkService;*

..

..

..

}
\\

With Spring, developer can now always use @Inject annotation to declare such reference. One of the top two reasons for us to try Spring experiments in Javelin, since with more complete dependency injection, it gives us a cleaner component coding practice. (the other top reason is that we have broader integration supports from many other third-party vendors, i.e., JUnit)

4. CloudStack Spring component coding conventions