Methods Summary |
---|
private static void | addModule(com.sun.enterprise.deployment.backend.DeployableObjectType type, com.sun.enterprise.config.ConfigBean module)Adds the specified module of the specified type.
getAppsConfigBean().addValue(toConfigBeanType(type), module);
|
public static void | addToConfig(com.sun.enterprise.deployment.backend.DeploymentRequest request)
try {
ConfigBean newApp = createNewModule(request.getType());
DeployableObjectType type = request.getType();
AttributeList attrList = populateAttributeList(request);
for (Object obj : attrList) {
Attribute attr = (Attribute) obj;
newApp.setAttributeValue(attr.getName(), (String) attr.getValue());
}
setPropertyOnAppBean(newApp, request);
addModule(request.getType(), newApp);
getConfigContext().resetConfigChangeList();
} catch (Exception e) {
if (e instanceof IASDeploymentException) {
throw (IASDeploymentException)e;
} else {
throw new IASDeploymentException(e);
}
}
|
private static com.sun.enterprise.admin.util.HostAndPort | buildHostAndPortFromConfig(com.sun.enterprise.config.ConfigContext configContext, boolean securityEnabled)Prepare HostAndPort object from the specified configuration.
Config config = ServerBeansFactory.getConfigBean(configContext);
HttpService httpService = config.getHttpService();
HttpListener [] listeners = httpService.getHttpListener();
return findNonadminListener(configContext, listeners, securityEnabled);
|
private static com.sun.enterprise.admin.util.HostAndPort | buildHostAndPortFromCurrentConfig(boolean securityEnabled)Prepare HostAndPort from the current configuration.
ServerContext serverContext = ApplicationServer.getServerContext();
if (serverContext == null) {
throw new IllegalStateException("Unable to locate server context");
}
ConfigContext configContext = serverContext.getConfigContext();
if (configContext == null) {
throw new IllegalStateException("Unable to locate config context from server");
}
return buildHostAndPortFromConfig(configContext, securityEnabled);
|
public static void | checkAbort(java.lang.String moduleID)
DeploymentRequest request =
DeploymentRequestRegistry.getRegistry().getDeploymentRequest(
moduleID);
if (request != null && request.isAborted()) {
DeploymentRequestRegistry.getRegistry().removeDeploymentRequest(
moduleID);
String msg = localStrings.getString(
"enterprise.deployment.phasing.operation.abort",
new Object[]{ moduleID });
throw new IASDeploymentException(msg);
}
|
public static void | checkAppReferencesBeforeUndeployFromDomain(java.lang.String appName)
try {
// make sure no one reference the app before we undeploy it
if (ApplicationHelper.isApplicationReferenced(
getConfigContext(), appName)) {
throw new IASDeploymentException(localStrings.getString("applicationIsReferenced", appName, ApplicationHelper.getApplicationReferenceesAsString(getConfigContext(), appName)));
}
} catch (IASDeploymentException ex) {
throw (ex);
} catch (Exception ex) {
throw new IASDeploymentException(ex);
}
|
private static java.lang.String | checkConnectorDependentResources(com.sun.enterprise.deployment.backend.DeploymentRequest req)
String id = req.getName();
MBeanServer mbs = MBeanServerFactory.getMBeanServer();
ObjectName mbeanName =
new ObjectName("com.sun.appserv:type=resources,category=config");
Object[] params = new Object[] {};
String[] signature = new String[] {};
// check admin objects
ObjectName[] adminObjs =
(ObjectName[]) mbs.invoke(mbeanName, LIST_ADMIN_OBJECTS,
params, signature);
for(int i = 0 ; i< adminObjs.length;i++) {
String raName =
(String)mbs.getAttribute(adminObjs[i],"res_adapter");
if(id.equals(raName)) {
String adminObjName =
(String)mbs.getAttribute(adminObjs[i], "jndi_name");
return ("admin object [" + adminObjName + "]");
}
}
// check pool and resources
ObjectName[] poolNames = (ObjectName[])mbs.invoke(mbeanName,
LIST_CONNECTOR_CONNECTION_POOLS, params, signature);
for (int i = 0 ; i< poolNames.length;i++) {
String raName = (String)mbs.getAttribute(poolNames[i],
"resource_adapter_name");
if(id.equals(raName)) {
String poolName = (String)mbs.getAttribute(poolNames[i],
"name");
return ("connector connection pool [" + poolName + "]");
}
}
// check resource adapter config
ObjectName[] resAdapterConfigs = (ObjectName[])mbs.invoke(mbeanName,
LIST_RESOURCE_ADAPTER_CONFIGS, params, signature);
for (int i = 0 ; i< resAdapterConfigs.length;i++) {
String raName = (String)mbs.getAttribute(resAdapterConfigs[i],
"resource_adapter_name");
if(id.equals(raName)) {
return ("resource adapter config");
}
}
return null;
|
public static java.lang.String | checkConnectorDependentResourcesForUndeploy(com.sun.enterprise.deployment.backend.DeploymentRequest req)
try {
if (req.getCascade() || !containsResourceAdapter(req)) {
return null;
}
List<Resource> resourceList = getResourceList(req, false, null);
if (resourceList == null || resourceList.size() == 0) {
return checkConnectorDependentResources(req);
} else {
return null;
}
} catch (Exception e) {
sLogger.log(Level.WARNING, e.getMessage(), e);
return null;
}
|
public static void | checkWebModuleReferences(java.lang.String webModuleName)This method checks if any of the virtual servers has the given web
module as default-web-module. If yes, it throws exception.
ArrayList virtualServerIds = new ArrayList();
try {
Config config = (Config) ConfigBeansFactory.getConfigBeanByXPath(
getConfigContext(), ServerXPathHelper.XPATH_CONFIG);
HttpService httpService = config.getHttpService();
VirtualServer[] virtualServers = httpService.getVirtualServer();
for (int j = 0; j < virtualServers.length; j++) {
VirtualServer aServer = virtualServers[j];
String defWebModule = aServer.getDefaultWebModule();
if ((defWebModule != null) &&
(defWebModule.equals(webModuleName))) {
virtualServerIds.add(aServer.getId());
}
}
} catch (Exception e) {
throw new IASDeploymentException(e);
}
if (!virtualServerIds.isEmpty()) {
throw new IASDeploymentException(localStrings.getString(
"enterprise.deployment.phasing.def_web_module_refs_exist",
virtualServerIds.toString(), webModuleName));
}
|
public static boolean | containsResourceAdapter(com.sun.enterprise.deployment.backend.DeploymentRequest req)
boolean containsRar = false;
if(!req.isApplication())
{
if (req.isConnectorModule()) {
containsRar = true;
}
} else {
Application app = getInstanceManager(DeployableObjectType.APP
).getRegisteredDescriptor(req.getName());
if ( (app != null) && (app.getRarComponentCount() != 0) ) {
containsRar = true;
}
}
return containsRar;
|
private static com.sun.enterprise.config.ConfigBean | createNewModule(com.sun.enterprise.deployment.backend.DeployableObjectType type)Creates a new instance of the specified module type.
ConfigBean result = null;
if (type.equals(DeployableObjectType.APP)) {
result = new J2eeApplication();
} else if (type.equals(DeployableObjectType.CAR)) {
result = new AppclientModule();
} else if (type.equals(DeployableObjectType.CONN)) {
result = new ConnectorModule();
} else if (type.equals(DeployableObjectType.EJB)) {
result = new EjbModule();
} else if (type.equals(DeployableObjectType.WEB)) {
result = new WebModule();
} else {
throw new IllegalArgumentException(type.toString());
}
return result;
|
private static com.sun.enterprise.admin.util.HostAndPort | findNonadminListener(com.sun.enterprise.config.ConfigContext configContext, com.sun.enterprise.config.serverbeans.HttpListener[] listeners, boolean securityEnabled)Find the first non-admin HTTP listener in the specified list with the
requested security setting.
/*
*Find a listener that is enabled, not the admin listener, with the
*the requested security setting.
*/
HostAndPort result = null;
for (HttpListener listener : listeners) {
if (listener.isEnabled()
&& ! listener.getDefaultVirtualServer().equals(
com.sun.enterprise.web.VirtualServer.ADMIN_VS)
&& listener.isSecurityEnabled() == securityEnabled) {
String serverName = listener.getServerName();
if (serverName == null || serverName.trim().equals("")) {
serverName = getDefaultHostName();
}
String portStr = listener.getPort();
String redirectPortStr = listener.getRedirectPort();
if (redirectPortStr != null && ! redirectPortStr.trim().equals("")) {
portStr = redirectPortStr;
}
/*
*Resolve any property expression to an integer.
*/
String resolvedPortStr =
new PropertyResolver(configContext,
getInstanceName()).resolve(portStr);
int port = Integer.parseInt(resolvedPortStr);
result = new HostAndPort(serverName, port, listener.isSecurityEnabled());
break;
}
}
return result;
|
protected static void | flushConfigAndSendEvents()
AdminContext adminContext =
AdminService.getAdminService().getAdminContext();
ConfigContext ctx = adminContext.getAdminConfigContext();
if (ctx.isChanged()) {
ctx.flush();
}
new AdminNotificationHelper(adminContext).sendNotification();
|
public static DeploymentTarget | getAndValidateDeploymentTarget(java.lang.String targetName, java.lang.String appName, boolean isDeleting)
try {
final DeploymentTarget target = getDeploymentTarget(targetName);
if (targetName == null) {
// If the targetName passed in was null, we need to set it
// to its default value.
targetName = target.getTarget().getName();
}
if (target.getTarget().getType() == TargetType.SERVER ||
target.getTarget().getType() == TargetType.DAS) {
// make sure we have the reference before we delete it
if (isDeleting) {
if (!ServerHelper.serverReferencesApplication(
getConfigContext(), targetName, appName)) {
throw new IASDeploymentException(localStrings.getString("serverApplicationRefDoesNotExist", targetName, appName));
}
// make sure we don't have the reference already before
// we create it again
} else {
if (ServerHelper.serverReferencesApplication(
getConfigContext(), targetName, appName)) {
throw new IASDeploymentException(localStrings.getString("serverApplicationRefAlreadyExists", appName, targetName));
}
}
} else if (target.getTarget().getType() == TargetType.CLUSTER){
// make sure we have the reference before we delete it
if (isDeleting) {
if (!ClusterHelper.clusterReferencesApplication(
getConfigContext(), targetName, appName)) {
throw new IASDeploymentException(localStrings.getString("clusterApplicationRefDoesNotExist", targetName, appName));
}
// make sure we don't have the reference already before
// we create it again
} else {
if (ClusterHelper.clusterReferencesApplication(
getConfigContext(), targetName, appName)) {
throw new IASDeploymentException(localStrings.getString("clusterApplicationRefAlreadyExists", appName, targetName));
}
}
}
return target;
} catch (IASDeploymentException ex) {
throw (ex);
} catch (Exception ex) {
throw new IASDeploymentException(ex);
}
|
private static com.sun.enterprise.config.serverbeans.Applications | getAppsConfigBean()
ConfigContext configContext = getConfigContext();
Domain domainConfig = ConfigAPIHelper.getDomainConfigBean(configContext);
Applications appsConfig = domainConfig.getApplications();
return appsConfig;
|
public static java.lang.String | getClientJarPath(java.lang.String moduleID)
// let's ensure first that our client jar is ready.
ClientJarMakerRegistry registry = ClientJarMakerRegistry.getInstance();
if (registry.isRegistered(moduleID)) {
// let's wait until it is finished.
registry.waitForCompletion(moduleID);
}
return moduleID + DeploymentImplConstants.ClientJarSuffix;
|
public static com.sun.enterprise.config.ConfigContext | getConfigContext()
try {
AdminService adminService = AdminService.getAdminService();
if (adminService != null) {
ConfigContext config =
adminService.getAdminContext().getAdminConfigContext();
return config;
} else {
return null;
}
} catch (Exception e) {
sLogger.log(Level.WARNING, e.getMessage(), e);
return null;
}
|
public static java.lang.String[] | getContextRootsForEmbeddedWebApp(java.lang.String appName)This method is for j2ee application with embedded web modules.
First it tries to get application from AppsManager of DAS,
if it's not already loaded there, then we load from disk.
Since this method might read from disk, it could be time-consuming.
The context roots in sun-application.xml will override the ones
defined in application.xml.
The method returns String[0] when there is no web module in the
application.
try {
AppsManager appsManager =
new AppsManager(new InstanceEnvironment(getInstanceName()));
Application application =
appsManager.getRegisteredDescriptor(appName);
// if the application already loaded on DAS
if (application != null) {
ArrayList contextRoots = new ArrayList();
for (Iterator itr = application.getWebBundleDescriptors().iterator(); itr.hasNext();) {
WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
contextRoots.add(wbd.getContextRoot());
}
return (String[])contextRoots.toArray(new String[contextRoots.size()]);
// if not, read from disk
} else {
// load from generated/xml dir first
// print a warning if generated/xml dir is not there
// and load from original dir (upgrade scenario)
String xmlDir = appsManager.getGeneratedXMLLocation(appName);
if (!FileUtils.safeIsDirectory(xmlDir)) {
String appDir = appsManager.getLocation(appName);
// log a warning message in the server log
sLogger.log(Level.WARNING, "deployment.no_xmldir",
new Object[]{xmlDir, appDir});
xmlDir = appDir;
}
AppDD appDD = new AppDD(new File(xmlDir));
return appDD.getContextRoots();
}
} catch (Exception e) {
if (e instanceof IASDeploymentException) {
throw (IASDeploymentException)e;
} else {
throw new IASDeploymentException(e);
}
}
|
private static java.lang.String | getDefaultHostName()
String defaultHostName = "localhost";
try {
InetAddress host = InetAddress.getLocalHost();
defaultHostName = host.getCanonicalHostName();
} catch(UnknownHostException uhe) {
sLogger.log(Level.FINEST, "mbean.get_local_host_error", uhe);
sLogger.log(Level.INFO, "mbean.use_default_host");
}
return defaultHostName;
|
private static int | getDefaultPort(boolean securityEnabled)
int port = 0;
if (securityEnabled) {
port = 8181;
} else {
port = 8080;
}
sLogger.log(Level.INFO, "mbean.use_default_port", String.valueOf(port));
return port;
|
public static com.sun.enterprise.deployment.backend.DeployableObjectType | getDeployableObjectType(javax.enterprise.deploy.shared.ModuleType type)This method should be removed once we remove the use of
DeployableObjectType.
if (ModuleType.EAR.equals(type)) {
return DeployableObjectType.APP;
} else if (ModuleType.EJB.equals(type)) {
return DeployableObjectType.EJB;
} else if (ModuleType.WAR.equals(type)) {
return DeployableObjectType.WEB;
} else if (ModuleType.CAR.equals(type)) {
return DeployableObjectType.CAR;
} else if (ModuleType.RAR.equals(type)) {
return DeployableObjectType.CONN;
}
return null;
|
public static DeploymentTarget | getDeploymentTarget(java.lang.String targetName)
try {
final DeploymentTarget target = DeploymentTargetFactory.getDeploymentTargetFactory().getTarget(getConfigContext(), getDomainName(), targetName);
return target;
} catch (IASDeploymentException ex) {
throw (ex);
} catch (Exception ex) {
throw new IASDeploymentException(ex);
}
|
public static java.lang.String | getDomainName()
try {
AdminService adminService = AdminService.getAdminService();
if (adminService != null) {
String domainName =
adminService.getAdminContext().getDomainName();
return domainName;
} else {
return null;
}
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
public static java.io.FilenameFilter | getFilenameFilter(java.lang.String fileName)
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
if ( (new File(dir, name)).isDirectory()) {
return true;
} else if (name !=null && name.equals(fileName)){
return true;
} else {
return false;
}
}
};
return filter;
|
private static com.sun.enterprise.admin.util.HostAndPort | getHostAndPort(boolean securityEnabled)
return buildHostAndPortFromCurrentConfig(securityEnabled);
|
private static java.lang.String | getHostName(com.sun.enterprise.admin.util.HostAndPort hap)
String hostName = hap.getHost();
if (hostName == null || hostName.trim().equals("")) {
hostName = getDefaultHostName();
}
return hostName;
|
public static com.sun.enterprise.instance.BaseManager | getInstanceManager(com.sun.enterprise.deployment.backend.DeployableObjectType moduleType)
try {
InstanceEnvironment insEnv =
new InstanceEnvironment(getInstanceName());
if (moduleType.equals(DeployableObjectType.APP)) {
return new AppsManager(insEnv);
} else if (moduleType.equals(DeployableObjectType.EJB)) {
return new EjbModulesManager(insEnv);
} else if(moduleType.equals(DeployableObjectType.WEB)) {
return new WebModulesManager(insEnv);
} else if(moduleType.equals(DeployableObjectType.CONN)) {
return new ConnectorModulesManager(insEnv);
} else if (moduleType.equals(DeployableObjectType.CAR)) {
return new AppclientModulesManager(insEnv);
} else {
// invalid module type
return null;
}
} catch (Exception e) {
sLogger.log(Level.WARNING, e.getMessage(), e);
return null;
}
|
public static java.lang.String | getInstanceName()
return ApplicationServer.getServerContext().getInstanceName();
|
public static java.lang.String | getLocation(java.io.File appDir)
if (appDir != null) {
return (RelativePathResolver.unresolvePath(
appDir.getAbsolutePath(),
new String[] {SystemPropertyConstants.INSTANCE_ROOT_PROPERTY,
SystemPropertyConstants.INSTALL_ROOT_PROPERTY}));
} else {
return null;
}
|
public static java.lang.String | getLocation(java.lang.String appId, com.sun.enterprise.deployment.backend.DeployableObjectType type)
try {
ConfigBean module = getModule(appId, type);
String location = module.getAttributeValue(ServerTags.LOCATION);
return (new RelativePathResolver()).resolve(location);
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
private static com.sun.enterprise.config.ConfigBean | getModule(java.lang.String appID, com.sun.enterprise.deployment.backend.DeployableObjectType type)Finds the module with the specified ID of the given type.
ConfigBean module = ApplicationHelper.findApplication(getConfigContext(), appID);
if (module != null && type.equals(toDeployableObjectType(module))) {
return module;
} else {
return null;
}
|
public static java.lang.String | getModuleTypeString(com.sun.enterprise.deployment.backend.DeployableObjectType moduleType)Get module type string using the DeployableObjectType. This string is used
while multicasting events to remote servers
String moduleTypeString = null;
if (moduleType.equals(DeployableObjectType.EJB))
{
moduleTypeString = ModuleDeployEvent.TYPE_EJBMODULE;
}
else if(moduleType.equals(DeployableObjectType.WEB))
{
moduleTypeString = ModuleDeployEvent.TYPE_WEBMODULE;
}
else if(moduleType.equals(DeployableObjectType.CONN))
{
moduleTypeString = ModuleDeployEvent.TYPE_CONNECTOR;
}
else if (moduleType.equals(DeployableObjectType.CAR))
{
moduleTypeString = ModuleDeployEvent.TYPE_APPCLIENT;
}
return moduleTypeString;
|
private static java.lang.Object | getNamedAttributeValue(javax.management.AttributeList attrs, java.lang.String attrName)Get value of named attribute from attributes list. If an attribute with
specified name does not exist, the method returns null. If there are
than one attributes with same name then the method returns value of
first matching attribute.
if (attrs == null || attrName == null) {
return null;
}
Object value = null;
Iterator iter = attrs.iterator();
while (iter.hasNext()) {
Attribute attr = (Attribute)iter.next();
if (attrName.equals(attr.getName())) {
value = attr.getValue();
break;
}
}
return value;
|
public static java.lang.String | getObjectType(java.lang.String appId, com.sun.enterprise.deployment.backend.DeployableObjectType type)
try {
// appclient module does not have object type
if (type.isCAR()) {
return null;
}
ConfigBean module = getModule(appId, type);
String objectType = module.getAttributeValue(ServerTags.OBJECT_TYPE);
return objectType;
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
private static int | getPort(com.sun.enterprise.admin.util.HostAndPort hap, boolean securityEnabled)
int port = hap.getPort();
if (port == 0) {
port = getDefaultPort(securityEnabled);
}
return port;
|
public static com.sun.enterprise.deployment.backend.DeployableObjectType | getRegisteredType(java.lang.String name)Returns the type of the registered component.
If the component is not registered throws a DeploymentException
try{
for(int i = 0; i< deployableObjectTypes.length; i++)
{
if (isRegistered(name, deployableObjectTypes[i])) {
return deployableObjectTypes[i];
}
}
}catch(Exception e){
throw new DeploymentException(e.getMessage());
}
String msg = localStrings.getString(
"enterprise.deployment.component.not.registered", name);
throw new DeploymentException(msg);
|
public static java.util.List | getResourceList(com.sun.enterprise.deployment.backend.DeploymentRequest req, boolean isForceParsing, DeploymentContext deploymentCtx)
List<Resource> resourceList = null;
// if resource list is null, it means it needs to
// read in sun-resource.xml and parse it,
// if resource list is empty, it means it's been processed
// but no sun-resource.xml is found
Application app = getInstanceManager(req.getType()
).getRegisteredDescriptor(req.getName());
if (app == null && deploymentCtx != null) {
app = deploymentCtx.getApplication(req.getName());
}
if (app != null && app.getResourceList() != null &&
!isForceParsing) {
// first try to get the in-memory copy from application
// always re-set the list from disk when isForceParsing is
// set to true
resourceList = (List<Resource>)app.getResourceList();
} else {
// then try to get it from resources.xml
// and set in the application object
resourceList = getResourcesFromResourcesXML(
req.getName(), req.getType(), deploymentCtx);
if (app != null) {
app.setResourceList(resourceList);
}
}
return resourceList;
|
private static java.util.List | getResourcesFromResourcesXML(java.lang.String appId, com.sun.enterprise.deployment.backend.DeployableObjectType moduleType, DeploymentContext deploymentCtx)
// retrieve all the sun-resources.xml under the
// generated/xml directory
String directoryToLook =
getInstanceManager(moduleType).getGeneratedXMLLocation(appId);
Set listOfFiles = FileUtil.getAllFilesUnder(
new File(directoryToLook),
getFilenameFilter(SUN_RESOURCE_XML), true);
// get the expected paths
ArrayList<String> expectedXMLPaths = new ArrayList<String>();
Application app = getInstanceManager(
moduleType).getRegisteredDescriptor(appId);
// The only case it could be null is during undeployment
// and when the application is already unregistered from
// instance manager. In that case, get it from the deployment
// context cache.
if (app == null && deploymentCtx != null) {
app = deploymentCtx.getApplication(appId);
}
if (app != null) {
if (app.isVirtual()) {
// for standalone module, it's under the root META-INF
expectedXMLPaths.add(SUN_RESOURCE_XML_PATH);
} else {
// for application
// first add the one under app root
expectedXMLPaths.add(SUN_RESOURCE_XML_PATH);
// then add the ones under sub module root
for (Iterator itr = app.getModules();itr.hasNext();) {
ModuleDescriptor aModule =
(ModuleDescriptor) itr.next();
String moduleUri = FileUtils.makeFriendlyFileName(
aModule.getArchiveUri());
String subModulePath = moduleUri +
File.separator + SUN_RESOURCE_XML_PATH;
expectedXMLPaths.add(subModulePath);
}
}
} else {
// the default
expectedXMLPaths.add(SUN_RESOURCE_XML_PATH);
}
// process all the sun-resources.xml and add them
// to a list for further processing
List<SunResourcesXML> resourcesXMLList =
new ArrayList<SunResourcesXML>();
for (Iterator fIter = listOfFiles.iterator(); fIter.hasNext(); ) {
File file = (File)fIter.next();
String filePath = file.getPath();
String xmlFilePath =
(new File(directoryToLook, filePath)).getAbsolutePath();
if (expectedXMLPaths.contains(filePath)) {
ResourcesXMLParser allResources =
new ResourcesXMLParser(xmlFilePath);
SunResourcesXML sunResourcesXML = new SunResourcesXML(
filePath, allResources.getResourcesList());
resourcesXMLList.add(sunResourcesXML);
} else {
sLogger.log(Level.WARNING,
"enterprise.deployment.ignore.sun.resources.xml",
xmlFilePath);
}
}
return processResourcesList(resourcesXMLList);
|
public static java.util.List | getTargetNamesFromTargetString(java.lang.String targetString)
if (targetString == null) {
return null;
}
StringTokenizer st = new StringTokenizer(targetString);
List<String> targetNames = new ArrayList<String>();
while (st.hasMoreTokens()) {
targetNames.add(st.nextToken());
}
return targetNames;
|
public static com.sun.enterprise.deployment.backend.DeployableObjectType | getTypeFromFile(java.lang.String name, java.lang.String filePath)This method returns the deployableObjectType of an archive by checking
the deployable descriptors in the archive
if(filePath == null)
throw new DeploymentException("deploy file not specified");
try {
//@@@ special handling the deployment of .class POJO webservice
//class.
if (filePath.endsWith(".class")) {
// get the top directory from the moduleID, in the case of
// autodeploy, the moduleID will be the full class name (with package)
// with . replaced with _
StringTokenizer tk = new StringTokenizer(name, "_");
File f = new File(filePath);
for (int i=0;i<tk.countTokens();i++) {
f = f.getParentFile();
}
try {
// it's important to not cache this because the class can
// change overtime... we need to load the last one.
URL[] urls = new URL[1];
urls[0] = f.toURL();
URLClassLoader cLoader = new URLClassLoader(urls,
DeploymentServiceUtils.class.getClassLoader());
String className = name.replaceAll("_", ".");
Class clazz = cLoader.loadClass(className);
if (clazz!=null && clazz.getAnnotation(javax.ejb.Stateless.class)!=null) {
return DeployableObjectType.EJB;
} else {
return DeployableObjectType.WEB;
}
} catch(Exception e) {
sLogger.log(Level.WARNING, e.getMessage(), e);
return DeployableObjectType.WEB;
}
}
Archivist archivist =
ArchivistFactory.getArchivistForArchive(filePath);
ModuleType moduleType = archivist.getModuleType();
return getDeployableObjectType(moduleType);
} catch (IOException ioe) {
DeploymentException de = new DeploymentException(
localStrings.getString(
"enterprise.deployment.ioexc_getting_archtype", filePath));
de.initCause(ioe);
throw de;
} catch(Exception ex) {
DeploymentException de = new DeploymentException(
localStrings.getString(
"enterprise.deployment.unknown.application.type", filePath));
de.initCause(ex);
throw de;
}
|
private static com.sun.enterprise.admin.util.HostAndPort | getVirtualServerHostAndPort(java.lang.String vs, boolean securityEnabled)
String serverName = null;
int port = 0;
try {
Domain domain = ConfigAPIHelper.getDomainConfigBean(getConfigContext());
Config config = domain.getConfigs().getConfig(0);
HttpService httpService = config.getHttpService();
HttpListener[] httpListener = httpService.getHttpListener();
VirtualServer[] virtualServer = httpService.getVirtualServer();
// iterate for each of the config virtual server
for (VirtualServer v : virtualServer) {
// virtual server id check
//
// if the virtual server obtained from application ref
// does not match with the virtual server from config
// then continue with next virtual server
if ( ! v.getId().equals(vs)) {
continue;
}
// should we check for state, let us assume ON for PE
// http listener
//
// Obtain the http listeners list from the virtual server
// and iterate to match with the http listeners from config.
// When a match is found get the host and port data
String httpListeners = v.getHttpListeners();
List<String> httpListenerList = (List<String>) StringUtils.parseStringList(httpListeners, " ,");
for (String vsHttpListenerID : httpListenerList) {
for (HttpListener listener : httpListener) {
if ( ! listener.getId().equals(vsHttpListenerID)) {
continue;
}
if ( ! listener.isEnabled()) {
continue;
}
if (listener.isSecurityEnabled() == securityEnabled) {
serverName = listener.getServerName();
if (serverName == null || serverName.trim().equals("")) {
serverName = getDefaultHostName();
}
String portStr = listener.getPort();
String redirPort = listener.getRedirectPort();
if (redirPort != null && !redirPort.trim().equals("")) {
portStr = redirPort;
}
final String resolvedPort =
new PropertyResolver(getConfigContext(),
getInstanceName()).resolve(portStr);
port = Integer.parseInt(resolvedPort);
return new HostAndPort(serverName, port);
}
}
}
}
} catch (Exception e) {
ServerInstanceException sie =
new ServerInstanceException(e.getLocalizedMessage());
sie.initCause(e);
throw sie;
}
return null;
|
public static boolean | isDirectoryDeployed(java.lang.String appId, com.sun.enterprise.deployment.backend.DeployableObjectType type)
try {
ConfigBean module = getModule(appId, type);
String[] attributeNames = module.getAttributeNames();
for (String attributeName: attributeNames) {
if (attributeName.equals(DIRECTORY_DEPLOYED_ATTR)) {
String directoryDeployed =
module.getAttributeValue(DIRECTORY_DEPLOYED_ATTR);
return Boolean.valueOf(directoryDeployed).booleanValue();
}
}
return false;
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
public static boolean | isEnabled(java.lang.String appId, com.sun.enterprise.deployment.backend.DeployableObjectType type)
try {
ConfigBean module = getModule(appId, type);
String enabled = module.getAttributeValue(ServerTags.ENABLED);
return Boolean.valueOf(enabled).booleanValue();
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
public static boolean | isExternallyManagedApp(java.lang.String appName, com.sun.enterprise.deployment.backend.DeployableObjectType type)
try {
ConfigBean appBean = getModule(appName, type);
if (appBean != null) {
ElementProperty extManagedProperty = null;
if (appBean instanceof J2eeApplication) {
J2eeApplication app = (J2eeApplication) appBean;
extManagedProperty =
app.getElementPropertyByName(EXTERNALLY_MANAGED);
} else if (appBean instanceof EjbModule) {
EjbModule app = (EjbModule) appBean;
extManagedProperty =
app.getElementPropertyByName(EXTERNALLY_MANAGED);
} else if (appBean instanceof WebModule) {
WebModule app = (WebModule) appBean;
extManagedProperty =
app.getElementPropertyByName(EXTERNALLY_MANAGED);
} else if (appBean instanceof AppclientModule) {
AppclientModule app = (AppclientModule) appBean;
extManagedProperty =
app.getElementPropertyByName(EXTERNALLY_MANAGED);
} else if (appBean instanceof ConnectorModule) {
ConnectorModule app = (ConnectorModule) appBean;
extManagedProperty =
app.getElementPropertyByName(EXTERNALLY_MANAGED);
}
if (extManagedProperty != null) {
return Boolean.valueOf(
extManagedProperty.getValue()).booleanValue();
} else {
return false;
}
} else {
return false;
}
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
public static boolean | isRegistered(java.lang.String appName, com.sun.enterprise.deployment.backend.DeployableObjectType type)
try {
ConfigBean module = getModule(appName, type);
return (module != null);
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
public static boolean | isSystem(java.lang.String appId, com.sun.enterprise.deployment.backend.DeployableObjectType type)
String objectType = getObjectType(appId, type);
if (objectType != null) {
return objectType.startsWith(SYSTEM_PREFIX);
} else {
return false;
}
|
static boolean | multicastEvent(int eventType, java.lang.String entityName, java.lang.String targetName)This method is used by StartPhase, StopPhases to multicast start/stop
events to the listeners. To multicast to a particular server the managedServerInstance
representing that particular server is used
return multicastEvent(eventType, entityName, null, targetName);
|
static boolean | multicastEvent(int eventType, java.lang.String entityName, java.lang.String moduleType, java.lang.String targetName)
return multicastEvent(eventType,entityName,moduleType, false, targetName);
|
static boolean | multicastEvent(int eventType, java.lang.String entityName, java.lang.String moduleType, boolean cascade, java.lang.String targetName)This method is used by StartPhase, StopPhases to multicast start/stop
events to the listeners. To multicast to a particular server the managedServerInstance
representing that particular server is used
return multicastEvent(eventType, entityName, moduleType, cascade, false, targetName) ;
|
static boolean | multicastEvent(int eventType, java.lang.String entityName, java.lang.String moduleType, boolean cascade, boolean forceDeploy, java.lang.String targetName)
return multicastEvent(eventType, entityName, moduleType, cascade, forceDeploy, Constants.LOAD_UNSET, targetName) ;
|
public static boolean | multicastEvent(int eventType, java.lang.String entityName, java.lang.String moduleType, boolean cascade, boolean forceDeploy, int loadUnloadAction, java.lang.String targetName)
// Flush config changes before sending the event. The events API
// requires that config be saved prior to sending event.
try {
ConfigContext config = getConfigContext();
if (config != null && config.isChanged()) {
config.flush();
} else {
// Server is initializing. Can not flush config changes.
}
} catch (ConfigException ce) {
throw new IASDeploymentException(ce);
}
try {
return DeploymentNotificationHelper.multicastEvent(eventType, entityName,
moduleType, cascade, forceDeploy, loadUnloadAction, targetName);
} catch (Throwable t) {
IASDeploymentException iasEx = new IASDeploymentException(t.getMessage());
iasEx.initCause(t);
throw iasEx;
}
// unreachable
|
private static javax.management.AttributeList | populateAttributeList(com.sun.enterprise.deployment.backend.DeploymentRequest request)
AttributeList attrList = new AttributeList();
String name = request.getName();
// name attribute
if (name != null && name.length() > 0 ) {
Attribute nameAttr = new Attribute(ServerTags.NAME, name);
attrList.add(nameAttr);
}
// location attribute
String location = getLocation(request.getDeployedDirectory());
if (location != null && location.length() > 0 ) {
Attribute locationAttr = new Attribute(ServerTags.LOCATION, location);
attrList.add(locationAttr);
}
// description attribute
String description = request.getDescription();
if (description != null && description.length() > 0 ) {
Attribute descriptionAttr =
new Attribute(ServerTags.DESCRIPTION, description);
attrList.add(descriptionAttr);
}
// enable attribute does not apply to app client module
if (! request.getType().isCAR()) {
String enabled = String.valueOf(request.isStartOnDeploy());
if (enabled != null && enabled.length() > 0 ) {
Attribute enableAttr = new Attribute(ServerTags.ENABLED, enabled);
attrList.add(enableAttr);
}
}
// java-web-start-enabled attribute
// applies to application and appclient module
if (request.getType().isAPP() || request.getType().isCAR()) {
String jwsEnabled =
String.valueOf(request.isJavaWebStartEnabled());
if (jwsEnabled != null && jwsEnabled.length() > 0 ) {
Attribute jwsEnableAttr = new Attribute(
ServerTags.JAVA_WEB_START_ENABLED, jwsEnabled);
attrList.add(jwsEnableAttr);
}
}
// libraries attribute
// applies to application, ejb, web module
if (request.getType().isAPP() || request.getType().isEJB() ||
request.getType().isWEB()) {
String libraries = request.getLibraries();
if (libraries != null && libraries.length() > 0 ) {
Attribute librariesAttr = new Attribute(
ServerTags.LIBRARIES, libraries);
attrList.add(librariesAttr);
}
}
// context-root attribute only apply to web module
if (request.getType().isWEB()) {
String contextRoot = request.getContextRoot();
if (contextRoot != null && contextRoot.length() > 0 ) {
Attribute contextRootAttr =
new Attribute(ServerTags.CONTEXT_ROOT, contextRoot);
attrList.add(contextRootAttr);
}
}
// availability-enabled attribute does not apply to app client
// or connector module
if (! request.getType().isCAR() && ! request.getType().isCONN()) {
String availEnabled = String.valueOf(request.isAvailabilityEnabled());
if (availEnabled!= null && availEnabled.length() > 0 ) {
Attribute availEnabledAttr =
new Attribute(ServerTags.AVAILABILITY_ENABLED, availEnabled);
attrList.add(availEnabledAttr);
}
}
// directory-deployed attribute
String dirDeployed = String.valueOf(request.isDirectory());
if (dirDeployed != null && dirDeployed.length() > 0 ) {
Attribute dirDeployedAttr =
new Attribute(ServerTags.DIRECTORY_DEPLOYED, dirDeployed);
attrList.add(dirDeployedAttr);
}
// other optional attributes like object-type
Properties optionalAttributes = request.getOptionalAttributes();
if (optionalAttributes != null) {
// remove the virtual-server attribute which belongs
// to application-ref
// cloning is done so that the original Properties object
// is not tampered with. The original Properties object is
// referred to in a few other places.
Properties mProps = (Properties) optionalAttributes.clone();
try {
mProps.remove(ServerTags.VIRTUAL_SERVERS);
} catch(Exception re) {}
Enumeration tags = mProps.keys();
while(tags.hasMoreElements()) {
String tag = (String)tags.nextElement();
String value = mProps.getProperty(tag);
if (tag != null && tag.length() > 0 &&
value != null && value.length() > 0) {
Attribute optionalAttr = new Attribute(tag, value);
attrList.add(optionalAttr);
}
}
}
return attrList;
|
private static java.util.List | processResourcesList(java.util.List resourcesXMLList)
// resolve the duplicates/conflicts within the archive
Set<Resource> resolvedResourcesWithinArchive =
ResourceUtilities.resolveResourceDuplicatesConflictsWithinArchive(
resourcesXMLList);
List<Resource> allResources = new ArrayList<Resource>();
for (Resource res: resolvedResourcesWithinArchive) {
allResources.add(res);
}
return allResources;
|
public static void | removeFromConfig(java.lang.String name, com.sun.enterprise.deployment.backend.DeployableObjectType type)
try {
ConfigBean module = getModule(name, type);
if (module != null) {
removeModule(type, module);
getConfigContext().flush();
getConfigContext().resetConfigChangeList();
}
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
private static void | removeModule(com.sun.enterprise.deployment.backend.DeployableObjectType type, com.sun.enterprise.config.ConfigBean module)Removes the specified module of the specified type.
removeReferences(module);
getAppsConfigBean().removeValue(toConfigBeanType(type), module);
|
private static void | removeReferences(com.sun.enterprise.config.ConfigBean module)Removes refererences to the specified module.
ConfigContext configContext = module.getConfigContext();
String name = module.getAttributeValue(ServerTags.NAME);
Server [] servers = ServerHelper.getServersReferencingApplication(configContext, name);
Cluster [] clusters = ClusterHelper.getClustersReferencingApplication(configContext, name);
for (Server s : servers) {
ApplicationRef ref = s.getApplicationRefByRef(name);
s.removeApplicationRef(ref);
}
for (Cluster c : clusters) {
ApplicationRef ref = c.getApplicationRefByRef(name);
c.removeApplicationRef(ref);
}
|
public static void | setContextRoot(java.lang.String appId, com.sun.enterprise.deployment.backend.DeployableObjectType type, java.lang.String contextRoot)
try {
if (contextRoot != null && contextRoot.length() > 0) {
ConfigBean module = getModule(appId, type);
module.setAttributeValue(ServerTags.CONTEXT_ROOT, contextRoot);
}
} catch (Exception e) {
throw new IASDeploymentException(e);
}
|
public static void | setHostAndPort(com.sun.enterprise.deployment.backend.DeploymentRequest req)Set http listener host and port in deployment request. If the server
is not configured properly the defaults used are localhost:8080 for
clear and localhost:8181 for SSL.
String virtualServers = (String) req.getOptionalAttributes().get(ServerTags.VIRTUAL_SERVERS);
if (virtualServers==null) {
HostAndPort hap = getHostAndPort(false);
if(hap != null) {
req.setHttpHostName(getHostName(hap));
req.setHttpPort(getPort(hap, false));
}
hap = getHostAndPort(true);
if(hap != null) {
req.setHttpsHostName(getHostName(hap));
req.setHttpsPort(getPort(hap, true));
}
} else {
StringTokenizer st = new StringTokenizer(virtualServers,",");
if (st.hasMoreTokens()) {
String aVirtualServer = st.nextToken();
HostAndPort hap = getVirtualServerHostAndPort(aVirtualServer, false);
if(hap != null) {
req.setHttpHostName(getHostName(hap));
req.setHttpPort(getPort(hap, false));
}
hap = getVirtualServerHostAndPort(aVirtualServer, true);
if(hap != null) {
req.setHttpsHostName(getHostName(hap));
req.setHttpsPort(getPort(hap, true));
}
}
}
|
public static void | setPropertyOnAppBean(com.sun.enterprise.config.ConfigBean appBean, com.sun.enterprise.deployment.backend.DeploymentRequest request)
if (request.isExternallyManagedApp()) {
ElementProperty extManagedProperty = new ElementProperty();
extManagedProperty.setName(EXTERNALLY_MANAGED);
extManagedProperty.setValue("true");
if (appBean instanceof J2eeApplication) {
J2eeApplication app = (J2eeApplication) appBean;
app.addElementProperty(extManagedProperty);
} else if (appBean instanceof EjbModule) {
EjbModule app = (EjbModule) appBean;
app.addElementProperty(extManagedProperty);
} else if (appBean instanceof WebModule) {
WebModule app = (WebModule) appBean;
app.addElementProperty(extManagedProperty);
} else if (appBean instanceof AppclientModule) {
AppclientModule app = (AppclientModule) appBean;
app.addElementProperty(extManagedProperty);
} else if (appBean instanceof ConnectorModule) {
ConnectorModule app = (ConnectorModule) appBean;
app.addElementProperty(extManagedProperty);
}
}
|
public static void | setResourceOptionsInRequest(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.util.DeploymentProperties props)
req.setResourceAction(props.getResourceAction());
req.setResourceTargetList(props.getResourceTargetList());
|
private static java.lang.String | toConfigBeanType(com.sun.enterprise.deployment.backend.DeployableObjectType type)Converts a deployable object type to the String for the ConfigBean type.
String result;
if (type.equals(DeployableObjectType.APP)) {
result = Applications.J2EE_APPLICATION;
} else if (type.equals(DeployableObjectType.CAR)) {
result = Applications.APPCLIENT_MODULE;
} else if (type.equals(DeployableObjectType.CONN)) {
result = Applications.CONNECTOR_MODULE;
} else if (type.equals(DeployableObjectType.EJB)) {
result = Applications.EJB_MODULE;
} else if (type.equals(DeployableObjectType.WEB)) {
result = Applications.WEB_MODULE;
} else {
throw new IllegalArgumentException(type.toString());
}
return result;
|
private static com.sun.enterprise.deployment.backend.DeployableObjectType | toDeployableObjectType(com.sun.enterprise.config.ConfigBean module)Returns the DeployableObjectType for the particular type of ConfigBean.
DeployableObjectType result;
if (module instanceof J2eeApplication) {
result = DeployableObjectType.APP;
} else if (module instanceof EjbModule) {
result = DeployableObjectType.EJB;
} else if (module instanceof WebModule) {
result = DeployableObjectType.WEB;
} else if (module instanceof LifecycleModule) {
result = DeployableObjectType.LCM;
} else if (module instanceof AppclientModule) {
result = DeployableObjectType.CAR;
} else if (module instanceof ConnectorModule) {
result = DeployableObjectType.CONN;
} else {
result = null;
}
return result;
|
public static void | updateConfig(com.sun.enterprise.deployment.backend.DeploymentRequest request)
try {
String name = request.getName();
ConfigBean appBean =
ApplicationHelper.findApplication(getConfigContext(), name);
if (appBean != null) {
for (Iterator itr = populateAttributeList(request).iterator();
itr.hasNext();) {
Attribute attr = (Attribute)itr.next();
appBean.setAttributeValue(attr.getName(),
(String)attr.getValue());
}
setPropertyOnAppBean(appBean, request);
getConfigContext().flush();
getConfigContext().resetConfigChangeList();
}
} catch (Exception e) {
if (e instanceof IASDeploymentException) {
throw (IASDeploymentException)e;
} else {
throw new IASDeploymentException(e);
}
}
|
public static void | validate(java.lang.String appID, com.sun.enterprise.deployment.backend.DeployableObjectType type, java.lang.String action, com.sun.enterprise.deployment.backend.DeploymentRequest request)This method checks if the app specified is of
a system application/module or
an externally managed application/module or
a resource adapter having dependent resources
boolean allowSystemAppModification =
(Boolean.valueOf(System.getProperty(
Constants.ALLOW_SYSAPP_DEPLOYMENT, "false")).booleanValue());
if(!allowSystemAppModification && isSystem(appID, type)) {
String msg = localStrings.getString(
"enterprise.deployment.phasing.component_is_system",
new Object[]{ action, appID });
throw new IASDeploymentException(msg);
}
boolean isExternallyManagedPath = request.isExternallyManagedPath();
if (!isExternallyManagedPath &&
isExternallyManagedApp(appID, type)) {
String msg = localStrings.getString("enterprise.deployment.phasing.component_is_externally_managed", new Object[] {action, appID});
throw new IASDeploymentException( msg );
}
// only when this is undeployment request
String resAction = request.getResourceAction();
if (action.equals(PEDeploymentService.STOP_ACTION) &&
resAction != null &&
resAction.equals(DeploymentProperties.RES_UNDEPLOYMENT)){
String dependentResource =
checkConnectorDependentResourcesForUndeploy(request);
if (dependentResource != null) {
String msg = localStrings.getString("enterprise.deployment.phasing.stop.dependentresexist", new Object[] {dependentResource, request.getName()});
throw new IASDeploymentException( msg );
}
}
|