Java Code Examples for org.springframework.beans.BeansException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project arkadiko, under directory /src/com/liferay/arkadiko/.

Source file: AKBeanPostProcessor.java

  19 
vote

/** 
 * Post process after initialisation.
 * @param bean the bean
 * @param beanId the bean id
 * @return the object
 * @throws BeansException the beans exception
 */
public Object postProcessAfterInitialization(Object bean,String beanId) throws BeansException {
  List<Class<?>> interfaces=AKIntrospector.getInterfacesAsList(bean);
  if (ignoreBean(bean,beanId,interfaces)) {
    return bean;
  }
  Framework framework=getFramework();
  BundleContext bundleContext=framework.getBundleContext();
  registerService(bundleContext,bean,beanId,interfaces);
  return createProxy(bundleContext,bean,beanId,interfaces);
}
 

Example 2

From project banshun, under directory /banshun/core/src/main/java/com/griddynamics/banshun/.

Source file: ExportTargetSource.java

  19 
vote

@Override public Object getTarget() throws BeansException {
  Object localTarget=target.get();
  if (localTarget == null) {
    if (target.compareAndSet(null,localTarget=getBeanFactory().getBean(getTargetBeanName()))) {
      return localTarget;
    }
 else {
      log.info("needles creation of bean " + targetBeanName + "caused by concurrency has been detected. ignoring new instance");
      return target.get();
    }
  }
  return localTarget;
}
 

Example 3

From project Blitz, under directory /src/com/laxser/blitz/scanning/context/.

Source file: BlitzWebAppContext.java

  19 
vote

@Override protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException {
  Resource[] configResources=getConfigResourcesThrows();
  if (configResources != null) {
    reader.loadBeanDefinitions(configResources);
  }
  String[] configLocations=getConfigLocations();
  if (configLocations != null) {
    for (int i=0; i < configLocations.length; i++) {
      reader.loadBeanDefinitions(configLocations[i]);
    }
  }
}
 

Example 4

From project caseconductor-platform, under directory /utest-domain-services/src/main/java/com/utest/domain/service/impl/.

Source file: DomainServiceBeanPostProcessor.java

  19 
vote

/** 
 * Process after bean initialization.
 */
@Override public Object postProcessAfterInitialization(final Object bean,final String beanName) throws BeansException {
  logger.debug("DomainServiceBeanPostProcessor postProcessAfterInitialization: " + beanName);
  if (bean instanceof Initializable) {
    ((Initializable)bean).initialize();
  }
  return bean;
}
 

Example 5

From project cometd, under directory /cometd-archetypes/spring-dojo-jetty7/src/main/resources/archetype-resources/src/main/java/.

Source file: BayeuxInitializer.java

  19 
vote

public Object postProcessBeforeInitialization(Object bean,String name) throws BeansException {
  processor.processDependencies(bean);
  processor.processConfigurations(bean);
  processor.processCallbacks(bean);
  return bean;
}
 

Example 6

From project common_1, under directory /src/main/java/org/powertac/util/.

Source file: PropertiesUtil.java

  19 
vote

@Override protected void processProperties(ConfigurableListableBeanFactory beanFactory,Properties props) throws BeansException {
  super.processProperties(beanFactory,props);
  propertiesMap=new HashMap<String,String>();
  for (  Object key : props.keySet()) {
    String keyStr=key.toString();
    propertiesMap.put(keyStr,resolvePlaceholder(props.getProperty(keyStr),props));
  }
}
 

Example 7

From project constretto-core, under directory /constretto-spring/src/main/java/org/constretto/spring/.

Source file: EnvironmentAnnotationConfigurer.java

  19 
vote

@SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
  if (!(configurableListableBeanFactory instanceof DefaultListableBeanFactory)) {
    throw new IllegalStateException("EnvironmentAnnotationConfigurer needs to operate on a DefaultListableBeanFactory");
  }
  DefaultListableBeanFactory defaultListableBeanFactory=(DefaultListableBeanFactory)configurableListableBeanFactory;
  defaultListableBeanFactory.setAutowireCandidateResolver(new ConstrettoAutowireCandidateResolver());
  String[] beanNames=configurableListableBeanFactory.getBeanDefinitionNames();
  int lowestDiscoveredPriority=Integer.MAX_VALUE;
  for (  String beanName : beanNames) {
    BeanDefinition beanDefinition=configurableListableBeanFactory.getBeanDefinition(beanName);
    if (beanDefinition.getBeanClassName() != null) {
      try {
        Class beanClass=Class.forName(beanDefinition.getBeanClassName());
        Environment environmentAnnotation=findEnvironmentAnnotation(beanClass);
        if (environmentAnnotation != null) {
          if (!assemblyContextResolver.getAssemblyContext().isEmpty()) {
            boolean autowireCandidate=decideIfAutowireCandiate(beanName,environmentAnnotation);
            beanDefinition.setAutowireCandidate(autowireCandidate);
            if (autowireCandidate) {
              removeNonAnnotatedBeansFromAutowireForType(beanClass,configurableListableBeanFactory);
            }
          }
 else {
            beanDefinition.setAutowireCandidate(false);
          }
        }
      }
 catch (      ClassNotFoundException e) {
        beanDefinition.setAutowireCandidate(false);
      }
    }
  }
}
 

Example 8

From project ddd-cqrs-sample, under directory /src/main/java/pl/com/bottega/ddd/infrastructure/events/impl/.

Source file: EventListenerBeanPostProcessor.java

  19 
vote

@Override public Object postProcessAfterInitialization(Object bean,String beanName) throws BeansException {
  if (!(bean instanceof SagaInstance)) {
    for (    Method method : bean.getClass().getMethods()) {
      EventListener listenerAnnotation=method.getAnnotation(EventListener.class);
      if (listenerAnnotation == null) {
        continue;
      }
      Class<?> eventType=method.getParameterTypes()[0];
      if (listenerAnnotation.asynchronous()) {
        EventHandler handler=new AsynchronousEventHandler(eventType,beanName,method,beanFactory);
        eventPublisher.registerEventHandler(handler);
      }
 else {
        EventHandler handler=new SpringEventHandler(eventType,beanName,method,beanFactory);
        eventPublisher.registerEventHandler(handler);
      }
    }
  }
  return bean;
}
 

