001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.axis2.client;
017:
018: import java.net.URL;
019:
020: import org.apache.axis2.context.ConfigurationContext;
021: import org.apache.axis2.jaxws.ClientConfigurationFactory;
022: import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
023: import org.apache.axis2.metadata.registry.MetadataFactoryRegistry;
024: import org.apache.commons.logging.Log;
025: import org.apache.commons.logging.LogFactory;
026: import org.apache.geronimo.gbean.AbstractName;
027: import org.apache.geronimo.gbean.GBeanInfo;
028: import org.apache.geronimo.gbean.GBeanInfoBuilder;
029: import org.apache.geronimo.gbean.GBeanLifecycle;
030: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
031: import org.apache.geronimo.kernel.Kernel;
032:
033: public class Axis2ConfigGBean implements GBeanLifecycle {
034:
035: private static final Log LOG = LogFactory
036: .getLog(Axis2ConfigGBean.class);
037:
038: private AbstractName moduleName;
039: private ClassLoader classLoder;
040:
041: public Axis2ConfigGBean(ClassLoader classLoader, Kernel kernel,
042: URL configurationBaseUrl, AbstractName moduleName) {
043: this .moduleName = moduleName;
044: this .classLoder = classLoader;
045: }
046:
047: public synchronized static Axis2ClientConfigurationFactory registerClientConfigurationFactory() {
048: ClientConfigurationFactory factory = (ClientConfigurationFactory) MetadataFactoryRegistry
049: .getFactory(ClientConfigurationFactory.class);
050: if (factory instanceof Axis2ClientConfigurationFactory) {
051: return (Axis2ClientConfigurationFactory) factory;
052: } else {
053: factory = new Axis2ClientConfigurationFactory(false);
054: MetadataFactoryRegistry.setFactory(
055: ClientConfigurationFactory.class, factory);
056: LOG.debug("Registered client configuration factory: "
057: + factory);
058: // ensure that the factory was installed at the right time
059: if (factory != DescriptionFactoryImpl
060: .getClientConfigurationFactory()) {
061: throw new RuntimeException(
062: "Client configuration factory was registered too late");
063: }
064: return (Axis2ClientConfigurationFactory) factory;
065: }
066: }
067:
068: public void doStart() throws Exception {
069: registerClientConfigurationFactory();
070: }
071:
072: public void doStop() throws Exception {
073: ConfigurationContext configContext = registerClientConfigurationFactory()
074: .clearCache(this .classLoder);
075: DescriptionFactoryImpl
076: .clearServiceDescriptionCache(configContext);
077: }
078:
079: public void doFail() {
080: }
081:
082: public static final GBeanInfo GBEAN_INFO;
083:
084: static {
085: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
086: Axis2ConfigGBean.class, Axis2ConfigGBean.class,
087: NameFactory.GERONIMO_SERVICE);
088:
089: infoFactory.addAttribute("classLoader", ClassLoader.class,
090: false);
091: infoFactory.addAttribute("kernel", Kernel.class, false);
092: infoFactory.addAttribute("configurationBaseUrl", URL.class,
093: true);
094: infoFactory
095: .addAttribute("moduleName", AbstractName.class, true);
096:
097: infoFactory.setConstructor(new String[] { "classLoader",
098: "kernel", "configurationBaseUrl", "moduleName" });
099:
100: GBEAN_INFO = infoFactory.getBeanInfo();
101: }
102:
103: public static GBeanInfo getGBeanInfo() {
104: return GBEAN_INFO;
105: }
106:
107: }
|