Wednesday, March 9, 2016

Hazle cast cache usage in wso2 products

Hazle cast cache usage in wso2 products:

Imports:

import javax.cache.Cache;

import javax.cache.CacheConfiguration;

import javax.cache.CacheManager;

import javax.cache.Caching;

Code:


private void playWithCache()

{

final CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager("test");

final String cacheName = "cacheXXX";

final Cache<String, Integer> cache = cacheManager.<String,Integer>getCache(cacheName) == null ? cacheManager.<String,Integer>createCacheBuilder(cacheName).setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.MINUTES, 10)).setStoreByValue(false).build() : cacheManager.<String,Integer>getCache(cacheName);

final intvalue = 9876;

final String key = "key-1";



logger.info("Getting cache entry from cache: "+cache.get(key));

logger.info("Inserting cache entry into cache..");

cache.put(key, value);

logger.info("Inserting cache entry into cache done.");

logger.info("Getting cache entry from cache after insertion: "+cache.get(key));

}

How to do ssh tunnel to private network

From localhost:
ssh -L6389:localhost:389 user1@ip1

From IP1:
ssh -L389:localhost:389 user1@ip2

Tuesday, March 8, 2016

12 IntelliJ IDEA Keyboard Shortcuts, mandatory to know!

intellij-idea-shortcuts-small

1. (Un)Comment line: Cmd + L

Transforming the current line into comment is essential in bug tracking. Instead of going to the beginning of line and manually typing //, Cmd+L will do that for us. Even cooler, the editor will know how to uncomment lines, even when commented out manually. A good thing to know is that caret will move to the next line automatically, allowing multiple lines to be commented out at once.
Line comment

2. (Un)Comment selection: Shift + Control + /

Similar to line commenting, this shortcut will surround the current selection. While line commenting is quicker, here you can be much more precise and more creative with comments. Refer to the figure below for comparison.
Selection comment