Example 9

From project EasySOA, under directory /easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-httpdiscoveryproxy/src/main/java/org/easysoa/cxf/.

Source file: EasySOABusFactory.java

  19 
vote

/** 
 * Does the same thing as in SpringBusFactory.finishCreatingBus(), but calls a custom myFinishCreatingBus() that adds an anti-deadlock wait
 * @param bac
 * @return
 */
public Bus createBus(String cfgFiles[],boolean includeDefaults){
  try {
    String userCfgFile=System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
    String sysCfgFileUrl=System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
    Resource r=BusApplicationContext.findResource(Configurer.DEFAULT_USER_CFG_FILE);
    if (context == null && userCfgFile == null && cfgFiles == null && sysCfgFileUrl == null && (r == null || !r.exists()) && includeDefaults) {
      return new org.apache.cxf.bus.CXFBusFactory().createBus();
    }
    return myFinishCreatingBus(createApplicationContext(cfgFiles,includeDefaults));
  }
 catch (  BeansException ex) {
    LogUtils.log(LOG,Level.WARNING,"APP_CONTEXT_CREATION_FAILED_MSG",ex,(Object[])null);
    throw new RuntimeException(ex);
  }
}
 

Example 10

From project elw, under directory /server/src/main/java/elw/dao/.

Source file: PropertyOverrideConfCommons.java

  19 
vote

@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties props) throws BeansException {
  final CompositeConfiguration compConf=ConfigLoader.getConfiguration(baseName);
  if (props == null) {
    props=new Properties();
  }
  for (Iterator<String> keyIt=compConf.getKeys(); keyIt.hasNext(); ) {
    final String key=keyIt.next();
    if (key.length() <= prefix.length() || !key.startsWith(prefix)) {
      continue;
    }
    props.put(key.substring(prefix.length()),compConf.getString(key));
  }
  super.processProperties(beanFactoryToProcess,props);
}
 

Example 11

From project FunctionalTestsPortlet, under directory /src/main/java/org/springframework/portlet/filter/.

Source file: GenericPortletFilterBean.java

  19 
vote

@Override public void init(FilterConfig filterConfig) throws PortletException {
  Assert.notNull(filterConfig,"FilterConfig must not be null");
  if (logger.isDebugEnabled()) {
    logger.debug("Initializing filter '" + filterConfig.getFilterName() + "'");
  }
  this.filterConfig=filterConfig;
  try {
    PropertyValues pvs=new FilterConfigPropertyValues(filterConfig,this.requiredProperties);
    BeanWrapper bw=PropertyAccessorFactory.forBeanPropertyAccess(this);
    ResourceLoader resourceLoader=new PortletContextResourceLoader(filterConfig.getPortletContext());
    bw.registerCustomEditor(Resource.class,new ResourceEditor(resourceLoader));
    initBeanWrapper(bw);
    bw.setPropertyValues(pvs,true);
  }
 catch (  BeansException ex) {
    String msg="Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': "+ ex.getMessage();
    logger.error(msg,ex);
    throw new PortletException(msg,ex);
  }
  initFilterBean();
  if (logger.isDebugEnabled()) {
    logger.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully");
  }
}
 

Example 12

From project galaxy, under directory /src/co/paralleluniverse/common/spring/.

Source file: SpringContainerHelper.java

  19 
vote

/** 
 * adds hooks to capture autowired constructor args and add them as dependencies
 * @return 
 */
private static DefaultListableBeanFactory createBeanFactory(){
  return new DefaultListableBeanFactory(){
{
      final InstantiationStrategy is=getInstantiationStrategy();
      setInstantiationStrategy(new InstantiationStrategy(){
        @Override public Object instantiate(        RootBeanDefinition beanDefinition,        String beanName,        BeanFactory owner) throws BeansException {
          return is.instantiate(beanDefinition,beanName,owner);
        }
        @Override public Object instantiate(        RootBeanDefinition beanDefinition,        String beanName,        BeanFactory owner,        Constructor<?> ctor,        Object[] args) throws BeansException {
          final Object bean=is.instantiate(beanDefinition,beanName,owner,ctor,args);
          addDependencies(bean,args);
          return bean;
        }
        @Override public Object instantiate(        RootBeanDefinition beanDefinition,        String beanName,        BeanFactory owner,        Object factoryBean,        Method factoryMethod,        Object[] args) throws BeansException {
          final Object bean=is.instantiate(beanDefinition,beanName,owner,factoryBean,factoryMethod,args);
          addDependencies(bean,args);
          return bean;
        }
      }
);
    }
    private void addDependencies(    Object bean,    Object[] args){
      if (bean instanceof Service) {
        for (        Object arg : args) {
          if (arg instanceof Service) {
            ((Service)arg).addDependedBy((Service)bean);
            ((Service)bean).addDependsOn((Service)arg);
          }
        }
      }
    }
  }
;
}
 

Example 13

From project Gemini-Blueprint, under directory /core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/.

Source file: BlueprintConverterConfigurer.java

  19 
vote

public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  if (beanFactory instanceof AbstractBeanFactory) {
    AbstractBeanFactory bf=((AbstractBeanFactory)beanFactory);
    ConversionService cs=bf.getConversionService();
    if (cs instanceof SpringBlueprintConverterService) {
      cs=null;
    }
    SpringBlueprintConverterService sbc=new SpringBlueprintConverterService(cs,bf);
    sbc.add(converters);
    bf.setConversionService(sbc);
  }
}
 

Example 14

From project geronimo-xbean, under directory /xbean-spring/src/main/java/org/apache/xbean/spring/context/.

