CLOUDSTACK-1455: fix the wiring for dynamically created objects

This commit is contained in:
Kelven Yang 2013-02-28 15:43:34 -08:00
parent 2093aefcb8
commit 15bcb0e0c7
2 changed files with 1 additions and 51 deletions

View File

@ -1,41 +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.
package org.apache.cloudstack.engine.cloud.entity.api;
import com.cloud.utils.component.ComponentContext;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;
@Component
public class VirtualMachineEntityFactory implements FactoryBean<VirtualMachineEntityImpl>{
@Override
public VirtualMachineEntityImpl getObject() throws Exception {
return ComponentContext.inject(VirtualMachineEntityImpl.class.newInstance());
}
@Override
public Class<?> getObjectType() {
return VirtualMachineEntityImpl.class;
}
@Override
public boolean isSingleton() {
return false;
}
}

View File

@ -29,7 +29,6 @@ import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityFactory;
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
@ -66,9 +65,6 @@ public class CloudOrchestrator implements OrchestrationService {
@Inject
private VMEntityManager vmEntityManager;
@Inject
private VirtualMachineEntityFactory _vmEntityFactory;
@Inject
private VirtualMachineManager _itMgr;
@ -174,12 +170,7 @@ public class CloudOrchestrator implements OrchestrationService {
}
}
VirtualMachineEntityImpl vmEntity = null;
try {
vmEntity = _vmEntityFactory.getObject();
} catch (Exception e) {
// add error handling here
}
VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));