本文整理了Java中info.magnolia.objectfactory.Components.getComponentProvider()
方法的一些代码示例,展示了Components.getComponentProvider()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Components.getComponentProvider()
方法的具体详情如下:
包路径:info.magnolia.objectfactory.Components
类名称:Components
方法名:getComponentProvider
[英]Returns the currently set ComponentProvider.
[中]返回当前设置的ComponentProvider。
代码示例来源:origin: info.magnolia/magnolia-core
/**
* @see Content2BeanProcessor
* @deprecated since 4.5 use {@link Content2Bean}
* TODO -- this method has a bunch of usage points
*/
public static Object toBean(Content node, boolean recursive, Content2BeanTransformer transformer) throws Content2BeanException {
return toBean(node, recursive, transformer, Components.getComponentProvider());
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* @see Content2BeanProcessor
* @deprecated since 4.5 - use {@link Content2Bean}
*/
public static Object setProperties(Object bean, Content node, boolean recursive, Content2BeanTransformer transformer) throws Content2BeanException {
return setProperties(bean, node, recursive, transformer, Components.getComponentProvider());
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Returns a component from the currently set {@link ComponentProvider}. Consider using IoC to inject the component instead.
*/
public static <T> T getComponent(Class<T> type) {
return getComponentProvider().getComponent(type);
}
代码示例来源:origin: info.magnolia/magnolia-core
protected Node2BeanTransformer getTransformerFromAnnotation(AnnotatedElement writeMethod) {
final TransformedBy transformerAnnotation = writeMethod.getAnnotation(TransformedBy.class);
final Class<Node2BeanTransformer> transformerClass = transformerAnnotation == null ? null : (Class<Node2BeanTransformer>) transformerAnnotation.value();
return transformerClass == null ? null : Components.getComponentProvider().newInstance(transformerClass);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
protected ServerConfiguration transformNode(Node node) throws Node2BeanException, RepositoryException {
return (ServerConfiguration) Components.getComponent(Node2BeanProcessor.class).toBean(node, false, new Node2BeanTransformerImpl() {
@Override
public Object newBeanInstance(TransformationState state, Map properties, ComponentProvider componentProvider) {
return new ServerConfiguration();
}
}, Components.getComponentProvider());
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Object toBean(Node node, final Class<?> defaultClass) throws Node2BeanException, RepositoryException {
return transformAndLogProblems(node, true, new Node2BeanTransformerImpl() {
@Override
protected TypeDescriptor onResolveType(TypeMapping mapping, TransformationState state, TypeDescriptor resolvedType, ComponentProvider componentProvider) {
if (resolvedType == null && state.getLevel() == 1) {
return mapping.getTypeDescriptor(defaultClass);
}
return resolvedType;
}
}, defaultTransformer.newState(), getComponentProvider());
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* @return new instance of the web context on every call.
*/
public WebContext createWebContext(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) {
final WebContextFactory ctxFactory = Components.getComponentProvider().getComponent(WebContextFactory.class);
return ctxFactory.createWebContext(request, response, servletContext);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Object toBean(Node node) throws Node2BeanException, RepositoryException {
return transformAndLogProblems(node, true, defaultTransformer, defaultTransformer.newState(), getComponentProvider());
}
代码示例来源:origin: info.magnolia/magnolia-core
public static String getPublicKey() {
ActivationManager aman = Components.getComponentProvider().getComponent(ActivationManager.class);
return aman.getPublicKey();
}
代码示例来源:origin: info.magnolia/magnolia-core
public static <T> T getComponentWithAnnotation(Class<T> type, Annotation annotation) {
ComponentProvider componentProvider = getComponentProvider();
if (!(componentProvider instanceof GuiceComponentProvider)) {
throw new NoSuchComponentException("Component provider does not support resolving of components by annotation.");
}
Injector injector = ((GuiceComponentProvider) componentProvider).getInjector();
Key<T> key = Key.get(type, annotation);
if (!GuiceUtils.hasExplicitBindingFor(injector, key)) {
throw new NoSuchComponentException("No component configuration for type [" + type.getName() + "] with annotation [" + annotation + "] found. Please add a configuration to your module descriptor.");
}
return injector.getInstance(key);
}
代码示例来源:origin: info.magnolia/magnolia-templating-jsp
protected C createTemplatingElement() {
// FIXME use scope instead of fetching the RenderingContext for passing it as an argument
final RenderingEngine renderingEngine = Components.getComponent(RenderingEngine.class);
final RenderingContext renderingContext = renderingEngine.getRenderingContext();
return Components.getComponentProvider().newInstance(getTemplatingElementClass(), renderingContext);
}
代码示例来源:origin: info.magnolia/magnolia-templating
protected C createTemplatingElement() {
// FIXME use scope instead of fetching the RenderingContext for passing it as an argument
final RenderingEngine renderingEngine = Components.getComponent(RenderingEngine.class);
final RenderingContext renderingContext = renderingEngine.getRenderingContext();
return Components.getComponentProvider().newInstance(getTemplatingElementClass(), renderingContext);
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Before
public void setUp() {
final ActionRenderer actionRenderer = mock(ActionRenderer.class);
when(actionRenderer.start(any(), eq(actionListener))).thenReturn(actionView);
ComponentsTestUtil.setInstance(ActionRenderer.class, actionRenderer);
view = mock(EditorActionAreaView.class);
editorActionAreaPresenter = new EditorActionAreaPresenterImpl(view, Components.getComponentProvider());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testPushingAndPoppingComponentProvider() throws Exception {
// GIVEN
ComponentProvider previous = mock(ComponentProvider.class);
Components.setComponentProvider(previous);
assertSame(previous, Components.getComponentProvider());
// WHEN
ComponentProvider other = mock(ComponentProvider.class);
Components.pushProvider(other);
// THEN
assertSame(other, Components.getComponentProvider());
Components.popProvider();
assertSame(previous, Components.getComponentProvider());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void multiValuePropertyDoesNotCauseErrorWhenResolvingTypes() throws Exception {
// GIVEN
Node node = new MockNode("foo");
node.setProperty("field", new String[]{"value", "value2"});
node.setProperty("class", SimpleBean.class.getName());
// WHEN
TransformationStateImpl state = new TransformationStateImpl();
state.pushNode(node);
TypeDescriptor typeDescriptor = transformer.resolveType(typeMapping, state, Components.getComponentProvider());
// THEN
assertThat(typeDescriptor.getType().getName(), is(SimpleBean.class.getName()));
}
代码示例来源:origin: info.magnolia.activation/magnolia-module-activation
@Override
public boolean execute(Context ctx) throws Exception {
if (StringUtils.isNotBlank(getPath()) && isProperty(getPath())) {
throw new UnsupportedOperationException("Deactivation is not supported for properties.");
}
Syndicator syndicator = Components.getComponentProvider().newInstance(Syndicator.class);
syndicator.init(getUser(ctx), this.getRepository(), ContentRepository.getDefaultWorkspace(this.getRepository()), new Rule());
final Content node = getNode(ctx);
syndicator.deactivate(node);
return true;
}
代码示例来源:origin: info.magnolia/magnolia-core
public static void checkOrInitRepositoryManager() {
if (Components.getComponentProvider() == null) {
setupMockRepoManager();
}
try {
Components.getComponent(RepositoryManager.class);
} catch (IllegalStateException | MgnlInstantiationException e) {
setupMockRepoManager();
}
}
代码示例来源:origin: info.magnolia.activation/magnolia-module-activation
public Syndicator getSyndicator() {
// lazy bound, but only if this is a clone
if (syndicator == null) {
syndicator = Components.getComponentProvider().newInstance(Syndicator.class);
syndicator.init(
getUser(),
this.getRepository(),
ContentRepository.getDefaultWorkspace(this.getRepository()),
getRule());
}
return syndicator;
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-admincentral
/**
* Initialize components used by {@link PulsePresenter}.
*/
private void initComponents() {
ComponentsTestUtil.setInstance(PulseDefinition.class, pulseDefinition);
ComponentsTestUtil.setInstance(PulseListDefinition.class, mock(PulseListDefinition.class));
ComponentsTestUtil.setInstance(EventBus.class, eventBus);
ComponentsTestUtil.setInstance(PulseView.class, view);
ComponentsTestUtil.setInstance(Shell.class, mock(ShellImpl.class));
ComponentsTestUtil.setInstance(AppController.class, mock(AppController.class));
ComponentsTestUtil.setInstance(MessagesManager.class, mock(MessagesManager.class));
ComponentsTestUtil.setInstance(ComponentProvider.class, Components.getComponentProvider());
ComponentsTestUtil.setInstance(PulseListView.class, mock(PulseListView.class));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void beanWithClassDefined2() throws Exception {
// GIVEN
final Session session = SessionTestUtil.createSession("test",
"/parent.class=" + OtherSimpleBean.class.getName(),
"/parent.string=hello"
);
// WHEN
final OtherSimpleBean bean = (OtherSimpleBean) node2bean.toBean(session.getNode("/parent"), false, new ProxyingNode2BeanTransformer(), Components.getComponentProvider());
// THEN
assertTrue(bean instanceof SimpleBean);
assertEquals("proxied: hello", bean.getString());
}
内容来源于网络,如有侵权,请联系作者删除!