Source file: ClassPathXmlApplicationContext.java

  19 
vote

/** 
 * Creates a ClassPathXmlApplicationContext which loads the configuration at the specified locations on the class path.
 * @param configLocations the locations of the configuration files on the class path
 * @param refresh if true the configurations are immedately loaded; otherwise the configurations are not loadeduntil refresh() is called
 * @param parent the parent of this application context
 * @param xmlPreprocessors the SpringXmlPreprocessors to apply before passing the xml to Spring for processing
 * @throws BeansException if a problem occurs while reading the configuration
 */
public ClassPathXmlApplicationContext(String[] configLocations,boolean refresh,ApplicationContext parent,List xmlPreprocessors) throws BeansException {
  super(configLocations,false,parent);
  this.xmlPreprocessors=xmlPreprocessors;
  if (refresh) {
    refresh();
  }
}
 

Example 15

From project heritrix3, under directory /commons/src/main/java/org/archive/spring/.

Source file: ConfigPathConfigurer.java

  19 
vote

/** 
 * Remember ApplicationContext, and if possible primary  configuration file's home directory.  Requires appCtx be a PathSharingContext 
 * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
 */
public void setApplicationContext(ApplicationContext appCtx) throws BeansException {
  this.appCtx=(PathSharingContext)appCtx;
  String basePath;
  if (appCtx instanceof PathSharingContext) {
    basePath=this.appCtx.getConfigurationFile().getParent();
  }
 else {
    basePath=".";
  }
  path=new ConfigPath("job base",basePath);
  path.setConfigurer(this);
}
 

Example 16

From project james, under directory /container-spring/src/main/java/org/apache/james/container/spring/bean/factory/protocols/.

Source file: ProtocolHandlerLoaderBeanFactory.java

  19 
vote

@SuppressWarnings("unchecked") @Override public ProtocolHandler load(String name,Configuration config) throws LoadingException {
  try {
    Class<ProtocolHandler> c=(Class<ProtocolHandler>)getBeanFactory().getBeanClassLoader().loadClass(name);
    ProtocolHandler handler=(ProtocolHandler)getBeanFactory().createBean(c);
    if (handler instanceof LifecycleAwareProtocolHandler) {
      ((InitializingLifecycleAwareProtocolHandler)handler).init(config);
    }
    return handler;
  }
 catch (  ClassNotFoundException e) {
    throw new LoadingException("Unable to load handler",e);
  }
catch (  BeansException e) {
    throw new LoadingException("Unable to load handler",e);
  }
catch (  ConfigurationException e) {
    throw new LoadingException("Unable to load handler",e);
  }
}
 

Example 17

From project java-maven-tests, under directory /src/pg-lock-test/src/main/java/com/alexshabanov/service/impl/conf/.

Source file: AppConfigurationManager.java

  19 
vote

/** 
 * {@inheritDoc}Add all the inferior context's beans definitions.
 */
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
  final DefaultListableBeanFactory beanFactory=new DefaultListableBeanFactory(hostContext);
  final XmlBeanDefinitionReader reader=new XmlBeanDefinitionReader(beanFactory);
  reader.loadBeanDefinitions(new ClassPathResource(daoContextLocation),new ClassPathResource(INFERIOR_CONTEXT_LOCATION));
  hostPropertyConfigurer.postProcessBeanFactory(beanFactory);
  for (  final String beanName : reader.getBeanFactory().getBeanDefinitionNames()) {
    registry.registerBeanDefinition(beanName,reader.getBeanFactory().getBeanDefinition(beanName));
  }
}
 

Example 18

From project jdonframework, under directory /doc/chinese/.

Source file: AppContextJdon.java

  19 
vote

/** 
 * ApplicationContextAware's method at first run, startup Jdon Framework 
 */
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  this.applicationContext=applicationContext;
  if (servletContext == null)   if (applicationContext instanceof WebApplicationContext) {
    servletContext=((WebApplicationContext)applicationContext).getServletContext();
    if (servletContext == null) {
      System.err.print("this class only fit for Spring Web Application");
      return;
    }
  }
  AppContextWrapper acw=new ServletContextWrapper(servletContext);
  ContainerFinder containerFinder=new ContainerFinderImp();
  containerWrapper=containerFinder.findContainer(acw);
}
 

Example 19

From project jsecurity, under directory /support/spring/src/main/java/org/apache/ki/spring/.

Source file: LifecycleBeanPostProcessor.java

  19 
vote

/** 
 * Calls the <tt>init()</tt> methods on the bean if it implements  {@link org.apache.ki.util.Initializable}
 * @param object the object being initialized.
 * @param name   the name of the bean being initialized.
 * @return the initialized bean.
 * @throws BeansException if any exception is thrown during initialization.
 */
public Object postProcessBeforeInitialization(Object object,String name) throws BeansException {
  if (object instanceof Initializable) {
    try {
      if (log.isDebugEnabled()) {
        log.debug("Initializing bean [" + name + "]...");
      }
      ((Initializable)object).init();
    }
 catch (    Exception e) {
      throw new FatalBeanException("Error initializing bean [" + name + "]",e);
    }
  }
  return object;
}
 

Example 20

From project juzu, under directory /core/src/main/java/juzu/impl/inject/spi/spring/.

Source file: SingletonInstantiationStrategy.java

  19 
vote

public Object instantiate(RootBeanDefinition beanDefinition,String beanName,BeanFactory owner) throws BeansException {
  Object instance=singletons.get(beanName);
  if (instance != null) {
    return instance;
  }
  return delegate.instantiate(beanDefinition,beanName,owner);
}
 

Example 21

From project mapfish-print, under directory /src/main/java/org/mapfish/print/map/readers/.

Source file: MapReaderFactoryFinder.java

  19 
vote

