diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2008-11-21 15:26:59 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2008-11-21 15:26:59 +0000 |
commit | a57cecb559519b23dee762a4be00d4ba738fb91b (patch) | |
tree | 072c1ac9c3cb66f7263953a86279f96aa6810ed7 /src/net/java | |
parent | 6cf18aba4a123923e89a5ce17964415e3c075c44 (diff) | |
download | jitsi-a57cecb559519b23dee762a4be00d4ba738fb91b.zip jitsi-a57cecb559519b23dee762a4be00d4ba738fb91b.tar.gz jitsi-a57cecb559519b23dee762a4be00d4ba738fb91b.tar.bz2 |
Eliminates duplication among the ~28 Resources classes.
Diffstat (limited to 'src/net/java')
32 files changed, 156 insertions, 976 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java b/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java index 7859949..25a8204 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/Resources.java @@ -11,19 +11,13 @@ */ package net.java.sip.communicator.impl.protocol.ssh; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; /** - * * @author Shobhit Jindal */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - public static ImageID SSH_LOGO = new ImageID("protocolIconSsh"); /** @@ -45,22 +39,6 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - byte[] image = null; - InputStream inputStream; - try - { - inputStream = - SSHActivator.getResources().getImageInputStream(imageID.getId()); - - image = new byte[inputStream.available()]; - - inputStream.read(image); - } - catch (IOException exc) - { - log.error("Failed to load image:" + imageID.getId(), exc); - } - - return image; + return SSHActivator.getResources().getImageInBytes(imageID.getId()); } } diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java b/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java index 37af1ad..36f8a5d 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/SSHActivator.java @@ -9,7 +9,6 @@ * SSH Suport in SIP Communicator - GSoC' 07 Project * */ - package net.java.sip.communicator.impl.protocol.ssh; import java.util.*; @@ -124,17 +123,8 @@ public class SSHActivator public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = (ResourceManagementService) bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils.getService(bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/impl/systray/Resources.java b/src/net/java/sip/communicator/impl/systray/Resources.java index d92bcd4..baad7cf 100644 --- a/src/net/java/sip/communicator/impl/systray/Resources.java +++ b/src/net/java/sip/communicator/impl/systray/Resources.java @@ -4,21 +4,14 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.impl.systray; -import java.awt.image.*; -import java.io.*; import java.net.*; -import java.util.*; -import javax.imageio.*; import javax.swing.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; -import org.osgi.framework.*; /** * The Messages class manages the access to the internationalization * properties files. @@ -27,8 +20,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -61,24 +52,7 @@ public class Resources */ public static ImageIcon getImage(String imageID) { - BufferedImage image = null; - - InputStream in = - getResources().getImageInputStream(imageID); - - if(in == null) - return null; - - try - { - image = ImageIO.read(in); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return new ImageIcon(image); + return getResources().getImage(imageID); } /** @@ -106,18 +80,9 @@ public class Resources public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = SystrayActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)SystrayActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(SystrayActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/accountinfo/Resources.java b/src/net/java/sip/communicator/plugin/accountinfo/Resources.java index 0ed178e..b72b9b0 100644 --- a/src/net/java/sip/communicator/plugin/accountinfo/Resources.java +++ b/src/net/java/sip/communicator/plugin/accountinfo/Resources.java @@ -4,29 +4,20 @@ * Distributable under LGPL license.
* See terms of license at gnu.org.
*/
-
package net.java.sip.communicator.plugin.accountinfo;
-import java.awt.image.*;
-import java.io.*;
-
-import javax.imageio.*;
import javax.swing.*;
import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-import org.osgi.framework.*;
/**
* The <tt>Resources</tt> class manages the access to the internationalization
* properties files and the image resources used in this plugin.
*
* @author Yana Stamcheva
*/
-public class Resources {
-
- private static Logger log = Logger.getLogger(Resources.class);
-
+public class Resources
+{
private static ResourceManagementService resourcesService;
/**
@@ -46,24 +37,7 @@ public class Resources { */
public static ImageIcon getImage(String imageID)
{
- BufferedImage image = null;
-
- InputStream in =
- getResources().getImageInputStream(imageID);
-
- if(in == null)
- return null;
-
- try
- {
- image = ImageIO.read(in);
- }
- catch (IOException e)
- {
- log.error("Failed to load image:" + imageID, e);
- }
-
- return new ImageIcon(image);
+ return getResources().getImage(imageID);
}
/**
@@ -73,42 +47,15 @@ public class Resources { */
public static byte[] getImageInBytes(String imageID)
{
- InputStream in =
- getResources().getImageInputStream(imageID);
-
- if(in == null)
- return null;
-
- byte[] image = null;
-
- try
- {
- image = new byte[in.available()];
- in.read(image);
- }
- catch (IOException e)
- {
- log.error("Failed to load image:" + imageID, e);
- }
-
- return image;
+ return getResources().getImageInBytes(imageID);
}
public static ResourceManagementService getResources()
{
if (resourcesService == null)
- {
- ServiceReference serviceReference = AccountInfoActivator.bundleContext
- .getServiceReference(ResourceManagementService.class.getName());
-
- if(serviceReference == null)
- return null;
-
- resourcesService =
- (ResourceManagementService)AccountInfoActivator.bundleContext
- .getService(serviceReference);
- }
-
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(AccountInfoActivator.bundleContext);
return resourcesService;
}
}
diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java index 9217b0a..c3bb9b8 100644 --- a/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.aimaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -21,8 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -52,42 +45,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = AimAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)AimAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(AimAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/autoaway/Resources.java b/src/net/java/sip/communicator/plugin/autoaway/Resources.java index be97e3c..0370790 100644 --- a/src/net/java/sip/communicator/plugin/autoaway/Resources.java +++ b/src/net/java/sip/communicator/plugin/autoaway/Resources.java @@ -6,15 +6,8 @@ */
package net.java.sip.communicator.plugin.autoaway;
-import java.io.*;
-import java.awt.image.*;
-import javax.imageio.*;
-import javax.swing.*;
import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-import org.osgi.framework.*;
-
/**
* The Messages class manages the access to the internationalization properties
* files.
@@ -23,8 +16,6 @@ import org.osgi.framework.*; */
public class Resources
{
- private static Logger logger = Logger.getLogger(Resources.class);
-
private static ResourceManagementService resourcesService;
/**
@@ -47,18 +38,9 @@ public class Resources public static ResourceManagementService getResources()
{
if (resourcesService == null)
- {
- ServiceReference serviceReference = AutoAwayActivator.bundleContext
- .getServiceReference(ResourceManagementService.class.getName());
-
- if(serviceReference == null)
- return null;
-
- resourcesService =
- (ResourceManagementService)AutoAwayActivator.bundleContext
- .getService(serviceReference);
- }
-
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(AutoAwayActivator.bundleContext);
return resourcesService;
}
}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/Resources.java b/src/net/java/sip/communicator/plugin/contactinfo/Resources.java index bfee23b..29a61fb 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/Resources.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/Resources.java @@ -4,7 +4,6 @@ * Distributable under LGPL license.
* See terms of license at gnu.org.
*/
-
package net.java.sip.communicator.plugin.contactinfo;
import java.awt.*;
@@ -16,8 +15,6 @@ import javax.imageio.*; import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
-import org.osgi.framework.*;
-
/**
* The <tt>Resources</tt> class manages the access to the internationalization
* properties files and the image resources used in this plugin.
@@ -70,18 +67,9 @@ public class Resources { public static ResourceManagementService getResources()
{
if (resourcesService == null)
- {
- ServiceReference serviceReference = ContactInfoActivator.bundleContext
- .getServiceReference(ResourceManagementService.class.getName());
-
- if(serviceReference == null)
- return null;
-
- resourcesService =
- (ResourceManagementService)ContactInfoActivator.bundleContext
- .getService(serviceReference);
- }
-
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(ContactInfoActivator.bundleContext);
return resourcesService;
}
}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java index 63e9e3f..d761695 100644 --- a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.dictaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -22,8 +17,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; public static ImageID DICT_LOGO = new ImageID("protocolIconDict"); @@ -48,42 +41,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = DictAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)DictAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(DictAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/Resources.java b/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/Resources.java index 7a37e28..2f18f24 100644 --- a/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/Resources.java +++ b/src/net/java/sip/communicator/plugin/extendedcallhistorysearch/Resources.java @@ -4,19 +4,11 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.plugin.extendedcallhistorysearch; -import java.awt.image.*; -import java.io.*; - -import javax.imageio.*; import javax.swing.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -24,10 +16,8 @@ import org.osgi.framework.*; * * @author Yana Stamcheva */ -public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - +public class Resources +{ private static ResourceManagementService resourcesService; /** @@ -48,24 +38,7 @@ public class Resources { */ public static ImageIcon getImage(String imageID) { - BufferedImage image = null; - - InputStream in = - getResources().getImageInputStream(imageID); - - if(in == null) - return null; - - try - { - image = ImageIO.read(in); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return new ImageIcon(image); + return getResources().getImage(imageID); } /** @@ -90,22 +63,13 @@ public class Resources { { return getResources().getColor(key); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = ExtendedCallHistorySearchActivator.context - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)ExtendedCallHistorySearchActivator.context - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(ExtendedCallHistorySearchActivator.context); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/generalconfig/Resources.java b/src/net/java/sip/communicator/plugin/generalconfig/Resources.java index 45c8829..140c4e3 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/Resources.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/Resources.java @@ -4,16 +4,9 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.plugin.generalconfig; -import java.io.*; -import java.util.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -23,8 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -64,42 +55,15 @@ public class Resources */ public static byte[] getImage(String imageId) { - InputStream in = - getResources().getImageInputStream(imageId); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageId, e); - } - - return image; + return getResources().getImageInBytes(imageId); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = GeneralConfigPluginActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)GeneralConfigPluginActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(GeneralConfigPluginActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java index 747a48c..c2c8f03 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.gibberishaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -21,9 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -55,42 +47,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = GibberishAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)GibberishAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(GibberishAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/Resources.java index ee94ab3..25bf8b9 100644 --- a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/Resources.java @@ -5,12 +5,7 @@ */
package net.java.sip.communicator.plugin.googletalkaccregwizz;
-import java.io.*;
-
import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
/**
* The <tt>Resources</tt> class manages the access to the internationalization
@@ -20,8 +15,6 @@ import org.osgi.framework.*; */
public class Resources
{
- private static Logger log = Logger.getLogger(Resources.class);
-
private static ResourceManagementService resourcesService;
/**
@@ -64,25 +57,7 @@ public class Resources */
public static byte[] getImage(ImageID imageID)
{
- InputStream in =
- getResources().getImageInputStream(imageID.getId());
-
- if(in == null)
- return null;
-
- byte[] image = null;
-
- try
- {
- image = new byte[in.available()];
- in.read(image);
- }
- catch (IOException e)
- {
- log.error("Failed to load image:" + imageID, e);
- }
-
- return image;
+ return getResources().getImageInBytes(imageID.getId());
}
/**
@@ -96,22 +71,13 @@ public class Resources {
return getResources().getI18NString(key);
}
-
+
public static ResourceManagementService getResources()
{
if (resourcesService == null)
- {
- ServiceReference serviceReference = GoogleTalkAccRegWizzActivator.bundleContext
- .getServiceReference(ResourceManagementService.class.getName());
-
- if(serviceReference == null)
- return null;
-
- resourcesService =
- (ResourceManagementService)GoogleTalkAccRegWizzActivator.bundleContext
- .getService(serviceReference);
- }
-
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(GoogleTalkAccRegWizzActivator.bundleContext);
return resourcesService;
}
}
diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java index 012eb35..e42ac29 100644 --- a/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.icqaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -21,8 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; public static ImageID ICQ_LOGO = new ImageID("protocolIconIcq"); @@ -47,42 +40,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = IcqAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)IcqAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(IcqAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java index 22a5308..aa04d38 100644 --- a/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.ircaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The Messages class manages the access to the internationalization @@ -21,9 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -53,42 +45,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = IrcAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)IrcAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(IrcAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java index 19497f7..60ebb44 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/Resources.java @@ -9,9 +9,6 @@ package net.java.sip.communicator.plugin.jabberaccregwizz; import java.io.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -21,8 +18,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -65,25 +60,7 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } /** @@ -101,18 +78,9 @@ public class Resources public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = JabberAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)JabberAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(JabberAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java index 2b1974b..bdc436c 100644 --- a/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java +++ b/src/net/java/sip/communicator/plugin/keybindingchooser/KeybindingChooserActivator.java @@ -62,20 +62,8 @@ public class KeybindingChooserActivator public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = - bundleContext - .getServiceReference(ResourceManagementService.class - .getName()); - - if (serviceReference == null) - return null; - resourcesService = - (ResourceManagementService) bundleContext - .getService(serviceReference); - } - + ResourceManagementServiceUtils.getService(bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/Resources.java b/src/net/java/sip/communicator/plugin/keybindingchooser/Resources.java index 4e9f0bc..156f31a 100644 --- a/src/net/java/sip/communicator/plugin/keybindingchooser/Resources.java +++ b/src/net/java/sip/communicator/plugin/keybindingchooser/Resources.java @@ -6,10 +6,6 @@ */ package net.java.sip.communicator.plugin.keybindingchooser; -import java.io.*; - -import net.java.sip.communicator.util.*; - /** * The <tt>Resources</tt> class manages the access to the internationalization * properties files and the image resources used in this plugin. @@ -18,7 +14,6 @@ import net.java.sip.communicator.util.*; */ public class Resources { - private static Logger logger = Logger.getLogger(Resources.class); /** * Returns an internationalized string corresponding to the given key. @@ -39,25 +34,7 @@ public class Resources */ public static byte[] getImageInBytes(String imageID) { - InputStream in = - KeybindingChooserActivator.getResources().getImageInputStream( - imageID); - - if (in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - logger.error("Failed to load image:" + imageID, e); - } - - return image; + return KeybindingChooserActivator.getResources().getImageInBytes( + imageID); } } diff --git a/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java b/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java index 880b487..2903215 100644 --- a/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java +++ b/src/net/java/sip/communicator/plugin/mailbox/MailboxActivator.java @@ -11,9 +11,9 @@ import org.osgi.framework.*; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.service.media.*; import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; /** * Activates the Mailbox plug-in. @@ -165,17 +165,8 @@ public class MailboxActivator public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = (ResourceManagementService) bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils.getService(bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/mailbox/Resources.java b/src/net/java/sip/communicator/plugin/mailbox/Resources.java index ef56e24..55274df 100644 --- a/src/net/java/sip/communicator/plugin/mailbox/Resources.java +++ b/src/net/java/sip/communicator/plugin/mailbox/Resources.java @@ -6,15 +6,6 @@ */ package net.java.sip.communicator.plugin.mailbox; -import java.awt.image.*; -import java.io.*; -import java.util.*; - -import javax.imageio.*; -import javax.swing.*; - -import net.java.sip.communicator.util.*; - /** * The <tt>Resources</tt> class manages the access to the internationalization * properties files and the image resources used in this plugin. @@ -23,7 +14,6 @@ import net.java.sip.communicator.util.*; */ public class Resources { - private static Logger logger = Logger.getLogger(Resources.class); /** * Returns an internationalized string corresponding to the given key. @@ -44,22 +34,6 @@ public class Resources */ public static byte[] getImageInBytes(String imageID) { - logger.debug("Loading imageID=" + imageID); - - try - { - InputStream in = - MailboxActivator.getResources().getImageInputStream(imageID); - byte[] image = new byte[in.available()]; - in.read(image); - - return image; - } - catch (IOException e) - { - logger.error("Failed to load image:" + imageID, e); - } - - return null; + return MailboxActivator.getResources().getImageInBytes(imageID); } -}
\ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java index 04be3d6..c94ae66 100644 --- a/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.msnaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -21,8 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -54,42 +47,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = MsnAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)MsnAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(MsnAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java index 5618e38..1090338 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/Resources.java @@ -4,28 +4,22 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.plugin.notificationconfiguration; -import java.io.*; import java.net.*; import java.util.*; import javax.swing.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The Messages class manages the access to the internationalization * properties files. * @author Yana Stamcheva */ -public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); +public class Resources +{ /** * Returns an internationalized string corresponding to the given key. @@ -68,37 +62,17 @@ public class Resources { */ public static byte[] getImageInBytes(String imageID) { - InputStream in = - getResources().getImageInputStream(imageID); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID); } private static ResourceManagementService getResources() { - ServiceReference serviceReference = NotificationConfigurationActivator - .bundleContext.getServiceReference( - ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - return (ResourceManagementService) NotificationConfigurationActivator - .bundleContext.getService(serviceReference); + /* + * TODO If the method is called more than once, the trend seems to be + * caching the value. + */ + return ResourceManagementServiceUtils + .getService(NotificationConfigurationActivator.bundleContext); } } diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java b/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java index 7c1e2cf..b53e23f 100644 --- a/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java +++ b/src/net/java/sip/communicator/plugin/pluginmanager/Resources.java @@ -4,19 +4,9 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.plugin.pluginmanager; -import java.awt.image.*; -import java.io.*; - -import javax.imageio.*; -import javax.swing.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -26,8 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger logger = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -52,22 +40,13 @@ public class Resources { return getResources().getColor(key); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = PluginManagerActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)PluginManagerActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(PluginManagerActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/profiler4j/Resources.java b/src/net/java/sip/communicator/plugin/profiler4j/Resources.java index 2dcef41..78dd5fa 100644 --- a/src/net/java/sip/communicator/plugin/profiler4j/Resources.java +++ b/src/net/java/sip/communicator/plugin/profiler4j/Resources.java @@ -6,8 +6,6 @@ */ package net.java.sip.communicator.plugin.profiler4j; -import java.util.*; -import org.osgi.framework.*; import net.java.sip.communicator.service.resources.*; /** @@ -30,23 +28,13 @@ public class Resources { return getResources().getI18NString(key); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = ProfilerActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if (serviceReference == null) { - return null; - } - - resourcesService = - (ResourceManagementService) ProfilerActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(ProfilerActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java index 91e017e..4b809fc 100644 --- a/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/rssaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.rssaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -21,9 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -55,42 +47,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = RssAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)RssAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(RssAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java index 4141876..4ea99a6 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java @@ -8,8 +8,6 @@ package net.java.sip.communicator.plugin.simpleaccreg; import net.java.sip.communicator.service.resources.*; -import org.osgi.framework.*; - /** * The <tt>Resources</tt> class manages the access to the internationalization * properties files and the image resources used in this plugin. @@ -66,22 +64,13 @@ public class Resources { return getResources().getSettingsString(key); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = SimpleAccountRegistrationActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)SimpleAccountRegistrationActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(SimpleAccountRegistrationActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java index 2d596e6..58cf8e1 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.sipaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -19,10 +14,8 @@ import org.osgi.framework.*; * * @author Yana Stamcheva */ -public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - +public class Resources +{ private static ResourceManagementService resourcesService; public static ImageID SIP_LOGO = new ImageID("protocolIconSip"); @@ -47,42 +40,15 @@ public class Resources { */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = SIPAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)SIPAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(SIPAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java index 39eb9bc..1b7dbcc 100644 --- a/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java @@ -13,12 +13,7 @@ */ package net.java.sip.communicator.plugin.sshaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -28,9 +23,6 @@ import org.osgi.framework.*; */ public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; public static ImageID SSH_LOGO = new ImageID("protocolIconSsh"); @@ -55,42 +47,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = SSHAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)SSHAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(SSHAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/updatechecker/Resources.java b/src/net/java/sip/communicator/plugin/updatechecker/Resources.java index 3d9264b..69fe7f0 100644 --- a/src/net/java/sip/communicator/plugin/updatechecker/Resources.java +++ b/src/net/java/sip/communicator/plugin/updatechecker/Resources.java @@ -6,13 +6,9 @@ package net.java.sip.communicator.plugin.updatechecker; import java.io.*; -import java.net.*; import java.util.*; -import java.util.logging.*; -import javax.swing.*; - -import net.java.sip.communicator.util.Logger; +import net.java.sip.communicator.util.*; /** * diff --git a/src/net/java/sip/communicator/plugin/whiteboard/Resources.java b/src/net/java/sip/communicator/plugin/whiteboard/Resources.java index 75a5959..a5e7c01 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/Resources.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/Resources.java @@ -3,21 +3,11 @@ * * Distributable under LGPL license. See terms of license at gnu.org. */ - package net.java.sip.communicator.plugin.whiteboard; -import java.awt.image.*; -import java.io.*; -import java.text.*; -import java.util.*; - -import javax.imageio.*; import javax.swing.*; import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -27,9 +17,6 @@ import org.osgi.framework.*; */ public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; /** @@ -76,41 +63,15 @@ public class Resources */ public static ImageIcon getImage(String imageID) { - BufferedImage image = null; - - InputStream in = - getResources().getImageInputStream(imageID); - - if(in == null) - return null; - - try - { - image = ImageIO.read(in); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return new ImageIcon(image); + return getResources().getImage(imageID); } - + public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = WhiteboardActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)WhiteboardActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(WhiteboardActivator.bundleContext); return resourcesService; } -}
\ No newline at end of file +} diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java index b25d791..7da5d09 100644 --- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.yahooaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>Resources</tt> class manages the access to the internationalization @@ -21,8 +16,6 @@ import org.osgi.framework.*; */ public class Resources { - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; public static ImageID YAHOO_LOGO = new ImageID("protocolIconYahoo"); @@ -46,42 +39,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = YahooAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)YahooAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(YahooAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java index fc3b4cd..0a5dc27 100644 --- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java +++ b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java @@ -6,12 +6,7 @@ */ package net.java.sip.communicator.plugin.zeroconfaccregwizz; -import java.io.*; - import net.java.sip.communicator.service.resources.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The Resources class manages the access to the internationalization @@ -22,9 +17,6 @@ import org.osgi.framework.*; */ public class Resources { - - private static Logger log = Logger.getLogger(Resources.class); - private static ResourceManagementService resourcesService; public static ImageID ZEROCONF_LOGO = new ImageID("protocolIconZeroconf"); @@ -48,42 +40,15 @@ public class Resources */ public static byte[] getImage(ImageID imageID) { - InputStream in = - getResources().getImageInputStream(imageID.getId()); - - if(in == null) - return null; - - byte[] image = null; - - try - { - image = new byte[in.available()]; - in.read(image); - } - catch (IOException e) - { - log.error("Failed to load image:" + imageID, e); - } - - return image; + return getResources().getImageInBytes(imageID.getId()); } public static ResourceManagementService getResources() { if (resourcesService == null) - { - ServiceReference serviceReference = ZeroconfAccRegWizzActivator.bundleContext - .getServiceReference(ResourceManagementService.class.getName()); - - if(serviceReference == null) - return null; - - resourcesService = - (ResourceManagementService)ZeroconfAccRegWizzActivator.bundleContext - .getService(serviceReference); - } - + resourcesService = + ResourceManagementServiceUtils + .getService(ZeroconfAccRegWizzActivator.bundleContext); return resourcesService; } } diff --git a/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java b/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java new file mode 100644 index 0000000..048baec --- /dev/null +++ b/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java @@ -0,0 +1,30 @@ +/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.resources;
+
+import org.osgi.framework.*;
+
+/**
+ * @author Lubomir Marinov
+ */
+public final class ResourceManagementServiceUtils
+{
+ public static ResourceManagementService getService(
+ BundleContext bundleContext)
+ {
+ ServiceReference ref =
+ bundleContext.getServiceReference(ResourceManagementService.class
+ .getName());
+
+ return (ref == null) ? null : (ResourceManagementService) bundleContext
+ .getService(ref);
+ }
+
+ private ResourceManagementServiceUtils()
+ {
+ }
+}
|