public.javadoc.org.spincast.plugins.undertow.SpincastUndertowServer.html Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of spincast-website Show documentation
                Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
                
            
SpincastUndertowServer (org.spincast:spincast-framework 0.9.21 API) 
org.spincast.plugins.undertow
Class SpincastUndertowServer
- java.lang.Object
 
- 
- org.spincast.plugins.undertow.SpincastUndertowServer
 
 
- 
- 
Field Summary
Fields  
Modifier and Type 
Field and Description 
 
protected org.slf4j.Logger 
logger  
 
static String 
UNDERTOW_EXCEPTION_CODE_REQUEST_TOO_LARGE  
 
 
- 
Constructor Summary
Constructors  
Constructor and Description 
 
SpincastUndertowServer(ISpincastConfig config,
                      ISpincastUndertowConfig spincastUndertowConfig,
                      IFrontController frontController,
                      ISpincastUtils spincastUtils,
                      ICookieFactory cookieFactory,
                      ICorsHandlerFactory corsHandlerFactory,
                      IGzipCheckerHandlerFactory gzipCheckerHandlerFactory,
                      IFileClassPathResourceManagerFactory fileClassPathResourceManagerFactory,
                      ISpincastHttpAuthIdentityManagerFactory spincastHttpAuthIdentityManagerFactory,
                      IWebsocketEndpointFactory spincastWebsocketEndpointFactory,
                      ISSLContextFactory sslContextFactory)
Constructor
 
 
 
- 
Method Summary
All Methods Instance Methods Concrete Methods  
Modifier and Type 
Method and Description 
 
protected io.undertow.Undertow.Builder 
addBuilderOptions(io.undertow.Undertow.Builder builder)  
 
void 
addCookies(Object exchange,
          Map<String,ICookie> cookies)
Adds cookies.
 
 
void 
addHttpAuthentication(String realmName,
                     String username,
                     String password)
Adds a user to an HTTP protected realm.
 
 
protected void 
addHttpListener(io.undertow.Undertow.Builder builder,
               String serverHost,
               int httpServerPort)  
 
protected void 
addHttpsListener(io.undertow.Undertow.Builder builder,
                String serverHost,
                int httpsServerPort)  
 
void 
addStaticResourceToServe(IStaticResource<?> staticResource)
Adds a static resource to serve directly by the server.
 
 
protected io.undertow.server.HttpServerExchange 
castExchange(Object exchange)  
 
void 
createHttpAuthenticationRealm(String pathPrefix,
                             String realmName)
Creates HTTP authentication protection (realm) for the
 specified path prefix.
 
 
protected IWebsocketEndpointHandler 
createUndertowWebsocketEndpointHandler(String endpointId,
                                      IWebsocketEndpointHandler appHandler)  
 
void 
end(Object exchange)
Ends the exchange.
 
 
void 
flushBytes(Object exchange,
          byte[] bytes,
          boolean end)
Flushes some bytes to the response.
 
 
boolean 
forceRequestSizeValidation(Object exchangeObj)
Is the request size valid?
 
 
protected io.undertow.io.IoCallback 
getCloseExchangeCallback()  
 
protected ISpincastConfig 
getConfig()  
 
ContentTypeDefaults 
getContentTypeBestMatch(Object exchangeObj)
Gets the best Content-Type to use for the current request.
 
 
protected String 
getCookieEncoding()  
 
protected ICookieFactory 
getCookieFactory()  
 
Map<String,ICookie> 
getCookies(Object exchange)
Gets the current cookies.
 
 
protected ICorsHandlerFactory 
getCorsHandlerFactory()  
 
protected io.undertow.io.IoCallback 
getDoNothingCallback()  
 
protected IFileClassPathResourceManagerFactory 
getFileClassPathResourceManagerFactory()  
 
protected io.undertow.server.HttpHandler 
getFinalHandler()
The very first handler considered by Undertow.
 
 
protected io.undertow.server.handlers.form.FormData 
getFormData(io.undertow.server.HttpServerExchange exchange)
May return NULL.
 
 
Map<String,List<String>> 
getFormDatas(Object exchangeObj)
The form datas, if any.
 
 
protected io.undertow.server.handlers.form.FormParserFactory 
getFormParserFactory()  
 
protected IFrontController 
getFrontController()  
 
