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


Java Component類代碼示例

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


Component類屬於org.restlet包,在下文中一共展示了Component類的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();
}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:18,代碼來源:AbstractResourceTest.java

示例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();

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

示例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();
}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:17,代碼來源:Server.java

示例4: testListPaging

import org.restlet.Component; //導入依賴的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

示例5: 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();
	}

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

示例6: appLifeCycleManager

import org.restlet.Component; //導入依賴的package包/類
@Bean
public AppLifeCycleManagerImpl appLifeCycleManager() throws Exception {

	List<? extends StartupCheck> preStartupCheckList = Arrays.asList(
			beanFactory.getBean(ConfigCheck.class),
			beanFactory.getBean(CodecCheck.class));

	List<? extends ApplicationService> serviceList = Arrays.asList(
			new RestletService((Component) beanFactory
					.getBean("restletPingComponent")), new RestletService(
					(Component) beanFactory.getBean("restletComponent")),
			beanFactory.getBean(CollectorServerService.class), beanFactory
					.getBean(FileCloseService.class), beanFactory
					.getBean(GroupHeartbeatService.class), beanFactory
					.getBean(MetricsAppService.class), beanFactory
					.getBean(OrphanedFilesCheckService.class), beanFactory
					.getBean(StatusUpdaterThread.class), beanFactory
					.getBean(DiskSpaceCheckService.class), beanFactory
					.getBean(ZStoreExpireCheckService.class));

	List<? extends StartupCheck> postStartupList = Arrays
			.asList(beanFactory.getBean(PingCheck.class));

	return new AppLifeCycleManagerImpl(preStartupCheckList, serviceList,
			postStartupList);
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:27,代碼來源:CollectorDI.java

示例7: restletPingComponent

import org.restlet.Component; //導入依賴的package包/類
/**
 * Configures a restlet ping component
 * 
 * @return
 */
@Bean
public Component restletPingComponent() {
	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);
	Component component = new Component();

	component.getServers().add(
			org.restlet.data.Protocol.HTTP,
			configuration.getInt(CollectorProperties.WRITER.PING_PORT
					.toString(),
					(Integer) CollectorProperties.WRITER.PING_PORT
							.getDefaultValue()));
	component.getDefaultHost().attach(restletPingApplication());

	return component;
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:22,代碼來源:CollectorDI.java

示例8: 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();
	}

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

示例9: restletComponent

import org.restlet.Component; //導入依賴的package包/類
/**
 * Configures a restlet component
 * 
 * @return
 */
@Bean
public Component restletComponent() {
	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);
	Component component = new Component();
	component.getServers().add(
			org.restlet.data.Protocol.HTTP,
			configuration.getInt(
					CoordinationProperties.PROP.COORDINATION_PORT
							.toString(),
					(Integer) CoordinationProperties.PROP.COORDINATION_PORT
							.getDefaultValue()));
	component.getDefaultHost().attach(restletApplication());

	return component;
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:22,代碼來源:CoordinationDI.java

示例10: main

import org.restlet.Component; //導入依賴的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

示例11: ControllerStarter

import org.restlet.Component; //導入依賴的package包/類
public ControllerStarter(ControllerConf conf) {
  LOGGER.info("Trying to init ControllerStarter with config: {}", conf);
  _config = conf;
  HelixKafkaMirrorMakerMetricsReporter.init(conf);
  _component = new Component();
  _controllerRestApp = new ControllerRestApplication(null);
  _helixMirrorMakerManager = new HelixMirrorMakerManager(_config);
  _validationManager = new ValidationManager(_helixMirrorMakerManager);
  _srcKafkaValidationManager = getSourceKafkaClusterValidationManager();
  _autoTopicWhitelistingManager = getAutoTopicWhitelistingManager();
  if (_config.getBackUpToGit()) {
    _clusterInfoBackupManager = new ClusterInfoBackupManager(_helixMirrorMakerManager,
        new GitBackUpHandler(conf.getRemoteBackupRepo(), conf.getLocalGitRepoPath()), _config);
  } else {
    _clusterInfoBackupManager = new ClusterInfoBackupManager(_helixMirrorMakerManager,
        new FileBackUpHandler(conf.getLocalBackupFilePath()), _config);
  }
}
 
開發者ID:uber,項目名稱:uReplicator,代碼行數:19,代碼來源:ControllerStarter.java

示例12: ControllerStarter

import org.restlet.Component; //導入依賴的package包/類
public ControllerStarter(ControllerConf conf) {
  LOGGER.info("Trying to init ControllerStarter with config: {}", conf);
  _config = conf;
  HelixKafkaMirrorMakerMetricsReporter.init(conf);
  _component = new Component();
  _controllerRestApp = new ControllerRestApplication(null);
  _helixMirrorMakerManager = new HelixMirrorMakerManager(_config);
  _validationManager = new ValidationManager(_helixMirrorMakerManager);
  _srcKafkaValidationManager = getSourceKafkaClusterValidationManager();
  _autoTopicWhitelistingManager = getAutoTopicWhitelistingManager();
  if (_config.getBackUpToGit()) {
    _clusterInfoBackupManager =
        new ClusterInfoBackupManager(_helixMirrorMakerManager, new GitBackUpHandler(conf.getRemoteBackupRepo(),
            conf.getLocalGitRepoPath()), _config);
  } else {
    _clusterInfoBackupManager =
        new ClusterInfoBackupManager(_helixMirrorMakerManager, new FileBackUpHandler(conf.getLocalBackupFilePath()),
            _config);
  }
}
 
開發者ID:uber,項目名稱:chaperone,代碼行數:21,代碼來源:ControllerStarter.java

示例13: 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");
}
 
開發者ID:o3project,項目名稱:ocnrm,代碼行數:17,代碼來源:OcnRMServ.java

示例14: setUp

import org.restlet.Component; //導入依賴的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

示例15: getCollection

import org.restlet.Component; //導入依賴的package包/類
/**
 * The MongoDB collection used for the store.
 * 
 * @return The MongoDB collection
 */
public MongoCollection<Document> getCollection()
{
	if( collection == null )
	{
		Component component = InstanceUtil.getComponent();
		if( component != null )
		{
			MongoClient client = (MongoClient) component.getContext().getAttributes().get( MONGODB_CLIENT_ATTRIBUTE );
			if( client != null )
			{
				MongoDatabase database = client.getDatabase( "prudence" );
				if( database != null )
					collection = database.getCollection( collectionName );
			}
		}
	}

	if( collection == null )
		throw new RuntimeException( "MongoDB client must be configured in order to use HazelcastMongoDbMapStore" );

	return collection;
}
 
開發者ID:tliron,項目名稱:prudence,代碼行數:28,代碼來源:HazelcastMongoDbMapStore.java


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