本文整理匯總了Java中org.restlet.Component.start方法的典型用法代碼示例。如果您正苦於以下問題:Java Component.start方法的具體用法?Java Component.start怎麽用?Java Component.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.restlet.Component
的用法示例。
在下文中一共展示了Component.start方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startServer
import org.restlet.Component; //導入方法依賴的package包/類
@BeforeClass
public static void startServer() throws Exception {
// Creating restlet component
component = new Component();
// The status service is disabled by default.
component.getStatusService().setEnabled(false);
component.getClients().add(Protocol.HTTP);
component.getClients().add(Protocol.FILE);
component.getClients().add(Protocol.WAR);
component.getClients().add(Protocol.RIAP);
component.getServers().add(Protocol.HTTP, portNumber);
component.start();
}
示例2: main
import org.restlet.Component; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// Create a new Component.
Component component = new Component();
// Add a new HTTP server listening on port 8182.
Server server = component.getServers().add(Protocol.HTTP, 8182);
server.getContext().getParameters().add("useForwardedForHeader", "true");
ShindigApplication application = new ShindigApplication(server.getContext());
// Attach the sample application.
component.getDefaultHost().attach("/shindig", application);
server.getContext().getAttributes().put(Constants.CONTEXT_PATH_KEY, "/shindig");
server.getContext().getAttributes().put(Constants.BASE_URL_KEY, "http://localhost:8182");
// Start the component.
component.start();
}
示例3: main
import org.restlet.Component; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// Create a new Component.
Component component = new Component();
// Add a new HTTP server listening on port 8182.
org.restlet.Server server = component.getServers().add(Protocol.HTTP, 8182);
server.getContext().getParameters().add("useForwardedForHeader", "true");
RestletSpringApplication application = new RestletSpringApplication();
// Attach the sample application.
component.getDefaultHost().attach( application);
// Start the component.
component.start();
}
示例4: testGetsStatus
import org.restlet.Component; //導入方法依賴的package包/類
@Test
public void testGetsStatus() throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, port);
component.getDefaultHost().attach(setupApp());
component.start();
try {
Client client = new Client(Protocol.HTTP);
for(File file: Arrays.asList(new File("test1.txt"), new File("test2.txt"), new File("test3.txt"))){
FileTrackingStatus status = getStatusObject(client, file.getAbsolutePath());
assertNotNull(status);
assertEquals(file.getAbsolutePath(), status.getPath());
}
} finally {
component.stop();
}
}
示例5: testPingCheckOK
import org.restlet.Component; //導入方法依賴的package包/類
/**
* Tests that the PingCheck does not through errors when the ping service is
* running
*
* @throws Exception
*/
@Test
public void testPingCheckOK() throws Exception {
Component pingComp = (Component) bootstrap
.getBean("restletPingComponent");
pingComp.start();
try {
PingCheck pingCheck = bootstrap.getBean(PingCheck.class);
pingCheck.runCheck();
assertTrue(true);
} catch (Throwable t) {
t.printStackTrace();
assertTrue(false);
} finally {
pingComp.stop();
}
}
示例6: main
import org.restlet.Component; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
logger.info("main() Start");
if (args.length == 0) {
loadProperties("");
} else {
loadProperties(args[0]);
}
Component component = new Component();
component.getServers().add(Protocol.HTTP, SERVER_PORT);
component.getDefaultHost().attach(SERVER_PATH, new RMrouterApplication());
component.start();
logger.info("main() End");
}
示例7: onCreate
import org.restlet.Component; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// create datastore
File path = getApplicationContext().getDir("datastores", MODE_PRIVATE);
DatastoreManager manager = new DatastoreManager(path.getAbsolutePath());
Datastore ds = manager.openDatastore("mydb");
ds.close();
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getDefaultHost().attachDefault(HttpListener.class);
try {
component.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例8: setUp
import org.restlet.Component; //導入方法依賴的package包/類
@Before
public void setUp() {
ServerManager.getInstance().setServer(new StubMCServer());
component = new Component();
client = new Client(Protocol.HTTP);
// Add a new HTTP server listening on port 8182.
component.getServers().add(Protocol.HTTP, port);
// Attach the sample application.
component.getDefaultHost().attach("/mcrest", new RestApplication());
try {
component.start();
} catch (Exception e) {
e.printStackTrace();
}
serverUrl = "http://127.0.0.1:"+port+"/mcrest";
}
示例9: authDisableTest
import org.restlet.Component; //導入方法依賴的package包/類
@Test
public void authDisableTest(){
AuthPara auth = new AuthPara(USER,PASSWORD,false);
Component component = new Component();
component.getServers().add(Protocol.HTTP, port);
component.getDefaultHost().attach("/mcrest", new RestApplication(auth));
try {
component.start();
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
String responseString = getRequestResult("/").getEntityAsText();
Assert.assertTrue(responseString.contains("MCStub"));
String worldResult = getRequestResult("/world").getEntityAsText();
Assert.assertTrue(worldResult.contains("testWorld"));
}
示例10: authEnableAllResource
import org.restlet.Component; //導入方法依賴的package包/類
@Test
public void authEnableAllResource(){
AuthPara auth = new AuthPara(USER,PASSWORD,genAllResoureceList(),true);
component = new Component();
component.getServers().add(Protocol.HTTP, port);
component.getDefaultHost().attach("/mcrest", new RestApplication(auth));
try {
component.start();
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
int statusCode = getRequestResult("/").getStatus().getCode();
Assert.assertEquals(statusCode, 401);
statusCode = getRequestResult("/player").getStatus().getCode();
Assert.assertEquals(statusCode, 401);
statusCode = getRequestResult("/world").getStatus().getCode();
Assert.assertEquals(statusCode, 401);
}
示例11: main
import org.restlet.Component; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
logger.debug("main() Start");
// プロパティファイル呼び出し
if (args.length == 0) {
loadProperties(null);
} else {
loadProperties(args[0]);
}
Component component = new Component();
component.getServers().add(Protocol.HTTP, loader.getServicePort());
component.getDefaultHost().attach(loader.getCommonPath(), new PseudoMfRouter());
component.getDefaultHost().attach("/ui/", new PseudoMfGuiRouter());
component.getContext().getParameters().add("maxThreads", "10");
component.start();
logger.debug("CurrentDir:{}", System.getProperty("user.dir"));
logger.info("## dummyMC GUI URI: http://<HOST>:{}/ui/index.html", loader.getServicePort());
logger.debug("main() End");
}
示例12: main
import org.restlet.Component; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
// Create a new Component.
Component component = new Component();
// Add a new HTTP server listening on port 8182.
component.getServers().add(Protocol.HTTP, 8182);
// Attach the sample application.
component.getDefaultHost().attach(new LeanBeanApplication());
// Start the component.
component.start();
} catch (Exception e) {
// Something is wrong.
e.printStackTrace();
}
}
示例13: run
import org.restlet.Component; //導入方法依賴的package包/類
/**
* Run the Application on an open port.
*
*/
public void run() {
try {
setStatusService(new StatusService() {
@Override
public Representation getRepresentation(Status status,
Request request,
Response response) {
return new JacksonRepresentation<>(status);
}
});
// Start listening for REST requests
component = new Component();
server = component.getServers().add(Protocol.HTTP, 0);
component.getDefaultHost().attach(this);
component.start();
} catch (Exception e) {
// Web server did not start.
throw new IllegalStateException(e);
}
}
示例14: main
import org.restlet.Component; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
// Create a new Component.
Component component = new Component();
// Add a new HTTP server listening on port 8082.
component.getServers().add(Protocol.HTTP, 8080);
// Attach the sample application.
component.getDefaultHost().attach(new RestletApplication());
// Start the component.
component.start();
} catch (Exception e) {
// Something is wrong.
e.printStackTrace();
}
}
示例15: main
import org.restlet.Component; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getClients().add(Protocol.FILE);
//TODO: To test with the restlet 2.1 Maybe the maxTotalConnections could be avoided
// see: http://restlet-discuss.1400322.n2.nabble.com/rejectedExecution-td4513620.html
//component.getServers().add(Protocol.HTTP, SERVER_PORT);
Server server = new Server(Protocol.HTTP, 8111);
component.getServers().add(server);
server.getContext().getParameters().add("maxTotalConnections", "50");
//end TODO
Engine.getInstance().getRegisteredServers().clear();
Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(server));
component.getClients().add(Protocol.FILE);
component.getDefaultHost().attach(new FreedomRestServer());
component.start();
}