String 
getFullUrl(Object exchangeObj)
The full encoded URL of the original request, including the queryString.
 
 
protected IGzipCheckerHandlerFactory 
getGzipCheckerHandlerFactory()  
 
protected Map<String,String> 
getHttpAuthActiveRealms()  
 
protected io.undertow.server.handlers.PathHandler 
getHttpAuthenticationHandler()
Handler to check for HTTP authentication requirement.
 
 
Map<String,String> 
getHttpAuthenticationRealms()
Returns the existing HTTP authentication realms, the
 key being the realm's name and the value being the
 prefix path associated to this realm.
 
 
protected io.undertow.server.HttpHandler 
getHttpAuthHandlerNextHandler()  
 
protected Map<String,ISpincastHttpAuthIdentityManager> 
getHttpAuthIdentityManagersByRealmName()  
 
HttpMethod 
getHttpMethod(Object exchange)
Gets the HTTP method associated with the request.
 
 
protected ISpincastHttpAuthIdentityManager 
getOrCreateHttpAuthIdentityManagersByRealmName(String realmName)  
 
Map<String,List<String>> 
getQueryStringParams(Object exchange)
Gets the queryString parameters.
 
 
InputStream 
getRawInputStream(Object exchangeObj)
The raw InputStream of the current request.
 
 
protected String 
getRealmNameToDisplay(String pathPrefix,
                     String realmName)
The realm name to display.
 
 
Map<String,List<String>> 
getRequestHeaders(Object exchangeObj)
The headers from the request.
 
 
String 
getRequestScheme(Object exchange)
Gets the request scheme, "http" for example.
 
 
Map<String,List<String>> 
getResponseHeaders(Object exchangeObj)
Gets the response headers.
 
 
protected io.undertow.Undertow.Builder 
getServerBuilder()  
 
protected int 
getServerStartTryNbr()  
 
protected io.undertow.server.HttpHandler 
getSpincastFrontControllerHandler()  
 
protected ISpincastHttpAuthIdentityManagerFactory 
getSpincastHttpAuthIdentityManagerFactory()  
 
protected ISpincastUndertowConfig 
getSpincastUndertowConfig()  
 
protected ISpincastUtils 
getSpincastUtils()  
 
protected IWebsocketEndpointFactory 
getSpincastWebsocketEndpointFactory()  
 
protected ISSLContextFactory 
getSslContextFactory()  
 
protected long 
getStartServerSleepMilliseconds()  
 
IStaticResource<?> 
getStaticResourceServed(String urlPath)
Gets a static resource served directly by the server, using its path.
 
 
protected io.undertow.server.handlers.PathHandler 
getStaticResourcesPathHandler()  
 
Set<IStaticResource<?>> 
getStaticResourcesServed()
Gets all static resource served directly by the server.
 
 
protected Map<String,IStaticResource<?>> 
getStaticResourcesServedByUrlPath()  
 
Map<String,List<File>> 
getUploadedFiles(Object exchangeObj)
The uploaded files, if any.
 
 
protected Object 
getWebsocketEndpointCreationLock(String endpointId)
Gets the creation/close lock for a specific Websocket endpoint.
 
 
IWebsocketEndpointManager 
getWebsocketEndpointManager(String endpointId)
Returns the manager for a Websockets endpoint.
 
 
List<IWebsocketEndpointManager> 
getWebsocketEndpointManagers()
Returns the managers of the existing Websockets endpoints.
 
 
protected Map<String,IWebsocketEndpoint> 
getWebsocketEndpointsMap()  
 
boolean 
isResponseClosed(Object exchange)
Is the response closed?
 
 
boolean 
isResponseHeadersSent(Object exchange)
Are the response headers sent?
 
 
void 
removeAllStaticResourcesServed()
Removes all static resources served directly by the server.
 
 
void 
removeHttpAuthentication(String username)
Removes a user from all HTTP protected realms.
 
 
void 
removeHttpAuthentication(String username,
                        String realmName)
Removes a user to an HTTP protected realm.
 
 
void 
removeResponseHeader(Object exchange,
                    String name)
Removes a response header.
 
 
protected void 
removeStaticResource(StaticResourceType staticResourceType,
                    String urlPath)  
 
