mathservice.java

来自「globus toolkit Math例子」· Java 代码 · 共 51 行

JAVA
51
字号
package org.globus.examples.services.core.factory.impl;import java.rmi.RemoteException;import org.globus.wsrf.ResourceContext;import org.globus.examples.stubs.MathService_instance.AddResponse;import org.globus.examples.stubs.MathService_instance.GetValueRP;import org.globus.examples.stubs.MathService_instance.SubtractResponse;public class MathService {	/*	 * Private method that gets a reference to the resource specified in the	 * endpoint reference.	 */	private MathResource getResource() throws RemoteException {		Object resource = null;		try {			resource = ResourceContext.getResourceContext().getResource();		} catch (Exception e) {			throw new RemoteException("", e);		}		MathResource mathResource = (MathResource) resource;		return mathResource;	}	/* Implementation of add, subtract, and getValue operations */	public AddResponse add(int a) throws RemoteException {		MathResource mathResource = getResource();		mathResource.setValue(mathResource.getValue() + a);		mathResource.setLastOp("ADDITION");		return new AddResponse();	}	public SubtractResponse subtract(int a) throws RemoteException {		MathResource mathResource = getResource();		mathResource.setValue(mathResource.getValue() - a);		mathResource.setLastOp("SUBTRACTION");		return new SubtractResponse();	}	public int getValueRP(GetValueRP params) throws RemoteException {		MathResource mathResource = getResource();		return mathResource.getValue();	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?