### Eclipse Workspace Patch 1.0 #P oak-core Index: src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java =================================================================== --- src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java (revision 1763455) +++ src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettings.java (working copy) @@ -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,37 @@ 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. + * Wrap this object into a QueryEngineSettingsMBeanImpl. + * Creating the object is + * relatively slow, and at runtime, as few such objects as possible should + * be created (ideally, only one per Oak instance). * - * @return the limit + * @return the new QueryEngineSettingsMBeanImpl object */ + public QueryEngineSettingsMBeanImpl wrap() { + return new QueryEngineSettingsMBeanImpl(this); + } + @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 +95,5 @@ public boolean isSql2Optimisation() { return sql2Optimisation; } + } Index: src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java =================================================================== --- src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java (revision 0) +++ src/main/java/org/apache/jackrabbit/oak/query/QueryEngineSettingsMBeanImpl.java (working copy) @@ -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; + } + +} Index: src/main/java/org/apache/jackrabbit/oak/Oak.java =================================================================== --- src/main/java/org/apache/jackrabbit/oak/Oak.java (revision 1763455) +++ src/main/java/org/apache/jackrabbit/oak/Oak.java (working copy) @@ -79,6 +79,7 @@ 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 @@ private final List initializers = newArrayList(); - private QueryEngineSettings queryEngineSettings = new QueryEngineSettings(); + private QueryEngineSettingsMBeanImpl queryEngineSettings = new QueryEngineSettingsMBeanImpl(); private final List queryIndexProviders = newArrayList(); @@ -380,7 +381,7 @@ @Nonnull public Oak with(@Nonnull QueryEngineSettings queryEngineSettings) { - this.queryEngineSettings = queryEngineSettings; + this.queryEngineSettings = queryEngineSettings.wrap(); return this; } @@ -526,7 +527,7 @@ } QueryEngineSettings queryEngineSettings = WhiteboardUtils.getService(whiteboard, QueryEngineSettings.class); if (queryEngineSettings != null) { - this.queryEngineSettings = queryEngineSettings; + this.queryEngineSettings = queryEngineSettings.wrap(); } return this; } @@ -701,7 +702,7 @@ store, composite, defaultWorkspaceName, - queryEngineSettings, + queryEngineSettings.unwrap(), indexProvider, securityProvider, new AggregatingDescriptors(t)) {