Author: thomasm
Date: Fri Oct 14 11:49:57 2016
New Revision: 1764879

URL: http://svn.apache.org/viewvc?rev=1764879&view=rev
Log:
OAK-4817 QueryEngineSettings without MBean

Added:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java
Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java?rev=1764879&r1=1764878&r2=1764879&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java 
(original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java 
Fri Oct 14 11:49:57 2016
@@ -79,6 +79,7 @@ import org.apache.jackrabbit.oak.plugins
 import 
org.apache.jackrabbit.oak.plugins.index.property.jmx.PropertyIndexAsyncReindexMBean;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
 import org.apache.jackrabbit.oak.query.QueryEngineSettings;
+import org.apache.jackrabbit.oak.query.QueryEngineSettingsMBeanImpl;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider;
@@ -132,7 +133,7 @@ public class Oak {
     
     private final List<RepositoryInitializer> initializers = newArrayList();
 
-    private QueryEngineSettings queryEngineSettings = new 
QueryEngineSettings();
+    private QueryEngineSettingsMBeanImpl queryEngineSettings = new 
QueryEngineSettingsMBeanImpl();
 
     private final List<QueryIndexProvider> queryIndexProviders = 
newArrayList();
 
@@ -380,7 +381,7 @@ public class Oak {
 
     @Nonnull
     public Oak with(@Nonnull QueryEngineSettings queryEngineSettings) {
-        this.queryEngineSettings = queryEngineSettings;
+        this.queryEngineSettings = new 
QueryEngineSettingsMBeanImpl(queryEngineSettings);
         return this;
     }
 
@@ -526,7 +527,7 @@ public class Oak {
         }
         QueryEngineSettings queryEngineSettings = 
WhiteboardUtils.getService(whiteboard, QueryEngineSettings.class);
         if (queryEngineSettings != null) {
-            this.queryEngineSettings = queryEngineSettings;
+            this.queryEngineSettings = new 
QueryEngineSettingsMBeanImpl(queryEngineSettings);
         }
         return this;
     }
@@ -701,7 +702,7 @@ public class Oak {
                 store,
                 composite,
                 defaultWorkspaceName,
-                queryEngineSettings,
+                queryEngineSettings.unwrap(),
                 indexProvider,
                 securityProvider,
                 new AggregatingDescriptors(t)) {

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java?rev=1764879&r1=1764878&r2=1764879&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java
 Fri Oct 14 11:49:57 2016
@@ -19,12 +19,11 @@
 package org.apache.jackrabbit.oak.query;
 
 import org.apache.jackrabbit.oak.api.jmx.QueryEngineSettingsMBean;
-import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
 
 /**
  * Settings of the query engine.
  */
-public class QueryEngineSettings extends AnnotatedStandardMBean implements 
QueryEngineSettingsMBean {
+public class QueryEngineSettings implements QueryEngineSettingsMBean {
     
     /**
      * the flag used to turn on/off the optimisations on top of the {@link 
Query} object.
@@ -49,56 +48,25 @@ public class QueryEngineSettings extends
             DEFAULT_FULL_TEXT_COMPARISON_WITHOUT_INDEX;
     
     private boolean sql2Optimisation = 
Boolean.parseBoolean(System.getProperty(SQL2_OPTIMISATION_FLAG, "true"));
-
-    /**
-     * Create a new query engine settings object. Creating the object is
-     * relatively slow, and at runtime, as few such objects as possible should
-     * be created (ideally, only one per Oak instance). Creating new instances
-     * also means they can not be configured using JMX, as one would expect.
-     */
+    
     public QueryEngineSettings() {
-        super(QueryEngineSettingsMBean.class);
     }
-
-    /**
-     * Get the limit on how many nodes a query may read at most into memory, 
for
-     * "order by" and "distinct" queries. If this limit is exceeded, the query
-     * throws an exception.
-     * 
-     * @return the limit
-     */
+    
     @Override
     public long getLimitInMemory() {
         return limitInMemory;
     }
     
-    /**
-     * Change the limit.
-     * 
-     * @param limitInMemory the new limit
-     */
     @Override
     public void setLimitInMemory(long limitInMemory) {
         this.limitInMemory = limitInMemory;
     }
     
-    /**
-     * Get the limit on how many nodes a query may read at most (raw read
-     * operations, including skipped nodes). If this limit is exceeded, the
-     * query throws an exception.
-     * 
-     * @return the limit
-     */
     @Override
     public long getLimitReads() {
         return limitReads;
     }
     
-    /**
-     * Change the limit.
-     * 
-     * @param limitReads the new limit
-     */
     @Override
     public void setLimitReads(long limitReads) {
         this.limitReads = limitReads;
@@ -115,4 +83,5 @@ public class QueryEngineSettings extends
     public boolean isSql2Optimisation() {
         return sql2Optimisation;
     }
+
 }

Added: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java?rev=1764879&view=auto
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java
 (added)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java
 Fri Oct 14 11:49:57 2016
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.query;
+
+import org.apache.jackrabbit.oak.api.jmx.QueryEngineSettingsMBean;
+import org.apache.jackrabbit.oak.commons.jmx.AnnotatedStandardMBean;
+
+/**
+ * Settings of the query engine. This instance is an AnnotatedStandardMBean.
+ */
+public class QueryEngineSettingsMBeanImpl extends AnnotatedStandardMBean 
+        implements QueryEngineSettingsMBean {
+    
+    private final QueryEngineSettings settings;
+    
+    /**
+     * Create a new query engine settings object. Creating the object is
+     * relatively slow, and at runtime, as few such objects as possible should
+     * be created (ideally, only one per Oak instance). Creating new instances
+     * also means they can not be configured using JMX, as one would expect.
+     */
+    public QueryEngineSettingsMBeanImpl(QueryEngineSettings settings) {
+        super(QueryEngineSettingsMBean.class);
+        this.settings = settings;
+    }
+
+    /**
+     * Create a new query engine settings object. Creating the object is
+     * relatively slow, and at runtime, as few such objects as possible should
+     * be created (ideally, only one per Oak instance). Creating new instances
+     * also means they can not be configured using JMX, as one would expect.
+     */
+    public QueryEngineSettingsMBeanImpl() {
+        this(new QueryEngineSettings());
+    }
+
+    @Override
+    public long getLimitInMemory() {
+        return settings.getLimitInMemory();
+    }
+    
+    @Override
+    public void setLimitInMemory(long limitInMemory) {
+        settings.setLimitInMemory(limitInMemory);
+    }
+    
+    @Override
+    public long getLimitReads() {
+        return settings.getLimitReads();
+    }
+    
+    @Override
+    public void setLimitReads(long limitReads) {
+        settings.setLimitReads(limitReads);
+    }
+    
+    public void setFullTextComparisonWithoutIndex(boolean 
fullTextComparisonWithoutIndex) {
+        
settings.setFullTextComparisonWithoutIndex(fullTextComparisonWithoutIndex);
+    }
+    
+    public boolean getFullTextComparisonWithoutIndex() {
+        return settings.getFullTextComparisonWithoutIndex();
+    }
+    
+    public boolean isSql2Optimisation() {
+        return settings.isSql2Optimisation();
+    }
+
+    public QueryEngineSettings unwrap() {
+        return settings;
+    }
+
+}


Reply via email to