void 
removeStaticResourcesServed(StaticResourceType staticResourceType,
                           String urlPath)
Removes a static resource served directly by the server.
 
 
protected void 
sendWebsocketEnpointsClosedWhenServerStops()  
 
void 
setResponseHeader(Object exchangeObj,
                 String name,
                 List<String> values)
Sets a response header.
 
 
void 
setResponseHeaders(Object exchange,
                  Map<String,List<String>> headers)
Sets the response headers.
 
 
void 
setResponseStatusCode(Object exchange,
                     int statusCode)
Sets the response status code.
 
 
void 
start()
Starts the server.
 
 
void 
stop()
Stops the server
 
 
void 
websocketCloseEndpoint(String endpointId)
Closes a Websocket endpoint.
 
 
void 
websocketCloseEndpoint(String endpointId,
                      int closingCode,
                      String closingReason)
Closes the entire Websocket endpoint.
 
 
void 
websocketConnection(Object exchangeObj,
                   String endpointId,
                   String peerId)
Transforms the request to a peer Websocket connection
 on the endpoint 'endpointId'.
 
 
IWebsocketEndpointManager 
websocketCreateEndpoint(String endpointId,
                       IWebsocketEndpointHandler appEndpointHandler)
Creates a new Websocket endpoint.
 
 
 
 
- 
- 
Field Detail
- 
logger
protected final org.slf4j.Logger logger
 
- 
UNDERTOW_EXCEPTION_CODE_REQUEST_TOO_LARGE
public static final String UNDERTOW_EXCEPTION_CODE_REQUEST_TOO_LARGE
- See Also:
 
- Constant Field Values
 
 
 
- 
Constructor Detail
- 
SpincastUndertowServer
@Inject
public SpincastUndertowServer(ISpincastConfig config,
                                       ISpincastUndertowConfig spincastUndertowConfig,
                                       IFrontController frontController,
                                       ISpincastUtils spincastUtils,
                                       ICookieFactory cookieFactory,
                                       ICorsHandlerFactory corsHandlerFactory,
                                       IGzipCheckerHandlerFactory gzipCheckerHandlerFactory,
                                       IFileClassPathResourceManagerFactory fileClassPathResourceManagerFactory,
                                       ISpincastHttpAuthIdentityManagerFactory spincastHttpAuthIdentityManagerFactory,
                                       IWebsocketEndpointFactory spincastWebsocketEndpointFactory,
                                       ISSLContextFactory sslContextFactory)
Constructor
 
 
- 
Method Detail
- 
getConfig
protected ISpincastConfig getConfig()
 
- 
getSpincastUndertowConfig
protected ISpincastUndertowConfig getSpincastUndertowConfig()
 
- 
getFrontController
protected IFrontController getFrontController()
 
- 
getSpincastUtils
protected ISpincastUtils getSpincastUtils()
 
- 
getCookieFactory
protected ICookieFactory getCookieFactory()
 
- 
getCorsHandlerFactory
protected ICorsHandlerFactory getCorsHandlerFactory()
 
- 
getGzipCheckerHandlerFactory
protected IGzipCheckerHandlerFactory getGzipCheckerHandlerFactory()
 
- 
getFileClassPathResourceManagerFactory
protected IFileClassPathResourceManagerFactory getFileClassPathResourceManagerFactory()
 
- 
getSpincastHttpAuthIdentityManagerFactory
protected ISpincastHttpAuthIdentityManagerFactory getSpincastHttpAuthIdentityManagerFactory()
 
- 
getSpincastWebsocketEndpointFactory
protected IWebsocketEndpointFactory getSpincastWebsocketEndpointFactory()
 
- 
getStaticResourcesServedByUrlPath
protected Map<String,IStaticResource<?>> getStaticResourcesServedByUrlPath()
 
- 
getHttpAuthIdentityManagersByRealmName
protected Map<String,ISpincastHttpAuthIdentityManager> getHttpAuthIdentityManagersByRealmName()
 
- 
getWebsocketEndpointsMap
protected Map<String,IWebsocketEndpoint> getWebsocketEndpointsMap()
 
- 
getSslContextFactory
protected ISSLContextFactory getSslContextFactory()
 
