1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.sql.LanguageDbPropertySetter |
4 | |
5 | Copyright 1999, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.sql; |
22 | |
23 | import org.apache.derby.iapi.services.property.PropertySetCallback; |
24 | import org.apache.derby.iapi.services.property.PropertyUtil; |
25 | import org.apache.derby.iapi.reference.Property; |
26 | import org.apache.derby.iapi.reference.SQLState; |
27 | import org.apache.derby.iapi.services.daemon.Serviceable; |
28 | import org.apache.derby.iapi.services.sanity.SanityManager; |
29 | import org.apache.derby.iapi.services.context.ContextService; |
30 | import org.apache.derby.iapi.error.StandardException; |
31 | import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; |
32 | import org.apache.derby.iapi.store.access.TransactionController; |
33 | import java.io.Serializable; |
34 | import java.util.Dictionary; |
35 | |
36 | /** |
37 | * A class to handle setting language database properties |
38 | */ |
39 | public class LanguageDbPropertySetter implements PropertySetCallback |
40 | { |
41 | public void init(boolean dbOnly, Dictionary p) { |
42 | // not called yet ... |
43 | } |
44 | /** @exception StandardException Thrown on error. */ |
45 | public boolean validate |
46 | ( |
47 | String key, |
48 | Serializable value, |
49 | Dictionary p |
50 | ) throws StandardException |
51 | { |
52 | // Disallow changing sqlAuthorization from true to false or null after |
53 | // switching to Standard authorization |
54 | if (key.trim().equals(Property.SQL_AUTHORIZATION_PROPERTY)) |
55 | { |
56 | LanguageConnectionContext lcc = (LanguageConnectionContext) |
57 | ContextService.getContext(LanguageConnectionContext.CONTEXT_ID); |
58 | |
59 | if (lcc.usesSqlAuthorization() && !Boolean.valueOf((String)value).booleanValue()) |
60 | throw StandardException.newException(SQLState.PROPERTY_UNSUPPORTED_CHANGE, |
61 | key, value); |
62 | } |
63 | |
64 | if (key.equals(Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL)) { |
65 | PropertyUtil.intPropertyValue( |
66 | Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL, |
67 | value, |
68 | Property.MIN_LANGUAGE_STALE_PLAN_CHECK_INTERVAL, |
69 | Integer.MAX_VALUE, |
70 | Property.DEFAULT_LANGUAGE_STALE_PLAN_CHECK_INTERVAL |
71 | ); |
72 | return true; |
73 | } |
74 | |
75 | return false; |
76 | } |
77 | |
78 | public Serviceable apply |
79 | ( |
80 | String key, |
81 | Serializable value, |
82 | Dictionary p |
83 | ) |
84 | { |
85 | return null; |
86 | } |
87 | |
88 | public Serializable map |
89 | ( |
90 | String key, |
91 | Serializable value, |
92 | Dictionary p |
93 | ) |
94 | { |
95 | return null; |
96 | } |
97 | } |