Search in sources :

Example 41 with PostConstruct

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();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PostConstruct(javax.annotation.PostConstruct)

Example 42 with PostConstruct

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);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ChannelTreeContentProvider(alma.acs.eventbrowser.parts.ChannelTreeProviders.ChannelTreeContentProvider) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ChannelTreeLabelProvider(alma.acs.eventbrowser.parts.ChannelTreeProviders.ChannelTreeLabelProvider) PostConstruct(javax.annotation.PostConstruct)

Example 43 with PostConstruct

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();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Table(org.eclipse.swt.widgets.Table) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) StatusLineWriter(alma.acs.eventbrowser.status.StatusLineWriter) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PostConstruct(javax.annotation.PostConstruct)

Example 44 with PostConstruct

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();
}
Also used : EmbeddedAgent(org.apache.flume.agent.embedded.EmbeddedAgent) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PostConstruct(javax.annotation.PostConstruct)

Example 45 with PostConstruct

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));
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurationListener(org.apache.commons.configuration.event.ConfigurationListener) ConfigurationEvent(org.apache.commons.configuration.event.ConfigurationEvent) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)248 IOException (java.io.IOException)28 File (java.io.File)18 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)17 Map (java.util.Map)15 ArrayList (java.util.ArrayList)12 ExternalResource (com.vaadin.server.ExternalResource)11 HashMap (java.util.HashMap)10 InitialContext (javax.naming.InitialContext)9 Label (com.vaadin.ui.Label)8 VerticalLayout (com.vaadin.ui.VerticalLayout)8 Request (com.nabalive.framework.web.Request)7 Response (com.nabalive.framework.web.Response)7 Route (com.nabalive.framework.web.Route)7 Link (com.vaadin.ui.Link)7 Properties (java.util.Properties)7 Method (java.lang.reflect.Method)5 InputStream (java.io.InputStream)4 URISyntaxException (java.net.URISyntaxException)4 Path (java.nio.file.Path)4