- 
getHttpAuthenticationRealms
public Map<String,String> getHttpAuthenticationRealms()
Description copied from interface: IServer
Returns the existing HTTP authentication realms, the
 key being the realm's name and the value being the
 prefix path associated to this realm.
 
 The map is immutable.
 
- Specified by:
 
getHttpAuthenticationRealms in interface IServer 
 
- 
getFormParserFactory
protected io.undertow.server.handlers.form.FormParserFactory getFormParserFactory()
 
- 
start
public void start()
Description copied from interface: IServer
Starts the server.
 
- 
getServerStartTryNbr
protected int getServerStartTryNbr()
 
- 
getStartServerSleepMilliseconds
protected long getStartServerSleepMilliseconds()
 
- 
getServerBuilder
protected io.undertow.Undertow.Builder getServerBuilder()
 
- 
addHttpListener
protected void addHttpListener(io.undertow.Undertow.Builder builder,
                               String serverHost,
                               int httpServerPort)
 
- 
addHttpsListener
protected void addHttpsListener(io.undertow.Undertow.Builder builder,
                                String serverHost,
                                int httpsServerPort)
 
- 
addBuilderOptions
protected io.undertow.Undertow.Builder addBuilderOptions(io.undertow.Undertow.Builder builder)
 
- 
getFinalHandler
protected io.undertow.server.HttpHandler getFinalHandler()
The very first handler considered by Undertow.
 
- 
getHttpAuthenticationHandler
protected io.undertow.server.handlers.PathHandler getHttpAuthenticationHandler()
Handler to check for HTTP authentication requirement.
 
- 
getHttpAuthHandlerNextHandler
protected io.undertow.server.HttpHandler getHttpAuthHandlerNextHandler()
 
- 
createHttpAuthenticationRealm
public void createHttpAuthenticationRealm(String pathPrefix,
                                          String realmName)
Description copied from interface: IServer
Creates HTTP authentication protection (realm) for the
 specified path prefix.
- Specified by:
 
createHttpAuthenticationRealm in interface IServer 
realmName - The name of the realm. Must be unique on this server,
 otherwise an exception is thrown. This allows the application to add
 user to the realm using its name. 
 
- 
getRealmNameToDisplay
protected String getRealmNameToDisplay(String pathPrefix,
                                       String realmName)
The realm name to display.
 
- 
getOrCreateHttpAuthIdentityManagersByRealmName
protected ISpincastHttpAuthIdentityManager getOrCreateHttpAuthIdentityManagersByRealmName(String realmName)
 
- 
addHttpAuthentication
public void addHttpAuthentication(String realmName,
                                  String username,
                                  String password)
Description copied from interface: IServer
Adds a user to an HTTP protected realm.
- Specified by:
 
addHttpAuthentication in interface IServer 
 
- 
removeHttpAuthentication
public void removeHttpAuthentication(String username,
                                     String realmName)
Description copied from interface: IServer
Removes a user to an HTTP protected realm.
- Specified by:
 
removeHttpAuthentication in interface IServer 
 
- 
removeHttpAuthentication
public void removeHttpAuthentication(String username)
Description copied from interface: IServer
Removes a user from all HTTP protected realms.
- Specified by:
 
removeHttpAuthentication in interface IServer 
 
- 
getSpincastFrontControllerHandler
protected io.undertow.server.HttpHandler getSpincastFrontControllerHandler()
 
- 
stop
public void stop()
Description copied from interface: IServer
Stops the server
 
- 
sendWebsocketEnpointsClosedWhenServerStops
protected void sendWebsocketEnpointsClosedWhenServerStops()
 
- 
getStaticResourcesPathHandler
protected io.undertow.server.handlers.PathHandler getStaticResourcesPathHandler()
 
- 
addStaticResourceToServe
public void addStaticResourceToServe(IStaticResource<?> staticResource)
Description copied from interface: IServer
Adds a static resource to serve directly by the server.
- Specified by:
 
addStaticResourceToServe in interface IServer 
 
- 
removeStaticResourcesServed
public void removeStaticResourcesServed(StaticResourceType staticResourceType,
                                        String urlPath)
Description copied from interface: IServer
Removes a static resource served directly by the server.
- Specified by:
 
removeStaticResourcesServed in interface IServer 
 
- 
removeAllStaticResourcesServed
public void removeAllStaticResourcesServed()
Description copied from interface: IServer
Removes all static resources served directly by the server.
- Specified by:
 
