KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > LanguageDbPropertySetter


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.LanguageDbPropertySetter
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql;
23
24 import org.apache.derby.iapi.services.property.PropertySetCallback;
25 import org.apache.derby.iapi.services.property.PropertyUtil;
26 import org.apache.derby.iapi.reference.Property;
27 import org.apache.derby.iapi.reference.SQLState;
28 import org.apache.derby.iapi.services.daemon.Serviceable;
29 import org.apache.derby.iapi.services.sanity.SanityManager;
30 import org.apache.derby.iapi.services.context.ContextService;
31 import org.apache.derby.iapi.error.StandardException;
32 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
33 import org.apache.derby.iapi.store.access.TransactionController;
34 import java.io.Serializable JavaDoc;
35 import java.util.Dictionary JavaDoc;
36
37 /**
38  * A class to handle setting language database properties
39  */

40 public class LanguageDbPropertySetter implements PropertySetCallback
41 {
42     public void init(boolean dbOnly, Dictionary JavaDoc p) {
43         // not called yet ...
44
}
45     /** @exception StandardException Thrown on error. */
46     public boolean validate
47     (
48         String JavaDoc key,
49         Serializable JavaDoc value,
50         Dictionary JavaDoc p
51     ) throws StandardException
52     {
53         // Disallow changing sqlAuthorization from true to false or null after
54
// switching to Standard authorization
55
if (key.trim().equals(Property.SQL_AUTHORIZATION_PROPERTY))
56         {
57             LanguageConnectionContext lcc = (LanguageConnectionContext)
58                     ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);
59
60             if (lcc.usesSqlAuthorization() && !Boolean.valueOf((String JavaDoc)value).booleanValue())
61                 throw StandardException.newException(SQLState.PROPERTY_UNSUPPORTED_CHANGE,
62                     key, value);
63         }
64
65         if (key.equals(Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL)) {
66             PropertyUtil.intPropertyValue(
67                         Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
68                         value,
69                         Property.MIN_LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
70                         Integer.MAX_VALUE,
71                         Property.DEFAULT_LANGUAGE_STALE_PLAN_CHECK_INTERVAL
72                         );
73             return true;
74         }
75
76         return false;
77     }
78
79     public Serviceable apply
80     (
81         String JavaDoc key,
82         Serializable JavaDoc value,
83         Dictionary JavaDoc p
84     )
85     {
86         return null;
87     }
88
89     public Serializable JavaDoc map
90     (
91         String JavaDoc key,
92         Serializable JavaDoc value,
93         Dictionary JavaDoc p
94     )
95     {
96         return null;
97     }
98 }
99
Popular Tags