|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2011 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 10-19
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.equinox.metatype; |
11 |
package org.eclipse.equinox.metatype; |
| 12 |
|
12 |
|
| 13 |
import java.io.IOException; |
13 |
import java.security.AccessController; |
| 14 |
import java.security.*; |
14 |
import java.security.PrivilegedExceptionAction; |
| 15 |
import java.util.Hashtable; |
15 |
import java.util.Hashtable; |
| 16 |
import javax.xml.parsers.SAXParserFactory; |
16 |
import javax.xml.parsers.SAXParserFactory; |
|
|
17 |
import org.eclipse.osgi.util.NLS; |
| 17 |
import org.osgi.framework.*; |
18 |
import org.osgi.framework.*; |
| 18 |
import org.osgi.service.log.LogService; |
19 |
import org.osgi.service.log.LogService; |
| 19 |
import org.osgi.service.metatype.MetaTypeInformation; |
20 |
import org.osgi.service.metatype.MetaTypeInformation; |
|
Lines 46-78
Link Here
|
| 46 |
* @see org.osgi.service.metatype.MetaTypeService#getMetaTypeInformation(org.osgi.framework.Bundle) |
47 |
* @see org.osgi.service.metatype.MetaTypeService#getMetaTypeInformation(org.osgi.framework.Bundle) |
| 47 |
*/ |
48 |
*/ |
| 48 |
public MetaTypeInformation getMetaTypeInformation(Bundle bundle) { |
49 |
public MetaTypeInformation getMetaTypeInformation(Bundle bundle) { |
| 49 |
|
50 |
return getMetaTypeProvider(bundle); |
| 50 |
MetaTypeInformation mti; |
|
|
| 51 |
try { |
| 52 |
mti = getMetaTypeProvider(bundle); |
| 53 |
} catch (IOException e) { |
| 54 |
logger.log(LogService.LOG_ERROR, "IOException in MetaTypeInformation:getMetaTypeInformation(Bundle bundle)"); //$NON-NLS-1$ |
| 55 |
e.printStackTrace(); |
| 56 |
mti = null; |
| 57 |
} |
| 58 |
return mti; |
| 59 |
} |
51 |
} |
| 60 |
|
52 |
|
| 61 |
/** |
53 |
/** |
| 62 |
* Internal Method - to get MetaTypeProvider object. |
54 |
* Internal Method - to get MetaTypeProvider object. |
| 63 |
*/ |
55 |
*/ |
| 64 |
private MetaTypeInformation getMetaTypeProvider(final Bundle b) throws java.io.IOException { |
56 |
private MetaTypeInformation getMetaTypeProvider(final Bundle b) { |
| 65 |
|
57 |
final LogService loggerTemp = this.logger; |
|
|
58 |
final ServiceTracker<Object, Object> tracker = this.metaTypeProviderTracker; |
| 66 |
try { |
59 |
try { |
| 67 |
Long bID = new Long(b.getBundleId()); |
60 |
Long bID = new Long(b.getBundleId()); |
| 68 |
synchronized (_mtps) { |
61 |
synchronized (_mtps) { |
| 69 |
if (_mtps.containsKey(bID)) |
62 |
if (_mtps.containsKey(bID)) |
| 70 |
return _mtps.get(bID); |
63 |
return _mtps.get(bID); |
| 71 |
// Avoid synthetic accessor method warnings. |
64 |
// Avoid synthetic accessor method warnings. |
| 72 |
final LogService loggerTemp = this.logger; |
65 |
|
| 73 |
final ServiceTracker<Object, Object> tracker = this.metaTypeProviderTracker; |
|
|
| 74 |
MetaTypeInformation mti = AccessController.doPrivileged(new PrivilegedExceptionAction<MetaTypeInformation>() { |
66 |
MetaTypeInformation mti = AccessController.doPrivileged(new PrivilegedExceptionAction<MetaTypeInformation>() { |
| 75 |
public MetaTypeInformation run() throws IOException { |
67 |
public MetaTypeInformation run() { |
| 76 |
MetaTypeInformationImpl impl = new MetaTypeInformationImpl(b, _parserFactory, loggerTemp); |
68 |
MetaTypeInformationImpl impl = new MetaTypeInformationImpl(b, _parserFactory, loggerTemp); |
| 77 |
if (!impl._isThereMeta) |
69 |
if (!impl._isThereMeta) |
| 78 |
return new MetaTypeProviderTracker(b, loggerTemp, tracker); |
70 |
return new MetaTypeProviderTracker(b, loggerTemp, tracker); |
|
Lines 82-89
Link Here
|
| 82 |
_mtps.put(bID, mti); |
74 |
_mtps.put(bID, mti); |
| 83 |
return mti; |
75 |
return mti; |
| 84 |
} |
76 |
} |
| 85 |
} catch (PrivilegedActionException pae) { |
77 |
} catch (Exception e) { |
| 86 |
throw (IOException) pae.getException(); |
78 |
logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.EXCEPTION_MESSAGE, e.getMessage()), e); |
|
|
79 |
return new MetaTypeProviderTracker(b, loggerTemp, tracker); |
| 87 |
} |
80 |
} |
| 88 |
} |
81 |
} |
| 89 |
|
82 |
|