use of org.restlet.Component in project GeoGig by boundlessgeo.
the class Main method startServer.
static void startServer(String repo) throws Exception {
GeoGIG geogig = loadGeoGIG(repo);
org.restlet.Context context = new org.restlet.Context();
Application application = new Main(geogig);
application.setContext(context);
Component comp = new Component();
comp.getDefaultHost().attach(application);
comp.getServers().add(Protocol.HTTP, 8182);
comp.start();
}
use of org.restlet.Component in project AJSC by att.
the class RestletSpringServlet method getServer.
public HttpServerHelper getServer(HttpServletRequest request) {
// Lazy initialization with double-check.
HttpServerHelper result;
// // Find the attribute name to use to store the server
// // reference
final String serverAttributeName = getInitParameter(NAME_SERVER_ATTRIBUTE, NAME_SERVER_ATTRIBUTE_DEFAULT + "." + getServletName());
Component component = getComponent();
// System.out.println("isFirstRequest:" +isFirstRequest);
// if ((!isFirstRequest) && isNewRouteAdded(request, component)) {
// result = createServer(request, component);
// getServletContext().setAttribute(serverAttributeName, result);
// } else {
// System.out.println("Super getServer");
result = super.getServer(request);
// }
isFirstRequest = false;
return result;
}
use of org.restlet.Component in project lobcder by skoulouzis.
the class RestletFileserver method main.
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8080);
// Restlet logs requests by default
// component.getLogService().setEnabled(false);
component.getDefaultHost().attach(new Application() {
@Override
public Restlet createInboundRoot() {
FileSystemResourceFactory factory = new FileSystemResourceFactory(new File(System.getProperty("user.home")), new NullSecurityManager());
factory.setContentService(new SimpleFileContentService());
factory.setLockManager(new FsMemoryLockManager());
return new WebDavRestlet(factory);
}
});
component.start();
System.out.println("Restlet demo fileserver started, open http://localhost:8080 in your browser or WebDAV client...");
}
use of org.restlet.Component in project vcell by virtualcell.
the class TestRestServerBlinov method main.
public static void main(String[] args) {
try {
// The following mimics the the VCell server and database without having to connect to them
// arg[0] (first argument) is directory path on local system where you have exported .vcml models from VCell client
// that you want to use to test the biomodel web page generating code, these files are a proxy for the VCell database
// Test biomodel vcml documents
File biomodel_vcml_dir = new File(args[0]);
File[] dirFiles = biomodel_vcml_dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isFile();
}
});
// final List<Element> parseOverrideElementsFromVCML = MathOverrides.parseOverrideElementsFromVCML(new CommentStringTokenizer(xmlString));
for (int i = 0; i < dirFiles.length; i++) {
try {
// Read in each file found in the directory passed in args[0] check if it can be imported as a BioModel
// If it fails just skip.
// The imported BioModel is cached as BioModelRep info and are returned when the Resource objects make a 'query'
final BioModel bm = XmlHelper.XMLToBioModel(new XMLSource(dirFiles[i]));
mapBMidToFileName.put(bm.getVersion().getVersionKey().toString(), dirFiles[i]);
final SimulationContext[] simulationContexts = bm.getSimulationContexts();
SimContextRep[] scr = new SimContextRep[simulationContexts.length];
KeyValue[] scrKeys = new KeyValue[simulationContexts.length];
for (int j = 0; j < simulationContexts.length; j++) {
// KeyValue scKey, BigDecimal branchID, String name, User owner, KeyValue mathKey)
scrKeys[j] = simulationContexts[j].getVersion().getVersionKey();
scr[j] = new SimContextRep(scrKeys[j], simulationContexts[j].getVersion().getBranchID(), simulationContexts[j].getName(), simulationContexts[j].getVersion().getOwner(), simulationContexts[j].getModel().getKey());
}
final Simulation[] simulations = bm.getSimulations();
SimulationRep[] sreps = new SimulationRep[simulations.length];
KeyValue[] srepKeys = new KeyValue[simulations.length];
for (int j = 0; j < simulations.length; j++) {
// KeyValue key, BigDecimal branchID, String name, User owner, KeyValue mathKey, SolverTaskDescription solverTaskDescription, Element[] mathOverrideElements
srepKeys[j] = simulations[j].getVersion().getVersionKey();
// public SimulationRep(KeyValue key, BigDecimal branchID, String name, User owner, KeyValue mathKey, SolverTaskDescription solverTaskDescription, MathOverrides.Element[] mathOverrideElements) {
// final MathOverrides mathOverrides = simulations[j].getSolverTaskDescription().getSimulation().getMathOverrides();
// for(int k=0;k<mathOverrides.getScanCount();k++) {
// MathOverrides.Element elem = new Element(mathOverrides.get, null);
// }
sreps[j] = new SimulationRep(srepKeys[j], simulations[j].getVersion().getBranchID(), simulations[j].getName(), simulations[j].getVersion().getOwner(), simulations[j].getMathDescription().getKey(), simulations[j].getSolverTaskDescription(), new MathOverrides.Element[] {});
}
// KeyValue bmKey, String name, int privacy, User[] groupUsers, Date date, String annot, BigDecimal branchID, KeyValue modelRef, User owner, KeyValue[] simKeyList, KeyValue[] simContextKeyList)
BioModelRep bmrep = new BioModelRep(bm.getVersion().getVersionKey(), bm.getName(), bm.getVersion().getGroupAccess().getGroupid().intValue(), new User[] {}, bm.getVersion().getDate(), bm.getVersion().getAnnot(), bm.getVersion().getBranchID(), bm.getModel().getVersion().getVersionKey(), bm.getVersion().getOwner(), srepKeys, scrKeys);
for (int j = 0; j < simulationContexts.length; j++) {
bmrep.addSimContextRep(scr[j]);
}
for (int j = 0; j < simulations.length; j++) {
bmrep.addSimulationRep(sreps[j]);
}
bioModelRepArr.add(bmrep);
mapBMidToBiomodelRep.put(bm.getVersion().getVersionKey().toString(), bmrep);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Create a Restlet server on local machine that will accept queries from a regular web browser
Component restletComponent = new Component();
// So FreeMarker html formatting scripts work (.ftl files in {EclipseWorkspaceRootDir}/vcell/vcell-api/src/main/resources/(*.ftl}
restletComponent.getClients().add(Protocol.CLAP);
Server server = restletComponent.getServers().add(Protocol.HTTP, 8182);
server.getContext().getParameters().add("useForwardedForHeader", "true");
// restletComponent.getInternalRouter().setDefaultMatchingMode(Template.MODE_STARTS_WITH);
final VirtualHost defaultHost = restletComponent.getDefaultHost();
// getVcellApiApplication() actually makes the connections URL->ServerResource
// e.g. http://{HostNameWhereThisProgramIsRunning}:8182/biomodel -> BiomodelServerResource
// See getVCellApiApplication() for other mappings (router attachments)
defaultHost.attach(getVCellApiApplication());
// Start servlet which can be accessed with base URL http://{HostNameWhereThisProgramIsRunning}:8182
restletComponent.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.restlet.Component in project pinot by linkedin.
the class StarTreeJsonNode method startServer.
private void startServer(final File segmentDirectory, final String json) throws Exception {
Component component = new Component();
int port = 8090;
component.getServers().add(Protocol.HTTP, port);
component.getClients().add(Protocol.FILE);
Application application = new Application() {
@Override
public Restlet createInboundRoot() {
Router router = new Router(getContext());
StarTreeViewRestResource.json = json;
router.attach("/data", StarTreeViewRestResource.class);
Directory directory = new Directory(getContext(), getClass().getClassLoader().getResource("star-tree.html").toString());
router.attach(directory);
return router;
}
};
VirtualHost defaultHost = component.getDefaultHost();
defaultHost.attach(application);
component.start();
LOGGER.info("Go to http://{}:{}/ to view the star tree", VirtualHost.getLocalHostName(), port);
}
Aggregations