removeAllStaticResourcesServed in interface IServer 
 
- 
removeStaticResource
protected void removeStaticResource(StaticResourceType staticResourceType,
                                    String urlPath)
 
- 
getStaticResourceServed
public IStaticResource<?> getStaticResourceServed(String urlPath)
Description copied from interface: IServer
Gets a static resource served directly by the server, using its path.
- Specified by:
 
getStaticResourceServed in interface IServer 
 
- 
getStaticResourcesServed
public Set<IStaticResource<?>> getStaticResourcesServed()
Description copied from interface: IServer
Gets all static resource served directly by the server.
- Specified by:
 
getStaticResourcesServed in interface IServer 
 
- 
getHttpMethod
public HttpMethod getHttpMethod(Object exchange)
Description copied from interface: IServer
Gets the HTTP method associated with the request.
- Specified by:
 
getHttpMethod in interface IServer 
 
- 
castExchange
protected io.undertow.server.HttpServerExchange castExchange(Object exchange)
 
- 
getContentTypeBestMatch
public ContentTypeDefaults getContentTypeBestMatch(Object exchangeObj)
Description copied from interface: IServer
Gets the best Content-Type to use for the current request.
- Specified by:
 
getContentTypeBestMatch in interface IServer 
 
- 
getFullUrl
public String getFullUrl(Object exchangeObj)
Description copied from interface: IServer
The full encoded URL of the original request, including the queryString. 
 Even if the request is forwarded elsewhere in the framework, this
 URL won't change, it will still be the original one.
- Specified by:
 
getFullUrl in interface IServer 
 
- 
setResponseHeader
public void setResponseHeader(Object exchangeObj,
                              String name,
                              List<String> values)
Description copied from interface: IServer
Sets a response header. Override any existing one with the same name.
- Specified by:
 
setResponseHeader in interface IServer 
 
- 
setResponseHeaders
public void setResponseHeaders(Object exchange,
                               Map<String,List<String>> headers)
Description copied from interface: IServer
Sets the response headers. Override any existing ones.
- Specified by:
 
setResponseHeaders in interface IServer 
 
- 
getResponseHeaders
public Map<String,List<String>> getResponseHeaders(Object exchangeObj)
Description copied from interface: IServer
Gets the response headers.
- Specified by:
 
getResponseHeaders in interface IServer 
 
- 
removeResponseHeader
public void removeResponseHeader(Object exchange,
                                 String name)
Description copied from interface: IServer
Removes a response header.
- Specified by:
 
removeResponseHeader in interface IServer 
 
- 
setResponseStatusCode
public void setResponseStatusCode(Object exchange,
                                  int statusCode)
Description copied from interface: IServer
Sets the response status code.
- Specified by:
 
setResponseStatusCode in interface IServer 
 
- 
getDoNothingCallback
protected io.undertow.io.IoCallback getDoNothingCallback()
 
- 
getCloseExchangeCallback
protected io.undertow.io.IoCallback getCloseExchangeCallback()
 
- 
flushBytes
public void flushBytes(Object exchange,
                       byte[] bytes,
                       boolean end)
Description copied from interface: IServer
Flushes some bytes to the response.
- Specified by:
 
flushBytes in interface IServer 
end - if true, the exchange will be closed
 and nothing more can be send. 
 
- 
end
public void end(Object exchange)
Description copied from interface: IServer
Ends the exchange. Nothing more can be send.
 
- 
isResponseClosed
public boolean isResponseClosed(Object exchange)
Description copied from interface: IServer
Is the response closed?
- Specified by:
 
isResponseClosed in interface IServer 
 
- 
isResponseHeadersSent
public boolean isResponseHeadersSent(Object exchange)
Description copied from interface: IServer
Are the response headers sent?
- Specified by:
 
isResponseHeadersSent in interface IServer 
 
- 
getRequestScheme
public String getRequestScheme(Object exchange)
Description copied from interface: IServer
Gets the request scheme, "http" for example.
- Specified by:
 
getRequestScheme in interface IServer 
 
- 
addCookies
public void addCookies(Object exchange,
                       Map<String,ICookie> cookies)
Description copied from interface: IServer
Adds cookies.
- Specified by:
 
addCookies in interface IServer 
 
