mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@3987 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4133 . Removed LicenseComponent reference from projects\repository\source\java\org\alfresco\repo\descriptor\DescriptorServiceImpl.java git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4135 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,16 +41,12 @@ import org.alfresco.service.license.LicenseService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.AbstractLifecycleBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
|
||||
@@ -59,12 +55,10 @@ import org.springframework.core.io.Resource;
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class DescriptorServiceImpl implements DescriptorService, ApplicationListener, InitializingBean, ApplicationContextAware, DisposableBean
|
||||
public class DescriptorServiceImpl extends AbstractLifecycleBean implements DescriptorService, InitializingBean
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class);
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
private Properties serverProperties;
|
||||
|
||||
private ImporterBootstrap systemBootstrap;
|
||||
@@ -78,14 +72,6 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
|
||||
private Descriptor installedRepoDescriptor;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server descriptor from a resource file
|
||||
*
|
||||
@@ -163,36 +149,36 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
|
||||
return (licenseService == null) ? null : licenseService.getLicense();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
public void onApplicationEvent(ApplicationEvent event)
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
if (event instanceof ContextRefreshedEvent)
|
||||
// initialise the repository descriptor
|
||||
// note: this requires that the repository schema has already been initialised
|
||||
TransactionWork<Descriptor> createDescriptorWork = new TransactionUtil.TransactionWork<Descriptor>()
|
||||
{
|
||||
// initialise the repository descriptor
|
||||
// note: this requires that the repository schema has already been initialised
|
||||
TransactionWork<Descriptor> createDescriptorWork = new TransactionUtil.TransactionWork<Descriptor>()
|
||||
public Descriptor doWork()
|
||||
{
|
||||
public Descriptor doWork()
|
||||
{
|
||||
// initialise license service (if installed)
|
||||
initialiseLicenseService();
|
||||
|
||||
// verify license, but only if license component is installed
|
||||
licenseService.verifyLicense();
|
||||
|
||||
// persist the server descriptor values
|
||||
updateCurrentRepositoryDescriptor(serverDescriptor);
|
||||
// initialise license service (if installed)
|
||||
initialiseLicenseService();
|
||||
|
||||
// verify license, but only if license component is installed
|
||||
licenseService.verifyLicense();
|
||||
|
||||
// persist the server descriptor values
|
||||
updateCurrentRepositoryDescriptor(serverDescriptor);
|
||||
|
||||
// return the repository installed descriptor
|
||||
return createInstalledRepositoryDescriptor();
|
||||
}
|
||||
};
|
||||
installedRepoDescriptor = TransactionUtil.executeInUserTransaction(transactionService, createDescriptorWork);
|
||||
}
|
||||
// return the repository installed descriptor
|
||||
return createInstalledRepositoryDescriptor();
|
||||
}
|
||||
};
|
||||
installedRepoDescriptor = TransactionUtil.executeInUserTransaction(transactionService, createDescriptorWork);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise Descriptors
|
||||
*/
|
||||
@@ -202,13 +188,6 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
|
||||
serverDescriptor = createServerDescriptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destruction hook
|
||||
*/
|
||||
public void destroy() throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create server descriptor
|
||||
*
|
||||
@@ -358,7 +337,7 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
|
||||
// be declaratively taken out in an installed environment.
|
||||
Class licenseComponentClass = Class.forName("org.alfresco.license.LicenseComponent");
|
||||
Constructor constructor = licenseComponentClass.getConstructor(new Class[] { ApplicationContext.class} );
|
||||
licenseService = (LicenseService)constructor.newInstance(new Object[] { applicationContext });
|
||||
licenseService = (LicenseService)constructor.newInstance(new Object[] { getApplicationContext() });
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
@@ -766,4 +745,5 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
|
||||
return serverProperties.getProperty(key, "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,11 +23,10 @@ import java.util.Map;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.license.LicenseDescriptor;
|
||||
import org.alfresco.util.AbstractLifecycleBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
|
||||
|
||||
/**
|
||||
@@ -35,7 +34,7 @@ import org.springframework.context.event.ContextRefreshedEvent;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class DescriptorStartupLog implements ApplicationListener
|
||||
public class DescriptorStartupLog extends AbstractLifecycleBean
|
||||
{
|
||||
// Logger
|
||||
private static final Log logger = LogFactory.getLog(DescriptorService.class);
|
||||
@@ -52,82 +51,6 @@ public class DescriptorStartupLog implements ApplicationListener
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
public void onApplicationEvent(ApplicationEvent event)
|
||||
{
|
||||
if (event instanceof ContextRefreshedEvent)
|
||||
{
|
||||
//
|
||||
// log output of VM stats
|
||||
//
|
||||
Map properties = System.getProperties();
|
||||
String version = (properties.get("java.runtime.version") == null) ? "unknown" : (String)properties.get("java.runtime.version");
|
||||
long maxHeap = Runtime.getRuntime().maxMemory();
|
||||
float maxHeapMB = maxHeap / 1024l;
|
||||
maxHeapMB = maxHeapMB / 1024l;
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info(String.format("Alfresco JVM - v%s; maximum heap size %.3fMB", version, maxHeapMB));
|
||||
}
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
if (version.startsWith("1.2") || version.startsWith("1.3") || version.startsWith("1.4"))
|
||||
{
|
||||
logger.warn(String.format("Alfresco JVM - WARNING - v1.5 is required; currently using v%s", version));
|
||||
}
|
||||
if (maxHeapMB < 500)
|
||||
{
|
||||
logger.warn(String.format("Alfresco JVM - WARNING - maximum heap size %.3fMB is less than recommended 512MB", maxHeapMB));
|
||||
}
|
||||
}
|
||||
|
||||
// Log License Descriptors (if applicable)
|
||||
LicenseDescriptor license = descriptorService.getLicenseDescriptor();
|
||||
if (license != null && logger.isInfoEnabled())
|
||||
{
|
||||
String subject = license.getSubject();
|
||||
String msg = "Alfresco license: " + subject;
|
||||
String holder = getHolderOrganisation(license.getHolder());
|
||||
if (holder != null)
|
||||
{
|
||||
msg += " granted to " + holder;
|
||||
}
|
||||
Date validUntil = license.getValidUntil();
|
||||
if (validUntil != null)
|
||||
{
|
||||
Integer days = license.getDays();
|
||||
Integer remainingDays = license.getRemainingDays();
|
||||
|
||||
msg += " limited to " + days + " days expiring " + validUntil + " (" + remainingDays + " days remaining)";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += " (does not expire)";
|
||||
}
|
||||
|
||||
|
||||
logger.info(msg);
|
||||
}
|
||||
|
||||
// Log Repository Descriptors
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
Descriptor serverDescriptor = descriptorService.getServerDescriptor();
|
||||
Descriptor installedRepoDescriptor = descriptorService.getInstalledRepositoryDescriptor();
|
||||
String serverEdition = serverDescriptor.getEdition();
|
||||
String serverVersion = serverDescriptor.getVersion();
|
||||
int serverSchemaVersion = serverDescriptor.getSchema();
|
||||
String installedRepoVersion = installedRepoDescriptor.getVersion();
|
||||
int installedSchemaVersion = installedRepoDescriptor.getSchema();
|
||||
logger.info(String.format("Alfresco started (%s): Current version %s schema %d - Installed version %s schema %d",
|
||||
serverEdition, serverVersion, serverSchemaVersion, installedRepoVersion, installedSchemaVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Organisation from Principal
|
||||
*
|
||||
@@ -156,5 +79,83 @@ public class DescriptorStartupLog implements ApplicationListener
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
//
|
||||
// log output of VM stats
|
||||
//
|
||||
Map properties = System.getProperties();
|
||||
String version = (properties.get("java.runtime.version") == null) ? "unknown" : (String)properties.get("java.runtime.version");
|
||||
long maxHeap = Runtime.getRuntime().maxMemory();
|
||||
float maxHeapMB = maxHeap / 1024l;
|
||||
maxHeapMB = maxHeapMB / 1024l;
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info(String.format("Alfresco JVM - v%s; maximum heap size %.3fMB", version, maxHeapMB));
|
||||
}
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
if (version.startsWith("1.2") || version.startsWith("1.3") || version.startsWith("1.4"))
|
||||
{
|
||||
logger.warn(String.format("Alfresco JVM - WARNING - v1.5 is required; currently using v%s", version));
|
||||
}
|
||||
if (maxHeapMB < 500)
|
||||
{
|
||||
logger.warn(String.format("Alfresco JVM - WARNING - maximum heap size %.3fMB is less than recommended 512MB", maxHeapMB));
|
||||
}
|
||||
}
|
||||
|
||||
// Log License Descriptors (if applicable)
|
||||
LicenseDescriptor license = descriptorService.getLicenseDescriptor();
|
||||
if (license != null && logger.isInfoEnabled())
|
||||
{
|
||||
String subject = license.getSubject();
|
||||
String msg = "Alfresco license: " + subject;
|
||||
String holder = getHolderOrganisation(license.getHolder());
|
||||
if (holder != null)
|
||||
{
|
||||
msg += " granted to " + holder;
|
||||
}
|
||||
Date validUntil = license.getValidUntil();
|
||||
if (validUntil != null)
|
||||
{
|
||||
Integer days = license.getDays();
|
||||
Integer remainingDays = license.getRemainingDays();
|
||||
|
||||
msg += " limited to " + days + " days expiring " + validUntil + " (" + remainingDays + " days remaining)";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += " (does not expire)";
|
||||
}
|
||||
|
||||
|
||||
logger.info(msg);
|
||||
}
|
||||
|
||||
// Log Repository Descriptors
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
Descriptor serverDescriptor = descriptorService.getServerDescriptor();
|
||||
Descriptor installedRepoDescriptor = descriptorService.getInstalledRepositoryDescriptor();
|
||||
String serverEdition = serverDescriptor.getEdition();
|
||||
String serverVersion = serverDescriptor.getVersion();
|
||||
int serverSchemaVersion = serverDescriptor.getSchema();
|
||||
String installedRepoVersion = installedRepoDescriptor.getVersion();
|
||||
int installedSchemaVersion = installedRepoDescriptor.getSchema();
|
||||
logger.info(String.format("Alfresco started (%s): Current version %s schema %d - Installed version %s schema %d",
|
||||
serverEdition, serverVersion, serverSchemaVersion, installedRepoVersion, installedSchemaVersion));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user