001: /*
002: * ServiceManagerImpl.java
003: *
004: * Created on January 7, 2005, 11:12 AM
005: */
006:
007: package com.sun.portal.service.serviceregistry.impl;
008:
009: import java.io.File;
010: import java.util.Map;
011: import java.util.HashMap;
012: import java.util.Collection;
013:
014: import javax.servlet.http.HttpServletRequest;
015:
016: import com.sun.portal.service.Service;
017: import com.sun.portal.service.portlet.PortletService;
018: import com.sun.portal.service.portlet.PortletServiceFactory;
019: import com.sun.portal.service.serviceregistry.ServiceRegistryException;
020: import com.sun.portal.service.serviceregistry.ServiceRegistry;
021:
022: import com.sun.portal.service.ServiceInitData;
023: import java.lang.UnsupportedOperationException;
024:
025: import com.sun.portal.desktop.dp.DPChannel;
026: import com.sun.portal.desktop.dp.DPContainerChannel;
027: import com.sun.portal.service.provider.ProviderService;
028: import com.sun.portal.service.provider.ProviderServiceFactory;
029:
030: /**
031: *
032: * @author mjain
033: */
034: public class ServiceRegistryImpl implements ServiceRegistry {
035:
036: private static String DELIMITER = ".";
037: private static String PORTLET_PREFIX = "__Portlet__";
038:
039: public void init(HttpServletRequest request) {
040:
041: }
042:
043: public void init(String username, String password) {
044:
045: }
046:
047: void doInit() {
048: }
049:
050: public Collection getServices() throws ServiceRegistryException {
051: throw new UnsupportedOperationException();
052: }
053:
054: public Service getService(String uniqueServiceId)
055: throws ServiceRegistryException {
056: throw new UnsupportedOperationException();
057: }
058:
059: public void addService(Service service)
060: throws ServiceRegistryException {
061:
062: throw new UnsupportedOperationException();
063:
064: }
065:
066: public void removeService(String uniqueServiceID)
067: throws ServiceRegistryException {
068: throw new UnsupportedOperationException();
069:
070: }
071:
072: public Service getService(DPChannel channel) {
073: if (channel instanceof DPContainerChannel) {
074: return null;
075: }
076:
077: String providerName = channel.getProviderName();
078: Service service = null;
079: if (!providerName.startsWith("_")) {
080: service = ProviderServiceFactory
081: .instantiateProviderService();
082: ((ProviderService) service).init(providerName, null);
083: } else if (providerName.startsWith("__Portlet__")) {
084:
085: String appName = getPortletAppName(providerName);
086: String portletName = getPortletName(providerName);
087: service = PortletServiceFactory.instantiatePortletService();
088: ((PortletService) service).init(portletName, appName, null);
089: }
090: return service;
091: }
092:
093: private static String getPortletAppName(String providerName) {
094: return providerName.substring(PORTLET_PREFIX.length(),
095: providerName.indexOf(DELIMITER));
096: }
097:
098: private static String getPortletName(String providerName) {
099: return providerName
100: .substring(providerName.indexOf(DELIMITER) + 1);
101: }
102:
103: }
|