📄 mathservice.java
字号:
package org.globus.examples.services.core.notifications.impl;import java.rmi.RemoteException;import org.globus.wsrf.Resource;import org.globus.wsrf.ResourceProperties;import org.globus.wsrf.ResourceProperty;import org.globus.wsrf.ResourcePropertySet;import org.globus.wsrf.impl.SimpleResourcePropertySet;import org.globus.wsrf.impl.SimpleResourceProperty;import org.globus.wsrf.Topic;import org.globus.wsrf.TopicList;import org.globus.wsrf.TopicListAccessor;import org.globus.wsrf.impl.ResourcePropertyTopic;import org.globus.wsrf.impl.SimpleTopicList;import org.globus.examples.stubs.MathService_instance_notif.AddResponse;import org.globus.examples.stubs.MathService_instance_notif.SubtractResponse;public class MathService implements Resource, ResourceProperties, TopicListAccessor { /* Resource Property set */ private ResourcePropertySet propSet; /* Resource properties */ private ResourceProperty valueRP; private ResourceProperty lastOpRP; /* Topic list */ private TopicList topicList; /* Constructor. Initializes RPs and topic */ public MathService() throws RemoteException { /* Create RP set */ this.propSet = new SimpleResourcePropertySet( MathQNames.RESOURCE_PROPERTIES); /* Initialize the RP's */ try { valueRP = new SimpleResourceProperty(MathQNames.RP_VALUE); valueRP.add(new Integer(0)); lastOpRP = new SimpleResourceProperty(MathQNames.RP_LASTOP); lastOpRP.add("NONE"); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } /* Configure the Topics */ this.topicList = new SimpleTopicList(this); valueRP = new ResourcePropertyTopic(valueRP); ((ResourcePropertyTopic) valueRP).setSendOldValue(true); lastOpRP = new ResourcePropertyTopic(lastOpRP); ((ResourcePropertyTopic) lastOpRP).setSendOldValue(true); this.topicList.addTopic((Topic) valueRP); this.topicList.addTopic((Topic) lastOpRP); this.propSet.add(valueRP); this.propSet.add(lastOpRP); } /* Remotely-accessible operations */ public AddResponse add(int a) throws RemoteException { Integer value = (Integer) valueRP.get(0); value = new Integer(value.intValue() + a); valueRP.set(0, value); lastOpRP.set(0, "ADDITION"); return new AddResponse(); } public SubtractResponse subtract(int a) throws RemoteException { Integer value = (Integer) valueRP.get(0); valueRP.set(0, new Integer(value.intValue() - a)); lastOpRP.set(0, "SUBTRACTION"); return new SubtractResponse(); } /* Required by interface ResourceProperties */ public ResourcePropertySet getResourcePropertySet() { return this.propSet; } /* Required by interface TopicListAccessor */ public TopicList getTopicList() { return topicList; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -