use of org.restlet.Component in project GeoGig by boundlessgeo.
the class Serve method runInternal.
@Override
protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException {
String loc = repo != null && repo.size() > 0 ? repo.get(0) : ".";
GeoGIG geogig = loadGeoGIG(loc, cli);
Application application = new Main(geogig);
Component comp = new Component();
comp.getDefaultHost().attach(application);
comp.getServers().add(Protocol.HTTP, port);
cli.getConsole().println(String.format("Starting server on port %d, use CTRL+C to exit.", port));
try {
comp.start();
cli.setExitOnFinish(false);
} catch (BindException e) {
String msg = String.format("Port %d already in use, use the --port parameter to specify a different port", port);
throw new CommandFailedException(msg, e);
} catch (Exception e) {
throw new CommandFailedException("Unable to start server", e);
}
}
use of org.restlet.Component in project rest-assured by rest-assured.
the class StressITest method setUp.
@Before
public void setUp() throws Exception {
url = "http://localhost:8081/restlet/test";
component = new Component();
component.getLogService().setEnabled(true);
component.getServers().add(Protocol.HTTP, 8081);
component.getDefaultHost().attach("/restlet", new StressApp());
component.start();
RestAssured.config = RestAssuredConfig.config().connectionConfig(new ConnectionConfig().closeIdleConnectionsAfterEachResponse());
}
use of org.restlet.Component in project openems by OpenEMS.
the class ComponentSingleton method startComponent.
private static synchronized void startComponent(int port, ApiWorker apiWorker) throws OpenemsException {
ComponentSingleton.instance = new Component();
ComponentSingleton.instance.getServers().add(Protocol.HTTP, port);
ComponentSingleton.instance.getDefaultHost().attach("/rest", new RestApiApplication(apiWorker));
try {
ComponentSingleton.instance.start();
ComponentSingleton.port = port;
log.info("REST-Api started on port [" + port + "].");
} catch (Exception e) {
throw new OpenemsException("REST-Api failed on port [" + port + "].", e);
}
}
use of org.restlet.Component in project helix by apache.
the class HelixAdminWebApp method start.
public synchronized void start() throws Exception {
LOG.info("helixAdminWebApp starting");
if (_component == null) {
_zkClient = new ZkClient(_zkServerAddress, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
_rawZkClient = new ZkClient(_zkServerAddress, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ByteArraySerializer());
_component = new Component();
_component.getServers().add(Protocol.HTTP, _helixAdminPort);
Context applicationContext = _component.getContext().createChildContext();
applicationContext.getAttributes().put(RestAdminApplication.ZKSERVERADDRESS, _zkServerAddress);
applicationContext.getAttributes().put(RestAdminApplication.PORT, "" + _helixAdminPort);
applicationContext.getAttributes().put(RestAdminApplication.ZKCLIENT, _zkClient);
applicationContext.getAttributes().put(ResourceUtil.ContextKey.RAW_ZKCLIENT.toString(), _rawZkClient);
_adminApp = new RestAdminApplication(applicationContext);
// Attach the application to the component and start it
_component.getDefaultHost().attach(_adminApp);
_component.start();
}
LOG.info("helixAdminWebApp started on port: " + _helixAdminPort);
}
use of org.restlet.Component in project qi4j-sdk by Qi4j.
the class RestServerMixin method startServer.
@Override
public void startServer() throws Exception {
component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
RestApplication application = module.newObject(RestApplication.class, component.getContext());
component.getDefaultHost().attach(application);
component.start();
}
Aggregations