51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
package org.acme.service;
|
|
|
|
import org.gcube.common.core.state.GCUBEWSResource;
|
|
import org.globus.wsrf.ResourceProperty;
|
|
|
|
public class Resource extends GCUBEWSResource {
|
|
|
|
|
|
|
|
private static final String NAME_RP_NAME = "Name";
|
|
/** Client visits.*/
|
|
int calls;
|
|
/** Client name. */
|
|
String name;
|
|
|
|
/**{@inheritDoc}*/
|
|
public void initialise(Object... args) throws Exception {
|
|
if (args == null || args.length!=1) throw new IllegalArgumentException();
|
|
this.setName((String) args[0]);
|
|
}
|
|
|
|
/** Returns the number of client visits.
|
|
* @return the visits.*/
|
|
public synchronized int getVisits() {return calls;}
|
|
|
|
/** Returns the client name.
|
|
* @return the name.*/
|
|
public synchronized String getName() {
|
|
return (String) this.getResourcePropertySet().get(NAME_RP_NAME).get(0);
|
|
|
|
}
|
|
|
|
/** Sets the client name.
|
|
* @params the name.*/
|
|
public synchronized void setName(String name) {
|
|
ResourceProperty property = this.getResourcePropertySet().get(NAME_RP_NAME);
|
|
property.clear();
|
|
property.add(name);
|
|
}
|
|
|
|
/**Sets the number of client visits.
|
|
* the visits.*/
|
|
protected synchronized void addVisit() {this.calls++;}
|
|
|
|
@Override
|
|
protected String[] getPropertyNames() {
|
|
return new String[]{NAME_RP_NAME};
|
|
}
|
|
|
|
}
|