private ObjectHasher getObjectHasher(){ if (objectHasher != null){ return objectHasher; } synchronized (this) { objectHasher = picoContainer.getComponent(ObjectHasher.class); return objectHasher; } }
private ApplicationProperties getProperties() { // Lazy load the application properties return container.getComponent(ApplicationProperties.class); } }
@Override protected <T, V extends T> T instanceOf(final Class<T> type, final Class<V> ofClass) { if (container != null) { T instance = null; try { instance = container.getComponent(type); } catch (AmbiguousComponentResolutionException e) { instance = container.getComponent(ofClass); } if ( instance != null ){ return instance; } } return super.instanceOf(type, ofClass); }
/** * Retrieves and returns the index lifecycle manager instance * * @return index lifecycle manager */ IndexLifecycleManager getIndexLifecycleManager() { return getContainer().getComponent(IndexLifecycleManager.class); }
/** * Returns the {@link com.atlassian.jira.task.TaskManager} * * @return the {@link com.atlassian.jira.task.TaskManager} */ TaskManager getTaskManager() { return getContainer().getComponent(TaskManager.class); }
protected InvocationHandler getHandler(final PicoContainer container) { Object enabled = container.getComponent(enabledClass); Object disabled = container.getComponent(disabledClass); return new SwitchingInvocationHandler(enabled, disabled, getInvocationSwitcher()); }
public Object getComponentInstance(PicoContainer pico, Type type) throws PicoCompositionException { logger.debug("Providing {} instance via {}", targetType.getName(), componentFactoryClass.getName()); ComponentFactory<?> componentFactory = pico.getComponent(componentFactoryClass); return componentFactory.getInstance(); }
private static ConstantsManager getConstantsManager() { return getContainer().getComponent(ConstantsManager.class); }
private PluginAccessor getPluginAccessor() { return getContainer().getComponent(PluginAccessor.class); }
public Object createInstanceOfType(Class<?> type) { Object instance = parent.getComponent(type); if ( instance == null ){ throw new StepsInstanceNotFound(type, this); } return instance; }
@Override public Object resolve(Class argType) { if (argType == PicoContainer.class){ return container; } Object component = container.getComponent(argType); if (component == null) { logger.error("failed to get component of type "+argType.getName()+" from Pico container"); throw new JaversException(JaversExceptionCode.COMPONENT_NOT_FOUND, argType.getName()); } return component; } }
public T getComponentInstance(final PicoContainer container) throws PicoCompositionException { return container.getComponent(getComponentImplementation()); }
private static XSite instantiateXSite(URL url) { ScriptedContainerBuilder builder = new XMLContainerBuilder(url, Main.class.getClassLoader()); PicoContainer container = builder.buildContainer(null, null, false); return container.getComponent(XSite.class); }
@Override public Object getComponentInstance(PicoContainer container, Type into) throws PicoCompositionException { BehaviorFactory bf = (BehaviorFactory) injector.getComponentInstance(container, into); bf.wrap((ComponentFactory) container.getComponent(otherKey)); return bf; } }
private JiraWorkflow getWorkflow(PicoContainer parent, String workflowMode, String workflowName, HttpServletRequest request) { // Use the WorkflowManager to get the required workflow WorkflowManager workflowManager = parent.getComponent(WorkflowManager.class); JiraWorkflow workflow; if (workflowMode.equals(JiraWorkflow.LIVE)) { // get the "live" workflow workflow = workflowManager.getWorkflowClone(workflowName); } else if (workflowMode.equals(JiraWorkflow.DRAFT)) { // get the draft workflow workflow = workflowManager.getDraftWorkflow(workflowName); } else { throw new IllegalStateException("Invalid workflow mode '" + workflowMode + "'. " + getFullRequestUrl(request)); } return workflow; }
/** * {@inheritDoc} * * @param facesContext * @param name * @return the resulting object, either resolved through NanoWAR, or passed * onto the delegate resolver. * @throws EvaluationException * @see javax.faces.el.VariableResolver#resolveVariable(javax.faces.context.FacesContext, * java.lang.String) */ public Object resolveVariable(FacesContext facesContext, String name) { PicoContainer nano = getPicoContainer(facesContext); Object result = nano.getComponent(name); if (result == null) { return nested.resolveVariable(facesContext, name); } return result; }
/** * Instantiates an action using the PicoContainer found in the request scope. * if action or bean is not registered explicitely, new instance will be provided * on every invocation. * * @see com.opensymphony.xwork.ObjectFactory#buildBean(java.lang.Class) */ public Object buildBean(Class<?> actionClass) throws Exception { PicoContainer actionsContainer = currentRequestContainer.get(); Object action = actionsContainer.getComponent(actionClass); if (action == null) { // The action wasn't registered. Attempt to instantiate it. // use child container to prevent weirdest errors MutablePicoContainer child = new DefaultPicoContainer(actionsContainer); child.addComponent(actionClass); action = child.getComponent(actionClass); } return action; }
PicoContainer container = new DefaultPicoContainer(); container.addComponent(Earth.class); container.addComponent(Continent.class); container.addComponent(Country.class); container.addComponent(City.class, new ConstantParameter(cityName)); City barcelona = container.getComponent(City.class);
@Override public <T> void instantiated(PicoContainer container, ComponentAdapter<T> componentAdapter, Constructor<T> constructor, Object instantiated, Object[] injected, long duration) { final TypeNameExtractor extractor = container.getComponent(TypeNameExtractor.class); Object object = componentAdapter.getComponentKey(); if (object instanceof Class<?>) { Class<?> type = (Class<?>) object; setter.setAttribute(extractor.nameFor(type), instantiated); } else if (instantiated != null){ setter.setAttribute(extractor.nameFor(instantiated.getClass()), instantiated); } } }
/** * Run the migrations for the given system name * * @param arguments the command line arguments, if any * @throws Exception if anything goes wrong */ public static void main(final String[] arguments) throws Exception { AutopatchRegistry registry = new AutopatchRegistry(); PicoContainer pico = registry.configureContainer(); JdbcMigrationLauncherFactory launcherFactory = new JdbcMigrationLauncherFactoryLoader().createFactory(); StandaloneMigrationLauncher migrationLauncher = pico.getComponent(StandaloneMigrationLauncher.class); migrationLauncher.getMigrationUtil().setLauncherFactory(launcherFactory); migrationLauncher.run(arguments); registry.destroyContainer(); }