/*
* 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.muse.core.platform.osgi.axis2;
import org.apache.muse.core.Environment;
import org.apache.muse.core.descriptor.DeploymentDescriptor;
import org.apache.muse.core.platform.axis2.AxisIsolationLayer;
import org.apache.muse.core.platform.osgi.descriptor.OSGiDeploymentDescriptor;
import org.apache.muse.core.platform.osgi.util.OSGiReflectUtilHelper;
import org.apache.muse.util.ReflectUtils;
import org.apache.axis2.context.ServiceContext;
/**
*
* Axis2IsolationLayer is an OSGi aware extension of the Muse AxisIsolationLayer.
*
* @author Joel Hawkins (joelh)
*
*/
public class Axis2IsolationLayer extends AxisIsolationLayer {
protected boolean initializing = false;
protected boolean initialized = false;
private static Axis2IsolationLayer _instance = null;
public static Axis2IsolationLayer getInstance(){
_instance = new Axis2IsolationLayer();
return _instance;
}
public void init(ServiceContext serviceContext){
if(!initialized) initialize();
}
/**
* performs initialzation of the IsolationLayer, and installs the
* <code>OSGiReflectUtilHelper</code> singleton as the <code>ReflectUtils</code>
* helper.
*
* @see ReflectUtils
* @see OSGiReflectUtilHelper
*/
public void initialize() {
if(initializing) return;
ClassLoader prev = Thread.currentThread().getContextClassLoader();
try {
initializing = true;
ReflectUtils.setHelper(OSGiReflectUtilHelper.getDefault());
Thread.currentThread().setContextClassLoader(
Axis2IsolationLayer.class.getClassLoader());
super.initialize();
initialized = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
} finally {
Thread.currentThread().setContextClassLoader(prev);
}
}
/**
* @return an <code>Axis2Environment</code> instance
*
* @see Axis2Environment
*/
protected Environment createEnvironment() {
return new Axis2Environment();
}
/**
* @return an <code>OSGiDeploymentDescritpor</code> instance.
*
* @see OSGiDeploymentDescriptor
*/
protected DeploymentDescriptor createDeploymentDescriptor() {
return new OSGiDeploymentDescriptor();
}
}