OK then, go ahead. But we don't know what other properties we will add to
carbon-context.properties, and most probably we will not add any other
properties in the future.

On Wed, Oct 29, 2014 at 4:57 AM, Sameera Jayasoma <[email protected]> wrote:

> Hi Azeez,
>
> We've been using this pattern in the kernel. e.g. launch.ini. Shall we use
> property file names like following.
>
> *carbon-context.properties *(at moment this file contains only one
> property)
> *axis2-configuration-context.properties* (This file will be added in the
> future and it will contain properties which will get copied from
> super-tenant to tenant configuration context etc.)
>
>
>
>
> ------------------- launch.ini -------------------------
>
> # Eclipse Runtime Configuration Overrides
> # These properties are loaded prior to starting the framework and can also
> be used to override System Properties
> # @null is a special value used to override and clear the framework's copy
> of a System Property prior to starting the framework
> # "*" can be used together with @null to clear System Properties that
> match a prefix name.
>
> osgi.*=@null
> org.osgi.*=@null
> eclipse.*=@null
>
> osgi.parentClassloader=app
> osgi.contextClassLoaderParent=app
>
> # When osgi.clean is set to "true", any cached data used by the OSGi
> framework
> # will be wiped clean. This will clean the caches used to store bundle
>
> # dependency resolution and eclipse extension registry data. Using this
>
> # option will force OSGi framework to reinitialize these caches.
> # The following setting is put in place to get rid of the problems
> # faced when re-starting the system. Please note that, when this setting
> is
> # true, if you manually start a bundle, it would not be available when
> # you re-start the system. To avid this, copy the bundle jar to the
> plugins
> # folder, before you re-start the system.
>
> osgi.clean=true
>
> # Uncomment the following line to turn on Eclipse Equinox debugging.
> # You may also edit the osgi-debug.options file and fine tune the
> debugging
> # options to suite your needs.
> #osgi.debug=./repository/conf/osgi-debug.options
>
> # Following system property allows us to control the public JDK packages
> exported through the system bundle.
>
>
> org.osgi.framework.system.packages=javax.accessibility,\
> javax.activity,\
> javax.crypto,\
> javax.crypto.interfaces,\
> javax.crypto.spec,\
> javax.imageio,\
> javax.imageio.event,\
> javax.imageio.metadata,\
> javax.imageio.plugins.bmp,\
>
>
> On Wed, Oct 29, 2014 at 1:55 PM, Afkham Azeez <[email protected]> wrote:
>
>> A property file with a single property? Why have a property file in the
>> first place?
>>
>> On Wed, Oct 29, 2014 at 1:16 AM, Nipuni Perera <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> @Azeez
>>> I have updated the getOSGiService(Class clazz) method to
>>> getOSGiService(Class clazz, Hashtable<String, String> props) so that we can
>>> pass properties when access to osgi services registered under a specific
>>> interface and matching a given filter. I have updated the name of the file
>>> to carboncontext-osgi-services.properties.
>>> I have used following syntax for the
>>> carboncontext-osgi-services.properties file,
>>>
>>> allowed.osgi.services=\
>>>     org.wso2.carbon.user.core.service.RealmService.class,\
>>>     org.wso2.carbon.utils.ConfigurationContextService,\
>>>     ...
>>>
>>> Thus I have used
>>>  allowedOSGiServices =
>>> Arrays.asList(properties.get(CarbonConstants.OSGI_SERVICE_LIST).toString().split(","));
>>>
>>> I will keep the 2 methods in PCC and add above methods to CC. We wanted
>>> to improve above methods to use filters to access osgi services. I will
>>> update the fix with your suggestions.
>>>
>>> Thanks,
>>> Nipuni
>>>
>>> On Wed, Oct 29, 2014 at 1:20 PM, Afkham Azeez <[email protected]> wrote:
>>>
>>>>
>>>> On Wed, Oct 29, 2014 at 12:41 AM, Afkham Azeez <[email protected]> wrote:
>>>>
>>>>> Here you go. This is the implementation we require. I have not tested
>>>>> this but the logic flow should be correct.
>>>>>
>>>>>
>>>>>     /**
>>>>>      * Obtain the first OSGi service found for interface or class
>>>>> <code>clazz</code>
>>>>>      * @param clazz The type of the OSGi service
>>>>>      * @return The OSGi service
>>>>>      */
>>>>>     public Object getOSGiService(Class clazz) {
>>>>>         if(!allowedOSGiServices.contains(clazz.getName())) {
>>>>>             throw new SecurityException("OSGi service " + clazz + "
>>>>> cannot be accessed via CarbonContext");
>>>>>         }
>>>>>         BundleContext bundleContext = dataHolder.getBundleContext();
>>>>>         ServiceTracker serviceTracker = new
>>>>> ServiceTracker(bundleContext, clazz, null);
>>>>>         try {
>>>>>             serviceTracker.open();
>>>>>             return serviceTracker.getServices()[0];
>>>>>         } finally {
>>>>>             serviceTracker.close();
>>>>>         }
>>>>>     }
>>>>>
>>>>>     private static List<String> allowedOSGiServices = new
>>>>> ArrayList<String>();
>>>>>
>>>>>     static {
>>>>>         FileInputStream fileInputStream = null;
>>>>>         String osgiServicesFilename =
>>>>> CarbonUtils.getEtcCarbonConfigDirPath() + File.separator +
>>>>>                 "carboncontext-osgi-services.properties";
>>>>>         try {
>>>>>             Properties osgiServices = new Properties();
>>>>>             if(new File(osgiServicesFilename).exists()) { // this file
>>>>> is an optional file
>>>>>                 fileInputStream = new
>>>>> FileInputStream(osgiServicesFilename);
>>>>>                 osgiServices.load(fileInputStream);
>>>>>                 Set<String> propNames =
>>>>> osgiServices.stringPropertyNames();
>>>>>                 for (String propName : propNames) {
>>>>>                     allowedOSGiServices.add(propName);
>>>>>
>>>>
>>>> Oops... bug here... here is the correct code:
>>>>
>>>> allowedOSGiServices.add(osgiServices.getProperty(propName));
>>>>
>>>>
>>>>>                 }
>>>>>             }
>>>>>         } catch (IOException e) {
>>>>>             log.fatal("Cannot load " + osgiServicesFilename, e);
>>>>>         } finally {
>>>>>             if(fileInputStream != null){
>>>>>                 try {
>>>>>                     fileInputStream.close();
>>>>>                 } catch (IOException e) {
>>>>>                     log.warn("Could not close FileInputStream of file
>>>>> " + osgiServicesFilename, e);
>>>>>                 }
>>>>>             }
>>>>>         }
>>>>>     }
>>>>>
>>>>>     /**
>>>>>      * Obtain the OSGi services found for interface or class
>>>>> <code>clazz</code>
>>>>>      * @param clazz The type of the OSGi service
>>>>>      * @return The List of OSGi services
>>>>>      */
>>>>>     public List<Object> getOSGiServices(Class clazz) {
>>>>>         if(!allowedOSGiServices.contains(clazz.getName())) {
>>>>>             throw new SecurityException("OSGi service " + clazz + "
>>>>> cannot be accessed via CarbonContext");
>>>>>         }
>>>>>         BundleContext bundleContext = dataHolder.getBundleContext();
>>>>>         ServiceTracker serviceTracker = new
>>>>> ServiceTracker(bundleContext, clazz, null);
>>>>>         List<Object> services = new ArrayList<Object>();
>>>>>         try {
>>>>>             serviceTracker.open();
>>>>>             Collections.addAll(services, serviceTracker.getServices());
>>>>>         } finally {
>>>>>             serviceTracker.close();
>>>>>         }
>>>>>         return services;
>>>>>     }
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Afkham Azeez*
>>>> Director of Architecture; WSO2, Inc.; http://wso2.com
>>>> Member; Apache Software Foundation; http://www.apache.org/
>>>> * <http://www.apache.org/>*
>>>> *email: **[email protected]* <[email protected]>
>>>> * cell: +94 77 3320919 <%2B94%2077%203320919>blog: *
>>>> *http://blog.afkham.org* <http://blog.afkham.org>
>>>> *twitter: **http://twitter.com/afkham_azeez*
>>>> <http://twitter.com/afkham_azeez>
>>>> *linked-in: **http://lk.linkedin.com/in/afkhamazeez
>>>> <http://lk.linkedin.com/in/afkhamazeez>*
>>>>
>>>> *Lean . Enterprise . Middleware*
>>>>
>>>
>>>
>>>
>>> --
>>> Nipuni Perera
>>> Software Engineer; WSO2 Inc.; http://wso2.com
>>> Email: [email protected]
>>> Git hub profile: https://github.com/nipuni
>>> Mobile: +94 (71) 5626680
>>> <http://wso2.com>
>>>
>>>
>>
>>
>> --
>> *Afkham Azeez*
>> Director of Architecture; WSO2, Inc.; http://wso2.com
>> Member; Apache Software Foundation; http://www.apache.org/
>> * <http://www.apache.org/>*
>> *email: **[email protected]* <[email protected]>
>> * cell: +94 77 3320919 <%2B94%2077%203320919>blog: *
>> *http://blog.afkham.org* <http://blog.afkham.org>
>> *twitter: **http://twitter.com/afkham_azeez*
>> <http://twitter.com/afkham_azeez>
>> *linked-in: **http://lk.linkedin.com/in/afkhamazeez
>> <http://lk.linkedin.com/in/afkhamazeez>*
>>
>> *Lean . Enterprise . Middleware*
>>
>
>
>
> --
> Sameera Jayasoma,
> Software Architect,
>
> WSO2, Inc. (http://wso2.com)
> email: [email protected]
> blog: http://sameera.adahas.org
> twitter: https://twitter.com/sameerajayasoma
> flickr: http://www.flickr.com/photos/sameera-jayasoma/collections
> Mobile: 0094776364456
>
> Lean . Enterprise . Middleware
>
>


-- 
*Afkham Azeez*
Director of Architecture; WSO2, Inc.; http://wso2.com
Member; Apache Software Foundation; http://www.apache.org/
* <http://www.apache.org/>*
*email: **[email protected]* <[email protected]>
* cell: +94 77 3320919blog: **http://blog.afkham.org*
<http://blog.afkham.org>
*twitter: **http://twitter.com/afkham_azeez*
<http://twitter.com/afkham_azeez>
*linked-in: **http://lk.linkedin.com/in/afkhamazeez
<http://lk.linkedin.com/in/afkhamazeez>*

*Lean . Enterprise . Middleware*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to