@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  Map<String,MapReaderFactory> tmpFac=applicationContext.getBeansOfType(MapReaderFactory.class);
  for (  Map.Entry<String,MapReaderFactory> entry : tmpFac.entrySet()) {
    if (!entry.getKey().contains("-")) {
      throw new BeanInitializationException("All MapFactoryReaders must have an id with format:  type-MapReaderFactory");
    }
    factories.put(entry.getKey().split("-")[0].toLowerCase(),entry.getValue());
  }
}
 

Example 22

From project metrics-spring, under directory /src/main/java/com/ryantenney/metrics/spring/.

Source file: AbstractProxyingBeanPostProcessor.java

  19 
vote

@Override public Object postProcessAfterInitialization(Object bean,String beanName) throws BeansException {
  if (bean instanceof AopInfrastructureBean) {
    return bean;
  }
  final Class<?> targetClass=AopUtils.getTargetClass(bean);
  final Pointcut pointcut=getPointcut();
  if (AopUtils.canApply(pointcut,targetClass)) {
    final MethodInterceptor interceptor=getMethodInterceptor(targetClass);
    final PointcutAdvisor advisor=new DefaultPointcutAdvisor(pointcut,interceptor);
    if (bean instanceof Advised) {
      log.debug("Bean {} is already proxied, adding Advisor to existing proxy",beanName);
      ((Advised)bean).addAdvisor(0,advisor);
      return bean;
    }
    log.debug("Proxying bean {} of type {}",beanName,targetClass.getCanonicalName());
    final ProxyFactory proxyFactory=new ProxyFactory(bean);
    proxyFactory.copyFrom(this);
    proxyFactory.addAdvisor(advisor);
    return proxyFactory.getProxy(this.beanClassLoader);
  }
  return bean;
}
 

Example 23

From project miso-lims, under directory /miso-web/src/main/java/uk/ac/bbsrc/tgac/miso/webapp/util/.

Source file: MisoPropertyExporter.java

  19 
vote

@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties misoProps) throws BeansException {
  String baseStoragePath=misoProps.getProperty("miso.baseDirectory");
  if (baseStoragePath != null) {
    Map<String,String> propchecks=MisoWebUtils.checkCorePropertiesFiles(baseStoragePath);
    if (propchecks.keySet().contains("error")) {
      throw new BeanInitializationException(propchecks.get("error"));
    }
    List<String> propertiesList=Arrays.asList(new File(baseStoragePath).list(new PropertiesFilenameFilter()));
    for (    String propPath : propertiesList) {
      System.out.println("Attempting to load " + baseStoragePath + propPath);
      Properties tempProps;
      try {
        InputStream in=new FileInputStream(new File(baseStoragePath,propPath));
        tempProps=new Properties();
        try {
          tempProps.load(in);
          System.out.println("Loaded " + tempProps.keySet() + " from "+ propPath);
          CollectionUtils.mergePropertiesIntoMap(tempProps,misoProps);
        }
 catch (        IOException e) {
          throw new InvalidPropertyException(MisoPropertyExporter.class,"All","Cannot load " + baseStoragePath + propPath+ " properties. Cannot read file!");
        }
      }
 catch (      FileNotFoundException e) {
        throw new InvalidPropertyException(MisoPropertyExporter.class,"All","Cannot load " + baseStoragePath + propPath+ " properties. File does not exist!");
      }
    }
    super.processProperties(beanFactoryToProcess,misoProps);
    resolvedProperties=new HashMap<String,String>();
    for (    Object key : misoProps.keySet()) {
      String keyStr=key.toString();
      resolvedProperties.put(keyStr,misoProps.getProperty(keyStr));
    }
  }
 else {
    throw new InvalidPropertyException(MisoPropertyExporter.class,"miso.baseDirectory","Cannot resolve miso.baseDirectory. This should be specified in the " + "miso.properties file which should be made available on the classpath.");
  }
}
 

Example 24

From project onebusaway-quickstart, under directory /onebusaway-quickstart-webapp/src/main/java/org/onebusaway/quickstart/webapp/.

Source file: BootstrapWebApplicationContext.java

  19 
vote

@Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
  super.loadBeanDefinitions(beanFactory);
  System.out.println("=== BootstrapWebApplicationContext! ============================");
  ServletContext servletContext=getServletContext();
  final CommandLine cli=(CommandLine)servletContext.getAttribute(WebappCommon.COMMAND_LINE_CONTEXT_ATTRIBUTE);
  if (cli == null)   throw new IllegalStateException("expected a CommandLine object stored in the webapp context");
  final Map<String,BeanDefinition> beanDefinitions=configureBeanDefinitions(cli);
  if (beanDefinitions.isEmpty())   return;
  for (  Map.Entry<String,BeanDefinition> entry : beanDefinitions.entrySet()) {
    String beanName=entry.getKey();
    BeanDefinition beanDefinition=entry.getValue();
    beanFactory.registerBeanDefinition(beanName,beanDefinition);
  }
}
 

Example 25

From project opencredo-esper, under directory /esper-si-support/src/main/java/org/opencredo/esper/integration/config/xml/.

Source file: EsperWireTapChannelsBeanPostProcessor.java

  19 
vote

public Object postProcessAfterInitialization(Object bean,String beanName) throws BeansException {
  if (bean instanceof AbstractMessageChannel) {
    this.addMatchingWireTaps((AbstractMessageChannel)bean);
  }
  return bean;
}
 

Example 26

From project OpenID-Connect-Java-Spring-Server, under directory /openid-connect-client/src/main/java/org/mitre/openid/connect/client/.

Source file: OIDCSignedRequestFilter.java

  19 
vote

