Package org.apache.muse.core.platform.osgi.axis2.internal

Source Code of org.apache.muse.core.platform.osgi.axis2.internal.ResourceManagementAdminServiceImpl

/*=============================================================================*
*  Copyright 2006 The Apache Software Foundation
*
*  Licensed 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.internal;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.soap.SOAPException;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.muse.core.platform.osgi.ResourceManagementProvider;
import org.apache.muse.osgi.soa.core.SOAPProvider;
import org.apache.muse.osgi.soa.core.web.WebApp;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Bundle;

/**
*
* ResourceManagementAdminServiceImpl administers the interaction between the OSGi-hosted
* Muse Axis2 environment and an OSGi service that provides the actual Axis2 runtime environment
*
* @see ResourceManagementProvider
* @see ResourceManagementAdminService
* @author Joel Hawkins (joelh)
*
*/
public class ResourceManagementAdminServiceImpl implements ResourceManagementProvider {

  public static final String DEFAULT_CONTEXT = "management";

  private BundleContext context;
  private Bundle bundle;
  private SOAPProvider provider;

  public ResourceManagementAdminServiceImpl(BundleContext context, SOAPProvider provider){
    this.context = context;
    this.provider = provider;
  }


  public void deployManagementService(Bundle bundle, String homeName, String wsdlPath) throws SOAPException {
    deployManagementService(bundle, DEFAULT_CONTEXT, homeName);
  }


  public void deployManagementService(Bundle bundle, String contextPath, String srvName, String wsdlPath) throws SOAPException {
    WebApp webApp = null;
    if (contextPath != null) {
      try {
        webApp = provider.getWebApp(bundle, contextPath, true);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    // rename all references to service name
    try {
      ConfigurationContext context = (ConfigurationContext)provider.getProviderDeployer(webApp);
      AxisConfiguration axisConfig = context.getAxisConfiguration();
      Axis2ResourceManagementService service = new Axis2ResourceManagementService();
      service.setName(srvName);
      service.setWSDLPath(wsdlPath);
      service.setBundle(bundle);
      try {
        service.setFileName(new URL("file",contextPath, srvName));
      } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      axisConfig.addService(service);
      //provider.deployService(srvName, SOAPProvider.MESSAGE_BINDING_TYPE, Axis2IsolationLayer.class, Axis2IsolationLayer.getInstance());
    } catch (AxisFault se){
      se.printStackTrace();
    }
  }
}
TOP

Related Classes of org.apache.muse.core.platform.osgi.axis2.internal.ResourceManagementAdminServiceImpl

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.