author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 44797 | jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/WeakReferenceXMLSchema.java@8b3b3b911b8a |
child 47359 | e1a6c0168741 |
permissions | -rw-r--r-- |
6 | 1 |
/* |
2 |
* reserved comment block |
|
3 |
* DO NOT REMOVE OR ALTER! |
|
4 |
*/ |
|
5 |
/* |
|
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
6 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
7 |
* contributor license agreements. See the NOTICE file distributed with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
8 |
* this work for additional information regarding copyright ownership. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
9 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
10 |
* (the "License"); you may not use this file except in compliance with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
11 |
* the License. You may obtain a copy of the License at |
6 | 12 |
* |
13 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
14 |
* |
|
15 |
* Unless required by applicable law or agreed to in writing, software |
|
16 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
* See the License for the specific language governing permissions and |
|
19 |
* limitations under the License. |
|
20 |
*/ |
|
21 |
||
22 |
package com.sun.org.apache.xerces.internal.jaxp.validation; |
|
23 |
||
24 |
import java.lang.ref.WeakReference; |
|
25 |
||
26 |
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; |
|
27 |
||
28 |
/** |
|
29 |
* <p>An implementation of Schema for W3C XML Schemas |
|
30 |
* that keeps a weak reference to its grammar pool. If |
|
31 |
* no validators currently have a reference to the |
|
32 |
* grammar pool, the garbage collector is free to reclaim |
|
33 |
* its memory.</p> |
|
34 |
* |
|
35 |
* @author Michael Glavassevich, IBM |
|
36 |
*/ |
|
37 |
final class WeakReferenceXMLSchema extends AbstractXMLSchema { |
|
38 |
||
39 |
/** Weak reference to grammar pool. */ |
|
40 |
private WeakReference fGrammarPool = new WeakReference(null); |
|
41 |
||
42 |
public WeakReferenceXMLSchema() {} |
|
43 |
||
44 |
/* |
|
45 |
* XSGrammarPoolContainer methods |
|
46 |
*/ |
|
47 |
||
48 |
public synchronized XMLGrammarPool getGrammarPool() { |
|
49 |
XMLGrammarPool grammarPool = (XMLGrammarPool) fGrammarPool.get(); |
|
50 |
// If there's no grammar pool then either we haven't created one |
|
51 |
// yet or the garbage collector has already cleaned out the previous one. |
|
52 |
if (grammarPool == null) { |
|
53 |
grammarPool = new SoftReferenceGrammarPool(); |
|
54 |
fGrammarPool = new WeakReference(grammarPool); |
|
55 |
} |
|
56 |
return grammarPool; |
|
57 |
} |
|
58 |
||
59 |
public boolean isFullyComposed() { |
|
60 |
return false; |
|
61 |
} |
|
62 |
||
63 |
} // WeakReferenceXMLSchema |