01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.harmony.luni.platform;
18:
19: import org.apache.harmony.kernel.vm.VM;
20:
21: /**
22: * Platform
23: *
24: */
25: public class Platform {
26:
27: static final IAdapterManager ADAPTER_MANAGER = new AdapterManager();
28:
29: static final IFileSystem FILE_SYSTEM = OSComponentFactory
30: .getFileSystem();
31:
32: static final IMemorySystem MEMORY_SYSTEM = OSComponentFactory
33: .getMemorySystem();
34:
35: static final INetworkSystem NETWORK_SYSTEM = OSComponentFactory
36: .getNetworkSystem();
37:
38: public static IAdapterManager getAdapterManager() {
39: return ADAPTER_MANAGER;
40: }
41:
42: private static final void accessCheck() {
43: if (VM.callerClassLoader() != null) {
44: throw new SecurityException();
45: }
46: }
47:
48: public static IFileSystem getFileSystem() {
49: accessCheck();
50: return FILE_SYSTEM;
51: }
52:
53: public static IMemorySystem getMemorySystem() {
54: accessCheck();
55: return MEMORY_SYSTEM;
56: }
57:
58: public static INetworkSystem getNetworkSystem() {
59: accessCheck();
60: return NETWORK_SYSTEM;
61: }
62: }
|