本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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");
}
示例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);
}
示例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();
}
示例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 );
}
示例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);
}
}