KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > internal > ClassServiceFactory


1 /*******************************************************************************
2  * Copyright (c) 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * wharley@bea.com - initial API and implementation
10  *
11  *******************************************************************************/

12
13 package org.eclipse.jdt.apt.core.internal;
14
15 import org.eclipse.core.runtime.CoreException;
16
17 class ClassServiceFactory implements IServiceFactory {
18     private final Class JavaDoc<?> _clazz;
19     
20     public ClassServiceFactory(Class JavaDoc<?> clazz) {
21         _clazz = clazz;
22     }
23
24     public Object JavaDoc newInstance() throws CoreException {
25         try {
26             return _clazz.newInstance();
27         } catch (InstantiationException JavaDoc e) {
28             throw new CoreException(AptPlugin.createWarningStatus(e,
29                     "Unable to create instance of annotation processor " + _clazz.getName())); //$NON-NLS-1$
30
} catch (IllegalAccessException JavaDoc e) {
31             throw new CoreException(AptPlugin.createWarningStatus(e,
32                     "Unable to create instance of annotation processor " + _clazz.getName())); //$NON-NLS-1$
33
}
34     }
35     
36     public String JavaDoc toString() {
37         if (_clazz == null) {
38             return "unknown (null)"; //$NON-NLS-1$
39
}
40         else {
41             return _clazz.getName();
42         }
43     }
44 }
Popular Tags