mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Mage.Stats WS module for getting server stats in json format
This commit is contained in:
parent
78c0d76088
commit
71614becc2
43 changed files with 1587 additions and 0 deletions
|
|
@ -0,0 +1,65 @@
|
|||
package com.xmage.ws.resource;
|
||||
|
||||
import com.xmage.core.decorators.Decorator;
|
||||
import com.xmage.ws.model.DomainErrors;
|
||||
import com.xmage.ws.representer.Representer;
|
||||
import net.minidev.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noxx
|
||||
*/
|
||||
public abstract class DefaultResource<R> implements Resource<R> {
|
||||
|
||||
protected DomainErrors.Errors error = DomainErrors.Errors.STATUS_OK;
|
||||
|
||||
protected R defaultResource;
|
||||
|
||||
protected Representer<R> representer;
|
||||
|
||||
protected java.util.List<Decorator> decorators = new ArrayList<Decorator>();
|
||||
|
||||
protected int version;
|
||||
|
||||
protected DefaultResource(Representer<R> representer) {
|
||||
this.representer = representer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getError() {
|
||||
return error.getCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R getDefault() {
|
||||
return defaultResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.List<Decorator> getDecorators() {
|
||||
return decorators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDecorator(Decorator decorator) {
|
||||
if (decorator != null) {
|
||||
this.decorators.add(decorator);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSONBody() {
|
||||
return representer.toJSON(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage() {
|
||||
return error.getMessage();
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue