このトピックでは、 UWLサービスのアクセス方法を取り上げて説明します。
UWLサービスの取得
Portal利用
IUWLService uwlService = (IUWLService) WDPortalUtils.getServiceReference(IUWLService.ALIAS_KEY); PortalRuntime.getRuntimeResources().getService(IUWLService.ALIAS_KEY);
JNDI利用
 
  // look up UWL service private														 
  IUWLService findService() throws NamingException {														 
    Properties env = new Properties();														 
          env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "com.sapportals.portal.prt.registry.PortalRegistryFactory");														 
          // create initial context														 
          InitialContext ctx = new InitialContext(env);														 
          // retrieve UWL service														 
          IUWLService uwlService = (IUWLService) ctx.lookup("/broker/services/" + IUWLService.ALIAS_KEY); return uwlService;														 
  }														 
	 ワークアイテムの走査
 
public void retriveItems() {														 
try {														
            // look up UWL service														
            IUWLService uwlService = findService();														
            // define session timeout period														
            final int sessionIdleTimeout = 60;														
            // create context														
            UWLContext uwlContext = new UWLContext();														
            // find logged in user.														
            IUser user = //TODO Get the user for whom the items are to be retrieved.														
            uwlContext.setUser(user);														
            uwlContext.setLocale(Locale.getDefault());														
            // begin session IUWLSession uwlSession;														
            uwlSession = uwlService.beginSession(uwlContext, sessionIdleTimeout);														
            uwlContext.setSession(uwlSession);														
            IUWLItemManager itemManager = uwlService.getItemManager(uwlContext);														
            QueryResult result = itemManager.getItems(uwlContext, null, null);														
            ItemCollection items = result.getItems();														
             Item item = null;														
            for (int i = 0; i < items.size(); i++) {														
              item = items.get(i);														
              // item.getSubject() can give you Task's Subject string														
              // item.getAttribute("taskId").getStringValue() gives you taskId														
              // (a check for null should be added also to avoid NullPointerException).														
              Map params = new HashMap();														
              params.put("taskId", item.getExternalId());														
              String executionURL = WDURLGenerator.getApplicationURL("sap.com/tc~bpem~wdui~taskinstance", "ATaskExecution", params);														
              //TODO Add code send mail which contains above URL.														
            }														
    } catch (UWLException e) {														
            e.printStackTrace();														
          } catch (NamingException e) {														
            e.printStackTrace();														
          }														
  } 
 
				
				
			 
				
				
			 
				
				
			 
				
				
			 
				
				
			 
				
				
			 
				
				
			