Search in sources :

Example 1 with WebConfiguration

use of org.apache.cayenne.configuration.web.WebConfiguration in project cayenne by apache.

the class ROPServlet method init.

@Override
public void init(ServletConfig configuration) throws ServletException {
    checkAlreadyConfigured(configuration.getServletContext());
    this.servletContext = configuration.getServletContext();
    WebConfiguration configAdapter = new WebConfiguration(configuration);
    String configurationLocation = configAdapter.getConfigurationLocation();
    Map<String, String> eventBridgeParameters = configAdapter.getOtherParameters();
    Collection<Module> modules = configAdapter.createModules();
    ServerRuntime runtime = ServerRuntime.builder().addConfig(configurationLocation).addModules(modules).addModule(binder -> ROPServerModule.contributeROPBridgeProperties(binder).putAll(eventBridgeParameters)).build();
    this.remoteService = runtime.getInjector().getInstance(RemoteService.class);
    this.serializationService = runtime.getInjector().getInstance(ROPSerializationService.class);
    WebUtil.setCayenneRuntime(servletContext, runtime);
    super.init(configuration);
}
Also used : ServletConfig(javax.servlet.ServletConfig) HttpServlet(javax.servlet.http.HttpServlet) WebUtil(org.apache.cayenne.configuration.web.WebUtil) ServletException(javax.servlet.ServletException) Collection(java.util.Collection) HttpServletResponse(javax.servlet.http.HttpServletResponse) RemoteSession(org.apache.cayenne.remote.RemoteSession) Module(org.apache.cayenne.di.Module) IOException(java.io.IOException) ROPServerModule(org.apache.cayenne.configuration.rop.server.ROPServerModule) CayenneRuntime(org.apache.cayenne.configuration.CayenneRuntime) HttpServletRequest(javax.servlet.http.HttpServletRequest) Map(java.util.Map) ServletContext(javax.servlet.ServletContext) ClientMessage(org.apache.cayenne.remote.ClientMessage) WebConfiguration(org.apache.cayenne.configuration.web.WebConfiguration) RemoteService(org.apache.cayenne.remote.RemoteService) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) RemoteService(org.apache.cayenne.remote.RemoteService) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) Module(org.apache.cayenne.di.Module) ROPServerModule(org.apache.cayenne.configuration.rop.server.ROPServerModule) WebConfiguration(org.apache.cayenne.configuration.web.WebConfiguration)

Example 2 with WebConfiguration

use of org.apache.cayenne.configuration.web.WebConfiguration in project cayenne by apache.

the class Http2ROPServlet method init.

@Override
public void init(ServletConfig configuration) throws ServletException {
    checkAlreadyConfigured(configuration.getServletContext());
    this.servletContext = configuration.getServletContext();
    WebConfiguration configAdapter = new WebConfiguration(configuration);
    String configurationLocation = configAdapter.getConfigurationLocation();
    Map<String, String> eventBridgeParameters = configAdapter.getOtherParameters();
    Collection<Module> modules = configAdapter.createModules();
    ServerRuntime runtime = ServerRuntime.builder().addConfig(configurationLocation).addModule(binder -> ROPServerModule.contributeROPBridgeProperties(binder).putAll(eventBridgeParameters)).addModules(modules).build();
    this.remoteService = runtime.getInjector().getInstance(RemoteService.class);
    this.serializationService = runtime.getInjector().getInstance(ROPSerializationService.class);
    WebUtil.setCayenneRuntime(servletContext, runtime);
}
Also used : RemoteService(org.apache.cayenne.remote.RemoteService) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) ROPSerializationService(org.apache.cayenne.rop.ROPSerializationService) Module(org.apache.cayenne.di.Module) ROPServerModule(org.apache.cayenne.configuration.rop.server.ROPServerModule) WebConfiguration(org.apache.cayenne.configuration.web.WebConfiguration)

Aggregations

ROPServerModule (org.apache.cayenne.configuration.rop.server.ROPServerModule)2 ServerRuntime (org.apache.cayenne.configuration.server.ServerRuntime)2 WebConfiguration (org.apache.cayenne.configuration.web.WebConfiguration)2 Module (org.apache.cayenne.di.Module)2 RemoteService (org.apache.cayenne.remote.RemoteService)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Map (java.util.Map)1 ServletConfig (javax.servlet.ServletConfig)1 ServletContext (javax.servlet.ServletContext)1 ServletException (javax.servlet.ServletException)1 HttpServlet (javax.servlet.http.HttpServlet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 CayenneRuntime (org.apache.cayenne.configuration.CayenneRuntime)1 WebUtil (org.apache.cayenne.configuration.web.WebUtil)1 ClientMessage (org.apache.cayenne.remote.ClientMessage)1 RemoteSession (org.apache.cayenne.remote.RemoteSession)1 ROPSerializationService (org.apache.cayenne.rop.ROPSerializationService)1