ConnectorInfoProviderService.java revision 73db7653fd150e027270e0e9cc9f421ea3ce6681
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2011-2013 ForgeRock AS. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/**
* The ConnectorInfoProviderService initiates the the embedded <a
* href="http://openicf.forgerock.org">OpenICF</a> and makes it available as a
* service.
* <p/>
*
* @author Laszlo Hordos
*/
@Properties({
unbind = "unbindConnectorEventPublisher",
/**
* Setup logging for the {@link OpenICFProvisionerService}.
*/
.getLogger(ConnectorInfoProviderService.class);
// Public Constants
"org.forgerock.openidm.provisioner.openicf.connectorinfoprovider";
// Private
private Map<String, Pair<RemoteFrameworkConnectionInfo, ConnectorEventHandler>> remoteFrameworkConnectionInfo =
private class ConnectorEventHandlerImpl implements ConnectorEventHandler {
private String connectorHost;
private ConnectorEventHandlerImpl() {
}
this.connectorHost = connectorHost;
}
if (null == connectorEvent)
return;
}
if (source instanceof ConnectorKey) {
synchronized (this) {
.entrySet()) {
// TODO What to do if it's null? Throw NPE now
try {
.getTopic())) {
} else {
.getInstance());
}
} else {
}
} catch (Throwable t) {
/* ignore */
}
}
}
}
}
}
}
}
/*
* If this newBuilder was instantiated for MetaDataProvider by
* Class#newInstance then this is false. If this newBuilder was activated by
* OSGi SCR then this is true.
*/
private boolean isOSGiServiceInstance = false;
/**
* ConnectorInfoManager service.
*/
}
}
/**
* ConnectorFacadeFactory service.
*/
}
}
/**
* ConnectorEventPublisher service.
*/
if (null == osgiConnectorEventHandler) {
}
}
}
try {
// String connectorLocation = DEFAULT_CONNECTORS_LOCATION;
// Initialise Local ConnectorInfoManager
} catch (JsonValueException e) {
throw new ComponentException("Invalid configuration, service can not be started", e);
}
try {
List.class);
if (!remoteConnectorHosts.isNull()) {
}
} catch (JsonValueException e) {
remoteConnectorHosts, e);
throw new ComponentException("Invalid configuration, service can not be started", e);
}
isOSGiServiceInstance = true;
.getFrameworkVersion());
}
throws JsonValueException {
try {
null);
if (connectorInfoManager instanceof Runnable
&& connectorInfoManager instanceof ConnectorEventPublisher) {
if (null == scheduledExecutorService) {
}
/*
* Specifies the interval, in seconds, at which
* heartbeat packets are transmitted.
*/
/*
* Specifies the number of missed heartbeat intervals
* after which a broker is considered suspect of
* failure. JsonValue heartbeatThreshold =
* remoteConnectorHosts
* .get("heartbeatThreshold").defaultTo
* (1).expect(Number.class);
*/
}
} else {
}
} catch (IllegalArgumentException e) {
}
}
}
try {
// This is a fix to support absolute path on OSX
}
}
} else {
try {
// Create a single newBuilder of ConnectorInfoManagerFactory
} catch (MalformedURLException e) {
}
}
} catch (UnsupportedEncodingException e) {
// Should never happen.
throw new UndeclaredThrowableException(e);
} catch (Throwable t) {
throw new ComponentException("LocalManager initialisation failed.", t);
}
}
if (null != scheduledExecutorService) {
}
for (Pair<RemoteFrameworkConnectionInfo, ConnectorEventHandler> pair : remoteFrameworkConnectionInfo
.values()) {
try {
} catch (Exception e) {
/* ignore */
}
}
}
}
// @Modified
// protected void update(ComponentContext context) {
// }
// ----- Implementation of ConfigurationService interface
/**
* {@inheritDoc}
*/
try {
// May throw IllegalArgumentException
}
// May throw IllegalArgumentException
}
}
} catch (JsonValueException e) {
throw new BadRequestException(e.getMessage(), e);
}
return result;
}
try {
throw new ServiceUnavailableException("Connector not found: "
+ ref.getConnectorKey());
}
} catch (ResourceException e) {
throw e;
} catch (Throwable t) {
throw new ServiceUnavailableException(t);
}
}
// ----- Implementation of ConnectorInfoProvider interface
/**
* {@inheritDoc}
*/
switch (connectorReference.getConnectorLocation()) {
case LOCAL:
break;
case OSGI:
break;
case REMOTE:
}
}
if (null != connectorInfoManager) {
try {
// Check if the version is an interval.
.getBundleVersion());
// Check id the version is in interval.
.getBundleVersion());
connectorInfo = ci;
}
}
}
}
} else {
.getConnectorKey());
}
} catch (Exception e) {
}
}
return connectorInfo;
}
/**
* {@inheritDoc}
*/
/*
* This implementation is not safe. An other thread can register or
* remove ConnectorInfo meanwhile findConnectorInfo and putIfAbsent.
* This will be fixed with
* ConnectorFacadeFactory#getConnectorFacadeAsync()
*/
}
} else {
}
}
}
}
/**
* {@inheritDoc}
*/
}
}
}
/**
* {@inheritDoc}
*/
if (null != osgiConnectorInfoManager) {
}
for (Pair<RemoteFrameworkConnectionInfo, ConnectorEventHandler> entry : remoteFrameworkConnectionInfo
.values()) {
try {
} catch (Exception e) {
}
}
}
}
if (null != osgiConnectorInfoManager) {
}
}
for (Map.Entry<String, Pair<RemoteFrameworkConnectionInfo, ConnectorEventHandler>> entry : remoteFrameworkConnectionInfo
.entrySet()) {
try {
}
} catch (Exception e) {
}
}
}
/**
* {@inheritDoc}
*
* @throws org.identityconnectors.framework.common.exceptions.ConnectorException
* if OpenICF failed to create new connector facade
*/
try {
try {
} catch (Exception e) {
}
}
} else {
return;
}
}
} catch (Throwable t) {
// TODO Use the utility to adopt the exception
}
throw new ServiceUnavailableException("ConnectorFacade can not be initialised");
}
/**
* {@inheritDoc}
*/
try {
} catch (Exception e) {
}
}
if (connectorInfo instanceof RemoteConnectorInfoImpl) {
for (Map.Entry<String, Pair<RemoteFrameworkConnectionInfo, ConnectorEventHandler>> entry : remoteFrameworkConnectionInfo
.entrySet()) {
.getKey());
break;
}
}
} else {
}
}
}
return jsonConfiguration;
}
throw new UnsupportedOperationException("ConnectorFacade can not be initialised");
}
/**
* {@inheritDoc}
*/
try {
List.class);
if (!remoteConnectorHosts.isNull()) {
}
}
} catch (JsonValueException e) {
"Invalid configuration remoteConnectorHosts must be list or null.", e);
}
if (isOSGiServiceInstance) {
try {
}
} catch (Exception e) {
pidOrFactory, instanceAlias }, e);
}
if (null != properties) {
if (property.isConfidential()
}
}
} else {
throw new WaitForMetaData(pidOrFactory);
}
} else {
throw new WaitForMetaData("Wait for the MetaDataProvider service newBuilder");
}
}
}
return result;
}
private ClassLoader getBundleParentClassLoader() {
if (null == bundleParentClassLoader) {
if (classes.isDirectory()) {
} else {
.getAbsolutePath());
}
if (lib.isDirectory()) {
}
});
}
}
} else {
.getAbsolutePath());
}
try {
} catch (MalformedURLException e) {
if (logger.isDebugEnabled()) {
.getAbsolutePath(), e);
}
}
}
} else {
}
}
return bundleParentClassLoader;
}
if (null == connectorURLs) {
try {
if (file.isDirectory()) {
}
};
}
}
urls =
+ DEFAULT_CONNECTORS_LOCATION + "/(.*).jar$");
} else {
"Local connector support disabled. No support for bundle URLs with protocol {}",
}
}
}
} catch (IOException ex) {
// TODO Add Message
} catch (URISyntaxException e) {
}
}
if (logger.isDebugEnabled()) {
for (URL u : _bundleURLs) {
}
}
}
return connectorURLs;
}
/**
* <p>
* Retrieve a list of filepaths from a given directory within a jar file. If
* filtered results are needed, you can supply a |filter| regular expression
* which will match each entry.
*
* @param jarLocation
* @param filter
* to filter the results within a regular expression.
* @return a list of files within the jar |file|
*/
if (jarLocation == null) {
return files; // Empty.
}
// left
try {
// Lets stream the jar file
// Iterate the jar entries within that jar. Then make sure it
// follows the
// filter given from the user.
do {
// The filter could be null or has a matching regular
// expression.
DEFAULT_CONNECTORS_LOCATION, "")));
}
}
} catch (IOException ioe) {
ioe);
}
return files;
}
/**
* {@inheritDoc}
*/
}
}