use of com.sun.enterprise.deployment.ApplicationClientDescriptor in project Payara by payara.
the class AppClientCheckMgrImpl method checkWebServicesClient.
protected void checkWebServicesClient(Descriptor descriptor) throws Exception {
if (verifierFrameworkContext.isPartition() && !verifierFrameworkContext.isWebServicesClient())
return;
WebServiceClientCheckMgrImpl webServiceClientCheckMgr = new WebServiceClientCheckMgrImpl(verifierFrameworkContext);
ApplicationClientDescriptor desc = (ApplicationClientDescriptor) descriptor;
if (desc.hasWebServiceClients()) {
Set serviceRefDescriptors = desc.getServiceReferenceDescriptors();
Iterator it = serviceRefDescriptors.iterator();
while (it.hasNext()) {
webServiceClientCheckMgr.setVerifierContext(context);
webServiceClientCheckMgr.check((ServiceReferenceDescriptor) it.next());
}
} else
// set not applicable for all tests in WebServices for this Appclient Bundle
webServiceClientCheckMgr.setVerifierContext(context);
}
use of com.sun.enterprise.deployment.ApplicationClientDescriptor in project Payara by payara.
the class FacadeLaunchable method selectFacadeFromGroup.
private static FacadeLaunchable selectFacadeFromGroup(final ServiceLocator habitat, final URI groupFacadeURI, final ArchiveFactory af, final String groupURIs, final String callerSpecifiedMainClassName, final String callerSpecifiedAppClientName, final String anchorDir) throws IOException, BootException, URISyntaxException, SAXParseException, UserError {
String[] archiveURIs = groupURIs.split(" ");
/*
* Search the app clients in the group in order, checking each for
* a match on either the caller-specified main class or the caller-specified
* client name.
*/
if (archiveURIs.length == 0) {
final String msg = MessageFormat.format(logger.getResourceBundle().getString("appclient.noClientsInGroup"), groupFacadeURI);
throw new UserError(msg);
}
/*
* Save the client names and main classes in case we need them in an
* error to the user.
*/
final List<String> knownClientNames = new ArrayList<String>();
final List<String> knownMainClasses = new ArrayList<String>();
for (String uriText : archiveURIs) {
URI clientFacadeURI = groupFacadeURI.resolve(uriText);
ReadableArchive clientFacadeRA = af.openArchive(clientFacadeURI);
Manifest facadeMF = clientFacadeRA.getManifest();
if (facadeMF == null) {
throw new UserError(MessageFormat.format(logger.getResourceBundle().getString("appclient.noMFInFacade"), clientFacadeRA instanceof FileArchive ? 1 : 0, new File(clientFacadeRA.getURI().getPath()).getAbsolutePath()));
}
Attributes facadeMainAttrs = facadeMF.getMainAttributes();
if (facadeMainAttrs == null) {
throw new UserError(MessageFormat.format(logger.getResourceBundle().getString("appclient.MFMissingEntry"), new File(clientFacadeRA.getURI().getPath()).getAbsolutePath(), GLASSFISH_APPCLIENT));
}
final String gfAppClient = facadeMainAttrs.getValue(GLASSFISH_APPCLIENT);
if (gfAppClient == null || gfAppClient.length() == 0) {
throw new UserError(MessageFormat.format(logger.getResourceBundle().getString("appclient.MFMissingEntry"), new File(clientFacadeRA.getURI().getPath()).getAbsolutePath(), GLASSFISH_APPCLIENT));
}
URI clientURI = clientFacadeURI.resolve(gfAppClient);
ReadableArchive clientRA = af.openArchive(clientURI);
if (!clientRA.exists()) {
throw new UserError(MessageFormat.format(logger.getResourceBundle().getString("appclient.missingClient"), new File(clientRA.getURI().getSchemeSpecificPart()).getAbsolutePath()));
}
AppClientArchivist facadeClientArchivist = getArchivist(habitat);
MultiReadableArchive combinedRA = openCombinedReadableArchive(habitat, clientFacadeRA, clientRA);
final ApplicationClientDescriptor facadeClientDescriptor = facadeClientArchivist.open(combinedRA);
final String moduleID = Launchable.LaunchableUtil.moduleID(groupFacadeURI, clientURI, facadeClientDescriptor);
final Manifest clientMF = clientRA.getManifest();
if (clientMF == null) {
throw new UserError(MessageFormat.format(logger.getResourceBundle().getString("appclient.noMFInFacade"), clientRA instanceof FileArchive ? 1 : 0, new File(clientRA.getURI().getSchemeSpecificPart()).getAbsolutePath()));
}
Attributes mainAttrs = clientMF.getMainAttributes();
if (mainAttrs == null) {
throw new UserError(MessageFormat.format(logger.getResourceBundle().getString("appclient.MFMissingEntry"), new File(clientFacadeRA.getURI().getPath()).getAbsolutePath(), Attributes.Name.MAIN_CLASS.toString()));
}
final String clientMainClassName = mainAttrs.getValue(Attributes.Name.MAIN_CLASS);
if (clientMainClassName == null || clientMainClassName.length() == 0) {
throw new UserError(MessageFormat.format(logger.getResourceBundle().getString("appclient.MFMissingEntry"), new File(clientFacadeRA.getURI().getPath()).getAbsolutePath(), Attributes.Name.MAIN_CLASS.toString()));
}
knownMainClasses.add(clientMainClassName);
knownClientNames.add(moduleID);
/*
* Look for an entry corresponding to the
* main class or app name the caller requested. Treat as a%
* special case if the user specifies no main class and no
* app name - use the first app client present. Also use the
* first app client if there is only one present; warn if
* the user specified a main class or a name but it does not
* match the single app client that's present.
*/
FacadeLaunchable facade = null;
if (Launchable.LaunchableUtil.matchesAnyClass(clientRA, callerSpecifiedMainClassName)) {
facade = new FacadeLaunchable(habitat, clientFacadeRA, facadeMainAttrs, clientRA, callerSpecifiedMainClassName, anchorDir);
/*
* If the caller-specified class name does not match the
* Main-Class setting for this client archive then inform the user.
*/
if (!clientMainClassName.equals(callerSpecifiedMainClassName)) {
logger.log(Level.INFO, MessageFormat.format(logger.getResourceBundle().getString("appclient.foundMainClassDiffFromManifest"), new Object[] { groupFacadeURI, moduleID, callerSpecifiedMainClassName, clientMainClassName }));
}
} else if (Launchable.LaunchableUtil.matchesName(moduleID, groupFacadeURI, facadeClientDescriptor, callerSpecifiedAppClientName)) {
/*
* Get the main class name from the matching client JAR's manifest.
*/
facade = new FacadeLaunchable(habitat, clientFacadeRA, facadeMainAttrs, clientRA, clientMainClassName, anchorDir);
} else if (archiveURIs.length == 1) {
/*
* If only one client exists, use the main class recorded in
* the group facade unless the caller specified one.
*/
facade = new FacadeLaunchable(habitat, clientFacadeRA, facadeMainAttrs, clientRA, (callerSpecifiedMainClassName != null ? callerSpecifiedMainClassName : facadeMainAttrs.getValue(GLASSFISH_APPCLIENT_MAIN_CLASS)), anchorDir);
/*
* If the user specified a main class or an app name then warn
* if that value does not match the one client we found - but
* go ahead an run it anyway.
*/
if ((callerSpecifiedMainClassName != null && !clientMainClassName.equals(callerSpecifiedMainClassName)) || (callerSpecifiedAppClientName != null && !Launchable.LaunchableUtil.matchesName(moduleID, groupFacadeURI, facadeClientDescriptor, callerSpecifiedAppClientName))) {
logger.log(Level.WARNING, MessageFormat.format(logger.getResourceBundle().getString("appclient.singleNestedClientNoMatch"), new Object[] { groupFacadeURI, knownClientNames.toString(), knownMainClasses.toString(), callerSpecifiedMainClassName, callerSpecifiedAppClientName }));
}
}
if (facade != null) {
return facade;
}
}
/*
* No client facade matched the caller-provided selection (either
* main class name or app client name), or there are multiple clients
* but the caller did not specify either mainClass or name.
* Yet we know we're working
* with a group facade, so report the failure to find a matching
* client as an error.
*/
String msg;
if ((callerSpecifiedAppClientName == null) && (callerSpecifiedMainClassName == null)) {
final String format = logger.getResourceBundle().getString("appclient.multClientsNoChoice");
msg = MessageFormat.format(format, knownMainClasses.toString(), knownClientNames.toString());
} else {
final String format = logger.getResourceBundle().getString("appclient.noMatchingClientInGroup");
msg = MessageFormat.format(format, groupFacadeURI, callerSpecifiedMainClassName, callerSpecifiedAppClientName, knownMainClasses.toString(), knownClientNames.toString());
}
throw new UserError(msg);
}
use of com.sun.enterprise.deployment.ApplicationClientDescriptor in project Payara by payara.
the class Util method getMainClassNameForAppClient.
/**
*Returns the main class name for the app client represented by the module descriptor.
*@param moduleDescr the module descriptor for the app client of interest
*@return main class name of the app client
*/
public static String getMainClassNameForAppClient(ModuleDescriptor moduleDescr) throws IOException, FileNotFoundException, org.xml.sax.SAXParseException {
RootDeploymentDescriptor bd = moduleDescr.getDescriptor();
ApplicationClientDescriptor acDescr = (ApplicationClientDescriptor) bd;
String mainClassName = acDescr.getMainClassName();
return mainClassName;
}
use of com.sun.enterprise.deployment.ApplicationClientDescriptor in project Payara by payara.
the class UndeployedLaunchable method newUndeployedLaunchable.
static UndeployedLaunchable newUndeployedLaunchable(final ServiceLocator habitat, final ReadableArchive ra, final String callerSuppliedMainClassName, final String callerSuppliedAppName, final ClassLoader classLoader) throws IOException, SAXParseException, UserError {
ArchivistFactory af = Util.getArchivistFactory();
/*
* Try letting the factory decide what type of archive this is. That
* will often allow an app client or an EAR archive to be detected
* automatically.
*/
Archivist archivist = af.getArchivist(ModuleType.CAR.toString(), classLoader);
if (archivist == null) {
throw new UserError(localStrings.get("appclient.invalidArchive", ra.getURI().toASCIIString()));
}
final ArchiveType moduleType = archivist.getModuleType();
if (moduleType != null && moduleType.equals(DOLUtils.carType())) {
return new UndeployedLaunchable(habitat, ra, (AppClientArchivist) archivist, callerSuppliedMainClassName);
} else if (moduleType != null && moduleType.equals(DOLUtils.earType())) {
/*
* Locate the app client submodule that matches the main class name
* or the app client name.
*/
Application app = (Application) archivist.open(ra);
for (ModuleDescriptor<BundleDescriptor> md : app.getModules()) {
if (!md.getModuleType().equals(DOLUtils.carType())) {
continue;
}
ApplicationClientDescriptor acd = (ApplicationClientDescriptor) md.getDescriptor();
final String displayName = acd.getDisplayName();
final String appName = acd.getModuleID();
ArchiveFactory archiveFactory = Util.getArchiveFactory();
ReadableArchive clientRA = archiveFactory.openArchive(ra.getURI().resolve(md.getArchiveUri()));
/*
* Choose this nested app client if the caller-supplied name
* matches, or if the caller-supplied main class matches, or
* if neither was provided.
*/
final boolean useThisClient = (displayName != null && displayName.equals(callerSuppliedAppName)) || (appName != null && appName.equals(callerSuppliedAppName)) || (callerSuppliedMainClassName != null && clientRA.exists(classToResource(callerSuppliedMainClassName)) || (callerSuppliedAppName == null && callerSuppliedMainClassName == null));
if (useThisClient) {
return new UndeployedLaunchable(habitat, clientRA, acd, callerSuppliedMainClassName);
}
clientRA.close();
}
throw new UserError(localStrings.get("appclient.noMatchingClientInEAR", ra.getURI(), callerSuppliedMainClassName, callerSuppliedAppName));
} else {
/*
* There is a possibility that the user is trying to launch an
* archive that is more than one type of archive: such as an EJB
* but also an app client (because the manifest identifies a main
* class, for example).
*
* Earlier the archivist factory might have returned the other type
* of archivist - such as the EJB archivist. Now see if the app
* client archivist will work when selected directly.
*/
archivist = af.getArchivist(DOLUtils.carType());
/*
* Try to open the archive as an app client archive just to see
* if it works.
*/
RootDeploymentDescriptor tempACD = archivist.open(ra);
if (tempACD != null && tempACD instanceof ApplicationClientDescriptor) {
/*
* Start with a fresh archivist - unopened - so we can request
* anno processing, etc. before opening it for real.
*/
archivist = af.getArchivist(DOLUtils.carType());
return new UndeployedLaunchable(habitat, ra, (AppClientArchivist) archivist, callerSuppliedMainClassName);
}
throw new UserError(localStrings.get("appclient.unexpectedArchive", ra.getURI()));
}
}
use of com.sun.enterprise.deployment.ApplicationClientDescriptor in project Payara by payara.
the class AppClientDeployerHelper method newInstance.
/**
* Returns the correct concrete implementation of Helper.
* @param dc the DeploymentContext for this deployment
* @return an instance of the correct type of Helper
* @throws java.io.IOException
*/
static AppClientDeployerHelper newInstance(final DeploymentContext dc, final AppClientArchivist archivist, final ClassLoader gfClientModuleLoader, final ServiceLocator habitat, final ASJarSigner jarSigner) throws IOException {
ApplicationClientDescriptor bundleDesc = dc.getModuleMetaData(ApplicationClientDescriptor.class);
Application application = bundleDesc.getApplication();
boolean insideEar = !application.isVirtual();
final AppClientDeployerHelper helper = (insideEar ? new NestedAppClientDeployerHelper(dc, bundleDesc, archivist, gfClientModuleLoader, application, habitat, jarSigner) : new StandaloneAppClientDeployerHelper(dc, bundleDesc, archivist, gfClientModuleLoader, application, habitat));
return helper;
}
Aggregations