本文整理了Java中org.restlet.Application
类的一些代码示例,展示了Application
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application
类的具体详情如下:
包路径:org.restlet.Application
类名称:Application
[英]Restlet that can be attached to one or more VirtualHosts. Applications are guaranteed to receive calls with their base reference set relatively to the VirtualHost that served them. This class is both a descriptor able to create the root Restlet and the actual Restlet that can be attached to one or more VirtualHost instances.
Applications also have many useful Services associated. They are available as properties that can be eventually overriden:
代码示例来源:origin: uber/chaperone
public AdminRestletResource() {
_helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext()
.getAttributes().get(HelixMirrorMakerManager.class.toString());
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Returns the parent application if it exists, or null.
*
* @return The parent application if it exists, or null.
*/
public Application getApplication() {
return Application.getCurrent();
}
代码示例来源:origin: uber/chaperone
_component.getClients().add(Protocol.WAR);
final Context applicationContext = _component.getContext().createChildContext();
applicationContext.getAttributes().put(ControllerConf.class.toString(), _config);
applicationContext.getAttributes().put(HelixMirrorMakerManager.class.toString(), _helixMirrorMakerManager);
applicationContext.getAttributes().put(ValidationManager.class.toString(), _validationManager);
_controllerRestApp.setContext(applicationContext);
代码示例来源:origin: ontopia/ontopia
public static Context getCurrentApplicationContext() {
Application application = Application.getCurrent();
if (application == null) {
return null;
}
return application.getContext();
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.osgi
/**
* Called to construct the actual application instance. Extenders will
* generally override this method.
*
* @param context
* the Restlet application context
* @return the newly constructed application instance
*/
protected Application doCreateApplication(Context context) {
// FIXME Workaround for a bug in Restlet 2.1M7 - the context should be
// passed to the Application
// constructor.
Application app = new Application();
app.setContext(context);
return app;
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.osgi
/**
* Called by OSGi DS to inject the router provider service
*
* @param routerProvider
* the router provider service
*/
public void bindRouterProvider(RouterProvider routerProvider) {
this.routerProvider = routerProvider;
if (application != null)
application.setInboundRoot(routerProvider
.getInboundRoot(application.getContext()));
}
代码示例来源:origin: org.restlet/org.restlet.ext.servlet
application.setContext(parentContext.createChildContext());
} catch (NoSuchMethodException e) {
log("[Restlet] ServerServlet couldn't invoke the constructor of the target class. Please check this class has a constructor without parameter. The constructor with a parameter of type Context will be used instead.");
parentContext.createChildContext());
final Context applicationContext = application.getContext();
.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
applicationContext.getParameters().add(initParam,
servletConfig.getInitParameter(initParam));
代码示例来源:origin: org.restlet.jee/org.restlet.ext.platform
.getDescription()));
if (application.toString().equals(application.getName())) {
LOGGER.log(Level.WARNING,
"Please provide a name to your application by overriding its method getName. Used "
contract.setName(application.getClass().getSimpleName());
} else {
contract.setName(application.getName());
application.getInboundRoot(), null /*
代码示例来源:origin: com.noelios.restlet/com.noelios.restlet.ext.servlet
application.setContext(new ServletContextAdapter(this,
parentContext));
} catch (NoSuchMethodException e) {
final Context applicationContext = application.getContext();
.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
applicationContext.getParameters().add(initParam,
servletConfig.getInitParameter(initParam));
.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
applicationContext.getParameters().add(initParam,
getServletContext().getInitParameter(initParam));
代码示例来源:origin: locationtech/geowave
final Context appContext = Application.getCurrent().getContext();
final ExecutorService opPool =
(ExecutorService) appContext.getAttributes().get("asyncOperationPool");
final ConcurrentHashMap<String, Future> opStatuses =
(ConcurrentHashMap<String, Future>) appContext.getAttributes().get(
"asyncOperationStatuses");
代码示例来源:origin: org.restlet/org.restlet
if (isStopped()) {
super.start();
if (getHelper() != null) {
getHelper().start();
if (getConnectorService() != null) {
getConnectorService().start();
if (getConverterService() != null) {
getConverterService().start();
if (getDecoderService() != null) {
getDecoderService().start();
if (getMetadataService() != null) {
getMetadataService().start();
if (getRangeService() != null) {
getRangeService().start();
if (getStatusService() != null) {
getStatusService().start();
if (getTaskService() != null) {
getTaskService().start();
if (getTunnelService() != null) {
getTunnelService().start();
代码示例来源:origin: unchartedsoftware/aperture-tiles
/**
* Creates the restlet application that will be used to handle all rest calls
* Takes a map of paths to resource classes
* <p/>
* Use the following three lines to access the routing multibinder:
* TypeLiteral<String> pathType = new TypeLiteral<String>() {};
* TypeLiteral<Class<? extends ServerResource>> clazzType = new TypeLiteral<Class<? extends ServerResource>>() {};
* MapBinder<String, Class<? extends ServerResource>> resourceBinder = MapBinder.newMapBinder(binder(), pathType, clazzType);
* resourceBinder.bind("/my/path").toInstance(MyResource.class);
*/
@Provides
Application createApplication( FinderFactory factory, Map<String, Class<? extends ServerResource>> routes ) {
Context context = new Context();
Application application = new Application();
application.setContext( context );
Router router = new Router( context );
// Set binding rules here
for ( Entry<String, Class<? extends ServerResource>> entry : routes.entrySet() ) {
final Class<? extends ServerResource> resource = entry.getValue();
logger.info( "Binding '" + entry.getKey() + "' to " + resource );
router.attach( entry.getKey(), factory.finder( resource ) );
}
application.setInboundRoot( router );
return application;
}
代码示例来源:origin: org.restlet.osgi/org.restlet
if (Application.getCurrent() != null
&& !Application.getCurrent().isDebugging()) {
Context.getCurrentLogger()
.log(Level.WARNING,
"The cause of the exception should be null except in debug mode");
representationObject, variant);
} catch (Exception e) {
Context.getCurrentLogger().log(
Level.WARNING,
"Could not serialize throwable class "
代码示例来源:origin: org.restlet/org.restlet
public void execute(final Runnable runnable) {
// Save the thread local variables
final Application currentApplication = Application.getCurrent();
final Context currentContext = Context.getCurrent();
final Integer currentVirtualHost = VirtualHost.getCurrent();
final Response currentResponse = Response.getCurrent();
executorService.execute(new Runnable() {
public void run() {
// Copy the thread local variables
Response.setCurrent(currentResponse);
Context.setCurrent(currentContext);
VirtualHost.setCurrent(currentVirtualHost);
Application.setCurrent(currentApplication);
try {
// Run the user task
runnable.run();
} finally {
// Reset the thread local variables
Response.setCurrent(null);
Context.setCurrent(null);
VirtualHost.setCurrent(-1);
Application.setCurrent(null);
}
}
});
}
代码示例来源:origin: apache/attic-polygene-java
@Override
public synchronized void start()
throws Exception
{
setName( polygeneApplication.name() );
Series<Parameter> parameters = getContext().getParameters();
String mode = parameters.getFirstValue( "org.apache.polygene.runtime.mode" );
super.start();
getLogger().info( "RestApplication successfully started." );
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
metadataService = Application.getCurrent().getMetadataService();
StringTokenizer stt = new StringTokenizer(extensions, ".");
while (stt.hasMoreTokens()) {
代码示例来源:origin: stackoverflow.com
Router router = new Router(); // Remove final from this.
router.attachDefault(HttpListener.class);
Component component = new Component();
Context ctx = component.getApplication().getContext().createChildContext(); // Remove final
ctx.getAttributes().put("mysharedobj", new MySharedObj());
org.restlet.Application myApp = new org.restlet.Application(ctx) {
@Override
public org.restlet.Restlet createInboundRoot() {
return router;
};
};
代码示例来源:origin: org.restlet.osgi/org.restlet
Filter filter = null;
for (Service service : getHelped().getServices()) {
if (service.isEnabled()) {
: getContext().createChildContext());
: getContext().createChildContext());
setInboundNext(getHelped().getInboundRoot());
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the metadata service of the parent application.
*
* @return The metadata service of the parent application.
*/
public MetadataService getMetadataService() {
return getApplication().getMetadataService();
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
public Representation getRepresentation(Status status, Request request,
Response response) {
// Create the data model
Map<String, String> dataModel = new ConcurrentHashMap<String, String>();
dataModel.put("applicationName", Application.getCurrent().getName());
dataModel.put("statusDescription", response.getStatus()
.getDescription());
dataModel.put("statusReasonPhrase", response.getStatus()
.getReasonPhrase());
// Load the FreeMarker template
Representation mailFtl = new ClientResource(
LocalReference.createClapReference(getClass().getPackage())
+ "/MailStatus.ftl").get();
// Wraps the bean with a FreeMarker representation
return new TemplateRepresentation(mailFtl, dataModel,
MediaType.TEXT_HTML);
}
内容来源于网络,如有侵权,请联系作者删除!