Author: rareddy
Date: 2009-03-17 12:22:15 -0400 (Tue, 17 Mar 2009)
New Revision: 566
Modified:
trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
trunk/engine/src/main/java/com/metamatrix/common/application/DQPGuiceModule.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java
trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AbstractAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties
Log:
TEIID-418: Made all the services load with "CommonExtensionClasspath" as the
base classloader. Now membership service, tracking service classes will be loaded from the
common extensions path. Audit manager was stripped from its static block.
Modified: trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
===================================================================
--- trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2009-03-17
14:25:36 UTC (rev 565)
+++ trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2009-03-17
16:22:15 UTC (rev 566)
@@ -48,7 +48,7 @@
<PropertyDefinition Name="ExtensionTranslationClass"
DisplayName="Extension SQL Translation Class" ShortDescription=""
DefaultValue="org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator"
IsExpert="true" />
<PropertyDefinition Name="IsXA" DisplayName="Is XA"
ShortDescription="Is XA" DefaultValue="true"
Multiplicity="1" IsConstrainedToAllowedValues="true"
IsPreferred="true" />
</ComponentType>
- <ComponentType Name="MetaMatrix JDBC 6 Connector"
ComponentTypeCode="2" Deployable="true" Deprecated="false"
Monitorable="false" SuperComponentType="JDBC Connector"
ParentComponentType="Connectors" LastChangedBy="metamatrixadmin"
LastChangedDate="2005-07-26T14:34:20.960-06:00"
CreatedBy="metamatrixadmin"
CreationDate="2005-07-26T14:34:20.960-06:00">
+ <ComponentType Name="Teiid JDBC 6 Connector"
ComponentTypeCode="2" Deployable="true" Deprecated="false"
Monitorable="false" SuperComponentType="JDBC Connector"
ParentComponentType="Connectors" LastChangedBy="metamatrixadmin"
LastChangedDate="2005-07-26T14:34:20.960-06:00"
CreatedBy="metamatrixadmin"
CreationDate="2005-07-26T14:34:20.960-06:00">
<PropertyDefinition Name="ConnectionSource"
DisplayName="Connection Source Class" ShortDescription="Driver, DataSource,
or XADataSource class name" DefaultValue="com.metamatrix.jdbc.MMDataSource"
Multiplicity="1" IsConstrainedToAllowedValues="false"
IsPreferred="true" />
<PropertyDefinition Name="URL" DisplayName="JDBC URL"
ShortDescription=""
DefaultValue="jdbc:metamatrix:<vdbName>@mm://<host>:<port>"
Multiplicity="1" IsConstrainedToAllowedValues="false"
IsPreferred="true" />
<PropertyDefinition Name="IsXA" DisplayName="Is XA"
ShortDescription="Is XA" DefaultValue="true"
Multiplicity="1" IsConstrainedToAllowedValues="true"
IsPreferred="true" />
Modified:
trunk/engine/src/main/java/com/metamatrix/common/application/DQPGuiceModule.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/common/application/DQPGuiceModule.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/engine/src/main/java/com/metamatrix/common/application/DQPGuiceModule.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -45,7 +45,7 @@
Class clazz = defaults.get(serviceName);
if (clazz != null && className != null) {
try {
- clazz = Class.forName(className);
+ clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
} catch (ClassNotFoundException e) {
throw new MetaMatrixRuntimeException(e);
}
Modified:
trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/engine/src/main/java/com/metamatrix/dqp/service/CustomizableTrackingService.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -207,7 +207,7 @@
props.setProperty(name, value);
}
- ClassLoader loader = this.getClass().getClassLoader();
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
CommandLoggerSPI logger =
(CommandLoggerSPI)loader.loadClass(commandLoggerClassname).newInstance();
logger.initialize(props);
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java 2009-03-17
14:25:36 UTC (rev 565)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -51,15 +51,21 @@
public UDFSource(InputStream udfStream, URL[] classpath) throws IOException {
this.classpath = classpath;
loadFunctions(udfStream);
+ }
+
+ public UDFSource(InputStream udfStream, ClassLoader classloader) throws IOException
{
+ this.classLoader = classloader;
+ loadFunctions(udfStream);
}
+
public Collection getFunctionMethods() {
return this.methods;
}
public Class getInvocationClass(String className) throws ClassNotFoundException {
// If no classpath is specified then use the default classpath
- if (classpath == null || classpath.length == 0) {
+ if (this.classLoader == null && (classpath == null || classpath.length ==
0)) {
return Class.forName(className);
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditManager.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -30,9 +30,7 @@
import java.util.concurrent.TimeUnit;
import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.properties.UnmodifiableProperties;
import com.metamatrix.common.queue.WorkerPool;
import com.metamatrix.common.queue.WorkerPoolFactory;
import com.metamatrix.common.util.PropertiesUtils;
@@ -102,10 +100,6 @@
*/
public final class AuditManager {
- /**
- * The name of the Auditing service.
- */
- public static final String NAME = "AuditingService"; //$NON-NLS-1$
/**
* The name of the configuration property that contains the message level for the
AuditManager.
@@ -114,17 +108,6 @@
public static final String SYSTEM_AUDIT_LEVEL_PROPERTY_NAME =
"metamatrix.audit.enabled"; //$NON-NLS-1$
/**
- * The name of the configuration property that contains the set of comma-separated
- * context names for messages <i>not</i> to be recorded. A message
context is simply
- * some string that identifies something about the component that generates
- * the message. The value for the contexts is application specific.
- * <p>
- * This is an optional property that defaults to no contexts (i.e., messages
- * with any context are recorded).
- */
- public static final String SYSTEM_AUDIT_CONTEXT_PROPERTY_NAME =
"metamatrix.audit.contexts"; //$NON-NLS-1$
-
- /**
* The name of the configuration property that contains 'true' if the log
messages
* are to be sent to System.out, or 'false' otherwise. This is an optional
* property that defaults to 'true'. Note, however, that if the message
@@ -145,75 +128,38 @@
protected static final String DEFAULT_AUDIT_MAX_THREADS = "1";
//$NON-NLS-1$
protected static final String DEFAULT_AUDIT_THREAD_TTL =
"600000"; //$NON-NLS-1$
- private static AuditManager INSTANCE = new AuditManager();
- private static AuditConfiguration CONFIGURATION = null;
- private static Properties AUDIT_PROPERTIES = new Properties();
- private static Properties UNMODIFIABLE_AUDIT_PROPERTIES = new
UnmodifiableProperties(AUDIT_PROPERTIES);
-
- private List auditDestinations;
+ private static AuditConfiguration configuration = null;
+ private List auditDestinations = new ArrayList();
private WorkerPool workerPool;
- private boolean isInitialized = false;
- private boolean isStopped = false;
- protected Object initializationLock = new Object();
-// private List initializationMessages = new ArrayList();
- static {
+ public AuditManager() {
+
+ // Log the beginning of the initialization
+ LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0001));
- // Get the AuditConfiguration from the current configuration properties ...
- AuditConfigurationFactory configFactory = new
CurrentConfigAuditConfigurationFactory();
Properties currentConfigProperties = new Properties();
Properties globalProperties =
CurrentConfiguration.getInstance().getProperties();
-
+
currentConfigProperties.putAll(globalProperties);
-
- AUDIT_PROPERTIES =
PropertiesUtils.clone(currentConfigProperties,System.getProperties(),true,false);
- UNMODIFIABLE_AUDIT_PROPERTIES = new UnmodifiableProperties(AUDIT_PROPERTIES);
+ Properties auditProperties =
PropertiesUtils.clone(currentConfigProperties,System.getProperties(),true,false);
+
auditProperties.setProperty(SingleFileAuditDestination.APPEND_PROPERTY_NAME,Boolean.TRUE.toString());
+
+ AuditConfigurationFactory configFactory = new
CurrentConfigAuditConfigurationFactory();
try {
- CONFIGURATION = configFactory.getConfiguration( UNMODIFIABLE_AUDIT_PROPERTIES
);
+ configuration = configFactory.getConfiguration(auditProperties );
} catch ( AuditConfigurationException e ) {
- LogManager.logWarning(LogSecurityConstants.CTX_AUDIT, e,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0004));
- CONFIGURATION = new BasicAuditConfiguration();
+ LogManager.logWarning(LogSecurityConstants.CTX_AUDIT, e,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0004));
+ configuration = new BasicAuditConfiguration();
}
- CONFIGURATION = new UnmodifiableAuditConfiguration(CONFIGURATION);
-
- }
-
- protected void finalize() {
- if ( this.isManagerStopped() ) {
- stop();
+
+ configuration = new UnmodifiableAuditConfiguration(configuration); //
Initialize the message destinations ...
+ if ( configuration.getAuditLevel() != AuditLevel.NONE ) {
+ this.initializeDestinations(auditProperties);
}
- }
- private AuditManager() {
- // Initialize the worker factory and message queue ...
- // Doing this before anything else allows messages to be enqueue before
- // and before the AuditManager is alive and before the destinations are created
...
- this.auditDestinations = new ArrayList();
- }
-
- private void init() {
- synchronized( AuditManager.this.initializationLock ) {
- if ( ! AuditManager.this.isInitialized() &&
!AuditManager.this.isManagerStopped() ) {
- AuditManager.this.initialize();
- }
- }
- }
-
- protected void initialize() {
- // Log the beginning of the initialization
- LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0001));
-
- // Initialize the message destinations ...
- if ( CONFIGURATION.getAuditLevel() != AuditLevel.NONE ) {
- this.initializeDestinations();
- }
-
- this.isInitialized = true;
-
// Log the destinations for the log messages ...
- LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0008, CONFIGURATION.toString()));
+ LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0008, configuration.toString()));
Iterator iter = this.auditDestinations.iterator();
StringBuffer dests = new StringBuffer();
while ( iter.hasNext() ) {
@@ -233,68 +179,48 @@
}
- private void initializeDestinations() {
+ private void initializeDestinations(Properties auditProperties) {
this.auditDestinations.clear();
- // If this is the first initialization, then get the system properties ...
- if ( ! this.isInitialized ) {
- Properties currentConfigProperties = new Properties();
- Properties globalProperties =
CurrentConfiguration.getInstance().getProperties();
-
- currentConfigProperties.putAll(globalProperties);
-
- AUDIT_PROPERTIES =
PropertiesUtils.clone(currentConfigProperties,System.getProperties(),true,false);
- } else {
- // If this is NOT the first initialization, make sure the file destination is
appended ...
-
AUDIT_PROPERTIES.setProperty(SingleFileAuditDestination.APPEND_PROPERTY_NAME,Boolean.TRUE.toString());
- }
- UNMODIFIABLE_AUDIT_PROPERTIES = new UnmodifiableProperties(AUDIT_PROPERTIES);
-
// Create and init the file destinations ...
- String specifiedLogFileName =
UNMODIFIABLE_AUDIT_PROPERTIES.getProperty(SingleFileAuditDestination.FILE_NAME_PROPERTY_NAME);
+ String specifiedLogFileName =
auditProperties.getProperty(SingleFileAuditDestination.FILE_NAME_PROPERTY_NAME);
if ( specifiedLogFileName != null && specifiedLogFileName.trim().length()
!= 0 ) {
SingleFileAuditDestination destination = new SingleFileAuditDestination();
try {
- destination.initialize(UNMODIFIABLE_AUDIT_PROPERTIES);
+ destination.initialize(auditProperties);
this.auditDestinations.add(destination);
- LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
- PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0004,
destination.getDescription()));
+ LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0004,
destination.getDescription()));
} catch( AuditDestinationInitFailedException e ) {
- LogManager.logError(LogSecurityConstants.CTX_AUDIT, e,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0006,
destination.getDescription()));
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT, e,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0006,
destination.getDescription()));
}
}
// Create and init the database destination, if enabled ...
- boolean dbEnabled =
Boolean.valueOf(UNMODIFIABLE_AUDIT_PROPERTIES.getProperty(DatabaseAuditDestination.DATABASE_PROPERTY_NAME)).booleanValue();
+ boolean dbEnabled =
Boolean.valueOf(auditProperties.getProperty(DatabaseAuditDestination.DATABASE_PROPERTY_NAME)).booleanValue();
if ( dbEnabled ) {
DatabaseAuditDestination destination = new DatabaseAuditDestination();
try {
- destination.initialize(UNMODIFIABLE_AUDIT_PROPERTIES);
+ destination.initialize(auditProperties);
this.auditDestinations.add(destination);
- LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
- PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0004,
destination.getDescription()));
+ LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0004,
destination.getDescription()));
} catch( AuditDestinationInitFailedException e ) {
- LogManager.logError(LogSecurityConstants.CTX_AUDIT, e,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0006,
destination.getDescription()));
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT, e,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0006,
destination.getDescription()));
}
} else {
- LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
- PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0005));
+ LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0005));
}
// Create the console destinations ...
- boolean includeConsole = Boolean.valueOf(
UNMODIFIABLE_AUDIT_PROPERTIES.getProperty(SYSTEM_AUDIT_CONSOLE_PROPERTY_NAME)
).booleanValue();
+ boolean includeConsole =
Boolean.valueOf(auditProperties.getProperty(SYSTEM_AUDIT_CONSOLE_PROPERTY_NAME)
).booleanValue();
if ( includeConsole || this.auditDestinations.size() == 0 ) {
ConsoleAuditDestination destination = new ConsoleAuditDestination();
try {
- destination.initialize(UNMODIFIABLE_AUDIT_PROPERTIES);
+ destination.initialize(auditProperties);
this.auditDestinations.add(destination);
LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0004,
destination.getDescription()));
} catch( AuditDestinationInitFailedException e ) {
- LogManager.logError(LogSecurityConstants.CTX_AUDIT, e,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0006,
destination.getDescription()));
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT, e,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0006,
destination.getDescription()));
}
}
@@ -309,22 +235,10 @@
1,
Integer.parseInt(threadTTLString));
} catch ( Exception e ) {
- I18nLogManager.logError(LogSecurityConstants.CTX_AUDIT,
ErrorMessageKeys.SEC_AUDIT_0007, e,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0007));
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0007, e));
}
}
- private boolean isInitialized() {
- return this.isInitialized;
- }
-
- protected static AuditManager getInstance() {
- if ( ! INSTANCE.isInitialized() ) {
- INSTANCE.init();
- }
- return INSTANCE;
- }
-
/**
* Send a critical message to the log. This level of message is generally
* used to record an event or error that must be recorded (if any logging
@@ -340,9 +254,23 @@
* @param permissions A collection of
<code>AuthorizationPermission</code>s
* that contain resources the given principal wishes to access.
*/
- public static void record(String context, String activity, String principal,
Collection permissions) {
+ public void record(String context, String activity, String principal, Collection
permissions) {
if (permissions != null && ! permissions.isEmpty()) {
-
AuditManager.getInstance().recordMessage(context,activity,principal,permissions);
+ if ( this.isLevelDiscarded( AuditLevel.FULL ) ) {
+ return;
+ }
+ List resources = new ArrayList(permissions.size());
+ Iterator permItr = permissions.iterator();
+ while ( permItr.hasNext() ) {
+
resources.add(((AuthorizationPermission)permItr.next()).getResourceName());
+ }
+
+ AuditMessage msg = new AuditMessage( context, activity, principal,
resources.toArray());
+ try {
+ addMessageToQueue(msg);
+ } catch ( Exception e2 ) {
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0010, e2));
+ }
}
}
@@ -362,9 +290,18 @@
* @param principal the principal attempting access to the given resources.
* @param resources the resources that the given proncipal is attempting to access.
*/
- public static void record(String context, String activity, String principal, Object[]
resources) {
+ public void record(String context, String activity, String principal, Object[]
resources) {
if (resources != null) {
-
AuditManager.getInstance().recordMessage(context,activity,principal,resources);
+ if ( this.isLevelDiscarded( AuditLevel.FULL ) ) {
+ return;
+ }
+
+ AuditMessage msg = new AuditMessage( context, activity, principal,
resources);
+ try {
+ addMessageToQueue(msg);
+ } catch ( Exception e2 ) {
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0010, e2));
+ }
}
}
@@ -384,18 +321,27 @@
* @param principal the principal attempting access to the given resources.
* @param resource the resource that the given proncipal is attempting to access.
*/
- public static void record(String context, String activity, String principal, String
resource) {
+ public void record(String context, String activity, String principal, String
resource) {
if (resource != null) {
-
AuditManager.getInstance().recordMessage(context,activity,principal,resource);
+ if ( this.isLevelDiscarded( AuditLevel.FULL ) ) {
+ return;
+ }
+
+ AuditMessage msg = new AuditMessage( context, activity, principal, new
Object[]{resource});
+ try {
+ addMessageToQueue(msg);
+ } catch ( Exception e2 ) {
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0010, e2));
+ }
}
}
private boolean isLevelDiscarded( int msgLevel ) {
- return CONFIGURATION.isLevelDiscarded(msgLevel);
+ return configuration.isLevelDiscarded(msgLevel);
}
private boolean isContextDiscarded( String context ) {
- return CONFIGURATION.isContextDiscarded(context);
+ return configuration.isContextDiscarded(context);
}
/**
@@ -408,65 +354,43 @@
* This method is designed to be called by an application that wishes to
* exit gracefully yet have all messages sent to the audit destinations.
*/
- public static void stop() {
- AuditManager manager = AuditManager.getInstance(); // may thread off the
initialization if called first
- synchronized( manager.initializationLock ) {
- if ( ! isStopped() ) {
- LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
- PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0006));
- try {
- if ( manager.workerPool != null ) {
- manager.workerPool.shutdown();
- }
+ public synchronized void stop() {
+ LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0006));
+ try {
+ if (this.workerPool != null ) {
+ this.workerPool.shutdown();
+ }
- // Sleep for another 1 second to allow the worker threads
- // to finish processing the last messages ...
- manager.workerPool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- Iterator iter = manager.auditDestinations.iterator();
- while(iter.hasNext()) {
- AuditDestination dest = (AuditDestination) iter.next();
- dest.shutdown();
- }
- manager.auditDestinations.clear();
- } catch (Exception e) {
- LogManager.logError(LogSecurityConstants.CTX_AUDIT, e,
-
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0008));
- }
- manager.isStopped = manager.workerPool.isTerminated();
- } else {
- LogManager.logWarning(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0009));
+ // Sleep for another 1 second to allow the worker threads
+ // to finish processing the last messages ...
+ this.workerPool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ Iterator iter = this.auditDestinations.iterator();
+ while(iter.hasNext()) {
+ AuditDestination dest = (AuditDestination) iter.next();
+ dest.shutdown();
}
+ this.auditDestinations.clear();
+ } catch (Exception e) {
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,
e,PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0008));
}
}
/**
- * Utility method to return whether the log manager for this VM is currently
stopped.
- * @return true if the log manager is currently stopped.
- */
- public static boolean isStopped() {
- return getInstance().isManagerStopped();
- }
-
- protected boolean isManagerStopped() {
- return this.isStopped;
- }
-
- /**
* Utility method to obtain the current log configuration for the AuditManager.
* @return the current log configuration
*/
- public static AuditConfiguration getAuditConfiguration() {
- return CONFIGURATION;
+ public AuditConfiguration getAuditConfiguration() {
+ return configuration;
}
- public static void setAuditConfiguration( AuditConfiguration config ) {
+ public void setAuditConfiguration( AuditConfiguration config ) {
if ( config != null ) {
LogManager.logInfo(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUDIT_0008, config));
if ( config instanceof UnmodifiableAuditConfiguration ) {
UnmodifiableAuditConfiguration unmodConfig =
(UnmodifiableAuditConfiguration) config;
- CONFIGURATION = (AuditConfiguration) unmodConfig.deepClone();
+ configuration = (AuditConfiguration) unmodConfig.deepClone();
} else {
- CONFIGURATION = new UnmodifiableAuditConfiguration( (AuditConfiguration)
config.clone() );
+ configuration = new UnmodifiableAuditConfiguration( (AuditConfiguration)
config.clone() );
}
}
}
@@ -478,21 +402,20 @@
* @return true if the message would be recorded if sent to the AuditManager,
* or false if it would be discarded by the AuditManager.
*/
- public static boolean isMessageToBeRecorded(String context) {
+ public boolean isMessageToBeRecorded(String context) {
if ( context == null ) {
return false;
}
// If the messsage's level is greater than the logging level,
// then the message should NOT be recorded ...
- AuditManager manager = AuditManager.getInstance();
- if ( manager.isLevelDiscarded(AuditLevel.FULL) ) {
+ if ( isLevelDiscarded(AuditLevel.FULL) ) {
return false;
}
// If the set contains the message's context and the msgLevel is
// not withing the requested recording levell, then do not log
- if ( manager.isContextDiscarded( context ) ) {
+ if ( isContextDiscarded( context ) ) {
return false;
}
return true;
@@ -505,91 +428,21 @@
* @return true if the message would be recorded if sent to the AuditManager,
* or false if it would be discarded by the AuditManager.
*/
- public static boolean isMessageToBeRecorded(AuditMessage message) {
+ public boolean isMessageToBeRecorded(AuditMessage message) {
if ( message == null ) {
return false;
}
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
- AuditManager manager = AuditManager.getInstance();
- if ( manager.isLevelDiscarded(AuditLevel.FULL) ) {
+ if ( isLevelDiscarded(AuditLevel.FULL) ) {
return false;
}
- // If the set contains the message's context and the msgLevel is
- // not withing the requested recording levell, then do not log
- if ( manager.isContextDiscarded( message.getContext() ) ) {
+ if ( isContextDiscarded( message.getContext() ) ) {
return false;
}
return true;
}
- protected void recordMessage(String context, String activity, String principal,
String resource) {
- // Check quickly the level of the message:
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
- if ( this.isLevelDiscarded( AuditLevel.FULL ) ) {
-//AuditMessage msg = new AuditMessage( context, activity, principal, new
Object[]{resource});
-//System.out.println("Discarding message: " + msg );
- return;
- }
-
- AuditMessage msg = new AuditMessage( context, activity, principal, new
Object[]{resource});
- try {
-//System.out.println("Enqueuing message: " + msg );
- addMessageToQueue(msg);
- } catch ( Exception e2 ) {
- I18nLogManager.logError(LogSecurityConstants.CTX_AUDIT,
ErrorMessageKeys.SEC_AUDIT_0010, e2,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0010));
- }
- }
-
- protected void recordMessage(String context, String activity, String principal,
Object[] resources) {
- // Check quickly the level of the message:
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
- if ( this.isLevelDiscarded( AuditLevel.FULL ) ) {
-//AuditMessage msg = new AuditMessage( context, activity, principal, resources);
-//System.out.println("Discarding message: " + msg );
- return;
- }
-
- AuditMessage msg = new AuditMessage( context, activity, principal, resources);
- try {
-//System.out.println("Enqueuing message: " + msg );
- addMessageToQueue(msg);
- } catch ( Exception e2 ) {
- I18nLogManager.logError(LogSecurityConstants.CTX_AUDIT,
ErrorMessageKeys.SEC_AUDIT_0010, e2,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0010));
- }
- }
-
- protected void recordMessage(String context, String activity, String principal,
Collection permissions) {
- // Check quickly the level of the message:
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
- if ( this.isManagerStopped() || this.isLevelDiscarded( AuditLevel.FULL ) ) {
-//AuditMessage msg = new AuditMessage( context, activity, principal, resources);
-//System.out.println("Discarding message: " + msg );
- return;
- }
- List resources = new ArrayList(permissions.size());
- Iterator permItr = permissions.iterator();
- while ( permItr.hasNext() ) {
- resources.add(((AuthorizationPermission)permItr.next()).getResourceName());
- }
-
- AuditMessage msg = new AuditMessage( context, activity, principal,
resources.toArray());
- try {
-//System.out.println("Enqueuing message: " + msg );
- addMessageToQueue(msg);
- } catch ( Exception e2 ) {
- I18nLogManager.logError(LogSecurityConstants.CTX_AUDIT,
ErrorMessageKeys.SEC_AUDIT_0010, e2,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0010));
- }
- }
-
/**
* Helper method to add a message to the queue
* @param msg Message for the queue
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AbstractAuditDestination.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AbstractAuditDestination.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/AbstractAuditDestination.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -55,19 +55,15 @@
"\"; using default class
\"",formatterClassName,"\""}); //$NON-NLS-1$ //$NON-NLS-2$
}
try {
- LogManager.logTrace(LogSecurityConstants.CTX_AUDIT,
- new Object[]{"Initializing audit message format class
\"",formatterClassName,"\""}); //$NON-NLS-1$ //$NON-NLS-2$
- Class formatterClass = Class.forName(formatterClassName);
+ LogManager.logTrace(LogSecurityConstants.CTX_AUDIT, new
Object[]{"Initializing audit message format class
\"",formatterClassName,"\""}); //$NON-NLS-1$ //$NON-NLS-2$
+ Class formatterClass =
Thread.currentThread().getContextClassLoader().loadClass(formatterClassName);
formatter = (AuditMessageFormat) formatterClass.newInstance();
} catch ( ClassNotFoundException e ) {
- throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0016,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0016,
formatterClassName));
+ throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0016,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0016, formatterClassName));
} catch ( ClassCastException e ) {
- throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0017,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0017,
formatterClassName, AuditMessageFormat.class.getName()));
+ throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0017,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0017, formatterClassName,
AuditMessageFormat.class.getName()));
} catch ( Exception e ) {
- throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0018,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0018,
formatterClassName));
+ throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0018,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0018, formatterClassName));
}
}
@@ -75,8 +71,7 @@
* Init the destination.
*/
public void initialize(Properties props) throws AuditDestinationInitFailedException {
- LogManager.logTrace(LogSecurityConstants.CTX_AUDIT,
- new Object[]{"Initializing audit destination class
\"",this.getClass().getName(),"\""}); //$NON-NLS-1$
//$NON-NLS-2$
+ LogManager.logTrace(LogSecurityConstants.CTX_AUDIT, new
Object[]{"Initializing audit destination class
\"",this.getClass().getName(),"\""}); //$NON-NLS-1$
//$NON-NLS-2$
}
/**
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/DatabaseAuditDestination.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -31,7 +31,7 @@
import java.util.Properties;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
-import com.metamatrix.common.log.I18nLogManager;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.util.DateUtil;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.platform.PlatformPlugin;
@@ -187,8 +187,7 @@
ex = e;
}
}
- I18nLogManager.logError(LogSecurityConstants.CTX_AUDIT,
ErrorMessageKeys.SEC_AUDIT_0019, ex,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0019));
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0019, ex));
}
@@ -199,7 +198,7 @@
*/
public void recordMsg(AuditMessage message) throws SQLException {
// Add values to Prepared statement
- Connection connection = JDBCConnectionPoolHelper.getInstance().getConnection();
//$NON-NLS-1$
+ Connection connection = JDBCConnectionPoolHelper.getInstance().getConnection();
PreparedStatement stmt = null;
try {
stmt = connection.prepareStatement(insertStr.toString());
@@ -240,17 +239,13 @@
stmt.close();
}
} catch (SQLException e) {
- I18nLogManager.logError(LogSecurityConstants.CTX_AUDIT,
- ErrorMessageKeys.SEC_AUDIT_0020, e, PlatformPlugin.Util
- .getString(ErrorMessageKeys.SEC_AUDIT_0020));
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0020,
e));
}
try {
connection.close();
} catch (SQLException e) {
- I18nLogManager.logError(LogSecurityConstants.CTX_AUDIT,
- ErrorMessageKeys.SEC_AUDIT_0021, e, PlatformPlugin.Util
- .getString(ErrorMessageKeys.SEC_AUDIT_0021));
+ LogManager.logError(LogSecurityConstants.CTX_AUDIT,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0021,e));
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -119,10 +119,7 @@
int index = fileName.indexOf(VM_NAME_TOKEN);
if ( index != -1 ) {
StringBuffer tempFileName = new StringBuffer(fileName);
- String processName = VMNaming.getProcessName();
- if ( processName == null || processName.trim().length() == 0 ) {
- processName = VMNaming.getConfigName();
- }
+ String processName =
VMNaming.getConfigName()+"_"+VMNaming.getProcessName(); //$NON-NLS-1$
tempFileName.replace(index,index+VM_NAME_TOKEN.length(),processName);
fileName = tempFileName.toString();
}
@@ -131,8 +128,7 @@
try {
fileWriter = new FileWriter(fileName, append);
} catch(IOException e) {
- throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0023,
- PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0023,
fileName, new Boolean(append)));
+ throw new AuditDestinationInitFailedException(e,
ErrorMessageKeys.SEC_AUDIT_0023,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUDIT_0023, fileName, new
Boolean(append)));
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/authorization/service/AuthorizationServiceImpl.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -116,6 +116,8 @@
* The transaction mgr for ManagedConnections.
*/
private TransactionMgr transMgr;
+
+ private AuditManager auditManager;
//
-----------------------------------------------------------------------------------
// S E R V I C E - R E L A T E D M E T H O D S
@@ -127,6 +129,8 @@
protected void initService(Properties env) {
try {
+ this.auditManager = new AuditManager();
+
membershipServiceProxy =
PlatformProxyHelper.getMembershipServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL);
if (env == null) {
@@ -185,13 +189,12 @@
protected void closeService() throws Exception {
if ( ! serviceClosed ) {
String instanceName = this.getInstanceName();
- LogManager.logInfo(LogSecurityConstants.CTX_AUTHORIZATION,
- PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUTHORIZATION_0001,
instanceName));
+ LogManager.logInfo(LogSecurityConstants.CTX_AUTHORIZATION,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUTHORIZATION_0001, instanceName));
serviceClosed = true;
+ auditManager.stop();
- LogManager.logInfo(LogSecurityConstants.CTX_AUTHORIZATION,
- PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUTHORIZATION_0002,
instanceName));
+ LogManager.logInfo(LogSecurityConstants.CTX_AUTHORIZATION,
PlatformPlugin.Util.getString(LogMessageKeys.SEC_AUTHORIZATION_0002, instanceName));
}
}
@@ -239,13 +242,13 @@
throws InvalidSessionException, AuthorizationMgmtException {
LogManager.logDetail(LogSecurityConstants.CTX_AUTHORIZATION, new
Object[]{"checkAccess(", sessionToken, ", ", contextName, ",
", request, ")"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
// Audit - request
- AuditManager.record(contextName, "checkAccess-request",
sessionToken.getUsername(), request.getResourceName()); //$NON-NLS-1$
+ auditManager.record(contextName, "checkAccess-request",
sessionToken.getUsername(), request.getResourceName()); //$NON-NLS-1$
boolean hasAccess = checkAccess(sessionToken, contextName, request, false);
if (!hasAccess) {
// Audit - denied
- AuditManager.record(contextName, "checkAccess-denied",
sessionToken.getUsername(), request.getResourceName()); //$NON-NLS-1$
+ auditManager.record(contextName, "checkAccess-denied",
sessionToken.getUsername(), request.getResourceName()); //$NON-NLS-1$
}
return hasAccess;
}
@@ -293,8 +296,9 @@
public Collection getInaccessibleResources(SessionToken sessionToken, String
contextName, Collection requests)
throws InvalidSessionException, AuthorizationMgmtException {
LogManager.logDetail(LogSecurityConstants.CTX_AUTHORIZATION, new
Object[]{"getInaccessibleResources(", sessionToken, ", ", contextName,
", ", requests, ")"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+
// Audit - request
- AuditManager.record(contextName, "getInaccessibleResources-request",
sessionToken.getUsername(), requests); //$NON-NLS-1$
+ auditManager.record(contextName, "getInaccessibleResources-request",
sessionToken.getUsername(), requests); //$NON-NLS-1$
if (isEntitled(sessionToken.getUsername())) {
return Collections.EMPTY_LIST;
@@ -324,10 +328,10 @@
if (results.isEmpty()) {
// Audit - granted all requests
- AuditManager.record(contextName, "getInaccessibleResources-granted
all", sessionToken.getUsername(), requests); //$NON-NLS-1$
+ auditManager.record(contextName, "getInaccessibleResources-granted
all", sessionToken.getUsername(), requests); //$NON-NLS-1$
} else {
// Audit - denied
- AuditManager.record(contextName, "getInaccessibleResources-denied",
sessionToken.getUsername(), results); //$NON-NLS-1$
+ auditManager.record(contextName, "getInaccessibleResources-denied",
sessionToken.getUsername(), results); //$NON-NLS-1$
}
return results;
}
@@ -1104,15 +1108,16 @@
throw new AuthorizationMgmtException(e,
ErrorMessageKeys.SEC_AUTHORIZATION_0052, exceptionMsg);
} finally {
if (success) {
- try {
- transaction.commit(); // commit the transaction
- transaction.close();
- } catch (Exception e) {
- String msg =
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUTHORIZATION_0053,
principal.toString());
- LogManager.logError(LogSecurityConstants.CTX_AUTHORIZATION,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUTHORIZATION_0053, e, msg));
- throw new AuthorizationMgmtException(e,
ErrorMessageKeys.SEC_AUTHORIZATION_0053, msg);
- }
-
+ if (transaction != null) {
+ try {
+ transaction.commit(); // commit the transaction
+ transaction.close();
+ } catch (Exception e) {
+ String msg =
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUTHORIZATION_0053,
principal.toString());
+ LogManager.logError(LogSecurityConstants.CTX_AUTHORIZATION,
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_AUTHORIZATION_0053, e, msg));
+ throw new AuthorizationMgmtException(e,
ErrorMessageKeys.SEC_AUTHORIZATION_0053, msg);
+ }
+ }
// Clear cache so that Auth serv reflects latest state next time
around
Collection removedPrincPolicyIDs =
this.authorizationCache.findPolicyIDs(principal, caller);
this.authorizationCache.removePolicysFromCache(removedPrincPolicyIDs);
@@ -1524,7 +1529,7 @@
return result;
}
// Audit - access modify
- AuditManager.record(SecurityAuditContexts.CTX_AUTHORIZATION,
"executeTransaction-modify", administrator.getUsername(),
this.printActions(actions)); //$NON-NLS-1$
+ auditManager.record(SecurityAuditContexts.CTX_AUTHORIZATION,
"executeTransaction-modify", administrator.getUsername(),
this.printActions(actions)); //$NON-NLS-1$
List actionsWithSameTarget = new ArrayList(7); // guessing at an initial size,
probably high
Object currentTarget = null;
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -213,7 +213,7 @@
if (className != null && className.length() > 0) {
try {
- domain = (MembershipDomain) Class.forName(className).newInstance();
+ domain = (MembershipDomain)
Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();
} catch (Throwable e) {
String msg =
PlatformPlugin.Util.getString(ErrorMessageKeys.SEC_MEMBERSHIP_0023, className);
throw new ServiceException(e, ErrorMessageKeys.SEC_MEMBERSHIP_0023,
msg);
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -161,7 +161,7 @@
while (iter.hasNext()) {
String handler = (String)iter.next();
try {
- SessionTerminationHandler sth =
(SessionTerminationHandler)Class.forName(handler).newInstance();
+ SessionTerminationHandler sth =
(SessionTerminationHandler)Thread.currentThread().getContextClassLoader().loadClass(handler).newInstance();
terminationHandlerMap.put(sth.getProductName(), sth);
} catch (ClassNotFoundException e) {
LogManager.logWarning(LogSecurityConstants.CTX_SESSION,e,PlatformPlugin.Util.getString(LogMessageKeys.SEC_SESSION_0002,
new Object[] {handler}));
Modified:
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -25,6 +25,7 @@
import java.io.File;
import java.lang.reflect.Proxy;
import java.net.InetAddress;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@@ -40,6 +41,7 @@
import com.metamatrix.admin.util.AdminMethodRoleResolver;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MultipleException;
+import com.metamatrix.common.classloader.URLFilteringClassLoader;
import com.metamatrix.common.comm.ClientServiceRegistry;
import com.metamatrix.common.comm.platform.socket.server.AdminAuthorizationInterceptor;
import com.metamatrix.common.comm.platform.socket.server.LogonImpl;
@@ -59,6 +61,7 @@
import com.metamatrix.common.config.api.VMComponentDefnID;
import com.metamatrix.common.config.api.VMComponentDefnType;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
+import com.metamatrix.common.extensionmodule.protocol.URLFactory;
import com.metamatrix.common.id.dbid.DBIDGenerator;
import com.metamatrix.common.id.dbid.DBIDGeneratorException;
import com.metamatrix.common.log.LogConfiguration;
@@ -115,6 +118,7 @@
import com.metamatrix.server.admin.apiimpl.QueryAdminAPIImpl;
import com.metamatrix.server.admin.apiimpl.RuntimeMetadataAdminAPIImpl;
import com.metamatrix.server.admin.apiimpl.TransactionAdminAPIImpl;
+import com.metamatrix.server.util.ServerPropertyNames;
/**
* This class is used to start up a server process and start all services that are
@@ -700,7 +704,20 @@
private void startService(ClientServiceRegistry serverListenerRegistry, ServiceID
serviceID, DeployedComponent deployedComponent,final String
serviceClass,ProductServiceConfigID pscID,Properties serviceProps) {
String serviceInstanceName = null;
+ ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
try {
+
+ String extensionClasspath =
CurrentConfiguration.getInstance().getProperties().getProperty(ServerPropertyNames.COMMON_EXTENSION_CLASPATH);
+ if (extensionClasspath != null && extensionClasspath.length() > 0) {
+ try {
+ ClassLoader commonExtensionClassLoader = new
URLFilteringClassLoader(URLFactory.parseURLs(extensionClasspath, ";"),
currentClassLoader); //$NON-NLS-1$
+ Thread.currentThread().setContextClassLoader(commonExtensionClassLoader);
+ logMessage(PlatformPlugin.Util.getString("commonextensionspath_in_use",
extensionClasspath, serviceID)); //$NON-NLS-1$
+ } catch (MalformedURLException e) {
+ logMessage(PlatformPlugin.Util.getString("commonextensionspath_not_in_use",extensionClasspath,
serviceID)); //$NON-NLS-1$
+ }
+ }
+
if (serviceID == null) {
serviceID = this.createServiceID();
}
@@ -718,7 +735,7 @@
}
// Create an instance of serviceClass
- final ServiceInterface service = (ServiceInterface)
Class.forName(serviceClass).newInstance();
+ final ServiceInterface service = (ServiceInterface)
Thread.currentThread().getContextClassLoader().loadClass(serviceClass).newInstance();
// Create ServiceRegistryBinding and register
final ServiceRegistryBinding binding = new ServiceRegistryBinding(serviceID,
service, routingID,serviceInstanceName, componentType,
serviceInstanceName,host.getFullName(), deployedComponent, pscID,
service.getCurrentState(), service.getStateChangeTime(),essential, this.messageBus);
@@ -739,6 +756,8 @@
} catch (Exception e) {
throw new ServiceException(e,
PlatformPlugin.Util.getString(ErrorMessageKeys.SERVICE_0028, serviceInstanceName));
+ } finally {
+ Thread.currentThread().setContextClassLoader(currentClassLoader);
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -310,7 +310,6 @@
private String buildClasspath(Properties connectorProperties) {
StringBuilder sb = new StringBuilder();
appendlasspath(connectorProperties.getProperty(ConnectorPropertyNames.CONNECTOR_CLASSPATH),
sb); // this is user defined, could be very specific to the binding
-
appendlasspath(connectorProperties.getProperty(ServerPropertyNames.COMMON_EXTENSION_CLASPATH),
sb); // this is common to the engine
appendlasspath(connectorProperties.getProperty(ConnectorPropertyNames.CONNECTOR_TYPE_CLASSPATH),
sb); // this is system defined; type classpath
return sb.toString();
}
Modified:
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-03-17
14:25:36 UTC (rev 565)
+++
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-03-17
16:22:15 UTC (rev 566)
@@ -105,22 +105,10 @@
* @param udfSource the source file for function definitions
*/
private void registerUDFSource(String udfSource) throws IOException {
- URL[] urls = null;
-
- String extensionClasspath =
CurrentConfiguration.getInstance().getProperties().getProperty(ServerPropertyNames.COMMON_EXTENSION_CLASPATH);
- if (extensionClasspath != null && extensionClasspath.trim().length() >
0){
- try {
- urls = URLFactory.parseURLs(extensionClasspath, CLASSPATH_DELIMITER);
- } catch (MalformedURLException e) {
- String message =
ServerPlugin.Util.getString("ExtensionFunctionMetadataSource.Cannot_parse_classpath___{0}___1",
extensionClasspath); //$NON-NLS-1$
- LogManager.logWarning(LogCommonConstants.CTX_CONFIG, e, message);
- }
- }
-
try {
InputStream in = retrieveUDFStream(udfSource);
if (in != null) {
- FunctionLibraryManager.registerSource(new UDFSource(in, urls));
+ FunctionLibraryManager.registerSource(new UDFSource(in,
Thread.currentThread().getContextClassLoader()));
}
} catch(ExtensionModuleNotFoundException e) {
LogManager.logDetail(LogCommonConstants.CTX_CONFIG, e,
ServerPlugin.Util.getString("QueryService.no_udf")); //$NON-NLS-1$
Modified: trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties
===================================================================
--- trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties 2009-03-17
14:25:36 UTC (rev 565)
+++ trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties 2009-03-17
16:22:15 UTC (rev 566)
@@ -1284,4 +1284,6 @@
SocketVMController.5=Could not find host information. Run the "setupmm" to
configure the server before trying to start.
RemoteProxy.localCallFailed=Remote client could not invoke local service method {0} on
{1}
-JGroupsMessageBus.noResponse=No response for remote method call
\ No newline at end of file
+JGroupsMessageBus.noResponse=No response for remote method call
+commonextensionspath_in_use=Extension modules "{0}" are in scope to create the
service - {1}
+commonextensionspath_not_in_use=Failed to use extension modules "{0}" to create
the service -{1}
\ No newline at end of file