Package org.apache.yoko.rmi.api

Source Code of org.apache.yoko.rmi.api.PortableRemoteObjectExt

/**
*
* 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.yoko.rmi.api;

import java.security.AccessController;
import org.apache.yoko.rmi.util.GetSystemPropertyAction;

public class PortableRemoteObjectExt {

    private static PortableRemoteObjectExtDelegate delegate;

    private static void init() {
        if (delegate != null)
            return;

        String name = (String)AccessController.doPrivileged(new GetSystemPropertyAction(
                "trifork.rmi.PortableRemoteObjectExtClass",
                "org.apache.yoko.rmi.impl.PortableRemoteObjectExtImpl"));

        Class clz = null;
        try {
            clz = Thread.currentThread().getContextClassLoader()
                    .loadClass(name);
        } catch (ClassNotFoundException ex) {

        }

        if (clz == null) {
            try {
                clz = Class.forName(name);
            } catch (ClassNotFoundException ex) {
                throw new RuntimeException(ex.getMessage());
            }
        }

        try {
            delegate = (PortableRemoteObjectExtDelegate) clz.newInstance();

        } catch (InstantiationException ex) {
            throw new RuntimeException("internal problem: " + ex.getMessage());

        } catch (IllegalAccessException ex) {
            throw new RuntimeException("internal problem: " + ex.getMessage());
        }
    }

    /** Return the currently active state for this thread */
    public static PortableRemoteObjectState getState() {
  init();
  return delegate.getCurrentState();
     }
}
TOP

Related Classes of org.apache.yoko.rmi.api.PortableRemoteObjectExt

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.