3. Documentation comment block: /** + Enter

Not quite a keyboard shortcut, this one is more of a code completion helper. After you create a member, go one line above it and type /** followed by a press on the Enter key. Voila, IDEA will automagically create a documentation block for you. If you place it above a method, the block will be populated with argument params, which can be tremendously useful.
EDIT: Denis Zhdanov of JetBrains pointed out a great new feature shipped as of v12, “Fix Doc Comment”. Read more about it here on his blog post.
I don’t think I can stress the importance of documentation in code. Please use line comments and documentation blocks as much as possible. They will help you more than you can imagine, others even more.
Documentation block

4. Delete line: Cmd + Y

Another no-brainer very useful. No need to get your hands off of keyboard to reach for the mouse, or use extra shortcuts to select a line + Backspace. Simply place caret at the line you want out of your project and push Cmd + Y.
Here’s how I remember that it’s Y and not another key, D for example. You know how deletions are frequently followed by a confirmation dialog? “Are you sure you want to delete this item?” and similar. Most of us have trained our eyes to find a short little word that begins with an Y – Yes. Here we’re skipping the dialog and agreeing immediately. Yes, delete the sucker!

5. Argument documentation for method calls: Cmd + P

Useful when you need to remember argument options when calling a method, this shortcut will pull up a callout with the information you need. It is even capable of learning from your documentation blocks.
Parameter callout

6. Incremental selection: Cmd + W

Although Cmd + W defaults to close tab/window in most applications (and so it did in IDEA < 11), IDEA 11 and up assigned to to a whole new purpose.  When you need to select a word, reference, statement, line, or entire block of code without lifting your hands from keyboard, this shortcut comes to the rescue. Press it once to select the word closes to the caret. Repeat to incrementally select larger chunks.
Incremental selection

7. Reformat code: Option + Cmd + L

Whether you are a fan of JSLint or you follow another JavaScript code style, you can configure IDEA to learn it and reformat your code accordingly. First, make sure you’re satisfied with settings found at Preferences -> Code Style – > Your Language. Walk through the tabs offered and set the style that best match your desired behavior. Once completed, go to your code.
Pressing Option + Cmd + L will politely ask you which section you want to reformat. It can be a selection, file, or even entire project.
In some situations, you may need to omit parts of code (e.g. when concatenating arrays of html strings). In such case, selecting a code area and hitting the shortcut will automatically offer to reformat selection. So hit shortcut and press enter for a quick and smart code reformat.

8. Cycle through the history of most recent changes: Cmd + Shift + Backspace

When editing huge files, and I mean many at the same time, it can get difficult to navigate through the maze of code. The effect is stronger when editing someone else’s code. In such situations, I find this shortcut very useful. It doesn’t delete anything, as Backspace may imply, it just shifts the caret over to the position of last change. It goes like that long ways through history, and even switches open files for you. If you haven’t already, try it out, it’s a gem.

9. Paste from five previous copies – Cmd + Shift + V

Does the OS default one slot in memory for copy-paste satisfy you? IDEA tracks your last five copies and allows you to chose from them when pasting. Instead of the accustomed Cmd + V for paste, add Shift to the combination and a dialog pops up, offering the options.
Paste history

10. Find members in current file: Cmd + F12

Easily on of my top three favorite shortcuts, this one emulates Cmd + Shift + O in Chrome Inspector. Basically, it shows a popup with all objects and respective members associated with a file. Moreover, if you start typing, it will perform a search and select the line you were looking for. Amazingly useful in big files.
As an added bonus, press the shortcut twice to show the inherited members.
Find members
If you can’t reproduce this on a Mac, make sure F12 (Fn + F12) is not registered to Mission Control. Simply go to OS X’s Settings -> Mission Control and remove any existing bindings. Now you can retry in IDEA.
Disable F12 in Mission Control

11. Find members in current project: Cmd + Alt + Shift + N

Finding members in a file is quick and easy. Alternatively, if you want to find members throughout the project, sacrificing just a tiny bit of speed, then this shortcut is meant for you.
Find members in a project

12. Show recently changed files: Cmd + Shift + E

IDEA will automatically manage your tabs so that you don’t have too many to clutter your workspace. In many workspaces, you might also want to close the project browser window in order to save some horizontal space. Getting to see the most recently edited files is a speed boost that will help any developer working in a similar environment. Just press Cmd + Shift + E and chose from the list, sorted in ascending order relative to the time of last edit. Guess what – it even works after you restart the editor!
Recent Edits
Note on automatic tab management: IDEA will auto close tabs to keep the workspace tidy. This action will not result in losses such as file state, undo/redo stack, or even scroll position. If, for any reason, you may want to keep a tab constantly visible, right click on it and select ‘Pin active tab’. I’m afraid here isn’t a default shortcut for pinning tabs.


Monday, March 7, 2016

List of admin services in WSO2-IS-5.0.0

Here is the list of admin wsdl services defined in wso2 is 5.0.0:

osgi> listAdminServices
Admin services deployed on this server:
1. ProvisioningAdminService, ProvisioningAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ProvisioningAdminService/
2. IdentitySAMLSSOConfigService, IdentitySAMLSSOConfigService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/IdentitySAMLSSOConfigService/
3. CarbonAppUploader, CarbonAppUploader, https://is-is-test9-int.devint.trimblepaas.com:9443/services/CarbonAppUploader/
4. JaggeryAppAdmin, JaggeryAppAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/JaggeryAppAdmin/
5. JaxwsWebappAdmin, JaxwsWebappAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/JaxwsWebappAdmin/
6. RemoteUserStoreManagerService, RemoteUserStoreManagerService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RemoteUserStoreManagerService/
7. UserProfileMgtService, UserProfileMgtService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/UserProfileMgtService/
8. StatisticsAdmin, StatisticsAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/StatisticsAdmin/
9. LoggedUserInfoAdmin, LoggedUserInfoAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/LoggedUserInfoAdmin/
10. WebappAdmin, WebappAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/WebappAdmin/
11. ws-xacml, ws-xacml, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ws-xacml/
12. RemoteUserRealmService, RemoteUserRealmService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RemoteUserRealmService/
13. TopicManagerAdminService, TopicManagerAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/TopicManagerAdminService/
14. ClaimManagementService, ClaimManagementService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ClaimManagementService/
15. IdentitySTSAdminService, IdentitySTSAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/IdentitySTSAdminService/
16. NDataSourceAdmin, NDataSourceAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/NDataSourceAdmin/
17. ServiceGroupAdmin, ServiceGroupAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ServiceGroupAdmin/
18. IdentityApplicationManagementService, IdentityApplicationManagementService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/IdentityApplicationManagementService/
19. CustomMeteringService, CustomMeteringService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/CustomMeteringService/
20. STSAdminService, STSAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/STSAdminService/
21. DirectoryServerManager, DirectoryServerManager, https://is-is-test9-int.devint.trimblepaas.com:9443/services/DirectoryServerManager/
22. OAuthAdminService, OAuthAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/OAuthAdminService/
23. RegistryAdminService, RegistryAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RegistryAdminService/
24. FileDownloadService, FileDownloadService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/FileDownloadService/
25. ContentSearchAdminService, ContentSearchAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ContentSearchAdminService/
26. LoginStatisticsAdmin, LoginStatisticsAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/LoginStatisticsAdmin/
27. CustomUIAdminService, CustomUIAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/CustomUIAdminService/
28. SearchAdminService, SearchAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/SearchAdminService/
29. RemoteAuthorizationManagerService, RemoteAuthorizationManagerService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RemoteAuthorizationManagerService/
30. RemoteProfileConfigurationManagerService, RemoteProfileConfigurationManagerService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RemoteProfileConfigurationManagerService/
31. SCIMConfigAdminService, SCIMConfigAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/SCIMConfigAdminService/
32. IdentityProviderAdminService, IdentityProviderAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/IdentityProviderAdminService/
33. IWAAuthenticator, IWAAuthenticator, https://is-is-test9-int.devint.trimblepaas.com:9443/services/IWAAuthenticator/
34. LoggingAdmin, LoggingAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/LoggingAdmin/
35. SampleDeployer, SampleDeployer, https://is-is-test9-int.devint.trimblepaas.com:9443/services/SampleDeployer/
36. XMPPConfigurationService, XMPPConfigurationService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/XMPPConfigurationService/
37. SecurityAdminService, SecurityAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/SecurityAdminService/
38. KeyStoreAdminService, KeyStoreAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/KeyStoreAdminService/
39. ServerRolesManager, ServerRolesManager, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ServerRolesManager/
40. IdentityProviderMgtService, IdentityProviderMgtService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/IdentityProviderMgtService/
41. ResourceAdminService, ResourceAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ResourceAdminService/
42. ThemeMgtService, ThemeMgtService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ThemeMgtService/
43. FileUploadService, FileUploadService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/FileUploadService/
44. RemoteTenantManagerService, RemoteTenantManagerService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RemoteTenantManagerService/
45. EventBrokerService, EventBrokerService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/EventBrokerService/
46. TracerAdmin, TracerAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/TracerAdmin/
47. MultipleCredentialsUserAdmin, MultipleCredentialsUserAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/MultipleCredentialsUserAdmin/
48. UserStoreConfigAdminService, UserStoreConfigAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/UserStoreConfigAdminService/
49. RepositoryAdminService, RepositoryAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RepositoryAdminService/
50. TenantMgtAdminService, TenantMgtAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/TenantMgtAdminService/
51. DeploymentSynchronizerAdmin, DeploymentSynchronizerAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/DeploymentSynchronizerAdmin/
52. EntitlementPolicyAdminService, EntitlementPolicyAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/EntitlementPolicyAdminService/
53. ServerAdmin, ServerAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ServerAdmin/
54. ServiceAdmin, ServiceAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ServiceAdmin/
55. UserIdentityManagementAdminService, UserIdentityManagementAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/UserIdentityManagementAdminService/
56. EntitlementAdminService, EntitlementAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/EntitlementAdminService/
57. UserAdmin, UserAdmin, https://is-is-test9-int.devint.trimblepaas.com:9443/services/UserAdmin/
58. AccountCredentialMgtConfigService, AccountCredentialMgtConfigService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/AccountCredentialMgtConfigService/
59. UserInformationRecoveryService, UserInformationRecoveryService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/UserInformationRecoveryService/
60. PropertiesAdminService, PropertiesAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/PropertiesAdminService/
61. LogViewer, LogViewer, https://is-is-test9-int.devint.trimblepaas.com:9443/services/LogViewer/
62. RemoteClaimManagerService, RemoteClaimManagerService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/RemoteClaimManagerService/
63. EntitlementService, EntitlementService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/EntitlementService/
64. OAuth2TokenValidationService, OAuth2TokenValidationService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/OAuth2TokenValidationService/
65. ProfilesAdminService, ProfilesAdminService, https://is-is-test9-int.devint.trimblepaas.com:9443/services/ProfilesAdminService/