com.cedarsoftware.config.NCubeConfiguration.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of n-cube Show documentation
Show all versions of n-cube Show documentation
Multi-dimensional Rule Engine
package com.cedarsoftware.config
import com.cedarsoftware.controller.NCubeController
import com.cedarsoftware.controller.NCubeControllerAdvice
import com.cedarsoftware.ncube.GroovyBase
import com.cedarsoftware.ncube.NCube
import com.cedarsoftware.ncube.NCubeAppContext
import com.cedarsoftware.ncube.NCubeJdbcPersisterAdapter
import com.cedarsoftware.ncube.NCubeManager
import com.cedarsoftware.ncube.NCubePersister
import com.cedarsoftware.ncube.NCubeRuntime
import com.cedarsoftware.ncube.PreCompiler
import com.cedarsoftware.ncube.rules.RulesConfiguration
import com.cedarsoftware.ncube.rules.RulesController
import com.cedarsoftware.ncube.util.CdnClassLoader
import com.cedarsoftware.ncube.util.GCacheManager
import com.cedarsoftware.util.HsqlSchemaCreator
import com.cedarsoftware.util.JsonHttpProxy
import com.cedarsoftware.util.ReflectiveProxy
import groovy.transform.CompileStatic
import ncube.grv.exp.NCubeGroovyExpression
import org.apache.http.HttpHost
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import javax.annotation.PostConstruct
/**
* We configure all NCube Spring beans here (annotation based). When pulling in the NCube library into a Spring / Spring
* Boot application, you need to set one (1) of three (3) profiles:
*
* - ncube-client: Use this if you are acting as a client of n-cube-storage server. You will use the NCubeRuntime
* class to talk to the ncube-storage-server.
* - ncube-storage-server: This springboot profile runs as a springboot app that takes HTTP JSON requests. The requests
* can be made directly or use the NCubeRuntime library to make them. This server only allows fetching and saving
* ncubes, any operations that do not execute code within an NCube.
* - ncube-combined-server: This springboot profile runs as a springboot app that takes HTTP JSON requests. The requests
* can be made directly or use the NCubeRuntime library to make them. This server does allow execution of code within
* the NCubes. Run the server in this mode for the NCubeEditor, for example - meaning this server is setup to be called
* from a Javascript front-end. The server can perform the executions needed (showing cell values in calculated mode, running
* NCube tests, etc.)
*
* In the consuming Springboot application, make sure you use the following in your Spring Application class:
{@code
...
@ComponentScan(basePackages = ['com.cedarsoftware.config'])
class NCubeApplication
...
}
For a Spring (but not Springboot) application to consume NCube, use the XML way to component scan:
{@literal<}context:component-scan base-package="com.cedarsoftware.config" /{@literal>}
* This will pick up all the NCube beans, including the NCubeRuntime bean.
*
* To make calls to the NCube servers, use the NCubeRuntime class:
import static com.cedarsoftware.ncube.NCubeAppContext.ncubeRuntime
...
NCube myCube = ncubeRuntime.getCube(...)
...
* @author John DeRegnaucourt ([email protected])
*
* Copyright (c) Cedar Software LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitatœions under the License.
*/
@CompileStatic
@Configuration
@ConfigurationProperties('ncube.performance')
@ComponentScan(basePackages = ['com.cedarsoftware.ncube.util'])
class NCubeConfiguration
{
// Target server (storage-server)
@Value('${ncube.target.host:localhost}') String host
@Value('${ncube.target.port:9000}') int port
@Value('${ncube.target.scheme:http}') String scheme
// JsonHttpProxy
@Value('${ncube.target.context:ncube}') String context
@Value('${ncube.target.username:#{null}}') String username
@Value('${ncube.target.password:#{null}}') String password
@Value('${ncube.target.numConnections:200}') int numConnections
@Value('${ncube.target.accessTokenUri:#{null}}') String accessTokenUri
// NCubeRuntime's cache
@Value('${ncube.cache.max.size:0}') int maxSizeNCubeCache
@Value('${ncube.cache.evict.type:expireAfterAccess}') String typeNCubeCache
@Value('${ncube.cache.evict.duration:4}') int durationNCubeCache
@Value('${ncube.cache.evict.units:hours}') String unitsNCubeCache
@Value('${ncube.cache.concurrency:16}') int concurrencyNCubeCache
// Permissions cache
@Value('${ncube.perm.cache.max.size:100000}') int maxSizePermCache
@Value('${ncube.perm.cache.evict.type:expireAfterAccess}') String typePermCache
@Value('${ncube.perm.cache.evict.duration:3}') int durationPermCache
@Value('${ncube.perm.cache.evict.units:minutes}') String unitsPermCache
@Value('${ncube.perm.cache.concurrency:16}') int concurrencyPermCache
// Location for generated source (optional) and compiled classes (optional)
@Value('${ncube.sources.dir:#{null}}') String sourcesDirectory
@Value('${ncube.classes.dir:#{null}}') String classesDirectory
// Limit size of coordinate displayed in each CommandCell exception list (--> [coordinate])
@Value('${ncube.stackEntry.coordinate.value.max:1000}') int stackEntryCoordinateValueMaxSize
// Limit coordinates displayed in each CommandCell exception list by key name (--> [coordinate])
@Value('${ncube.stackEntry.input.key.exclude:#{null}}') String stackEntryInputKeyExclude
// If true, "at" type methods on NCubeGroovyExpression will add their coords to their input map.
// This is legacy behavior that is probably not desirable going forward. We're allowing it for backwards compatibility.
@Value('${ncube.legacy.grv.exp:false}') boolean legacyNCubeGroovyExpression
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy