當前位置: 首頁>>代碼示例>>Java>>正文


Java Protocol類代碼示例

本文整理匯總了Java中org.restlet.data.Protocol的典型用法代碼示例。如果您正苦於以下問題:Java Protocol類的具體用法?Java Protocol怎麽用?Java Protocol使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Protocol類屬於org.restlet.data包,在下文中一共展示了Protocol類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startServer

import org.restlet.data.Protocol; //導入依賴的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();
}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:18,代碼來源:AbstractResourceTest.java

示例2: main

import org.restlet.data.Protocol; //導入依賴的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();

}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:20,代碼來源:ShindigServer.java

示例3: main

import org.restlet.data.Protocol; //導入依賴的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();
}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:17,代碼來源:Server.java

示例4: XEStudentEnrollment

import org.restlet.data.Protocol; //導入依賴的package包/類
public XEStudentEnrollment() {
	List<Protocol> protocols = new ArrayList<Protocol>();
	protocols.add(Protocol.HTTP);
	protocols.add(Protocol.HTTPS);
	iClient = new Client(protocols);
	try {
		String clazz = ApplicationProperty.CustomizationExternalTerm.value();
		if (clazz == null || clazz.isEmpty())
			iExternalTermProvider = new BannerTermProvider();
		else
			iExternalTermProvider = (ExternalTermProvider)Class.forName(clazz).getConstructor().newInstance();
	} catch (Exception e) {
		sLog.error("Failed to create external term provider, using the default one instead.", e);
		iExternalTermProvider = new BannerTermProvider();
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:17,代碼來源:XEStudentEnrollment.java

示例5: DegreeWorksCourseRequests

import org.restlet.data.Protocol; //導入依賴的package包/類
public DegreeWorksCourseRequests() {
	List<Protocol> protocols = new ArrayList<Protocol>();
	protocols.add(Protocol.HTTP);
	protocols.add(Protocol.HTTPS);
	iClient = new Client(protocols);
	try {
		String clazz = ApplicationProperty.CustomizationExternalTerm.value();
		if (clazz == null || clazz.isEmpty())
			iExternalTermProvider = new BannerTermProvider();
		else
			iExternalTermProvider = (ExternalTermProvider)Class.forName(clazz).getConstructor().newInstance();
	} catch (Exception e) {
		sLog.error("Failed to create external term provider, using the default one instead.", e);
		iExternalTermProvider = new BannerTermProvider();
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:17,代碼來源:DegreeWorksCourseRequests.java

示例6: DegreeWorksPlanScraper

import org.restlet.data.Protocol; //導入依賴的package包/類
public DegreeWorksPlanScraper(Set<String> filter) {
	List<Protocol> protocols = new ArrayList<Protocol>();
	protocols.add(Protocol.HTTP);
	protocols.add(Protocol.HTTPS);
	iClient = new Client(protocols);
	iFilter = filter;
	try {
		String clazz = ApplicationProperty.CustomizationExternalTerm.value();
		if (clazz == null || clazz.isEmpty())
			iExternalTermProvider = new BannerTermProvider();
		else
			iExternalTermProvider = (ExternalTermProvider)Class.forName(clazz).getConstructor().newInstance();
	} catch (Exception e) {
		sLog.error("Failed to create external term provider, using the default one instead.", e);
		iExternalTermProvider = new BannerTermProvider();
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:18,代碼來源:DegreeWorksPlanScraper.java

示例7: testListPaging

import org.restlet.data.Protocol; //導入依賴的package包/類
@Test
public void testListPaging() throws Exception {
	Component component = new Component();
	component.getServers().add(Protocol.HTTP, port);
	component.getDefaultHost().attach(setupAppPaging());
	component.start();

	try {
		Client client = new Client(Protocol.HTTP);

		long count = getCount(client, "READY");
		assertEquals(pagingTotal, count);

		Collection<FileTrackingStatus> statusObjColl = getStatusObject(
				client, "READY", 0, 30);

		assertEquals(30, statusObjColl.size());
	} finally {
		component.stop();
	}

}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:23,代碼來源:TestFileTrackerStatusResource.java

示例8: testGetsStatus

import org.restlet.data.Protocol; //導入依賴的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();
	}

}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:25,代碼來源:TestFileTrackerStatusPathResource.java

示例9: main

import org.restlet.data.Protocol; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
	
	final int port = 8182;

    createDevelopmentDatabase();

    // Set up a Restlet service
    final Router router = new Router();
    router.attachDefault(HttpListener.class);

    org.restlet.Application myApp = new org.restlet.Application() {
        @Override
        public org.restlet.Restlet createInboundRoot() {
        	Context ctx = getContext();
ctx.getParameters().add("databaseDir", databaseDir);
ctx.getParameters().add("port", Integer.toString(port));
router.setContext(ctx);
            return router;
        };
    };
    Component component = new Component();
    component.getDefaultHost().attach("/", myApp);

    new Server(Protocol.HTTP, port, component).start();
}
 
開發者ID:ibm-watson-data-lab,項目名稱:sync-android-p2p,代碼行數:26,代碼來源:Application.java

示例10: main

import org.restlet.data.Protocol; //導入依賴的package包/類
public static void main( String[] args )
    throws Exception
{
    Energy4Java polygene = new Energy4Java(  );

    Server server = new Server( Protocol.HTTP, 8888 );

    Application app = polygene.newApplication( new ForumAssembler(), new MetadataService() );

    app.activate();

    ContextRestlet restlet = app.findModule( "REST", "Restlet" ).newObject( ContextRestlet.class, new org.restlet.Context() );

    ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm");
    MapVerifier mapVerifier = new MapVerifier();
    mapVerifier.getLocalSecrets().put("rickard", "secret".toCharArray());
    guard.setVerifier(mapVerifier);

    guard.setNext(restlet);

    server.setNext( restlet );
    server.start();
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:24,代碼來源:Main.java

示例11: main

import org.restlet.data.Protocol; //導入依賴的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");
}
 
開發者ID:o3project,項目名稱:ocnrm,代碼行數:17,代碼來源:OcnRMServ.java

示例12: setUp

import org.restlet.data.Protocol; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    component = PowerMockito.mock(Component.class, RETURNS_DEEP_STUBS);

    ServerList list = PowerMockito.mock(ServerList.class);
    PowerMockito.doReturn(list).when(component).getServers();
    PowerMockito.doReturn(mock(Server.class)).when(list).add(any(Protocol.class), anyInt());

    VirtualHost host = PowerMockito.mock(VirtualHost.class);
    PowerMockito.doReturn(host).when(component).getDefaultHost();
    PowerMockito.doReturn(mock(TemplateRoute.class))
            .when(host).attach(anyString(), any(RMrouterApplication.class));

    PowerMockito.doNothing().when(component).start();

    PowerMockito.whenNew(Component.class).withNoArguments().thenReturn(component);

    OdenOsPropertyLoader loader = PowerMockito.spy(OdenOsPropertyLoader.getInstance());
    Whitebox.setInternalState(OcnRMServ.class, "loader", loader);

    dummyLogger = mock(Logger.class);
    Whitebox.setInternalState(OcnRMServ.class, "logger", dummyLogger);
}
 
開發者ID:o3project,項目名稱:ocnrm,代碼行數:24,代碼來源:OcnRMServTest.java

示例13: pullData

import org.restlet.data.Protocol; //導入依賴的package包/類
/**
 * Pulls data from CloudStack API
 *
 * @return JSON string
 * @throws IOException
 */
private String pullData() throws IOException {
    logger.trace("Starting to pull data from provided URL");

    // create connection
    Client client = new Client(Protocol.HTTP);
    ClientResource cr = new ClientResource(url);
    Request req = cr.getRequest();

    // now header
    Series<Header> headerValue = new Series<Header>(Header.class);
    req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
    headerValue.add("Accept", "application/json");
    headerValue.add("Content-Type", "application/json");

    // fire it up
    cr.get(MediaType.APPLICATION_JSON);
    Representation output = cr.getResponseEntity();

    logger.trace("Successfully pulled data from provided URL");

    // and return response data
    return output.getText();
}
 
開發者ID:icclab,項目名稱:cyclops-udr,代碼行數:30,代碼來源:CloudStackDownloader.java

示例14: handle

import org.restlet.data.Protocol; //導入依賴的package包/類
@Override
public void handle( Request request, Response response )
{
	// RIAP ignores hide
	if( request.getProtocol() != Protocol.RIAP )
	{
		String remainingPart = request.getResourceRef().getRemainingPart();
		for( Template hiddenUriTemplate : hiddenUriTemplates )
		{
			if( hiddenUriTemplate.match( remainingPart ) != -1 )
			{
				response.setStatus( Status.CLIENT_ERROR_NOT_FOUND );
				return;
			}
		}
	}

	super.handle( request, response );
}
 
開發者ID:tliron,項目名稱:prudence,代碼行數:20,代碼來源:PrudenceRouter.java

示例15: onCreate

import org.restlet.data.Protocol; //導入依賴的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);
    }
}
 
開發者ID:snowch,項目名稱:z_sync-android-p2p-example.deprecated,代碼行數:23,代碼來源:MainActivity.java


注:本文中的org.restlet.data.Protocol類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。