Skip to content

Commit 5a2cd68

Browse files
committed
Fix bug CLOUDSTACK-1171 due to spring injection.
1 parent fda8ec3 commit 5a2cd68

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
// Unless required by applicable law or agreed to in writing,
1212
// software distributed under the License is distributed on an
1313
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14-
// KIND, either express or implied. See the License for the
14+
// KIND, either express or implied. See the License for the
1515
// specific language governing permissions and limitations
1616
// under the License.
1717
package com.cloud.hypervisor.vmware.resource;
1818

19+
import javax.annotation.PostConstruct;
20+
import javax.inject.Inject;
21+
1922
import org.apache.log4j.Logger;
23+
import org.springframework.stereotype.Component;
2024

2125
import com.cloud.hypervisor.vmware.manager.VmwareManager;
2226
import com.cloud.hypervisor.vmware.manager.VmwareManagerImpl;
@@ -25,18 +29,25 @@
2529
import com.cloud.utils.component.ComponentContext;
2630

2731
import com.vmware.apputils.version.ExtendedAppUtil;
28-
32+
@Component
2933
public class VmwareContextFactory {
30-
34+
3135
private static final Logger s_logger = Logger.getLogger(VmwareContextFactory.class);
32-
36+
3337
private static volatile int s_seq = 1;
3438
private static VmwareManager s_vmwareMgr;
35-
39+
40+
@Inject VmwareManager _vmwareMgr;
41+
3642
static {
3743
// skip certificate check
3844
System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
39-
s_vmwareMgr = ComponentContext.inject(VmwareManagerImpl.class);
45+
//s_vmwareMgr = ComponentContext.inject(VmwareManagerImpl.class);
46+
}
47+
48+
@PostConstruct
49+
void init() {
50+
s_vmwareMgr = _vmwareMgr;
4051
}
4152

4253
public static VmwareContext create(String vCenterAddress, String vCenterUserName, String vCenterPassword) throws Exception {
@@ -49,13 +60,13 @@ public static VmwareContext create(String vCenterAddress, String vCenterUserName
4960

5061
if(s_logger.isDebugEnabled())
5162
s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));
52-
63+
5364
ExtendedAppUtil appUtil = ExtendedAppUtil.initialize(vCenterAddress + "-" + s_seq++, params);
54-
65+
5566
appUtil.connect();
5667
VmwareContext context = new VmwareContext(appUtil, vCenterAddress);
5768
context.registerStockObject(VmwareManager.CONTEXT_STOCK_NAME, s_vmwareMgr);
58-
69+
5970
context.registerStockObject("serviceconsole", s_vmwareMgr.getServiceConsolePortGroupName());
6071
context.registerStockObject("manageportgroup", s_vmwareMgr.getManagementPortGroupName());
6172

0 commit comments

Comments
 (0)