This commit is contained in:
Lucio Lelii 2008-12-15 18:32:12 +00:00
parent ca7acff4d8
commit a8337ffc47
1 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,68 @@
package org.gcube.vremanagement.vremodeler.impl.util;
import java.util.ArrayList;
import java.util.List;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.utils.handlers.GCUBEServiceClient;
import org.gcube.common.core.utils.handlers.GCUBEServiceHandler;
import org.gcube.common.vremanagement.ghnmanager.impl.contexts.ServiceContext;
import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType;
import org.gcube.vremanagement.vremanager.stubs.vremanager.service.VREManagerServiceAddressingLocator;
public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> {
private T returnValue;
private P parameter;
public T getReturnValue(){
return returnValue;
}
public void setParameter(P param){
this.parameter= param;
}
protected P getParameter(){
return this.parameter;
}
protected void setReturnValue(T returnValue){
this.returnValue= returnValue;
}
@Override
protected List<EndpointReferenceType> findInstances() throws Exception {
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"));
query.addAtomicConditions(new AtomicCondition("//ServiceClass", "VREManagement"));
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
for (GCUBERunningInstance instance : client.execute(query, ServiceContext.getContext().getScope()))
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
return eprs;
}
protected abstract T makeCall(VREManagerPortType mbportType) throws Exception;
protected void interact(EndpointReferenceType arg0) throws Exception{
VREManagerPortType mbpt= null;
try{
VREManagerServiceAddressingLocator mbsal= new VREManagerServiceAddressingLocator();
mbpt= mbsal.getVREManagerPortTypePort(arg0);
mbpt = GCUBERemotePortTypeContext.getProxy(mbpt,ServiceContext.getContext().getScope());
this.setReturnValue(this.makeCall(mbpt));
}catch(Exception e){throw e;}
}
}