Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.openejb.server;
import org.apache.openejb.EnvProps;
import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
import org.apache.openejb.assembler.classic.ServiceInfo;
import org.apache.openejb.loader.FileUtils;
import org.apache.openejb.loader.IO;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.monitoring.LocalMBeanServer;
import org.apache.openejb.monitoring.ManagedMBean;
import org.apache.openejb.monitoring.ObjectNameBuilder;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
import org.apache.xbean.recipe.ObjectRecipe;
import org.apache.xbean.recipe.Option;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import static org.apache.openejb.util.PropertyPlaceHolderHelper.holdsWithUpdate;
/**
* @version $Rev$ $Date$
* @org.apache.xbean.XBean element="serviceManager"
*/
public abstract class ServiceManager {
static Logger logger = Logger.getInstance(LogCategory.OPENEJB_SERVER, "org.apache.openejb.server.util.resources");
private static ServiceManager manager;
public ServiceManager() {
}
public static synchronized ServiceManager getManager() {
if (manager == null) {
manager = new SimpleServiceManager();
}
return manager;
}
public static synchronized ServiceManager get() {
return manager;
}
protected static synchronized void setServiceManager(final ServiceManager newManager) {
manager = newManager;
}
protected boolean accept(final String serviceName) {
return true;
}
protected List initServers(final Map availableServices)
throws IOException {
final List enabledServers = new ArrayList();
for (final Map.Entry serviceInfo : availableServices.entrySet()) {
final String serviceName = serviceInfo.getKey();
if (!accept(serviceName)) {
continue;
}
final ServerService service = initServer(serviceName, serviceInfo.getValue());
if (service != null) {
enabledServers.add(service);
}
}
return enabledServers;
}
protected ServerService initServer(final String serviceName, final Properties serviceProperties)
throws IOException {
final DiscoveryRegistry registry = SystemInstance.get().getComponent(DiscoveryRegistry.class);
final OpenEjbConfiguration conf = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
logger.debug("Processing ServerService(id=" + serviceName + ")");
overrideProperties(serviceName, serviceProperties);
serviceProperties.setProperty("name", serviceName);
if (conf != null && conf.facilities != null) {
final ServiceInfo info = new ServiceInfo();
info.className = ((Class) serviceProperties.get(ServerService.class)).getName();
info.service = "ServerService";
info.id = serviceName;
info.properties = serviceProperties;
conf.facilities.services.add(info);
}
final boolean enabled = isEnabled(serviceProperties);
logger.debug("Found ServerService(id=" + serviceName + ", disabled=" + (!enabled) + ")");
if (enabled) {
final Class serviceClass = (Class) serviceProperties.get(ServerService.class);
logger.info("Creating ServerService(id=" + serviceName + ")");
// log all properties on debug
if (logger.isDebugEnabled()) {
for (final Map.Entry