Get JMX working again for subsystem monitor beans.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55331 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2013-09-16 11:28:41 +00:00
parent 47436a8477
commit 94e3d8c118
4 changed files with 148 additions and 10 deletions

View File

@@ -0,0 +1,26 @@
package org.alfresco.repo.security.authentication;
import org.springframework.context.ApplicationEvent;
/**
* Event emmitted when an Authenticator is deleted, the source is the zoneId deleted.
*
* @author mrogers
*/
public class AuthenticatorDeletedEvent extends ApplicationEvent
{
/**
*
*/
private static final long serialVersionUID = 3641164223727881175L;
/**
*
* @param source a String with the zoneid
*/
public AuthenticatorDeletedEvent(Object source)
{
super(source);
}
}

View File

@@ -148,16 +148,18 @@ public class Monitor
return syncMonitor.getSynchronizationStatus(getZone(component.getId()));
}
public Date getSynchronizationLastUserUpdateTime()
{
return syncMonitor.getSynchronizationLastUserUpdateTime(getZone(component.getId()));
}
public Date getSynchronizationLastGroupUpdateTime()
{
return syncMonitor.getSynchronizationLastGroupUpdateTime(getZone(component.getId()));
}
// public Date getSynchronizationLastUserUpdateTime()
// {
// // TODO This method fails due to a unable to find transaction error - Comment out for now
// return syncMonitor.getSynchronizationLastUserUpdateTime(getZone(component.getId()));
// }
//
// public Date getSynchronizationLastGroupUpdateTime()
// {
// // TODO This method fails due to a unable to find transaction error - Comment out for now
// return syncMonitor.getSynchronizationLastGroupUpdateTime(getZone(component.getId()));
// }
//
public String getSynchronizationLastError()
{
return syncMonitor.getSynchronizationLastError(getZone(component.getId()));
@@ -168,6 +170,21 @@ public class Monitor
return syncMonitor.getSynchronizationSummary(getZone(component.getId()));
}
public String getLastRunOnServer()
{
return syncMonitor.getLastRunOnServer();
}
public Date getSyncStartTime()
{
return syncMonitor.getSyncStartTime();
}
public Date getSyncEndTime()
{
return syncMonitor.getSyncEndTime();
}
/**
* Get the zone for an ldap authentication component. e.g given [managed,ldap1] return ldap1
* @param id ths id of the subsystem

View File

@@ -63,6 +63,7 @@ import org.alfresco.repo.management.subsystems.ChildApplicationContextManager;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.authentication.AuthenticatorDeletedEvent;
import org.alfresco.repo.security.authority.UnknownAuthorityException;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
@@ -85,6 +86,8 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
import org.springframework.extensions.surf.util.I18NUtil;
@@ -119,6 +122,7 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
ChainingUserRegistrySynchronizerStatus,
TestableChainingUserRegistrySynchronizer,
ApplicationEventPublisherAware
{
/** The logger. */
private static final Log logger = LogFactory.getLog(ChainingUserRegistrySynchronizer.class);
@@ -2247,6 +2251,35 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
}, false, true);
}
private void notifyZoneDeleted(final String zoneId)
{
// this.applicationEventPublisher.publishEvent(new SynchronizeDirectoryDeleteZoneEvent(this, zoneId, batchProcessNames));
this.transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
ChainingUserRegistrySynchronizer.this.attributeService.setAttribute(
"",
ChainingUserRegistrySynchronizer.ROOT_ATTRIBUTE_PATH,
ChainingUserRegistrySynchronizer.STATUS_ATTRIBUTE,
zoneId);
ChainingUserRegistrySynchronizer.this.attributeService.setAttribute(
"",
ChainingUserRegistrySynchronizer.ROOT_ATTRIBUTE_PATH,
ChainingUserRegistrySynchronizer.SUMMARY_ATTRIBUTE,
zoneId);
ChainingUserRegistrySynchronizer.this.attributeService.setAttribute(
null,
ChainingUserRegistrySynchronizer.LAST_ERROR_ATTRIBUTE,
ChainingUserRegistrySynchronizer.SUMMARY_ATTRIBUTE,
zoneId);
return null;
}
}, false, true);
}
private void notifySyncDirectoryStart(final String zoneId, final String[] batchProcessNames)
{
this.applicationEventPublisher.publishEvent(new SynchronizeDirectoryStartEvent(this, zoneId, batchProcessNames));
@@ -2427,4 +2460,20 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean
{
return sysAdminParams;
}
@Override
public void onApplicationEvent(ApplicationEvent event)
{
if (event instanceof AuthenticatorDeletedEvent)
{
AuthenticatorDeletedEvent deleteEvent = (AuthenticatorDeletedEvent)event;
notifyZoneDeleted((String)deleteEvent.getSource());
}
else
{
// pass to the superclass
super.onApplicationEvent(event);
}
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2013-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.security.sync;
/**
* Delete od zone that has been synchronized
*
* @author mrogers
* @since 4.2
*/
public class SynchronizeDirectoryDeleteZoneEvent extends SynchronizeDirectoryEvent
{
private String batchProcessNames[];
public SynchronizeDirectoryDeleteZoneEvent(Object o, String zone, String batchProcessNames[])
{
super(o, zone);
this.batchProcessNames = batchProcessNames;
}
public String[] getBatchProcessNames()
{
return batchProcessNames;
}
/**
*
*/
private static final long serialVersionUID = 5374340649898136746L;
}