Spring changes in awsapi

This commit is contained in:
Prachi Damle 2013-01-28 15:59:10 -08:00
parent 4c1a69ac33
commit 2bfdce02f1
6 changed files with 125 additions and 2 deletions

View File

@ -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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.amazon, com.cloud" />
<!--
@DB support
-->
<aop:config proxy-target-class="true">
<aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
<aop:pointcut id="captureAnyMethod"
expression="execution(* *(..))"
/>
<aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod"/>
</aop:aspect>
</aop:config>
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
</beans>

View File

@ -304,6 +304,15 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webXml>./web/web.xml</webXml>
<warSourceDirectory>./target/generated-webapp</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
@ -319,7 +328,38 @@
<webXml>${basedir}/web/web.xml</webXml>
<webAppSourceDirectory>${basedir}/target/cloud-awsapi-${project.version}</webAppSourceDirectory>
</configuration>
</plugin>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>generate-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy
todir="${basedir}/target/generated-webapp/WEB-INF/classes">
<fileset dir="${basedir}/conf">
<include name="*.*" />
</fileset>
<globmapper from="*.in" to="*" />
<filterchain>
<filterreader
classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile"
value="${basedir}/../build/replace.properties" />
</filterreader>
</filterchain>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<!--
<plugins>

View File

@ -17,9 +17,11 @@
package com.cloud.bridge.service;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.UUID;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
@ -29,10 +31,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.bridge.persist.dao.CloudStackConfigurationDao;
import com.cloud.bridge.util.ConfigurationHelper;
import com.cloud.utils.db.DB;
@Component("EC2MainServlet")
@DB
public class EC2MainServlet extends HttpServlet{
@ -44,7 +49,23 @@ public class EC2MainServlet extends HttpServlet{
private static boolean isEC2APIEnabled = false;
public static final Logger logger = Logger.getLogger(EC2MainServlet.class);
@Inject CloudStackConfigurationDao csDao;
static CloudStackConfigurationDao s_csDao;
public EC2MainServlet() {
}
@PostConstruct
void initComponent() {
// Servlet injection does not always work for servlet container
// We use a hacking here to initialize static variables at Spring wiring time
if(csDao != null) {
s_csDao = csDao;
} else {
csDao = s_csDao;
}
}
/**
* We build the path to where the keystore holding the WS-Security X509 certificates
* are stored.

View File

@ -22,6 +22,15 @@
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<display-name>CloudBridge</display-name>
<servlet>
<servlet-name>EC2MainServlet</servlet-name>