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


Java Router.attachDefault方法代码示例

本文整理汇总了Java中org.restlet.routing.Router.attachDefault方法的典型用法代码示例。如果您正苦于以下问题:Java Router.attachDefault方法的具体用法?Java Router.attachDefault怎么用?Java Router.attachDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.restlet.routing.Router的用法示例。


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

示例1: main

import org.restlet.routing.Router; //导入方法依赖的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

示例2: configureRouter

import org.restlet.routing.Router; //导入方法依赖的package包/类
@Override
protected void configureRouter(int group, Router router) {
	switch (group) {
	case AWAITING_FOR_ACTIVATION:
		router.attachDefault(AwaitingForActivationResource.class);
		router.attach("/me", MeResource.class);
		router.attach("/me/events", MeEventsResource.class);
		break;
	case BANNED:
		router.attachDefault(BannedResource.class);
		break;
	case USER:
		router.attach("/event/{EVENT_ID}/register", EventRegisterResource.class);
		break;
	case MODERATOR:
		router.attach("/event/{EVENT_ID}/round/{ROUND_ID}/score/{USER_ID}", EventRoundUserScoreResource.class);
		break;
	case ADMIN:
		break;
	case SUPERADMIN:
		break;
	}
}
 
开发者ID:FightForSub,项目名称:FFS-Api,代码行数:24,代码来源:ApiV1.java

示例3: createInboundRoot

import org.restlet.routing.Router; //导入方法依赖的package包/类
@Override
public Restlet createInboundRoot() {
	
       Router router = new Router(getContext());
       router.attach("/", StatusResource.class);
       router.attach("/info/{type}", InfoResource.class);
       router.attach("/info/", InfoResource.class);
       router.attachDefault(ErrorHandlerResource.class);
       return router;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:11,代码来源:RestletApplication.java

示例4: getRestlet

import org.restlet.routing.Router; //导入方法依赖的package包/类
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/tenants/{tenant}/networks", NetworkResource.class); // GET
    router.attach("/tenants/{tenant}/networks/{network}", NetworkResource.class); // PUT, DELETE
    router.attach("/tenants/{tenant}/networks", NetworkResource.class); // POST
    router.attach("/tenants/{tenant}/networks/{network}/ports/{port}/attachment", HostResource.class);
    router.attachDefault(NoOp.class);
    return router;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:11,代码来源:VirtualNetworkWebRoutable.java

示例5: getRestlet

import org.restlet.routing.Router; //导入方法依赖的package包/类
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/vips/", VipsResource.class); // GET, POST
    router.attach("/vips/{vip}", VipsResource.class); // GET, PUT, DELETE 
    router.attach("/pools/", PoolsResource.class); // GET, POST
    router.attach("/pools/{pool}", PoolsResource.class); // GET, PUT, DELETE
    router.attach("/members/", MembersResource.class); // GET, POST
    router.attach("/members/{member}", MembersResource.class); // GET, PUT, DELETE
    router.attach("/pools/{pool}/members", PoolMemberResource.class); //GET
    router.attach("/health_monitors/", MonitorsResource.class); //GET, POST
    router.attach("/health_monitors/{monitor}", MonitorsResource.class); //GET, PUT, DELETE        
    router.attachDefault(NoOp.class);
    return router;
 }
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:LoadBalancerWebRoutable.java

示例6: createServer

import org.restlet.routing.Router; //导入方法依赖的package包/类
void createServer(final int port, final String dbname) throws Exception {

	final String databaseDir = Files.createTempDirectory(null).toAbsolutePath().toString();
	databaseDirs.put(port, databaseDir);

	DatastoreManager manager = DatastoreManager.getInstance(databaseDir);
	Datastore ds = manager.openDatastore(dbname);
	ds.close();

	Runnable r = new Runnable()
	{
		@Override
		public void run()
		{
			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);
			try {
				new Server(Protocol.HTTP, port, component).start();
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
	};
	new Thread(r).start();
}
 
开发者ID:ibm-watson-data-lab,项目名称:sync-android-p2p,代码行数:40,代码来源:P2PAbstractTest.java

示例7: onCreate

import org.restlet.routing.Router; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    AndroidLoggingHandler.reset(new AndroidLoggingHandler());
    java.util.logging.Logger.getLogger(HttpListener.class.getCanonicalName()).setLevel(Level.FINEST);

    try {
        // create datastore
        final File databaseDir = getApplicationContext().getDir("datastores", MODE_PRIVATE);
        final DatastoreManager manager = DatastoreManager.getInstance(databaseDir.getAbsolutePath());

        Datastore ds = manager.openDatastore("mydb");
        ds.close();

        // 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.getAbsolutePath());
				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();
        
    } catch (Exception e) {
    	Log.e("snowch.MyActivity", "Error", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:ibm-watson-data-lab,项目名称:sync-android-p2p,代码行数:41,代码来源:MainActivity.java

示例8: createInboundRoot

import org.restlet.routing.Router; //导入方法依赖的package包/类
/**
 * Creates a root Restlet that will receive all incoming calls.
 */
@Override
public synchronized Restlet createInboundRoot() {
	Router router = new Router(getContext());
	router.attachDefault(DefaultResource.class);
	ModelerServicesInit.attachResources(router);
	DiagramServicesInit.attachResources(router);
	JsonpFilter jsonpFilter = new JsonpFilter(getContext());
	jsonpFilter.setNext(router);
	return jsonpFilter;
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:14,代码来源:ActRestApplication.java

示例9: createInboundRoot

import org.restlet.routing.Router; //导入方法依赖的package包/类
/**
 * Creates a root Restlet that will receive all incoming calls.
 */
@Override
public Restlet createInboundRoot() {
	Router router = new Router(getContext());
	router.attachDefault(ProcessRequest.class);
	return router;
       }
 
开发者ID:okbqa,项目名称:rocknrole,代码行数:10,代码来源:RestletApp.java


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