- 
getCookies
public Map<String,ICookie> getCookies(Object exchange)
Description copied from interface: IServer
Gets the current cookies.
- Specified by:
 
getCookies in interface IServer 
 
- 
getCookieEncoding
protected String getCookieEncoding()
 
- 
getQueryStringParams
public Map<String,List<String>> getQueryStringParams(Object exchange)
Description copied from interface: IServer
Gets the queryString parameters.
- Specified by:
 
getQueryStringParams in interface IServer 
 
- 
getRawInputStream
public InputStream getRawInputStream(Object exchangeObj)
Description copied from interface: IServer
The raw InputStream of the current request.
- Specified by:
 
getRawInputStream in interface IServer 
 
- 
getFormData
protected io.undertow.server.handlers.form.FormData getFormData(io.undertow.server.HttpServerExchange exchange)
May return NULL.
 
- 
getFormDatas
public Map<String,List<String>> getFormDatas(Object exchangeObj)
Description copied from interface: IServer
The form datas, if any.
- Specified by:
 
getFormDatas in interface IServer 
 
- 
getUploadedFiles
public Map<String,List<File>> getUploadedFiles(Object exchangeObj)
Description copied from interface: IServer
The uploaded files, if any.
- Specified by:
 
getUploadedFiles in interface IServer 
 
- 
forceRequestSizeValidation
public boolean forceRequestSizeValidation(Object exchangeObj)
Description copied from interface: IServer
Is the request size valid?
- Specified by:
 
forceRequestSizeValidation in interface IServer 
 
- 
getRequestHeaders
public Map<String,List<String>> getRequestHeaders(Object exchangeObj)
Description copied from interface: IServer
The headers from the request. 
 The names are all lowercased.
- Specified by:
 
getRequestHeaders in interface IServer 
 
- 
getWebsocketEndpointCreationLock
protected Object getWebsocketEndpointCreationLock(String endpointId)
Gets the creation/close lock for a specific Websocket endpoint.
 
- 
websocketCreateEndpoint
public IWebsocketEndpointManager websocketCreateEndpoint(String endpointId,
                                                         IWebsocketEndpointHandler appEndpointHandler)
Description copied from interface: IServer
Creates a new Websocket endpoint.
- Specified by:
 
websocketCreateEndpoint in interface IServer 
- Returns:
 
- the manager for this endpoint.
 
 
- 
createUndertowWebsocketEndpointHandler
protected IWebsocketEndpointHandler createUndertowWebsocketEndpointHandler(String endpointId,
                                                                           IWebsocketEndpointHandler appHandler)
 
- 
websocketCloseEndpoint
public void websocketCloseEndpoint(String endpointId)
Description copied from interface: IServer
Closes a Websocket endpoint. No more connections will
 be accepter
- Specified by:
 
websocketCloseEndpoint in interface IServer 
 
- 
websocketCloseEndpoint
public void websocketCloseEndpoint(String endpointId,
                                   int closingCode,
                                   String closingReason)
Description copied from interface: IServer
Closes the entire Websocket endpoint. 
 All peer connections of this endpoint will be
 closed.
- Specified by:
 
websocketCloseEndpoint in interface IServer 
closingCode - The closing code. 
closingReason - The closing reason. 
 
- 
websocketConnection
public void websocketConnection(Object exchangeObj,
                                String endpointId,
                                String peerId)
Description copied from interface: IServer
Transforms the request to a peer Websocket connection
 on the endpoint 'endpointId'.
- Specified by:
 
websocketConnection in interface IServer 
 
- 
getWebsocketEndpointManagers
public List<IWebsocketEndpointManager> getWebsocketEndpointManagers()
Description copied from interface: IServer
Returns the managers of the existing Websockets endpoints.
- Specified by:
 
getWebsocketEndpointManagers in interface IServer 
 
- 
getWebsocketEndpointManager
public IWebsocketEndpointManager getWebsocketEndpointManager(String endpointId)
Description copied from interface: IServer
Returns the manager for a Websockets endpoint.
- Specified by:
 
getWebsocketEndpointManager in interface IServer 
- Returns:
 
- the manager or 
null if not found. 
 
 
 
Copyright © 2016. All rights reserved.
    © 2015 - 2025 Weber Informatics LLC | Privacy Policy