View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: Activator.java
13   * Created: 2007-11-22
14   * Author: apohllo
15   * $Id: Activator.java 2256 2009-01-07 16:23:10Z bmilos $
16   */
17  
18  package pl.edu.agh.cast.data;
19  
20  import org.apache.log4j.ConsoleAppender;
21  import org.apache.log4j.Level;
22  import org.apache.log4j.Logger;
23  import org.apache.log4j.PatternLayout;
24  import org.eclipse.core.runtime.Plugin;
25  import org.osgi.framework.BundleContext;
26  
27  /**
28   * The activator class controls the data plug-in life cycle.
29   *
30   * @author AGH CAST Team
31   */
32  public class Activator extends Plugin {
33  
34  	private static final String ID = "id"; //$NON-NLS-1$
35  
36  	private static final String NAME = "name"; //$NON-NLS-1$
37  
38  	private static final String DESCRIPTION = "description"; //$NON-NLS-1$
39  
40  	private static final String POINT = "point"; //$NON-NLS-1$
41  
42  	/**
43  	 * Data plug-in identifier.
44  	 */
45  	public static final String PLUGIN_ID = "pl.edu.agh.cast.data"; //$NON-NLS-1$
46  
47  	/**
48  	 * Data importer extension point identifier.
49  	 */
50  	public static final String DATA_IMPORTER_EXTENSION_ID = "pl.edu.agh.cast.importer.data"; //$NON-NLS-1$
51  
52  	/**
53  	 * Data preprocessor extension point identifier.
54  	 */
55  	public static final String DATA_PREPROCESSOR_EXTENSION_ID = "pl.edu.agh.cast.importer.preprocessing"; //$NON-NLS-1$
56  
57  	/**
58  	 * Data importer name identifier.
59  	 */
60  	public static final String DATA_IMPORTER_NAME = NAME;
61  
62  	/**
63  	 * Data importer ID identifier.
64  	 */
65  	public static final String DATA_IMPORTER_ID = ID;
66  
67  	/**
68  	 * Data importer description identifier.
69  	 */
70  	public static final String DATA_IMPORTER_DESCRIPTION = DESCRIPTION;
71  
72  	/**
73  	 * Data importer class identifier.
74  	 */
75  	public static final String DATA_IMPORTER_CLASS = POINT;
76  
77  	/**
78  	 * Data importer identifier.
79  	 */
80  	public static final String DATA_IMPORTER = "dataimporter"; //$NON-NLS-1$
81  
82  	/**
83  	 * Data preprocessor name identifier.
84  	 */
85  	public static final String DATA_PREPROCESSOR_NAME = NAME;
86  
87  	/**
88  	 * Data preprocessor ID identifier.
89  	 */
90  	public static final String DATA_PREPROCESSOR_ID = ID;
91  
92  	/**
93  	 * Data preprocessor class identifier.
94  	 */
95  	public static final String DATA_PREPROCESSOR_CLASS = POINT;
96  
97  	/**
98  	 * Data preprocessor description identifier.
99  	 */
100 	public static final String DATA_PREPROCESSOR_DESC = DESCRIPTION;
101 
102 	// The shared instance
103 	private static Activator plugin;
104 
105 	private static Logger log;
106 
107 	/**
108 	 * The constructor.
109 	 */
110 	public Activator() {
111 		plugin = this;
112 	}
113 
114 	/**
115 	 * Returns the shared logger of the data view plug-in.
116 	 *
117 	 * @return the shared logger
118 	 */
119 	public static Logger getLogger() {
120 		if (log == null) {
121 			log = Logger.getLogger(Activator.class);
122 			if (!log.getAllAppenders().hasMoreElements()) {
123 				// add default console appender
124 				log.addAppender(new ConsoleAppender(new PatternLayout("%c: %5p [%t] (%F:%L) - %m%n "))); //$NON-NLS-1$
125 				log.setLevel(Level.INFO);
126 			}
127 		}
128 		return log;
129 	}
130 
131 	/**
132 	 * Returns the shared instance.
133 	 *
134 	 * @return the shared instance
135 	 */
136 	public static Activator getDefault() {
137 		return plugin;
138 	}
139 
140 	/*
141 	 * --------------------------------------------------------------------------------------
142 	 * --------------------------OVERRIDED METHODS----------------------------------
143 	 * --------------------------------------------------------------------------------------
144 	 */
145 
146 	/**
147 	 * {@inheritDoc}
148 	 *
149 	 * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
150 	 */
151 	@Override
152 	public void start(BundleContext context) throws Exception {
153 		super.start(context);
154 	}
155 
156 	/**
157 	 * {@inheritDoc}
158 	 *
159 	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
160 	 */
161 	@Override
162 	public void stop(BundleContext context) throws Exception {
163 		plugin = null;
164 		super.stop(context);
165 	}
166 }