org.restlet.Application Java Examples
The following examples show how to use
org.restlet.Application.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Activator.java From scava with Eclipse Public License 2.0 | 6 votes |
public void start(BundleContext context) throws Exception { context.addServiceListener(new ServiceListener() { @Override public void serviceChanged(ServiceEvent event) { if (event.getType() == ServiceEvent.REGISTERED){ component = new Component(); Server server = new Server(Protocol.HTTP, 8182); component.getServers().add(server); component.setLogService(new LogService(false)); final Application app = new ApiApplication(); component.getDefaultHost().attachDefault(app); try { component.start(); } catch (Exception e) { e.printStackTrace(); } } } }, "(objectclass=" + ApiStartServiceToken.class.getName() +")"); }
Example #2
Source File: ApiAnalysisTests.java From scava with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws UnknownHostException { mongo = new Mongo(); helper = new ApiHelper(); PongoFactory.getInstance().getContributors().add(new OsgiPongoFactoryContributor()); platform = Platform.getInstance(); platform.setMongo(mongo); platform.initialize(); WORKER_ID = Configuration.getInstance().getSlaveIdentifier(); // Register Worker platform.getAnalysisRepositoryManager().getWorkerService().registerWorker(WORKER_ID); Component component = new Component(); Server server = new Server(Protocol.HTTP, 8182); component.getServers().add(server); final Application app = new ApiApplication(); component.getDefaultHost().attachDefault(app); try { component.start(); } catch (Exception e) { e.printStackTrace(); } }
Example #3
Source File: ProjectAnalysisTests.java From scava with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws UnknownHostException { mongo = new Mongo(); helper = new ApiHelper(); PongoFactory.getInstance().getContributors().add(new OsgiPongoFactoryContributor()); platform = Platform.getInstance(); platform.setMongo(mongo); platform.initialize(); WORKER_ID = Configuration.getInstance().getSlaveIdentifier(); // Register Worker platform.getAnalysisRepositoryManager().getWorkerService().registerWorker(WORKER_ID); Component component = new Component(); Server server = new Server(Protocol.HTTP, 8182); component.getServers().add(server); final Application app = new ApiApplication(); component.getDefaultHost().attachDefault(app); try { component.start(); } catch (Exception e) { e.printStackTrace(); } }
Example #4
Source File: WorkerStarter.java From uReplicator with Apache License 2.0 | 6 votes |
public void runRestApplication() throws Exception { if (workerConf.getWorkerPort() == 0) { return; } Component _component = new Component(); _component.getServers().add(Protocol.HTTP, workerConf.getWorkerPort()); _component.getClients().add(Protocol.FILE); _component.getClients().add(Protocol.JAR); Context applicationContext = _component.getContext().createChildContext(); LOGGER.info("Injecting workerInstance to the api context, port {}", workerConf.getWorkerPort()); applicationContext.getAttributes().put(WorkerInstance.class.toString(), workerInstance); Application restletApplication = new RestletApplication(null); restletApplication.setContext(applicationContext); _component.getDefaultHost().attach(restletApplication); _component.start(); }
Example #5
Source File: ManagerStarter.java From uReplicator with Apache License 2.0 | 5 votes |
public void start() throws Exception { _component.getServers().add(Protocol.HTTP, _config.getManagerPort()); _component.getClients().add(Protocol.FILE); _component.getClients().add(Protocol.JAR); Context applicationContext = _component.getContext().createChildContext(); LOGGER.info("Injecting conf and helix to the api context"); applicationContext.getAttributes().put(ManagerConf.class.toString(), _config); applicationContext.getAttributes() .put(ControllerHelixManager.class.toString(), _controllerHelixManager); applicationContext.getAttributes() .put(KafkaClusterValidationManager.class.toString(), _kafkaValidationManager); Application managerRestApp = new ManagerRestApplication(null); managerRestApp.setContext(applicationContext); _component.getDefaultHost().attach(managerRestApp); try { LOGGER.info("Starting helix manager"); _controllerHelixManager.start(); LOGGER.info("Starting src and dst kafka cluster validation manager"); _kafkaValidationManager.start(); LOGGER.info("Starting API component"); _component.start(); } catch (final Exception e) { LOGGER.error("Caught exception while starting uReplicator-Manager", e); throw e; } }
Example #6
Source File: RestComponent.java From microservices-comparison with Apache License 2.0 | 5 votes |
@Inject public RestComponent(@Hello Application helloApp, @Car Application carApp, Verifier authTokenVerifier) { getClients().add(Protocol.HTTPS); Server secureServer = getServers().add(Protocol.HTTPS, 8043); Series<Parameter> parameters = secureServer.getContext().getParameters(); parameters.add("sslContextFactory", "org.restlet.engine.ssl.DefaultSslContextFactory"); parameters.add("keyStorePath", System.getProperty("javax.net.ssl.keyStorePath")); getDefaultHost().attach("/api/hello", secure(helloApp, authTokenVerifier, "ame")); getDefaultHost().attach("/api/cars", secure(carApp, authTokenVerifier, "ame")); replaceConverter(JacksonConverter.class, new JacksonCustomConverter()); }
Example #7
Source File: RestComponent.java From microservices-comparison with Apache License 2.0 | 5 votes |
private Restlet secure(Application app, Verifier verifier, String realm) { ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext().createChildContext(), ChallengeScheme.HTTP_OAUTH_BEARER, realm); guard.setVerifier(verifier); guard.setNext(app); return guard; }
Example #8
Source File: ContextUtils.java From ontopia with Apache License 2.0 | 5 votes |
public static Context getCurrentApplicationContext() { Application application = Application.getCurrent(); if (application == null) { return null; } return application.getContext(); }
Example #9
Source File: OntopiaServlet.java From ontopia with Apache License 2.0 | 5 votes |
@Override protected Application createApplication(Context parentContext) { Application application = super.createApplication(parentContext); if (application == null) { application = new OntopiaRestApplication(parentContext.createChildContext()); } return application; }
Example #10
Source File: Activator.java From scava with Eclipse Public License 2.0 | 4 votes |
public void start(BundleContext context) throws Exception { System.err.println("Starting Admin bundle"); context.addServiceListener(new ServiceListener() { @Override public void serviceChanged(ServiceEvent event) { System.err.println(event); if (event.getType() == ServiceEvent.REGISTERED){ Application application = new AdminApplication(); component = new Component(); component.getServers().add(Protocol.HTTP, 8183); component.getClients().add(Protocol.FILE); boolean useAuth = Boolean.valueOf(Configuration.getInstance().getProperty("adminapi.use_authentication", "false")); if (useAuth) { String username = Configuration.getInstance().getProperty("adminapi.username", null); String password = Configuration.getInstance().getProperty("adminapi.password", null); ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "myRealm"); MapVerifier verifier = new MapVerifier(); verifier.getLocalSecrets().put(username, password.toCharArray()); guard.setVerifier(verifier); guard.setNext(application); component.getDefaultHost().attachDefault(guard); } else { component.getDefaultHost().attachDefault(application); } try { component.start(); } catch (Exception e) { e.printStackTrace(); } } } }, "(objectclass=" + ApiStartServiceToken.class.getName() +")"); }
Example #11
Source File: CarModule.java From microservices-comparison with Apache License 2.0 | 4 votes |
@Override protected void configure() { bind(Application.class).annotatedWith(Car.class).to(CarApplication.class); bind(CarRepository.class).to(InMemoryCarRepository.class); }
Example #12
Source File: HelloModule.java From microservices-comparison with Apache License 2.0 | 4 votes |
@Override protected void configure() { bind(Application.class).annotatedWith(Hello.class).to(HelloApplication.class); bind(CarService.class).to(RemoteCarService.class); }
Example #13
Source File: PolygeneServerServlet.java From attic-polygene-java with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings( "unchecked" ) protected Application createApplication( Context context ) { return module.newObject( Application.class, context.createChildContext(), getServletConfig(), getServletContext() ); }