package org.acme.service; import org.acme.sample.stubs.CallsResponse; import org.gcube.common.core.porttypes.GCUBEPortType; import org.gcube.common.core.types.VOID; import org.globus.wsrf.ResourceException; public class Stateful extends GCUBEPortType { @Override protected ServiceContext getServiceContext() {return ServiceContext.getContext();} public CallsResponse calls(VOID voidType) { try { Resource resource = this.getResource(); return new CallsResponse(resource.getVisits()+" for "+resource.getName()); } catch (Exception e) { throw new RuntimeException("problem",e); } } /** * * @return the stateful resource * @throws ResourceException if no resource was found in the current context */ private Resource getResource() throws ResourceException { return (Resource) StatefulContext.getContext().getWSHome().find(); } }