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.
/*
* Fabric3
* Copyright (c) 2009-2013 Metaform Systems
*
* Fabric3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version, with the
* following exception:
*
* Linking this software statically or dynamically with other
* modules is making a combined work based on this software.
* Thus, the terms and conditions of the GNU General Public
* License cover the whole combination.
*
* As a special exception, the copyright holders of this software
* give you permission to link this software with independent
* modules to produce an executable, regardless of the license
* terms of these independent modules, and to copy and distribute
* the resulting executable under terms of your choice, provided
* that you also meet, for each linked independent module, the
* terms and conditions of the license of that module. An
* independent module is a module which is not derived from or
* based on this software. If you modify this software, you may
* extend this exception to your version of the software, but
* you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version.
*
* Fabric3 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 General Public License for more details.
*
* You should have received a copy of the
* GNU General Public License along with Fabric3.
* If not, see .
*
* ----------------------------------------------------
*
* Portions originally based on Apache Tuscany 2007
* licensed under the Apache 2.0 license.
*
*/
package org.fabric3.implementation.system.singleton;
import javax.xml.namespace.QName;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.fabric3.api.annotation.monitor.MonitorLevel;
import org.fabric3.implementation.pojo.objectfactory.ArrayMultiplicityObjectFactory;
import org.fabric3.implementation.pojo.objectfactory.ListMultiplicityObjectFactory;
import org.fabric3.implementation.pojo.objectfactory.MapMultiplicityObjectFactory;
import org.fabric3.implementation.pojo.objectfactory.MultiplicityObjectFactory;
import org.fabric3.implementation.pojo.objectfactory.SetMultiplicityObjectFactory;
import org.fabric3.spi.component.InstanceDestructionException;
import org.fabric3.spi.component.InstanceInitException;
import org.fabric3.spi.component.InstanceLifecycleException;
import org.fabric3.spi.component.ScopedComponent;
import org.fabric3.spi.model.type.java.FieldInjectionSite;
import org.fabric3.spi.model.type.java.Injectable;
import org.fabric3.spi.model.type.java.InjectableType;
import org.fabric3.spi.model.type.java.InjectionSite;
import org.fabric3.spi.model.type.java.MethodInjectionSite;
import org.fabric3.spi.objectfactory.InjectionAttributes;
import org.fabric3.spi.objectfactory.ObjectCreationException;
import org.fabric3.spi.objectfactory.ObjectFactory;
import org.fabric3.spi.objectfactory.SingletonObjectFactory;
/**
* Wraps an object intended to serve as a system component provided to the Fabric3 runtime by the host environment.
*/
public class SingletonComponent implements ScopedComponent {
private final URI uri;
private Object instance;
private Map sites;
private Map reinjectionMappings;
private URI classLoaderId;
private MonitorLevel level = MonitorLevel.INFO;
private AtomicBoolean started = new AtomicBoolean(false);
public SingletonComponent(URI componentId, Object instance, Map mappings) {
this.uri = componentId;
this.instance = instance;
this.reinjectionMappings = new HashMap();
initializeInjectionSites(instance, mappings);
}
public URI getClassLoaderId() {
return classLoaderId;
}
public void setClassLoaderId(URI classLoaderId) {
this.classLoaderId = classLoaderId;
}
public String getKey() {
return null;
}
public URI getUri() {
return uri;
}
public void start() {
started.set(true);
}
public void stop() {
started.set(false);
}
public void startUpdate() {
for (ObjectFactory factory : reinjectionMappings.keySet()) {
if (factory instanceof MultiplicityObjectFactory) {
((MultiplicityObjectFactory) factory).startUpdate();
}
}
}
public void endUpdate() {
for (ObjectFactory factory : reinjectionMappings.keySet()) {
if (factory instanceof MultiplicityObjectFactory) {
((MultiplicityObjectFactory) factory).endUpdate();
}
}
}
public QName getDeployable() {
return null;
}
public boolean isEagerInit() {
return true;
}
public Object createInstance() throws ObjectCreationException {
return instance;
}
public void releaseInstance(Object instance) {
// no-op
}
public ObjectFactory