use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project spring-security by spring-projects.
the class WebTestUtils method getSpringSecurityFilterChain.
private static Filter getSpringSecurityFilterChain(ServletContext servletContext) {
Filter result = (Filter) servletContext.getAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN);
if (result != null) {
return result;
}
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
if (webApplicationContext != null) {
try {
return webApplicationContext.getBean(AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME, Filter.class);
} catch (NoSuchBeanDefinitionException notFound) {
}
}
return null;
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project aries by apache.
the class SpringTest method testSpringBundle.
@Test
public void testSpringBundle() throws Exception {
Bundle bundles = context().getBundleByName("org.apache.aries.blueprint.testbundles");
assertNotNull(bundles);
bundles.start();
BlueprintContainer container = startBundleBlueprint("org.apache.aries.blueprint.testbundles");
List list = (List) container.getComponentInstance("springList");
System.out.println(list);
BeanCItf beanC = (BeanCItf) list.get(4);
assertEquals(1, beanC.getInitialized());
try {
beanC.doSomething();
fail("Should have thrown an exception because the transaction manager is not defined");
} catch (NoSuchBeanDefinitionException e) {
// expected
}
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project cloudstack by apache.
the class UsageEventUtils method publishUsageEvent.
private static void publishUsageEvent(String usageEventType, Long accountId, Long zoneId, String resourceType, String resourceUUID) {
String configKey = "publish.usage.events";
String value = s_configDao.getValue(configKey);
boolean configValue = Boolean.parseBoolean(value);
if (!configValue)
return;
try {
s_eventBus = ComponentContext.getComponent(EventBus.class);
} catch (NoSuchBeanDefinitionException nbe) {
// no provider is configured to provide events bus, so just return
return;
}
Account account = s_accountDao.findById(accountId);
DataCenterVO dc = s_dcDao.findById(zoneId);
// if account has been deleted, this might be called during cleanup of resources and results in null pointer
if (account == null)
return;
// if an invalid zone is passed in, create event without zone UUID
String zoneUuid = null;
if (dc != null)
zoneUuid = dc.getUuid();
Event event = new Event(Name, EventCategory.USAGE_EVENT.getName(), usageEventType, resourceType, resourceUUID);
Map<String, String> eventDescription = new HashMap<String, String>();
eventDescription.put("account", account.getUuid());
eventDescription.put("zone", zoneUuid);
eventDescription.put("event", usageEventType);
eventDescription.put("resource", resourceType);
eventDescription.put("id", resourceUUID);
String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
eventDescription.put("eventDateTime", eventDate);
event.setDescription(eventDescription);
try {
s_eventBus.publish(event);
} catch (EventBusException e) {
s_logger.warn("Failed to publish usage event on the the event bus.");
}
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project cloudstack by apache.
the class ActionEventUtils method publishOnEventBus.
private static void publishOnEventBus(long userId, long accountId, String eventCategory, String eventType, Event.State state, String description) {
String configKey = Config.PublishActionEvent.key();
String value = s_configDao.getValue(configKey);
boolean configValue = Boolean.parseBoolean(value);
if (!configValue)
return;
try {
s_eventBus = ComponentContext.getComponent(EventBus.class);
} catch (NoSuchBeanDefinitionException nbe) {
// no provider is configured to provide events bus, so just return
return;
}
// get the entity details for which ActionEvent is generated
String entityType = null;
String entityUuid = null;
CallContext context = CallContext.current();
//Get entity Class(Example - VirtualMachine.class) from the event Type eg. - VM.CREATE
Class<?> entityClass = EventTypes.getEntityClassForEvent(eventType);
if (entityClass != null) {
//Get uuid from id
Object param = context.getContextParameter(entityClass);
if (param != null) {
try {
entityUuid = getEntityUuid(entityClass, param);
entityType = entityClass.getName();
} catch (Exception e) {
s_logger.debug("Caught exception while finding entityUUID, moving on");
}
}
}
org.apache.cloudstack.framework.events.Event event = new org.apache.cloudstack.framework.events.Event(ManagementService.Name, eventCategory, eventType, EventTypes.getEntityForEvent(eventType), entityUuid);
Map<String, String> eventDescription = new HashMap<String, String>();
Project project = s_projectDao.findByProjectAccountId(accountId);
Account account = s_accountDao.findById(accountId);
User user = s_userDao.findById(userId);
// if account has been deleted, this might be called during cleanup of resources and results in null pointer
if (account == null)
return;
if (user == null)
return;
if (project != null)
eventDescription.put("project", project.getUuid());
eventDescription.put("user", user.getUuid());
eventDescription.put("account", account.getUuid());
eventDescription.put("event", eventType);
eventDescription.put("status", state.toString());
eventDescription.put("entity", entityType);
eventDescription.put("entityuuid", entityUuid);
//Put all the first class entities that are touched during the action. For now atleast put in the vmid.
populateFirstClassEntities(eventDescription);
eventDescription.put("description", description);
String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
eventDescription.put("eventDateTime", eventDate);
event.setDescription(eventDescription);
try {
s_eventBus.publish(event);
} catch (EventBusException e) {
s_logger.warn("Failed to publish action event on the the event bus.");
}
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project cloudstack by apache.
the class UserVmStateListener method pubishOnEventBus.
private void pubishOnEventBus(String event, String status, VirtualMachine vo, VirtualMachine.State oldState, VirtualMachine.State newState) {
String configKey = Config.PublishResourceStateEvent.key();
String value = _configDao.getValue(configKey);
boolean configValue = Boolean.parseBoolean(value);
if (!configValue)
return;
try {
s_eventBus = ComponentContext.getComponent(EventBus.class);
} catch (NoSuchBeanDefinitionException nbe) {
// no provider is configured to provide events bus, so just return
return;
}
String resourceName = getEntityFromClassName(VirtualMachine.class.getName());
org.apache.cloudstack.framework.events.Event eventMsg = new org.apache.cloudstack.framework.events.Event(ManagementService.Name, EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid());
Map<String, String> eventDescription = new HashMap<String, String>();
eventDescription.put("resource", resourceName);
eventDescription.put("id", vo.getUuid());
eventDescription.put("old-state", oldState.name());
eventDescription.put("new-state", newState.name());
eventDescription.put("status", status);
String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
eventDescription.put("eventDateTime", eventDate);
eventMsg.setDescription(eventDescription);
try {
s_eventBus.publish(eventMsg);
} catch (org.apache.cloudstack.framework.events.EventBusException e) {
s_logger.warn("Failed to publish state change event on the the event bus.");
}
}
Aggregations