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


Java Application类代码示例

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


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

示例1: configure

import org.restlet.Application; //导入依赖的package包/类
@Override
protected final void configure() {

    if (injector != null) {
        throw new IllegalStateException(
                "can't reconfigure with existing Injector");
    }

    if (!alreadyBound.get()) {
        alreadyBound.set(true);

        bind(FinderFactory.class).toInstance(this);

        bind(Application.class).toProvider(newApplicationProvider());
        bind(Context.class).toProvider(newContextProvider());
        bind(Request.class).toProvider(newRequestProvider());
        bind(Response.class).toProvider(newResponseProvider());
    }

    for (com.google.inject.Module module : modules) {
        install(module);
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:24,代码来源:RestletGuice.java

示例2: findRoles

import org.restlet.Application; //导入依赖的package包/类
/**
 * Finds the roles mapped to a given user group.
 * 
 * @param application
 *            The parent application. Can't be null.
 * @param userGroup
 *            The user group.
 * @return The roles found.
 * @throws IllegalArgumentException
 *             If application is null.
 */
public Set<Role> findRoles(Application application, Group userGroup) {
    if (application == null) {
        throw new IllegalArgumentException(
                "The application argument can't be null");
    }

    Set<Role> result = new HashSet<Role>();
    Object source;

    for (RoleMapping mapping : getRoleMappings()) {
        source = mapping.getSource();

        if ((userGroup != null) && userGroup.equals(source)) {
            if (mapping.getTarget().getApplication() == application) {
                result.add(mapping.getTarget());
            }
        }
    }

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

示例3: getApplicationTask

import org.restlet.Application; //导入依赖的package包/类
/**
 * Gets the application task.
 * 
 * @return The application task or null if the application was not found
 * @see InstanceUtil#getApplication(String)
 */
public ApplicationTask<T> getApplicationTask()
{
	if( applicationTask == null )
	{
		Application application = InstanceUtil.getApplication( applicationName );
		if( application != null )
		{
			if( code != null )
				applicationTask = new ApplicationTask<T>( application, code, context );
			else
				applicationTask = new ApplicationTask<T>( application, documentName, entryPointName, context );
		}
	}

	return applicationTask;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:23,代码来源:SerializableApplicationTask.java

示例4: getApplication

import org.restlet.Application; //导入依赖的package包/类
/**
 * Gets an application associated with the current Prudence instance.
 * <p>
 * Expects that a map of applications was set in the
 * "com.threecrickets.prudence.applications" attribute of the component's
 * context.
 * 
 * @param name
 *        The application's full name
 * @return The application or null
 * @see #getComponent()
 */
public static Application getApplication( String name )
{
	Component component = getComponent();
	if( component != null )
	{
		ConcurrentMap<String, Object> attributes = component.getContext().getAttributes();
		if( attributes != null )
		{
			@SuppressWarnings("unchecked")
			Iterable<Application> applications = (Iterable<Application>) attributes.get( APPLICATIONS_ATTRIBUTE );
			if( applications != null )
				for( Application application : applications )
					if( name.equals( application.getName() ) )
						return application;
		}
	}

	return null;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:32,代码来源:InstanceUtil.java

示例5: ClassResource

import org.restlet.Application; //导入依赖的package包/类
/** Creates a new instance of ClassResource */
public ClassResource(ClassLoader classLoader,String path)
{
   setNegotiated(false);
   this.classLoader = classLoader;
   this.path = path;
   int extPos = path.lastIndexOf('.');
   Application app = this.getApplication();
   type = app.getMetadataService().getDefaultMediaType(); 
   if (extPos>=0) {
      String ext = path.substring(extPos+1);
      Metadata mdata = this.getApplication().getMetadataService().getMetadata(ext);
      if (mdata!=null) {
         type = MediaType.valueOf(mdata.getName());
      }
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:18,代码来源:ClassResource.java

示例6: ClassResource

import org.restlet.Application; //导入依赖的package包/类
/** Creates a new instance of ClassResource */
public ClassResource(Class baseClass,String path)
{
   setNegotiated(false);
   this.baseClass = baseClass;
   this.path = path;
   int extPos = path.lastIndexOf('.');
   Application app = this.getApplication();
   type = app.getMetadataService().getDefaultMediaType(); 
   if (extPos>=0) {
      String ext = path.substring(extPos+1);
      Metadata mdata = this.getApplication().getMetadataService().getMetadata(ext);
      if (mdata!=null) {
         type = MediaType.valueOf(mdata.getName());
      }
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:18,代码来源:LoginApplication.java

示例7: ReportRouter

import org.restlet.Application; //导入依赖的package包/类
public ReportRouter(Context context, Application application) throws ConfigurationException, ValidationException {
	super(context);

	String reportsLocation = Configuration.getInstance().getProperty("slipstream.reports.location");

	Authorizer authorizer = new ReportsAuthorizer();
	Authenticator authenticator = new CookieAuthenticator(getContext());
	authenticator.setOptional(false);
	authenticator.setEnroler(new SuperEnroler(application));
	authenticator.setNext(authorizer);

	ResultsDirectory directory = new ResultsDirectory(getContext(), "file://" + reportsLocation);
	Filter decorator = new ReportDecorator();
	decorator.setNext(directory);
	authorizer.setNext(decorator);
	attach("", authenticator);
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:18,代码来源:ReportRouter.java

示例8: main

import org.restlet.Application; //导入依赖的package包/类
public static void main(String[] args) throws ValidationException {

		Component component = new Component();

		component.getServers().add(Protocol.HTTP, 8182);
		component.getClients().add(Protocol.FILE);
		component.getClients().add(Protocol.HTTP);
		Application rootApplication = new RootApplication();
		component.getDefaultHost().attach("", rootApplication);

		try {
			component.start();
		} catch (Exception e) {
			log.log(Level.SEVERE, "Start error", e);
			log.severe("Starting SlipStream FAILED!");
			System.exit(1);
		}
		log.finest("SlipStream started!");
		log.finer("SlipStream started!");
		log.fine("SlipStream started!");
		log.info("SlipStream started!");
	}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:23,代码来源:Main.java

示例9: setupApp

import org.restlet.Application; //导入依赖的package包/类
protected Application setupApp() throws Exception {

		final MapTrackerMemory memory = new MapTrackerMemory();

		memory.updateFile(new FileTrackingStatus(1L, 10L, "test1.txt",
				FileTrackingStatus.STATUS.READY, 3, 4L, "testType1", new Date(), new Date()));
		memory.updateFile(new FileTrackingStatus(1L, 10L, "test2.txt",
				FileTrackingStatus.STATUS.READING, 3, 4L, "testType2", new Date(), new Date()));
		memory.updateFile(new FileTrackingStatus(1L, 10L, "test3.txt",
				FileTrackingStatus.STATUS.DONE, 3, 4L, "testType3", new Date(), new Date()));

		this.memory = memory;

		Finder finder = new Finder() {

			@Override
			public ServerResource find(Request request, Response response) {
				return fileTrackingStatusResource(memory);
			}

		};

		final Router router = new Router();
		router.attach("/files/list", finder);
		router.attach("/files/list/", finder);
		router.attach("/files/list/{status}", finder);

		return new Application() {

			@Override
			public Restlet createInboundRoot() {
				return router;
			}

		};

	}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:38,代码来源:TestFileTrackerStatusResource.java

示例10: setupApp

import org.restlet.Application; //导入依赖的package包/类
protected Application setupApp() throws Exception {

		final MapTrackerMemory memory = new MapTrackerMemory();

		memory.updateFile(new FileTrackingStatus(1L, 10L, new File("test1.txt")
				.getAbsolutePath(), FileTrackingStatus.STATUS.READY, 3, 4L,
				"testType1", new Date(), new Date()));
		memory.updateFile(new FileTrackingStatus(1L, 10L, new File("test2.txt")
				.getAbsolutePath(), FileTrackingStatus.STATUS.READING, 3, 4L,
				"testType2", new Date(), new Date()));
		memory.updateFile(new FileTrackingStatus(1L, 10L, new File("test3.txt")
				.getAbsolutePath(), FileTrackingStatus.STATUS.DONE, 3, 4L,
				"testType3", new Date(), new Date()));

		this.memory = memory;

		Finder finder = new Finder() {

			@Override
			public ServerResource find(Request request, Response response) {
				return fileTrackingStatusPathResource(memory);
			}

		};

		final Router router = new Router();
		router.attach("/files/status", finder, Template.MODE_STARTS_WITH);
		Application app = new Application() {

			@Override
			public Restlet createInboundRoot() {
				return router;
			}

		};

		return app;
	}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:39,代码来源:TestFileTrackerStatusPathResource.java

示例11: restApplication

import org.restlet.Application; //导入依赖的package包/类
/**
 * Returns a restlet application object with the correct router
 * configuration and resources added.
 * 
 * @return
 */
@Bean
public Application restApplication() {

	final Router router = new Router();

	attachFinder(router, "/collector/status",
			CollectorStatusResource.class, Template.MODE_STARTS_WITH);

	attachFinder(router, "/config", CollectorConfigResource.class,
			Template.MODE_STARTS_WITH);

	attachFinder(router, "/collector/shutdown", AppShutdownResource.class,
			Template.MODE_STARTS_WITH);

	attachFinder(router, "/collectors/status",
			CollectorsStatusResource.class, Template.MODE_STARTS_WITH);

	attachFinder(router, "/agents/status", AgentsStatusResource.class,
			Template.MODE_STARTS_WITH);

	attachFinder(router, "/agent/files", AgentStatusResource.class,
			Template.MODE_STARTS_WITH);
	attachFinder(router, "/agent/files?{query}", AgentStatusResource.class,
			Template.MODE_STARTS_WITH);

	Application app = new Application() {

		@Override
		public Restlet createInboundRoot() {
			return router;
		}

	};

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

示例12: restletPingApplication

import org.restlet.Application; //导入依赖的package包/类
/**
 * Returns a restlet application for the PingOKResource
 * 
 * @return
 */
@Bean
public Application restletPingApplication() {

	final Router router = new Router();
	attachFinder(router, "/", PingOKResource.class,
			Template.MODE_STARTS_WITH);

	Application app = new Application() {

		@Override
		public Restlet createInboundRoot() {
			return router;
		}

	};

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

示例13: createComponent

import org.restlet.Application; //导入依赖的package包/类
/**
 * Creates a Component that will used this reasource to always return ok.
 * 
 * @param port
 * @return
 */
public static Component createComponent(int port) {

	Finder finder = new Finder() {

		@Override
		public ServerResource find(Request request, Response response) {
			return new AlwaysOKRestlet();
		}

	};

	final Router router = new Router();
	router.attach("/", finder, Template.MODE_STARTS_WITH);
	
	Application app = new Application() {

		@Override
		public Restlet createInboundRoot() {
			return router;
		}

	};

	Component component = new Component();
	component.getServers().add(org.restlet.data.Protocol.HTTP, port);
	component.getDefaultHost().attach(app);

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

示例14: newApplicationProvider

import org.restlet.Application; //导入依赖的package包/类
/**
 * Creates a {@link Provider}r for the current {@link Application}.
 * Override to use a custom Application provider.
 * 
 * @return A {@link Provider} for the current {@link Application}.
 */
protected Provider<Application> newApplicationProvider() {
    return new Provider<Application>() {
        public Application get() {
            return Application.getCurrent();
        }
    };
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:14,代码来源:RestletGuice.java

示例15: newRouter

import org.restlet.Application; //导入依赖的package包/类
/**
 * Returns a new instance of {@link Router} linked to this application.
 * 
 * @return A new instance of {@link Router}.
 */
public Router newRouter() {
    final Application app = this;
    return new Router(getContext()) {
        @Override
        public Application getApplication() {
            return app;
        }
    };
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:15,代码来源:ResourceInjectingApplication.java


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