/** 
 * If either the jwkPublishUrl or x509PublishUrl fields are set on this bean, set up a listener on that URL to publish keys.
 */
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
  if (!Strings.isNullOrEmpty(getJwkPublishUrl()) || !Strings.isNullOrEmpty(getX509PublishUrl())) {
    BeanDefinitionBuilder clientKeyMapping=BeanDefinitionBuilder.rootBeanDefinition(ClientKeyPublisherMapping.class);
    BeanDefinitionBuilder viewResolver=BeanDefinitionBuilder.rootBeanDefinition(JwkViewResolver.class);
    if (!Strings.isNullOrEmpty(getJwkPublishUrl())) {
      clientKeyMapping.addPropertyValue("jwkPublishUrl",getJwkPublishUrl());
      jwkViewName="jwkKeyList-" + UUID.randomUUID().toString();
      viewResolver.addPropertyValue("jwkViewName",jwkViewName);
      BeanDefinitionBuilder jwkView=BeanDefinitionBuilder.rootBeanDefinition(JwkKeyListView.class);
      registry.registerBeanDefinition("jwkKeyList",jwkView.getBeanDefinition());
      viewResolver.addPropertyReference("jwk","jwkKeyList");
    }
    if (!Strings.isNullOrEmpty(getX509PublishUrl())) {
      clientKeyMapping.addPropertyValue("x509PublishUrl",getX509PublishUrl());
      x509ViewName="x509certs-" + UUID.randomUUID().toString();
      viewResolver.addPropertyValue("x509ViewName",x509ViewName);
      BeanDefinitionBuilder x509View=BeanDefinitionBuilder.rootBeanDefinition(X509CertificateView.class);
      registry.registerBeanDefinition("x509certs",x509View.getBeanDefinition());
      viewResolver.addPropertyReference("x509","x509certs");
    }
    registry.registerBeanDefinition("clientKeyMapping",clientKeyMapping.getBeanDefinition());
    registry.registerBeanDefinition("jwkViewResolver",viewResolver.getBeanDefinition());
  }
}
 

Example 27

From project org.ops4j.pax.wicket, under directory /test/src/main/java/org/ops4j/pax/wicket/test/spring/.

Source file: ApplicationContextMock.java

  19 
vote

public Object getBean(String name,Class requiredType) throws BeansException {
  Object bean=getBean(name);
  if (!requiredType.isAssignableFrom(bean.getClass())) {
    throw new BeanNotOfRequiredTypeException(name,requiredType,bean.getClass());
  }
  return bean;
}
 

Example 28

From project pegadi, under directory /webapp/src/main/java/org/pegadi/webapp/spring/.

Source file: PropertyReplacer.java

  19 
vote

public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
  ServletContextResourceLoader loader=new ServletContextResourceLoader(servletContext);
  Properties properties=new Properties();
  File file=(File)servletContext.getAttribute(DataDirectoryPropertyReplacer.SERVLET_CONTEXT_ATTR);
  properties.setProperty("dataDir",file.getAbsolutePath());
  List<Resource> resources=new ArrayList<Resource>();
  resources.add(loader.getResource("/WEB-INF/pegadi.conf"));
  File configFile=new File(file.getAbsolutePath(),"pegadi.conf");
  if (configFile.exists()) {
    resources.add(loader.getResource("file:" + configFile.getAbsolutePath()));
  }
  PropertyPlaceholderConfigurer configurer=new PropertyPlaceholderConfigurer();
  configurer.setLocations(resources.toArray(new Resource[]{}));
  configurer.setProperties(properties);
  configurer.postProcessBeanFactory(configurableListableBeanFactory);
}
 

Example 29

From project qi4j-libraries, under directory /spring/src/main/java/org/qi4j/library/spring/bootstrap/internal/application/.

Source file: Qi4jApplicationFactoryBean.java

  19 
vote

public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
  if (this.applicationBootstrap instanceof ApplicationContextAware) {
    ApplicationContextAware aware=(ApplicationContextAware)this.applicationBootstrap;
    aware.setApplicationContext(applicationContext);
  }
}
 

Example 30

From project rave, under directory /rave-components/rave-commons/src/main/java/org/apache/rave/util/.

Source file: OverridablePropertyPlaceholderConfigurer.java

  19 
vote

@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties props) throws BeansException {
  super.processProperties(beanFactoryToProcess,props);
  resolvedProps=new HashMap<String,String>();
  for (  Object key : props.keySet()) {
    String keyStr=key.toString();
    resolvedProps.put(keyStr,resolvePlaceholder(keyStr,props,SYSTEM_PROPERTIES_MODE_OVERRIDE));
  }
}
 

Example 31

From project Red5, under directory /src/org/red5/spring/.

Source file: ExtendedPropertyPlaceholderConfigurer.java

  19 
vote

@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties props) throws BeansException {
  props.putAll(copyOfGlobalProperties());
  logger.debug("Placeholder props: {}",props.toString());
  this.mergedProperties=props;
  super.processProperties(beanFactoryToProcess,props);
}
 

Example 32

From project red5-mavenized, under directory /red5_base/src/main/java/org/red5/spring/.

Source file: ExtendedPropertyPlaceholderConfigurer.java

  19 
vote

@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties props) throws BeansException {
  props.putAll(copyOfGlobalProperties());
  logger.debug("Placeholder props: {}",props.toString());
  this.mergedProperties=props;
  super.processProperties(beanFactoryToProcess,props);
}
 

Example 33

From project red5-server, under directory /src/org/red5/spring/.

Source file: ExtendedPropertyPlaceholderConfigurer.java

  19 
vote

@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties props) throws BeansException {
  props.putAll(copyOfGlobalProperties());
  logger.debug("Placeholder props: {}",props.toString());
  this.mergedProperties=props;
  super.processProperties(beanFactoryToProcess,props);
}
 

Example 34

From project riot, under directory /common/src/org/riotfamily/common/beans/injection/.

Source file: SpringBeanConfigurer.java

  19 
vote

