use of javax.annotation.PostConstruct in project ACS by ACS-Community.
the class ArchivingListPart method postConstruct.
@PostConstruct
public void postConstruct(Composite parent, IEventBroker eventBroker) {
try {
em = EventModel.getInstance();
} catch (Throwable thr) {
thr.printStackTrace();
IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
statusReporter.report(someStatus, StatusReporter.SHOW);
throw new RuntimeException(thr);
}
logger = em.getLogger();
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
gridLayout.verticalSpacing = 0;
parent.setLayout(gridLayout);
// buildCustomToolBar(parent);
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
/*
* "Time "+timeStamp+" "+m_channelName+" "+component+" "+count+"
* "+channelEventCount+" " +" "+evtTypeName+"
* "+evtCounter.get(evtTypeName)
*/
TableViewerColumn tvcol = new TableViewerColumn(viewer, SWT.NONE, 0);
tvcol.setLabelProvider(new TimeStampLabelProvider());
TableColumn col = tvcol.getColumn();
col.setText("Timestamp");
col.setWidth(190);
col.setAlignment(SWT.LEFT);
tvcol = new TableViewerColumn(viewer, SWT.NONE, 1);
tvcol.setLabelProvider(new EventSourceLabelProvider());
col = tvcol.getColumn();
col.setText("Device");
col.setWidth(100);
col.setAlignment(SWT.LEFT);
tvcol = new TableViewerColumn(viewer, SWT.NONE, 2);
tvcol.setLabelProvider(new BaciParameterLabelProvider());
col = tvcol.getColumn();
col.setText("Property");
col.setWidth(100);
col.setAlignment(SWT.LEFT);
tvcol = new TableViewerColumn(viewer, SWT.NONE, 3);
tvcol.setLabelProvider(new BaciPropertyValueLabelProvider());
col = tvcol.getColumn();
col.setText("Value");
col.setWidth(100);
col.setAlignment(SWT.LEFT);
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTable());
viewer.setContentProvider(new ArchivingListContentProvider(em));
viewer.setInput(new Object());
pel = new PopulateEventList(logger, viewer, new StatusLineWriter(eventBroker), em.getArchQueue(), "Monitor points");
eventListThread = pel.getThreadForEventList();
eventListThread.start();
}
use of javax.annotation.PostConstruct in project ACS by ACS-Community.
the class ChannelTreePart method postConstruct.
/**
* See http://www.vogella.com/articles/EclipseJFaceTree/article.html
*/
@PostConstruct
public void postConstruct(Composite parent, final IEclipseContext context, EMenuService menuService, IEventBroker eventBroker) {
try {
eventModel = EventModel.getInstance();
} catch (Throwable thr) {
thr.printStackTrace();
IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
statusReporter.report(someStatus, StatusReporter.SHOW);
throw new RuntimeException(thr);
}
// eventModel.getLogger().info("ChannelTreePart got EventModel instance.");
statusLineWriter = new StatusLineWriter(eventBroker);
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ChannelTreeContentProvider());
viewer.setLabelProvider(new ChannelTreeLabelProvider());
// Expand the tree. '2' means to show only the visible top-level nodes.
viewer.setAutoExpandLevel(2);
viewer.setComparator(new ServiceViewerComparator());
// Provide the root node to the ContentProvider
viewer.setInput(eventModel.getNotifyServicesRoot());
// Expand with doubleclick
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();
Object selectedNode = thisSelection.getFirstElement();
viewer.setExpandedState(selectedNode, !viewer.getExpandedState(selectedNode));
}
});
// Attach a selection listener to our tree that will post selections to the ESelectionService
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
selectionService.setSelection(selection.size() == 1 ? selection.getFirstElement() : selection.toArray());
}
});
// TODO: Take care of help system. Here's the E3 code:
// // Create the help context id for the viewer's control
// PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "alma.acs.eventbrowser.viewer");
hookContextMenu(menuService);
// TODO: this could be used by handlers etc, currently it's not
context.set(ChannelTreePart.class, this);
}
use of javax.annotation.PostConstruct in project ACS by ACS-Community.
the class EventListPart method postConstruct.
/**
*/
@PostConstruct
public void postConstruct(Composite parent, final IEclipseContext context, IEventBroker eventBroker, EMenuService menuService) {
try {
em = EventModel.getInstance();
} catch (Throwable thr) {
thr.printStackTrace();
IStatus someStatus = statusReporter.newStatus(IStatus.ERROR, "Connection with NCs failed.", thr);
statusReporter.report(someStatus, StatusReporter.SHOW);
throw new RuntimeException(thr);
}
logger = em.getLogger();
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
gridLayout.verticalSpacing = 0;
parent.setLayout(gridLayout);
// TODO: We currently have the filter text control in the regular view toolbar.
// The e3 eventGUI had a "custom tool bar" inserted here.
// We should decide which way it's better.
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
/*
* "Time "+timeStamp+" "+m_channelName+" "+component+" "+count+"
* "+channelEventCount+" " +" "+evtTypeName+"
* "+evtCounter.get(evtTypeName)
*/
TableViewerColumn tvcol = new TableViewerColumn(viewer, SWT.NONE, 0);
tvcol.setLabelProvider(new TimeStampLabelProvider());
TableColumn col = tvcol.getColumn();
col.setText("Timestamp");
col.setWidth(180);
col.setAlignment(SWT.LEFT);
tvcol = new TableViewerColumn(viewer, SWT.NONE, 1);
tvcol.setLabelProvider(new EventSourceLabelProvider());
col = tvcol.getColumn();
col.setText("Event source");
col.setWidth(150);
col.setAlignment(SWT.LEFT);
tvcol = new TableViewerColumn(viewer, SWT.NONE, 2);
tvcol.setLabelProvider(new CountLabelProvider());
col = tvcol.getColumn();
col.setText("# Events in channel");
col.setWidth(50);
col.setAlignment(SWT.LEFT);
tvcol = new TableViewerColumn(viewer, SWT.NONE, 3);
tvcol.setLabelProvider(new EventTypeLabelProvider());
col = tvcol.getColumn();
col.setText("Event type");
col.setWidth(150);
col.setAlignment(SWT.LEFT);
tvcol = new TableViewerColumn(viewer, SWT.NONE, 4);
tvcol.setLabelProvider(new EventTypeCountLabelProvider());
col = tvcol.getColumn();
col.setText("# Events this type");
col.setWidth(50);
col.setAlignment(SWT.LEFT);
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getTable());
viewer.setContentProvider(new EventListViewContentProvider(em));
// Attach a selection listener to our event list that will post the selected event for the event details list
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() == 1) {
selectionService.setSelection(selection.getFirstElement());
}
}
});
viewer.setInput(new Object());
hookContextMenu(menuService);
pel = new PopulateEventList(logger, viewer, new StatusLineWriter(eventBroker), em.getEventQueue(), "NC Events");
eventListThread = pel.getThreadForEventList();
eventListThread.start();
}
use of javax.annotation.PostConstruct in project chassis by Kixeye.
the class FlumeLoggerLoader method initialize.
@PostConstruct
public void initialize() {
multicaster.addApplicationListener(loggingListener);
ConcurrentHashMap<String, String> flumeConfig = new ConcurrentHashMap<>();
List<String> sinks = new ArrayList<>();
for (String server : servers) {
String sinkName = server.replace(":", "-").replace(".", "_");
String[] servers = server.split(":", 2);
if (servers.length == 2) {
flumeConfig.put(sinkName + ".type", "avro");
flumeConfig.put(sinkName + ".channels", "channel-" + name);
flumeConfig.put(sinkName + ".hostname", servers[0]);
flumeConfig.put(sinkName + ".port", servers[1]);
} else {
logger.error("Invalid server format [{}], should be [hostname:port]", server);
}
sinks.add(sinkName);
}
// force some properties
flumeConfig.put("channel.type", "file");
flumeConfig.put("sinks", StringUtils.collectionToDelimitedString(sinks, " "));
flumeConfig.putIfAbsent("processor.type", serversUsage);
flumeConfig.put("channel.checkpointDir", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/checkpoint"));
flumeConfig.put("channel.dataDirs", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/data"));
agent = new EmbeddedAgent(name);
agent.configure(flumeConfig);
agent.start();
appender = new FlumeLogAppender(agent, serviceName);
installFlumeAppender();
}
use of javax.annotation.PostConstruct in project chassis by Kixeye.
the class LoggingConfiguration method initialize.
@PostConstruct
public void initialize() {
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
if (config.containsKey(LOGBACK_CONFIG_NAME)) {
System.out.println("Loading logging config.");
reloadLogging(config.getString(LOGBACK_CONFIG_NAME));
}
config.addConfigurationListener(new ConfigurationListener() {
@Override
public synchronized void configurationChanged(ConfigurationEvent event) {
if ((event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY || event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY) && StringUtils.equalsIgnoreCase(LOGBACK_CONFIG_NAME, event.getPropertyName()) && event.getPropertyValue() != null && !event.isBeforeUpdate()) {
System.out.println("Reloading logging config.");
reloadLogging((String) event.getPropertyValue());
}
}
});
ConfigurationListener flumeConfigListener = new ConfigurationListener() {
private FlumeLoggerLoader loggerLoader = null;
public synchronized void configurationChanged(ConfigurationEvent event) {
if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY || event.getType() == AbstractConfiguration.EVENT_CLEAR_PROPERTY)) {
return;
}
if (FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY.equals(event.getPropertyName())) {
if ("true".equals(event.getPropertyValue())) {
if (loggerLoader == null) {
// construct the bean
loggerLoader = (FlumeLoggerLoader) applicationContext.getBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, "chassis");
}
// else we already have one so we're cool
} else {
if (loggerLoader != null) {
// delete the bean
ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) applicationContext.getParentBeanFactory();
beanFactory.destroyBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, loggerLoader);
loggerLoader = null;
}
// else we don't have any so we're cool
}
} else if (FlumeLoggerLoader.RELOAD_PROPERTIES.contains(event.getPropertyValue())) {
// only reload if we're already running - otherwise ignore
if (loggerLoader != null) {
// delete the bean
ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) applicationContext.getParentBeanFactory();
beanFactory.destroyBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, loggerLoader);
loggerLoader = null;
// construct the bean
loggerLoader = (FlumeLoggerLoader) applicationContext.getBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, "chassis");
}
// else we don't have any so we're cool
}
}
};
config.addConfigurationListener(flumeConfigListener);
flumeConfigListener.configurationChanged(new ConfigurationEvent(this, AbstractConfiguration.EVENT_SET_PROPERTY, FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY, config.getProperty(FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY), false));
}
Aggregations