You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2013/02/02 00:27:31 UTC

[15/50] [abbrv] git commit: refs/heads/master - Spring changes in awsapi

Spring changes in awsapi


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/2bfdce02
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/2bfdce02
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/2bfdce02

Branch: refs/heads/master
Commit: 2bfdce02f1bddcea9167fdada71f3972c74c1557
Parents: 4c1a69a
Author: Prachi Damle <pr...@cloud.com>
Authored: Mon Jan 28 15:59:10 2013 -0800
Committer: Prachi Damle <pr...@cloud.com>
Committed: Mon Jan 28 16:01:50 2013 -0800

----------------------------------------------------------------------
 awsapi/conf/applicationContext.xml.in              |   53 +++++++++++++++
 awsapi/conf/cloud-bridge.properties                |   25 -------
 awsapi/conf/cloud-bridge.properties.in             |   25 +++++++
 awsapi/conf/ec2-service.properties                 |   25 -------
 awsapi/conf/ec2-service.properties.in              |   25 +++++++
 awsapi/pom.xml                                     |   42 +++++++++++-
 .../com/cloud/bridge/service/EC2MainServlet.java   |   23 ++++++-
 awsapi/web/web.xml                                 |    9 +++
 8 files changed, 175 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/conf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/awsapi/conf/applicationContext.xml.in b/awsapi/conf/applicationContext.xml.in
new file mode 100644
index 0000000..0a24df2
--- /dev/null
+++ b/awsapi/conf/applicationContext.xml.in
@@ -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>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/conf/cloud-bridge.properties
----------------------------------------------------------------------
diff --git a/awsapi/conf/cloud-bridge.properties b/awsapi/conf/cloud-bridge.properties
deleted file mode 100644
index d0820e8..0000000
--- a/awsapi/conf/cloud-bridge.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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.
-
-host=http://localhost:7080/awsapi
-storage.root=/Users/john1/S3-Mount
-storage.multipartDir=__multipart__uploads__
-bucket.dns=false
-serviceEndpoint=localhost:7080
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/conf/cloud-bridge.properties.in
----------------------------------------------------------------------
diff --git a/awsapi/conf/cloud-bridge.properties.in b/awsapi/conf/cloud-bridge.properties.in
new file mode 100644
index 0000000..d0820e8
--- /dev/null
+++ b/awsapi/conf/cloud-bridge.properties.in
@@ -0,0 +1,25 @@
+# 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.
+
+host=http://localhost:7080/awsapi
+storage.root=/Users/john1/S3-Mount
+storage.multipartDir=__multipart__uploads__
+bucket.dns=false
+serviceEndpoint=localhost:7080
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/conf/ec2-service.properties
----------------------------------------------------------------------
diff --git a/awsapi/conf/ec2-service.properties b/awsapi/conf/ec2-service.properties
deleted file mode 100644
index 6af0f63..0000000
--- a/awsapi/conf/ec2-service.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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.
-
-managementServer=127.0.0.1
-cloudAPIPort=8080
-cloudstackVersion=2.2.0
-WSDLVersion=2010-11-15
-keystore=xes.keystore
-keystorePass=apache
-
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/conf/ec2-service.properties.in
----------------------------------------------------------------------
diff --git a/awsapi/conf/ec2-service.properties.in b/awsapi/conf/ec2-service.properties.in
new file mode 100644
index 0000000..6af0f63
--- /dev/null
+++ b/awsapi/conf/ec2-service.properties.in
@@ -0,0 +1,25 @@
+# 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.
+
+managementServer=127.0.0.1
+cloudAPIPort=8080
+cloudstackVersion=2.2.0
+WSDLVersion=2010-11-15
+keystore=xes.keystore
+keystorePass=apache
+
+

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/pom.xml
----------------------------------------------------------------------
diff --git a/awsapi/pom.xml b/awsapi/pom.xml
index 3ab5952..52b8f8c 100644
--- a/awsapi/pom.xml
+++ b/awsapi/pom.xml
@@ -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>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java b/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
index f5a2d21..e6f1f1b 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2MainServlet.java
@@ -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.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2bfdce02/awsapi/web/web.xml
----------------------------------------------------------------------
diff --git a/awsapi/web/web.xml b/awsapi/web/web.xml
index a5b0207..923a29b 100644
--- a/awsapi/web/web.xml
+++ b/awsapi/web/web.xml
@@ -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>