Please wait. This can take some minutes ...
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.
io.smallrye.beanbag.maven.PlexusContainerImpl Maven / Gradle / Ivy
Go to download
A supplier of Maven Resolver components using SmallRye BeanBag
package io.smallrye.beanbag.maven;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.context.Context;
import io.smallrye.beanbag.BeanBag;
import io.smallrye.beanbag.DependencyFilter;
class PlexusContainerImpl implements PlexusContainer {
private final BeanBag bb;
PlexusContainerImpl(final BeanBag bb) {
this.bb = bb;
}
public Context getContext() {
throw uns();
}
public Object lookup(final String role) throws ComponentLookupException {
try {
return bb.requireBean(Class.forName(role));
} catch (Exception e) {
throw new ComponentLookupException(e, role, null);
}
}
public Object lookup(final String role, final String hint) throws ComponentLookupException {
try {
return bb.requireBean(Class.forName(role), hint);
} catch (Exception e) {
throw new ComponentLookupException(e, role, hint);
}
}
public T lookup(final Class role) throws ComponentLookupException {
try {
return bb.requireBean(role);
} catch (Exception e) {
throw new ComponentLookupException(e, role.getName(), null);
}
}
public T lookup(final Class role, final String hint) throws ComponentLookupException {
try {
return bb.requireBean(role, hint);
} catch (Exception e) {
throw new ComponentLookupException(e, role.getName(), hint);
}
}
public T lookup(final Class type, final String role, final String hint) throws ComponentLookupException {
try {
return type.cast(lookup(role, hint));
} catch (Exception e) {
throw new ComponentLookupException(e, role, hint);
}
}
public List lookupList(final String role) throws ComponentLookupException {
try {
return List.copyOf(bb.getAllBeans(Class.forName(role)));
} catch (Exception e) {
throw new ComponentLookupException(e, role, null);
}
}
public List lookupList(final Class role) throws ComponentLookupException {
try {
return Collections.checkedList(bb.getAllBeans(role), role);
} catch (Exception e) {
throw new ComponentLookupException(e, role.getName(), null);
}
}
public Map lookupMap(final String role) throws ComponentLookupException {
try {
return Map.copyOf(bb.newScope().getAllBeansWithNames(Class.forName(role), DependencyFilter.ACCEPT));
} catch (Exception e) {
throw new ComponentLookupException(e, role, null);
}
}
public Map lookupMap(final Class role) throws ComponentLookupException {
try {
return Map.copyOf(bb.newScope().getAllBeansWithNames(role, DependencyFilter.ACCEPT));
} catch (Exception e) {
throw new ComponentLookupException(e, role.getName(), null);
}
}
public boolean hasComponent(final String role) {
try {
return bb.getOptionalBean(Class.forName(role)) != null;
} catch (Exception e) {
return false;
}
}
public boolean hasComponent(final String role, final String hint) {
try {
return bb.getOptionalBean(Class.forName(role), hint) != null;
} catch (Exception e) {
return false;
}
}
public boolean hasComponent(final Class> role) {
try {
return bb.getOptionalBean(role) != null;
} catch (Exception e) {
return false;
}
}
public boolean hasComponent(final Class> role, final String hint) {
try {
return bb.getOptionalBean(role, hint) != null;
} catch (Exception e) {
return false;
}
}
public boolean hasComponent(final Class> type, final String role, final String hint) {
try {
return type.cast(bb.getOptionalBean(Class.forName(role), hint)) != null;
} catch (Exception e) {
return false;
}
}
public void addComponent(final Object component, final String role) {
throw uns();
}
public void addComponent(final T component, final Class> role, final String hint) {
throw uns();
}
public void addComponentDescriptor(final ComponentDescriptor descriptor)
throws CycleDetectedInComponentGraphException {
throw uns();
}
public ComponentDescriptor> getComponentDescriptor(final String role, final String hint) {
throw uns();
}
public ComponentDescriptor getComponentDescriptor(final Class type, final String role, final String hint) {
throw uns();
}
public List> getComponentDescriptorList(final String role) {
throw uns();
}
public List> getComponentDescriptorList(final Class type, final String role) {
throw uns();
}
public Map> getComponentDescriptorMap(final String role) {
throw uns();
}
public Map> getComponentDescriptorMap(final Class type, final String role) {
throw uns();
}
public List> discoverComponents(final ClassRealm classRealm) throws PlexusConfigurationException {
throw uns();
}
public ClassRealm getContainerRealm() {
throw uns();
}
public ClassRealm setLookupRealm(final ClassRealm realm) {
throw uns();
}
public ClassRealm getLookupRealm() {
throw uns();
}
public ClassRealm createChildRealm(final String id) {
throw uns();
}
public void release(final Object component) {
}
public void releaseAll(final Map components) {
}
public void releaseAll(final List> components) {
}
public void dispose() {
}
private static UnsupportedOperationException uns() {
return new UnsupportedOperationException();
}
}