View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * All rights reserved. Check the documentation for licensing terms.
5    * https://caribou.iisg.agh.edu.pl/trac/cast
6    */
7   package pl.edu.agh.cast.schema;
8   
9   import org.apache.log4j.ConsoleAppender;
10  import org.apache.log4j.Logger;
11  import org.apache.log4j.PatternLayout;
12  import org.eclipse.core.runtime.Plugin;
13  import org.osgi.framework.BundleContext;
14  
15  /**
16   * The activator class controls the plug-in life cycle.
17   *
18   * @author AGH CAST Team
19   */
20  public class Activator extends Plugin {
21  
22      // The plug-in ID
23      public static final String PLUGIN_ID = "pl.edu.agh.cast.schema"; //$NON-NLS-1$
24  
25      // Plugin logger instance
26      private static Logger log;
27  
28      // The shared instance
29      private static Activator plugin;
30  
31      /**
32       * The constructor
33       */
34      public Activator() {
35          plugin = this;
36      }
37  
38      /*
39       * (non-Javadoc)
40       *
41       * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
42       */
43      public void start(BundleContext context) throws Exception {
44          super.start(context);
45      }
46  
47      /*
48       * (non-Javadoc)
49       *
50       * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
51       */
52      public void stop(BundleContext context) throws Exception {
53          plugin = null;
54          super.stop(context);
55      }
56  
57      /**
58       * Returns the shared instance
59       *
60       * @return the shared instance
61       */
62      public static Activator getDefault() {
63          return plugin;
64      }
65  
66      public static Logger getLogger() {
67          if (log == null) {
68              log = Logger.getLogger(Activator.class);
69              if (!log.getAllAppenders().hasMoreElements()) {
70                  // add default console appender
71                  log.addAppender(new ConsoleAppender(new PatternLayout("%5p [%t] (%F:%L) - %m%n"))); //$NON-NLS-1$
72              }
73          }
74          return log;
75      }
76  
77  }