[jboss-dev-forums] [Design of POJO Server] - Re: JBAS-5259, JMS Destination Names is showing as QueueServ

mark.spritzler do-not-reply at jboss.com
Mon Mar 17 18:08:17 EDT 2008


Not sure what I can really add.

Here is the code that runs while discovering the resource.

First at the AS discovery level we run


  | 
  | ProfileServiceFactory.refreshCurrentProfileView();
  | 
  | which looks like this.
  | 
  | try
  |         {
  |             Profile activeProfile = getProfileService().getActiveProfile();
  |             ProfileKey activeKey = activeProfile.getKey();
  |             getCurrentProfileView().loadProfile(activeKey);
  |         }
  |         catch (Exception e)
  |         {
  |             LOG.error("Could not find default Profile in Current Profile View", e);
  |         }
  | 
  | 
  | The following is the getProfileService() method call in the first line
  | 
  |     public static ProfileService getProfileService()
  |     {
  |         if (profileService == null)
  |         {
  |             InitialContext initialContext;
  |             try
  |             {
  |                 initialContext = new InitialContext();
  |             }
  |             catch (NamingException e)
  |             {
  |                 LOG.error("Unable to get an InitialContext to JBoss AS 5", e);
  |                 return null;
  |             }
  | 
  |             try
  |             {
  |                 profileService = (ProfileService) initialContext.lookup("ProfileService");
  | 
  |                 /*ManagementView view = getCurrentProfileView();
  |              ComponentType type = new ComponentType("DataSource", "LocalTx");
  |              Set<ManagedComponent> components = view.getComponentsForType(type);*/
  |             }
  |             catch (NamingException e)
  |             {
  |                 LOG.error("Could not find ProfileService Name on JBoss AS 5", e);
  |             }
  |             catch (Exception e)
  |             {
  |                 LOG.error("Exception thrown when looking up ProfileService on JBoss AS 5", e);
  |             }
  |         }
  |         return profileService;
  |     }
  | 
  | 

Then for each ComponentType it will run the following code


  | ComponentType componentType = ConversionUtil.getComponentType(resourceType);
  | 
  |         ManagementView mgtView = ProfileServiceFactory.getCurrentProfileView();
  | 
  |         Set<ManagedComponent> components = null;
  |         try
  |         {
  |             components = mgtView.getComponentsForType(componentType);
  |         }
  |         catch (Exception e)
  |         {
  |             LOG.error("Unable to get component for type " + componentType, e);
  |         }
  | 
  | The factory call to getCurrentProfileView() is here
  | 
  |     /**
  |      * Get the current profile's Management view. This will get the domains from the profile service
  |      * and return the first one in the list.
  |      *
  |      * @return ManagementView the management view of the first domain
  |      */
  |     public static ManagementView getCurrentProfileView()
  |     {
  |         if (currentProfileView == null)
  |         {
  |             currentProfileView = getProfileService().getViewManager();
  |             refreshCurrentProfileView();
  |         }
  |         return currentProfileView;
  |     }
  | 
  | 
  | the refreshCurrentProfileView() call above is below, but it is one and the same as you saw at the beginning of the code I just posted. :)
  | 
  | 
  | 
  |     /**
  |      * This will refresh the managementView to have all the newest resources.
  |      * It simply nulls out the "singleton" reference in this factory and calls
  |      * getCurrentProfileView to reload the view with loadProfile();
  |      */
  |     public static void refreshCurrentProfileView()
  |     {
  |         try
  |         {
  |             Profile activeProfile = getProfileService().getActiveProfile();
  |             ProfileKey activeKey = activeProfile.getKey();
  |             getCurrentProfileView().loadProfile(activeKey);
  |         }
  |         catch (Exception e)
  |         {
  |             LOG.error("Could not find default Profile in Current Profile View", e);
  |         }
  |     }
  | 
  | 


This is the code that was working before to discovering the Datasources and refreshing when creating and deleting datasource.

Mark

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4137226#4137226

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4137226



More information about the jboss-dev-forums mailing list