/** 
 * Looks for prototype beans who's class extends ConfigurableBean.
 */
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
  this.beanFactory=beanFactory;
  for (  String name : beanFactory.getBeanDefinitionNames()) {
    BeanDefinition bd=beanFactory.getMergedBeanDefinition(name);
    if (bd instanceof RootBeanDefinition) {
      RootBeanDefinition rbd=(RootBeanDefinition)bd;
      if (rbd.isPrototype()) {
        try {
          Class<?> beanClass=rbd.resolveBeanClass(beanFactory.getBeanClassLoader());
          if (beanClass != null && ConfigurableBean.class.isAssignableFrom(beanClass)) {
            prototypes.put(beanClass,name);
          }
        }
 catch (        ClassNotFoundException ex) {
          throw new CannotLoadBeanClassException(null,name,rbd.getBeanClassName(),ex);
        }
      }
    }
  }
  if (!prototypes.isEmpty()) {
    ConfigurableBean.configurer=this;
  }
}
 

Example 35

From project servicemix4-features, under directory /camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/.

Source file: SmxToCxfTest.java

  19 
vote

protected ClassPathXmlApplicationContext createApplicationContext(){
  return new ClassPathXmlApplicationContext("org/apache/servicemix/camel/spring/DummyBean.xml"){
    @Override public <T>T getBean(    String name,    Class<T> requiredType) throws BeansException {
      if (BUS_BEAN_NAME.equals(name)) {
        return requiredType.cast(bus);
      }
      return super.getBean(name,requiredType);
    }
  }
;
}
 

Example 36

From project shiro, under directory /support/spring/src/main/java/org/apache/shiro/spring/.

Source file: LifecycleBeanPostProcessor.java

  19 
vote

/** 
 * Calls the <tt>init()</tt> methods on the bean if it implements  {@link org.apache.shiro.util.Initializable}
 * @param object the object being initialized.
 * @param name   the name of the bean being initialized.
 * @return the initialized bean.
 * @throws BeansException if any exception is thrown during initialization.
 */
public Object postProcessBeforeInitialization(Object object,String name) throws BeansException {
  if (object instanceof Initializable) {
    try {
      if (log.isDebugEnabled()) {
        log.debug("Initializing bean [" + name + "]...");
      }
      ((Initializable)object).init();
    }
 catch (    Exception e) {
      throw new FatalBeanException("Error initializing bean [" + name + "]",e);
    }
  }
  return object;
}
 

Example 37

From project snowdrop, under directory /deployers/deployers-core/src/main/java/org/jboss/spring/factory/.

Source file: NamedXmlApplicationContext.java

  19 
vote

public NamedXmlApplicationContext(String defaultName,Resource resource,boolean refresh) throws BeansException {
  super(new String[]{},false);
  this.defaultName=defaultName;
  this.resource=resource;
  initializeNames(resource);
  if (refresh) {
    refresh();
  }
}
 

Example 38

From project spring-activiti-sandbox, under directory /src/main/java/org/activiti/spring/components/aop/.

Source file: ProcessStartAnnotationBeanPostProcessor.java

  19 
vote

public Object postProcessAfterInitialization(Object bean,String beanName) throws BeansException {
  if (bean instanceof AopInfrastructureBean) {
    return bean;
  }
  Class<?> targetClass=AopUtils.getTargetClass(bean);
  if (AopUtils.canApply(this.advisor,targetClass)) {
    if (bean instanceof Advised) {
      ((Advised)bean).addAdvisor(0,this.advisor);
      return bean;
    }
 else {
      ProxyFactory proxyFactory=new ProxyFactory(bean);
      proxyFactory.copyFrom(this);
      proxyFactory.addAdvisor(this.advisor);
      return proxyFactory.getProxy(this.beanClassLoader);
    }
  }
 else {
    return bean;
  }
}
 

Example 39

From project spring-advanced-marhshallers-and-service-exporters, under directory /obm/src/test/java/org/springframework/util/http/.

Source file: RestIntegrationTestUtils.java

  19 
vote

@Bean public ApplicationContextAware applicationContextExporter(){
  return new ApplicationContextAware(){
    @Override public void setApplicationContext(    ApplicationContext applicationContext) throws BeansException {
      beanFactoryMap.put(AbstractRestServiceConfiguration.this,applicationContext);
    }
  }
;
}
 

Example 40

From project spring-data-commons, under directory /spring-data-commons-core/src/main/java/org/springframework/data/mapping/context/.

Source file: AbstractMappingContext.java

  19 
vote

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  this.applicationContext=applicationContext;
  if (this.applicationEventPublisher == null) {
    this.applicationEventPublisher=applicationContext;
  }
}
 

Example 41

From project spring-data-keyvalue, under directory /spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/serializer/.

Source file: GenericToStringSerializer.java

  19 
vote

@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  if (converter == null && beanFactory instanceof ConfigurableBeanFactory) {
    ConfigurableBeanFactory cFB=(ConfigurableBeanFactory)beanFactory;
    ConversionService conversionService=cFB.getConversionService();
    converter=(conversionService != null ? new Converter(conversionService) : new Converter(cFB.getTypeConverter()));
  }
}
 

Example 42

From project spring-data-mongodb, under directory /spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/.

Source file: MongoTemplate.java

  19 
vote

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  prepareIndexCreator(applicationContext);
  eventPublisher=applicationContext;
  if (mappingContext instanceof ApplicationEventPublisherAware) {
    ((ApplicationEventPublisherAware)mappingContext).setApplicationEventPublisher(eventPublisher);
  }
  resourceLoader=applicationContext;
}
 

Example 43

From project spring-data-redis, under directory /src/main/java/org/springframework/data/redis/serializer/.

Source file: GenericToStringSerializer.java

  19 
vote

public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  if (converter == null && beanFactory instanceof ConfigurableBeanFactory) {
    ConfigurableBeanFactory cFB=(ConfigurableBeanFactory)beanFactory;
    ConversionService conversionService=cFB.getConversionService();
    converter=(conversionService != null ? new Converter(conversionService) : new Converter(cFB.getTypeConverter()));
  }
}
 

Example 44

From project spring-flex, under directory /spring-flex-core/src/main/java/org/springframework/flex/config/.

Source file: HibernateSerializationConfigPostProcessor.java

  19 
vote

@SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
  if (isHibernateDetected(beanFactory.getBeanClassLoader())) {
    BeanDefinition messageBrokerBeanDef=findMessageBrokerFactoryBeanDefinition(beanFactory);
    Assert.notNull("Could not find an appropriate bean definition for MessageBrokerBeanDefinitionFactoryBean.");
    MutablePropertyValues brokerProps=messageBrokerBeanDef.getPropertyValues();
    ManagedSet<RuntimeBeanReference> configProcessors;
    if (brokerProps.getPropertyValue(CONFIG_PROCESSORS_PROPERTY) != null) {
      configProcessors=(ManagedSet<RuntimeBeanReference>)brokerProps.getPropertyValue(CONFIG_PROCESSORS_PROPERTY).getValue();
    }
 else {
      configProcessors=new ManagedSet<RuntimeBeanReference>();
    }
    if (isAmfConversionServiceProcessorConfigured(beanFactory,configProcessors)) {
      return;
    }
    if (!ClassUtils.isAssignableValue(BeanDefinitionRegistry.class,beanFactory)) {
      if (log.isWarnEnabled()) {
        log.warn("Hibernate AMF serialization support could not be auto-configured because the current BeanFactory does not implement " + "BeanDefinitionRegistry.  In order for this support to be enabled, you must manually configure an instance of " + HIBERNATE_CONFIG_PROCESSOR_CLASS);
      }
    }
    BeanDefinitionRegistry registry=(BeanDefinitionRegistry)beanFactory;
    BeanDefinitionBuilder processorBuilder;
    if (isJpaDetected(beanFactory.getBeanClassLoader())) {
      processorBuilder=BeanDefinitionBuilder.rootBeanDefinition(JPA_HIBERNATE_CONFIG_PROCESSOR_CLASS);
    }
 else {
      processorBuilder=BeanDefinitionBuilder.rootBeanDefinition(HIBERNATE_CONFIG_PROCESSOR_CLASS);
    }
    String processorId=BeanDefinitionReaderUtils.registerWithGeneratedName(processorBuilder.getBeanDefinition(),registry);
    configProcessors.add(new RuntimeBeanReference(processorId));
  }
}
 

Example 45

From project spring-framework-samples, under directory /task-config/src/test/java/test/scratch/.

Source file: CustomConfigurationSample1.java

  19 
vote

@Bean public BeanFactoryPostProcessor test(){
  if (service == null) {
    throw new IllegalStateException("No service injected before BeanFactoryPostProcessor created");
  }
  return new BeanFactoryPostProcessor(){
    @Override public void postProcessBeanFactory(    ConfigurableListableBeanFactory beanFactory) throws BeansException {
      logger.info("Post processing: " + beanFactory);
      if (service == null) {
        throw new IllegalStateException("No service injected before BeanFactoryPostProcessor used");
      }
    }
  }
;
}
 

Example 46

From project spring-gemfire, under directory /src/main/java/org/springframework/data/gemfire/.

Source file: GemfireBeanFactoryLocator.java

  19 
vote

public BeanFactoryReference useBeanFactory(final String factoryKey) throws BeansException {
  BeanFactory factory;
  if (!StringUtils.hasText(factoryKey)) {
    if (!canUseDefaultBeanFactory)     throw new IllegalArgumentException("a non-null factoryKey needs to be specified as there are more then one factoryKeys available; " + beanFactories.keySet());
    factory=defaultFactory;
  }
 else {
    factory=beanFactories.get(factoryKey);
    if (factory == null)     throw new IllegalArgumentException("there is no beanFactory under key " + factoryKey);
  }
  return new SimpleBeanFactoryReference(factory);
}
 

Example 47

From project spring-hadoop, under directory /src/main/java/org/springframework/data/hadoop/fs/.

Source file: ChainedResourceLoader.java

  19 
vote

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  if (fallback == null) {
    fallback=applicationContext;
  }
  if (applicationContext instanceof GenericApplicationContext) {
    ((GenericApplicationContext)applicationContext).setResourceLoader(this);
  }
}
 

Example 48

From project spring-integration-activiti-sandbox, under directory /src/main/java/com/joshlong/activiti/coordinator/aop/.

Source file: ProcessStartAnnotationBeanPostProcessor.java

  19 
vote

public Object postProcessAfterInitialization(Object bean,String beanName) throws BeansException {
  Class<?> targetClass=AopUtils.getTargetClass(bean);
  if (targetClass == null) {
    return bean;
  }
  if (AopUtils.canApply(this.advisor,targetClass)) {
    if (bean instanceof Advised) {
      ((Advised)bean).addAdvisor(this.advisor);
      return bean;
    }
 else {
      ProxyFactory proxyFactory=new ProxyFactory(bean);
      proxyFactory.copyFrom(this);
      proxyFactory.addAdvisor(this.advisor);
      return proxyFactory.getProxy(this.beanClassLoader);
    }
  }
 else {
    return bean;
  }
}
 

Example 49

From project spring-js, under directory /src/main/java/org/springframework/context/access/.

Source file: ContextJndiBeanFactoryLocator.java

  19 
vote

/** 
 * Load/use a bean factory, as specified by a factory key which is a JNDI address, of the form <code>java:comp/env/ejb/BeanFactoryPath</code>. The contents of this JNDI location must be a string containing one or more classpath resource names (separated by any of the delimiters '<code>,; \t\n</code>' if there is more than one. The resulting BeanFactory (or ApplicationContext) will be created from the combined resources.
 * @see #createBeanFactory
 */
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
  try {
    String beanFactoryPath=lookup(factoryKey,String.class);
    if (logger.isTraceEnabled()) {
      logger.trace("Bean factory path from JNDI environment variable [" + factoryKey + "] is: "+ beanFactoryPath);
    }
    String[] paths=StringUtils.tokenizeToStringArray(beanFactoryPath,BEAN_FACTORY_PATH_DELIMITERS);
    return createBeanFactory(paths);
  }
 catch (  NamingException ex) {
    throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing "+ "the class path locations of XML bean definition files",ex);
  }
}
 

