当前位置: 首页>>代码示例>>Java>>正文


Java Directory类代码示例

本文整理汇总了Java中org.restlet.resource.Directory的典型用法代码示例。如果您正苦于以下问题:Java Directory类的具体用法?Java Directory怎么用?Java Directory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Directory类属于org.restlet.resource包,在下文中一共展示了Directory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInboundRoot

import org.restlet.resource.Directory; //导入依赖的package包/类
@Override
    public Restlet createInboundRoot() {
        // Create a router
        Router router = new Router(getContext());

        // Attach the resources to the router
        adminGuard = getAdminGuard();
        adminGuard.setNext(AdminResource.class);
        router.attach("/admin/{ares}/{idr}", adminGuard, Template.MODE_STARTS_WITH);
        router.attach("/admin/{ares}", adminGuard, Template.MODE_STARTS_WITH);
        router.attach("/admin", adminGuard, Template.MODE_STARTS_WITH);
//        Directory directory = new Directory(getContext(),getDocumentRoot());
//        directory.setIndexName("index.html");
        router.attach("/js", new Directory(getContext(),"file:///"+getDocumentRoot()+"/js"));
        router.attach("/css", new Directory(getContext(),"file:///"+getDocumentRoot()+"/css"));

        userGuard = getUserGuard();
        userGuard.setNext(PrintResource.class);
        router.attach("/print/", userGuard);
        router.attach("/", RootResource.class);
        
        
        // Return the root router
        return router;
    }
 
开发者ID:edabg,项目名称:fpgate,代码行数:26,代码来源:FPServer.java

示例2: doCreateRoot

import org.restlet.resource.Directory; //导入依赖的package包/类
/**
 * Called when the app root needs to be created. Override it if you need
 * "old way" to attach resources, or need to use the isStarted flag.
 * 
 * @param root
 * @param isStarted
 */
