Search in sources :

Example 6 with Component

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);
    }
}
Also used : BindException(java.net.BindException) Component(org.restlet.Component) Application(org.restlet.Application) Main(org.locationtech.geogig.web.Main) GeoGIG(org.locationtech.geogig.api.GeoGIG) CommandFailedException(org.locationtech.geogig.cli.CommandFailedException) IOException(java.io.IOException) BindException(java.net.BindException) InvalidParameterException(org.locationtech.geogig.cli.InvalidParameterException) CommandFailedException(org.locationtech.geogig.cli.CommandFailedException)

Example 7 with Component

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());
}
Also used : Component(org.restlet.Component) ConnectionConfig(io.restassured.config.ConnectionConfig) Before(org.junit.Before)

Example 8 with Component

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);
    }
}
Also used : OpenemsException(io.openems.common.exceptions.OpenemsException) Component(org.restlet.Component) OpenemsException(io.openems.common.exceptions.OpenemsException)

Example 9 with Component

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);
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) Context(org.restlet.Context) Component(org.restlet.Component) ByteArraySerializer(org.apache.helix.manager.zk.ByteArraySerializer) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer)

Example 10 with Component

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();
}
Also used : Component(org.restlet.Component)

Aggregations

Component (org.restlet.Component)10 Application (org.restlet.Application)4 File (java.io.File)2 IOException (java.io.IOException)2 GeoGIG (org.locationtech.geogig.api.GeoGIG)2 VirtualHost (org.restlet.routing.VirtualHost)2 BioModel (cbit.vcell.biomodel.BioModel)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 BioModelRep (cbit.vcell.modeldb.BioModelRep)1 SimContextRep (cbit.vcell.modeldb.SimContextRep)1 SimulationRep (cbit.vcell.modeldb.SimulationRep)1 Simulation (cbit.vcell.solver.Simulation)1 XMLSource (cbit.vcell.xml.XMLSource)1 FileSystemResourceFactory (io.milton.http.fs.FileSystemResourceFactory)1 FsMemoryLockManager (io.milton.http.fs.FsMemoryLockManager)1 NullSecurityManager (io.milton.http.fs.NullSecurityManager)1 SimpleFileContentService (io.milton.http.fs.SimpleFileContentService)1 WebDavRestlet (io.milton.restlet.WebDavRestlet)1 OpenemsException (io.openems.common.exceptions.OpenemsException)1 ConnectionConfig (io.restassured.config.ConnectionConfig)1