Example 50

From project spring-mom, under directory /src/main/java/com/excilys/spring/mom/annotation/.

Source file: MOMAnnotationProcessing.java

  19 
vote

@Override public Object postProcessAfterInitialization(final Object bean,String beanName) throws BeansException {
  final Class<?> clazz=bean.getClass();
  MOMController classAnnotation=clazz.getAnnotation(MOMController.class);
  if (classAnnotation != null) {
    LOGGER.debug("Found @MOMController annotated class : {}",clazz);
    ReflectionUtils.doWithMethods(clazz,new ReflectionUtils.MethodCallback(){
      public void doWith(      Method method) throws IllegalArgumentException, IllegalAccessException {
        MOMMapping methodAnnotation=method.getAnnotation(MOMMapping.class);
        if (methodAnnotation != null) {
          String topic=resolveProperty(methodAnnotation.topic());
          MOMMappingConsum consum=methodAnnotation.consumes();
          LOGGER.debug("Configuring @MOMMapping({}) method {}",consum,method);
          try {
            momClient.subscribe(topic,new MOMMethodHandler(method,bean,consum));
          }
 catch (          NotConnectedException e) {
            LOGGER.error("Can't subscribe to topic {}",topic,e);
          }
catch (          SocketException e) {
            LOGGER.error("Can't subscribe to topic {}",topic,e);
          }
        }
      }
    }
);
  }
  return bean;
}
 

Example 51

From project spring-security, under directory /config/src/main/java/org/springframework/security/config/debug/.

Source file: SecurityDebugBeanFactoryPostProcessor.java

  19 
vote

public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
  Logger.logger.warn("\n\n" + "********************************************************************\n" + "**********        Security debugging is enabled.       *************\n"+ "**********    This may include sensitive information.  *************\n"+ "**********      Do not use in a production system!     *************\n"+ "********************************************************************\n\n");
  if (registry.containsBeanDefinition(BeanIds.FILTER_CHAIN_PROXY)) {
    BeanDefinition fcpBeanDef=registry.getBeanDefinition(BeanIds.FILTER_CHAIN_PROXY);
    BeanDefinitionBuilder debugFilterBldr=BeanDefinitionBuilder.genericBeanDefinition(DebugFilter.class);
    debugFilterBldr.addConstructorArgValue(fcpBeanDef);
    registry.removeAlias(BeanIds.SPRING_SECURITY_FILTER_CHAIN);
    registry.registerBeanDefinition(BeanIds.SPRING_SECURITY_FILTER_CHAIN,debugFilterBldr.getBeanDefinition());
  }
}
 

Example 52

From project spring-security-saml, under directory /saml2-core/src/main/java/org/springframework/security/saml/.

Source file: SAMLBootstrap.java

  19 
vote

/** 
 * Automatically called to initialize whole module. Localizes parserPool from the factory and stores it.
 * @param beanFactory bean factory
 * @throws BeansException errors
 */
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
  try {
    PaosBootstrap.bootstrap();
    ParserPool pool=beanFactory.getBean(ParserPool.class);
    new ParserPoolHolder(pool);
    setMetadataKeyInfoGenerator();
  }
 catch (  ConfigurationException e) {
    throw new BootstrapException("Error invoking OpenSAML bootrap",e);
  }
}
 

Example 53

From project spring-test-mvc, under directory /src/main/java/org/springframework/test/web/server/setup/.

Source file: MockWebApplicationContext.java

  19 
vote

public Object initializeBean(Object existingBean,String beanName) throws BeansException {
  if (existingBean instanceof ApplicationContextAware) {
    ((ApplicationContextAware)existingBean).setApplicationContext(MockWebApplicationContext.this);
  }
  return existingBean;
}
 

Example 54

From project spring-utils, under directory /src/main/java/biz/deinum/springframework/aop/target/registry/impl/.

Source file: BeanFactoryTargetRegistry.java

  19 
vote

/** 
 * Gets the target from the ApplicationContext. The name of the bean is being constructed with the configured <code>prefix</code> and <code>suffix</code>.
 * @return the found object or <code>null</code>
 */
@Override @SuppressWarnings("unchecked") protected T getTargetInternal(final String context){
  final String beanName=this.getTargetName(context);
  T target=null;
  try {
    this.logger.debug("Retrieving bean '{}' from BeanFactory.",beanName);
    target=(T)this.beanFactory.getBean(beanName);
  }
 catch (  final BeansException be) {
    this.logger.warn("Could not retrieve bean '{}'",context,be);
  }
  return target;
}
 

Example 55

From project spring-webflow, under directory /spring-binding/src/main/java/org/springframework/binding/expression/beanwrapper/.

Source file: BeanWrapperExpression.java

  19 
vote

public Object getValue(Object context) throws EvaluationException {
  try {
    BeanWrapperImpl beanWrapper=new BeanWrapperImpl(context);
    return beanWrapper.getPropertyValue(expression);
  }
 catch (  NotReadablePropertyException e) {
    throw new PropertyNotFoundException(context.getClass(),expression,e);
  }
catch (  BeansException e) {
    throw new EvaluationException(context.getClass(),getExpressionString(),"A BeansException occurred getting the value for expression '" + getExpressionString() + "' on context ["+ context.getClass()+ "]",e);
  }
}
 

Example 56

From project springfaces, under directory /springfaces/src/main/java/org/springframework/springfaces/expression/spel/support/.

Source file: StandardEvaluationContextPostProcessorSupport.java

  19 
vote

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
  BeanExpressionResolver beanExpressionResolver=beanFactory.getBeanExpressionResolver();
  if (beanExpressionResolver != null) {
    Assert.state(isReplaceable(beanExpressionResolver),"Unable to replace beanExpressionResolver " + beanExpressionResolver.getClass());
    beanFactory.setBeanExpressionResolver(new PostProcessorAwareStandardBeanExpressionResolver());
  }
}