/** * Sets a modifiable list of client connectors. Method synchronized to make * compound action (clear, addAll) atomic, not for visibility. * * @param clients * A modifiable list of client connectors. */ public synchronized void setClients(ClientList clients) { this.clients.clear(); if (clients != null) { this.clients.addAll(clients); } }
/** * Adds a new client connector in the map supporting the given protocol. * * @param protocol * The connector protocol. * @return The added client. */ public Client add(Protocol protocol) { final Client result = new Client(protocol); result.setContext(getContext().createChildContext()); add(result); return result; }
/** * Attaches an application created from a WADL description document * available at a given URI reference. * * @param wadlRef * The URI reference to the WADL description document. * @return The created WADL application. */ public WadlApplication attach(Reference wadlRef) { WadlApplication result = null; // Adds some common client connectors to load the WADL documents if (!getClients().contains(wadlRef.getSchemeProtocol())) { getClients().add(wadlRef.getSchemeProtocol()); } // Get the WADL document final Response response = getContext().getClientDispatcher().handle( new Request(Method.GET, wadlRef)); if (response.getStatus().isSuccess() && response.isEntityAvailable()) { result = attach(response.getEntity()); } return result; }
this.clients = new ClientList(null); this.servers = new ServerList(null, this); this.logService = new LogService(true); this.statusService = new StatusService(true); this.clients.setContext(getContext()); this.servers.setContext(getContext());
@Override public boolean add(Client client) { // Set the client's context, if the client does not have already one. if (client.getContext() == null) { client.setContext(getContext().createChildContext()); } return super.add(client); }
/** * Adds a new client connector in the map supporting the given protocol. * * @param protocol * The connector protocol. * @return The added client. */ public Client add(Protocol protocol) { final Client result = new Client(protocol); result.setContext(getContext().createChildContext()); add(result); return result; }
/** * Constructor. */ public Component() { super(); this.hosts = new CopyOnWriteArrayList<VirtualHost>(); this.clients = new ClientList(null); this.servers = new ServerList(null, this); this.realms = new CopyOnWriteArrayList<Realm>(); this.services = new ServiceList(getContext()); if (Engine.getInstance() != null) { // To be done before setting the helper... this.services.add(new org.restlet.service.TaskService()); this.helper = new ComponentHelper(this); Context childContext = getContext().createChildContext(); this.defaultHost = new VirtualHost(childContext); this.internalRouter = new InternalRouter(childContext); this.services.add(new LogService()); getLogService().setContext(childContext); this.services.add(new StatusService()); getStatusService().setContext(childContext); this.clients.setContext(childContext); this.servers.setContext(childContext); } }
@Override public boolean add(Client client) { // Set the client's context, if the client does not have already one. if (client.getContext() == null) { client.setContext(getContext().createChildContext()); } return super.add(client); }
/** * Sets the modifiable list of client connectors. This method clears the * current list and adds all entries in the parameter list. * * @param clients * A list of client connectors. */ public void setClients(ClientList clients) { synchronized (getClients()) { if (clients != getClients()) { getClients().clear(); if (clients != null) { getClients().addAll(clients); } } } }
/** * Adds a new client connector in the map supporting the given protocol. * * @param protocol * The connector protocol. * @return The added client. */ public Client add(Protocol protocol) { final Client result = new Client(protocol); // result.setContext(getContext().createChildContext()); add(result); return result; }
/** * Sets the list of clients, either as protocol names, Protocol instances or * Client instances. * * @param clients * The list of clients. */ public synchronized void setClientsList(List<Object> clients) { for (final Object client : clients) { if (client instanceof String) { getClients().add(Protocol.valueOf((String) client)); } else if (client instanceof Protocol) { getClients().add((Protocol) client); } else if (client instanceof Client) { getClients().add((Client) client); } else { getLogger() .warning( "Unknown object found in the clients list. Only instances of String, org.restlet.data.Protocol and org.restlet.Client are allowed."); } } }
public static void main(String... args) throws Exception { // Create a component with an HTTP server connector final Component component = new Component(); component.getServers().add(Protocol.HTTP, 8585); component.getClients().add(Protocol.FILE); component.getClients().add(Protocol.CLAP); component.getClients().add(Protocol.HTTP); // Attach the application to the default host and start it component.getDefaultHost().attach("/foaf", new Application()); component.start(); }
public void start() throws Exception { Injector injector = RestletGuice.createInjector(modules); Application instance = injector.getInstance(application); Component component = new Component(); component.getServers().add(Protocol.HTTP, port); component.getClients().add(Protocol.FILE); component.getClients().add(Protocol.CLAP); component.getDefaultHost().attach(instance); component.start(); }
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(SourceKafkaClusterValidationManager.class.toString(), _srcKafkaValidationManager); Application managerRestApp = new ManagerRestApplication(null); managerRestApp.setContext(applicationContext); _component.getDefaultHost().attach(managerRestApp); try { LOGGER.info("Starting helix manager"); _controllerHelixManager.start(); LOGGER.info("Starting source kafka cluster validation manager"); _srcKafkaValidationManager.start(); LOGGER.info("Starting API component"); _component.start(); } catch (final Exception e) { LOGGER.error("Caught exception while starting uReplicator-Manager", e); throw e; } }
public static void main(String[] args) throws Exception { // Setup Restlet Component component = new Component(); component.getClients().add(Protocol.HTTP); component.getClients().add(Protocol.HTTPS); component.getServers().add(Protocol.HTTP, 8888); component.getDefaultHost().attach("/sample", new SampleApplication()); component.start(); } }
/** * default constructor for UmlgRestletComponent */ public UmlgRestletComponent() { setName("restAndJson"); setDescription("Halo, I am your first comment."); getClients().add(Protocol.FILE); getClients().add(Protocol.CLAP); getClients().add(Protocol.RIAP); Server server = new Server(new Context(), Protocol.HTTP, 8111); server.getContext().getParameters().set("tracing", "true"); getServers().add(server); attachApplications(); }