protected void doCreateRoot(Router root, boolean isStarted) {
	if (!isStarted) {
		return;
	}
	// publish the WAR contents
	Directory rootDir = new WebAppDirectory(getContext(), "war:///");
	rootDir.setListingAllowed(false);
	rootDir.setModifiable(false);
	rootDir.setNegotiatingContent(true);

	attach(root, false, "/", rootDir);
	root.attach(FileServerResource.RESOURCE_PATH, FileServerResource.class, Template.MODE_STARTS_WITH);

	this.getConnectorService().setClientProtocols(
			Arrays.asList(Protocol.HTTP, Protocol.FILE, Protocol.WAR, Protocol.RIAP));
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:24,代码来源:RestletSpringApplication.java

示例3: createInboundRoot

import org.restlet.resource.Directory; //导入依赖的package包/类
/**
 * Returns the root Restlet of this application.
 */
@Override
public Restlet createInboundRoot() {
    Router router = new Router(getContext());
    router.attach(ENVIRONMENT_PATH, EnvironmentsServerResource.class);
    router.attach(ENVIRONMENT_PATH+"/{number}", EnvironmentServerResource.class);
    router.attach(ENVIRONMENT_PATH+"/{env}/zones/", ZonesServerResource.class);
    router.attach(ENVIRONMENT_PATH+"/{env}/zones/{number}", ZoneServerResource.class);
    router.attach(FREEDOMOTIC_PATH+"/objects/", ObjectsServerResource.class);
    router.attach(FREEDOMOTIC_PATH+"/objects/{name}", ObjectServerResource.class);
    router.attach(FREEDOMOTIC_PATH+"/plugins/", PluginsServerResource.class);
    router.attach(FREEDOMOTIC_PATH+"/commands/hardware/", HardwareCommandsServerResource.class);
    router.attach(FREEDOMOTIC_PATH+"/commands/user/", UserCommandsServerResource.class);
    router.attach(FREEDOMOTIC_PATH+"/triggers/", TriggersServerResource.class);
    router.attach(FREEDOMOTIC_PATH+"/resources/{filename}", ImageResourceServerResource.class);
    router.attach(USER_PATH + "/{useraction}", UserServerResource.class);
    //Expose the resources dir as static server
    Directory dir = new Directory(getContext(), FILE_AND_SLASHES + resourcesPath);
    dir.setListingAllowed(true);
    System.out.println("Restapi resources is serving: " + FILE_AND_SLASHES + resourcesPath);
    router.attach(RESOURCES_PATH , dir);
    
    return router;
}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:27,代码来源:FreedomRestServer.java

示例4: getRestlet

import org.restlet.resource.Directory; //导入依赖的package包/类
@Override
public Restlet getRestlet(Context context) {
       Router router = new Router(context);
       router.attach("", new Directory(context, "clap://classloader/web/"));
       context.setClientDispatcher(new Client(context, Protocol.CLAP));
       return router;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:8,代码来源:StaticWebRoutable.java

示例5: createInboundRoot

import org.restlet.resource.Directory; //导入依赖的package包/类
@Override
public synchronized Restlet createInboundRoot() {
    logger.debug("createInboundRoot() Start");
    Router router = new Router(getContext());
    // gui
    router.attach("", new Directory(getContext(), "clap://classloader/web/"));
    getContext().setClientDispatcher(new Client(getContext(), Protocol.CLAP));
    logger.debug("createInboundRoot() End");
    return router;
}
 
开发者ID:o3project,项目名称:pseudoMF,代码行数:11,代码来源:PseudoMfGuiRouter.java

示例6: RootRouter

import org.restlet.resource.Directory; //导入依赖的package包/类
/**
 * Configures endpoints, sets up OrcidOAuthClient & OrcidWorkProvider and
 * places them in the RESTlet Context
 * 
 * Routes:
 * <ul>
 * <li>"/orcid/token" convert authz codes from orcid into authz tokens</li>
 * <li>"/orcid/requests" generate a authz request url (?redirect=true to
 * bounce user)</li>
 * <li>"/orcid/requests/{originalRef}" generate a authz request url with
 * originalRef as state param (?redirect=true to bounce user)</li>
 * <li>"/orcid/{orcid}/orcid-works/create" create a work by posting
 * OrcidWork XML (requires ?token= orcid oauth token)</li>
 * <li>"/meta/{id}" fetch metadata from external source - use (?json) for
 * raw form</li>
 * <li>"/webjars" webjars endpoint - example:
 * /webjars/bootstrap/3.0.3/css/bootstrap.min.css</li>
 * </ul>
 * 
 * 
 */
public RootRouter(Context context) {
	super(context);

	// import work rest routes
	this.attach("/orcid/token", OrcidTokenResource.class);
	//this.attach("/orcid/requests/{originalRef}", OrcidAuthURLResource.class);
	this.attach("/orcid/requests", OrcidAuthURLResource.class);//?originalRef optional

	this.attach("/orcid/search", OrcidSearchResource.class);

	this.attach("/orcid/{orcid}/orcid-works/create", OrcidWorkCreationResource.class);
	this.attach("/orcid/{orcid}", OrcidProfileResource.class);
	this.attach("/meta", MetadataFetchResource.class); //the configured type

	// reporting rest routes
	this.attach("/report/datatable", OrcidDataCentreReportResource.class);
	this.attach("/doiprefix/publishers", PublisherDOIPrefixResource.class);
	this.attach("/doiprefix/datacentres", DatacentreDOIPrefixResource.class);
	// identifier enumerations
	this.attach("/identifier/{type}", OrcidIdentifierResource.class);

	// add a webjars listener(see
	// http://demeranville.com/controlling-the-cache-headers-for-a-restlet-directory/
	final Directory dir = new Directory(getContext(), "clap://class/META-INF/resources/webjars");
	Filter cache = new CacheFilter(getContext(), dir);
	this.attach("/webjars", cache);

	log.info("RootRouter created, ready to serve");
}
 
开发者ID:TomDemeranville,项目名称:orcid-update-java,代码行数:51,代码来源:RootRouter.java

示例7: createInboundRoot

import org.restlet.resource.Directory; //导入依赖的package包/类
@Override
public Restlet createInboundRoot() {
    Directory directory = new Directory(getContext(), "clap://class/static/");
    directory.setDeeplyAccessible(true);

    Router router = new Router(getContext());
    router.attach("/web", directory);
    router.attach("/rest/todos", TodoListResource.class);
    router.attach("/rest/todos/{todoId}", TodoResource.class);
    return router;
}
 
开发者ID:OlivierCroisier,项目名称:restangular,代码行数:12,代码来源:RestangularApplication.java

示例8: attachStaticContent

import org.restlet.resource.Directory; //导入依赖的package包/类
/**
 * During dev, set static content to local dir (e.g.
 * "file:///Users/meb/Documents/workspace/SlipStream/SlipStreamServer/src/main/webapp/static-content/"
 * )
 */
private Directory attachStaticContent() {
	String staticContentLocation = System.getProperty("static.content.location", "war:///static-content");
	Directory directory = new Directory(getContext(), staticContentLocation);
	directory.setModifiable(false);
	directory.setListingAllowed(true);
	return directory;
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:13,代码来源:RootApplication.java

示例9: attachDownloadsDirectory

import org.restlet.resource.Directory; //导入依赖的package包/类
private Directory attachDownloadsDirectory() {
	String staticContentLocation = System.getProperty(
			"downloads.directory.location",
			"file:///opt/slipstream/downloads");
	Directory directory = new Directory(getContext(), staticContentLocation);
	directory.setModifiable(false);
	return directory;
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:9,代码来源:RootApplication.java

示例10: restletComponent

import org.restlet.resource.Directory; //导入依赖的package包/类
/**
 * Configures a restlet component
 * 
 * @return
 * @throws Exception
 */
@Bean
public Component restletComponent() throws Exception {

	org.apache.commons.configuration.Configuration configuration = beanFactory
			.getBean(org.apache.commons.configuration.Configuration.class);

	// we must initialise velocity before hand.
	// a cleaner solution for this must be found in the future.

	final String templateDir = configuration.getString(
			CollectorProperties.WEB.VELOCITY_TEMPLATE_DIR.toString(),
			(String) CollectorProperties.WEB.VELOCITY_TEMPLATE_DIR
					.getDefaultValue());

	String logFile = configuration.getString(
			CollectorProperties.WEB.VELOCITY_LOG_FILE.toString(),
			(String) CollectorProperties.WEB.VELOCITY_LOG_FILE
					.getDefaultValue());

	RuntimeSingleton.setProperty(
			RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateDir);
	RuntimeSingleton.setProperty(RuntimeConstants.RUNTIME_LOG, logFile);
	RuntimeSingleton.init();

	LOG.info("Using templates: " + templateDir);
	LOG.info("Using display log file : " + logFile);

	Component component = new Component();

	int port = configuration.getInt(
			CollectorProperties.WRITER.COLLECTOR_MON_PORT.toString(),
			(Integer) CollectorProperties.WRITER.COLLECTOR_MON_PORT
					.getDefaultValue());

	LOG.info("Using collector monitoring port: " + port);

	component.getServers().add(org.restlet.data.Protocol.HTTP, port);
	component.getClients().add(org.restlet.data.Protocol.FILE);

	Application staticApp = new Application(component.getContext()) {
		@Override
		public Restlet createRoot() {
			return new Directory(getContext(), "file://"
					+ new File(templateDir).getAbsolutePath());
		}
	};

	component.getDefaultHost().attach("/view", restApplication());
	component.getDefaultHost().attach("/static", staticApp);
	component.getDefaultHost().attach("/images", staticApp);

	return component;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:60,代码来源:CollectorDI.java

示例11: createInboundRoot

import org.restlet.resource.Directory; //导入依赖的package包/类
@Override
public Restlet createInboundRoot() {
  // Remove server-side HTTP timeout (see http://stackoverflow.com/questions/12943447/restlet-server-socket-timeout)
  getContext().getParameters().add("maxIoIdleTimeMs", ONE_HOUR_IN_MILLIS);
  getContext().getParameters().add("ioMaxIdleTimeMs", ONE_HOUR_IN_MILLIS);

  router = new Router(getContext());
  router.setDefaultMatchingMode(Template.MODE_EQUALS);

  /**
   * Start Routers 2.0
   */

  attachRoutesForClass(router, PinotTenantRestletResource.class);
  attachRoutesForClass(router, PinotSchemaRestletResource.class);
  attachRoutesForClass(router, PinotTableRestletResource.class);

  // GET
  attachRoutesForClass(router, PinotTableInstances.class);
  attachRoutesForClass(router, PinotTableSchema.class);
  attachRoutesForClass(router, PinotSegmentRestletResource.class);

  // PUT
  attachRoutesForClass(router, PinotTableSegmentConfigs.class);
  attachRoutesForClass(router, PinotTableIndexingConfigs.class);
  attachRoutesForClass(router, PinotTableTenantConfigs.class);
  attachRoutesForClass(router, PinotTableMetadataConfigs.class);

  // Uploading Downloading segments
  attachRoutesForClass(router, PinotSegmentUploadRestletResource.class);

  attachRoutesForClass(router, PinotVersionRestletResource.class);

  router.attach("/api", SwaggerResource.class);

  /**
   *  End Routes 2.0
   */

  attachRoutesForClass(router, PinotInstanceRestletResource.class);

  router.attach("/pinot-controller/admin", PinotControllerHealthCheck.class);

  router.attach("/pql", PqlQueryResource.class);

  final Restlet mainpage = new Restlet() {
    @Override
    public void handle(Request request, Response response) {
      final StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("<html>");
      stringBuilder.append("<head><title>Restlet Cluster Management page</title></head>");
      stringBuilder.append("<body bgcolor=white>");
      stringBuilder.append("<table border=\"0\">");
      stringBuilder.append("<tr>");
      stringBuilder.append("<td>");
      stringBuilder.append("<h1>Rest cluster management interface V1</h1>");
      stringBuilder.append("</td>");
      stringBuilder.append("</tr>");
      stringBuilder.append("</table>");
      stringBuilder.append("</body>");
      stringBuilder.append("</html>");
      response.setEntity(new StringRepresentation(stringBuilder.toString(), MediaType.TEXT_HTML));
    }
  };

  final Directory webdir = new Directory(getContext(), CONSOLE_WEBAPP_ROOT_PATH);
  webdir.setDeeplyAccessible(true);
  webdir.setIndexName("index.html");
  router.attach("/query", webdir);

  final Directory swaggerUiDir = new Directory(getContext(), getClass().getClassLoader().getResource("META-INF/resources/webjars/swagger-ui/2.1.8-M1").toString());
  swaggerUiDir.setDeeplyAccessible(true);
  router.attach("/swagger-ui", swaggerUiDir);

  final Redirector redirector = new Redirector(getContext(), "/swagger-ui/index.html?url=/api", Redirector.MODE_CLIENT_TEMPORARY);
  router.attach("/help", redirector);

  return router;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:80,代码来源:ControllerRestApplication.java

示例12: getMatchingMode

import org.restlet.resource.Directory; //导入依赖的package包/类
/**
 * Returns the matching mode for the target Restlet. By default it returns
 * {@link #getDefaultMatchingMode()}. If the target is an instance of
 * {@link Directory} or {@link Router} then the mode returned is
 * {@link Template#MODE_STARTS_WITH} to allow further routing by those
 * objects. If the target is an instance of {@link Filter}, then it returns
 * the matching mode for the {@link Filter#getNext()} Restlet recursively.
 * 
 * @param target
 *            The target Restlet.
 * @return The preferred matching mode.
 */
protected int getMatchingMode(Restlet target) {
    int result = getDefaultMatchingMode();

    if ((target instanceof Directory) || (target instanceof Router)) {
        result = Template.MODE_STARTS_WITH;
    } else if (target instanceof Filter) {
        result = getMatchingMode(((Filter) target).getNext());
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:24,代码来源:Router.java

示例13: getDirectory

import org.restlet.resource.Directory; //导入依赖的package包/类
/**
 * Returns the parent directory handler.
 * 
 * @return The parent directory handler.
 */
public Directory getDirectory() {
    return this.directory;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:9,代码来源:DirectoryServerResource.java


注:本文中的org.restlet.resource.Directory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。