org.jboss.as.webservices.metadata.AbstractMetaDataBuilderEJB Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbossws-wildfly821-server-integration
Show all versions of jbossws-wildfly821-server-integration
JBossWS WildFly 8.2.1.Final Server Side Integration
The newest version!
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.webservices.metadata;
import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
import java.util.List;
import org.jboss.as.webservices.metadata.model.EJBEndpoint;
import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
import org.jboss.wsf.spi.metadata.j2ee.EJBSecurityMetaData;
import org.jboss.wsf.spi.metadata.j2ee.PublishLocationAdapter;
import org.jboss.wsf.spi.metadata.j2ee.SLSBMetaData;
import org.jboss.wsf.spi.metadata.webservices.JBossPortComponentMetaData;
import org.jboss.wsf.spi.metadata.webservices.JBossWebserviceDescriptionMetaData;
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
/**
* @author Richard Opalka
*/
abstract class AbstractMetaDataBuilderEJB {
/**
* Builds universal EJB meta data model that is AS agnostic.
*
* @param dep
* webservice deployment
* @return universal EJB meta data model
*/
final EJBArchiveMetaData create(final Deployment dep) {
ROOT_LOGGER.creatingEjbDeployment(dep.getSimpleName());
final EJBArchiveMetaData.Builder ejbArchiveMDBuilder = new EJBArchiveMetaData.Builder();
this.buildEnterpriseBeansMetaData(dep, ejbArchiveMDBuilder);
this.buildWebservicesMetaData(dep, ejbArchiveMDBuilder);
return ejbArchiveMDBuilder.build();
}
/**
* Template method for build enterprise beans meta data.
*
* @param dep
* webservice deployment
* @param ejbMetaData
* universal EJB meta data model
*/
protected abstract void buildEnterpriseBeansMetaData(Deployment dep, EJBArchiveMetaData.Builder ejbMetaDataBuilder);
/**
* Builds webservices meta data. This methods sets:
*
* - context root
* - wsdl location resolver
* - config name
* - config file
*
*
* @param dep webservice deployment
* @param ejbArchiveMD universal EJB meta data model
*/
private void buildWebservicesMetaData(final Deployment dep, final EJBArchiveMetaData.Builder ejbArchiveMDBuilder)
{
final JBossWebservicesMetaData webservicesMD = WSHelper.getOptionalAttachment(dep, JBossWebservicesMetaData.class);
if (webservicesMD == null) return;
// set context root
final String contextRoot = webservicesMD.getContextRoot();
ejbArchiveMDBuilder.setWebServiceContextRoot(contextRoot);
ROOT_LOGGER.settingContextRoot(contextRoot);
// set config name
final String configName = webservicesMD.getConfigName();
ejbArchiveMDBuilder.setConfigName(configName);
ROOT_LOGGER.settingConfigName(configName);
// set config file
final String configFile = webservicesMD.getConfigFile();
ejbArchiveMDBuilder.setConfigFile(configFile);
ROOT_LOGGER.settingConfigFile(configFile);
// set wsdl location resolver
final JBossWebserviceDescriptionMetaData[] wsDescriptionsMD = webservicesMD.getWebserviceDescriptions();
final PublishLocationAdapter resolver = new PublishLocationAdapterImpl(wsDescriptionsMD);
ejbArchiveMDBuilder.setPublishLocationAdapter(resolver);
}
protected JBossPortComponentMetaData getPortComponent(final String ejbName, final JBossWebservicesMetaData jbossWebservicesMD) {
if (jbossWebservicesMD == null) return null;
for (final JBossPortComponentMetaData jbossPortComponentMD : jbossWebservicesMD.getPortComponents()) {
if (ejbName.equals(jbossPortComponentMD.getEjbName())) return jbossPortComponentMD;
}
return null;
}
/**
* Builds JBoss agnostic EJB meta data.
*
* @param wsEjbsMD
* jboss agnostic EJBs meta data
*/
protected void buildEnterpriseBeanMetaData(final List wsEjbsMD, final EJBEndpoint ejbEndpoint, final JBossWebservicesMetaData jbossWebservicesMD) {
final SLSBMetaData.Builder wsEjbMDBuilder = new SLSBMetaData.Builder();
// set EJB name and class
wsEjbMDBuilder.setEjbName(ejbEndpoint.getName());
wsEjbMDBuilder.setEjbClass(ejbEndpoint.getClassName());
final JBossPortComponentMetaData portComponentMD = getPortComponent(ejbEndpoint.getName(), jbossWebservicesMD);
if (portComponentMD != null) {
// set port component meta data
wsEjbMDBuilder.setPortComponentName(portComponentMD.getPortComponentName());
wsEjbMDBuilder.setPortComponentURI(portComponentMD.getPortComponentURI());
}
// set security meta data
// auth method
final String authMethod = getAuthMethod(ejbEndpoint, portComponentMD);
// transport guarantee
final String transportGuarantee = getTransportGuarantee(ejbEndpoint, portComponentMD);
// secure wsdl access
final boolean secureWsdlAccess = isSecureWsdlAccess(ejbEndpoint, portComponentMD);
final String realmName = getRealmName(ejbEndpoint, portComponentMD);
// propagate
wsEjbMDBuilder.setSecurityMetaData(new EJBSecurityMetaData(authMethod, realmName, transportGuarantee, secureWsdlAccess));
wsEjbsMD.add(wsEjbMDBuilder.build());
}
private static String getAuthMethod(final EJBEndpoint ejbEndpoint, final JBossPortComponentMetaData portComponentMD) {
if (ejbEndpoint.getAuthMethod() != null) return ejbEndpoint.getAuthMethod();
return portComponentMD != null ? portComponentMD.getAuthMethod() : null;
}
private static String getTransportGuarantee(final EJBEndpoint ejbEndpoint, final JBossPortComponentMetaData portComponentMD) {
if (ejbEndpoint.getTransportGuarantee() != null) return ejbEndpoint.getTransportGuarantee();
return portComponentMD != null ? portComponentMD.getTransportGuarantee() : null;
}
private static boolean isSecureWsdlAccess(final EJBEndpoint ejbEndpoint, final JBossPortComponentMetaData portComponentMD) {
if (ejbEndpoint.isSecureWsdlAccess()) return true;
return (portComponentMD != null && portComponentMD.getSecureWSDLAccess() != null) ? portComponentMD.getSecureWSDLAccess() : false;
}
private static String getRealmName(final EJBEndpoint ejbEndpoint, final JBossPortComponentMetaData portComponentMD) {
if (ejbEndpoint.getRealmName() != null) return ejbEndpoint.getRealmName();
return portComponentMD != null ? portComponentMD.getRealmName() : null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy