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 */ 017 018 package org.apache.geronimo.corba.deployment; 019 020 import java.util.Collection; 021 import java.util.Map; 022 023 import org.apache.xmlbeans.XmlObject; 024 import org.apache.xmlbeans.QNameSet; 025 import org.apache.geronimo.kernel.repository.Artifact; 026 import org.apache.geronimo.kernel.repository.Environment; 027 import org.apache.geronimo.j2ee.deployment.Module; 028 import org.apache.geronimo.j2ee.deployment.CorbaGBeanNameSource; 029 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 030 import org.apache.geronimo.naming.reference.ORBReference; 031 import org.apache.geronimo.naming.reference.HandleDelegateReference; 032 import org.apache.geronimo.naming.deployment.AbstractNamingBuilder; 033 import org.apache.geronimo.common.DeploymentException; 034 import org.apache.geronimo.gbean.GBeanInfo; 035 import org.apache.geronimo.gbean.GBeanInfoBuilder; 036 import org.apache.geronimo.gbean.AbstractNameQuery; 037 import org.apache.geronimo.gbean.SingleElementCollection; 038 039 /** 040 * @version $Rev: 535381 $ $Date: 2007-05-04 17:04:18 -0400 (Fri, 04 May 2007) $ 041 */ 042 public class CorbaRefBuilder extends AbstractNamingBuilder { 043 044 private final SingleElementCollection corbaGBeanNameSourceCollection; 045 046 public CorbaRefBuilder(Environment defaultEnvironment, Collection corbaGBeanNameSource) { 047 super(defaultEnvironment); 048 this.corbaGBeanNameSourceCollection = new SingleElementCollection(corbaGBeanNameSource); 049 } 050 051 protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) throws DeploymentException { 052 // if (OpenEjbCorbaRefBuilder.hasCssRefs(plan) || TSSLinkBuilder.hasTssLinks(plan)) { 053 return true; 054 // } 055 // return false; 056 } 057 058 public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException { 059 if (matchesDefaultEnvironment(module.getEnvironment())) { 060 CorbaGBeanNameSource corbaGBeanNameSource = (CorbaGBeanNameSource) corbaGBeanNameSourceCollection.getElement(); 061 if (corbaGBeanNameSource != null) { 062 AbstractNameQuery corbaName = corbaGBeanNameSource.getCorbaGBeanName(); 063 if (corbaName != null) { 064 Artifact[] moduleId = module.getConfigId(); 065 Map context = getJndiContextMap(componentContext); 066 context.put("ORB", new ORBReference(moduleId, corbaName)); 067 context.put("HandleDelegate", new HandleDelegateReference(moduleId, corbaName)); 068 } 069 } 070 } 071 } 072 073 public QNameSet getSpecQNameSet() { 074 return QNameSet.EMPTY; 075 } 076 077 public QNameSet getPlanQNameSet() { 078 return QNameSet.EMPTY; 079 } 080 081 public static final GBeanInfo GBEAN_INFO; 082 083 static { 084 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(CorbaRefBuilder.class, NameFactory.MODULE_BUILDER); 085 infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true); 086 infoBuilder.addReference("CorbaGBeanNameSource", CorbaGBeanNameSource.class); 087 infoBuilder.setConstructor(new String[]{"defaultEnvironment", "CorbaGBeanNameSource"}); 088 GBEAN_INFO = infoBuilder.getBeanInfo(); 089 } 090 091 public static GBeanInfo getGBeanInfo() { 092 return GBEAN_INFO; 093 } 094 095 }